Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .486
- .model flat, stdcall
- option casemap: none
- include windows.inc
- .code
- DllEntry PROC hINSTDLL:HINSTANCE, reason:DWORD, reserved1:DWORD
- mov eax, TRUE
- ret
- DllEntry ENDP
- PreSieveAtkinAsm proc stdcall sieve: PTR, limit: DWORD, x: DWORD, root: DWORD
- mov esi, sieve
- mov ebx, 0
- mainloop:
- inc ebx ;increment y
- cmp ebx, root ;compare root with y
- jg mainloopend ;y <= root
- ;n - eax
- ;y - ebx
- ;n = (4*x*x)+(y*y)
- part1:
- mov eax, x ;x
- mul eax ;x*x
- mov ecx, 4
- mul ecx ;4*x*x
- mov ecx, eax ;4*x*x in ecx
- mov eax, ebx ;y
- mul eax ;y*y
- add eax, ecx ;4*x*x+y*y in eax
- cmp eax, limit
- jle part2
- push eax ;push n to stack
- mov ecx, 12
- div ecx
- pop eax ;pop n from stack
- mov eax, 1
- cmp eax, edx
- je xor1 ;n
- mov eax, 5
- cmp eax, edx
- je xor1
- jmp part2
- ;n in eax
- xor1:
- not BOOL PTR [esi + 1 * eax]
- part2:
- ;n - eax
- ;y - ebx
- ;n = (3*x*x)+(y*y)
- mov eax, x ;x
- mul eax ;x*x
- mov ecx, 3
- mul ecx ;4*x*x
- mov ecx, eax ;4*x*x in ecx
- mov eax, ebx ;y
- mul eax ;y*y
- add eax, ecx ;4*x*x+y*y in eax
- cmp eax, limit
- jle part3
- push eax ;push n to stack
- mov ecx, 12
- div ecx
- pop eax ;pop n from stack
- mov eax, 7
- cmp eax, edx
- je xor2 ;n
- jmp part3
- ;n in eax
- xor2:
- not BOOL PTR [esi + 1 * eax]
- part3:
- ;n - eax
- ;y - ebx
- ;n = (4*x*x)-(y*y)
- cmp x, ebx
- jle mainloop
- mov eax, x ;x
- mul eax ;x*x
- mov ecx, 4
- mul ecx ;3*x*x
- mov ecx, eax ;3*x*x in ecx
- mov eax, ebx ;y
- mul eax ;y*y
- sub eax,ecx ;4*x*x-y*y in eax
- cmp eax, limit
- jle mainloop
- push eax ;push n to stack
- mov ecx, 12
- div ecx
- pop eax ;pop n from stack
- mov ecx, 11
- cmp ecx, edx
- je xor3
- jmp mainloop
- ;n in eax
- xor3:
- not BOOL PTR [esi + 1 * eax]
- mainloopend:
- leave
- ret
- PreSieveAtkinAsm endp
- END DllEntry
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement