Skip to content

Instantly share code, notes, and snippets.

@Allen-B1
Created October 24, 2018 01:50
Show Gist options
  • Save Allen-B1/f297f96dc5c387ef100d4d30b7e0f743 to your computer and use it in GitHub Desktop.
Save Allen-B1/f297f96dc5c387ef100d4d30b7e0f743 to your computer and use it in GitHub Desktop.
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