;testing speed of RSA coding (256 bit) ;for program CPUID (WildWest) ;author: halyavin ;structure of long number: ;rd 1 : length of number ;rd 39: digits of number ;length of zero number is equal to 1. number_digits=39 number_size=4*(number_digits+1) ;calling convention: ;procedures can change eax,ecx,edx init_rsatest: ;to do: add initialization which depends on processor. ret set_zero: ;eax - address of number ;[eax]:=0 ;result: eax isn't changed xor ecx,ecx xor edx,edx inc edx mov dword [eax],edx mov edx,39 add eax,4 .loop: mov dword [eax],ecx add eax,4 dec edx jnz .loop sub eax,160 ;size of number ret ladd: ;eax - first number ;edx - second number ;[eax]:=[eax]+[edx] pushad mov ecx,dword [eax] mov esi,dword [edx] mov ebp,eax cmp ecx,esi jg .l1 mov ecx,esi .l1: add eax,4 add edx,4 xor ebx,ebx xor esi,esi mov edi,ecx .l2: add ebx,dword [eax] adc ebx,dword [edx] adc esi,esi mov dword [eax],ebx mov ebx,esi add eax,4 xor esi,esi add edx,4 dec ecx jnz .l2 test ebx,ebx jz .lend inc dword [eax] inc edi .lend: mov eax,ebp mov dword [eax],edi popad ret lsub: ;eax - first number ;edx - second number ;[eax]=[eax]-[edx] ;[eax]>=[edx] pushad mov ecx,dword [eax] mov edi,ecx mov ebp,eax add eax,4 add edx,4 xor ebx,ebx xor esi,esi .l1: mov esi,dword [eax] sub esi,ebx sbb esi,dword [edx] mov dword [eax],esi sbb esi,esi mov ebx,esi neg ebx add eax,4 add edx,4 dec ecx jnz .l1 dec edi jz .lend sub eax,4 .l2: mov ebx,dword [eax] test ebx,ebx jnz .lend sub eax,4 dec edi jnz .l2 .lend: inc edi mov eax,ebp mov [eax],edi popad ret lcmp: ;eax - address of number ;edx - address of number ;result: ecx=1 if eax>edx ; ecx=0 if eax=edx ; ecx=-1 if eax