Created
October 24, 2018 01:50
-
-
Save Allen-B1/f297f96dc5c387ef100d4d30b7e0f743 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
isprime: | |
push eax | |
mov ecx, eax | |
sub ecx, 1 | |
.loop: | |
cmp ecx, 1 | |
je .is | |
pop eax | |
push eax | |
xor edx, edx ; edx = 0 | |
div ecx ; eax, edx = eax / ecx | |
sub ecx, 1 ; ecx -= 1 | |
cmp edx, 0 ; if edx == 0 | |
jne .loop | |
.isnot: | |
xor eax, eax | |
jmp .end | |
.is: | |
mov eax, 1 | |
; jmp .end | |
.end: | |
pop ecx | |
ret | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment