I'm trying to print prime numbers between 2 - 100000. But there's something wrong with my code. When It detects a non prime number It should go to the next one, yet it still prints it out, so instead of 2, 3, 5, 7.. I'm getting 2 3 4 5 6 7...
%include "io64.inc"
section .text
global CMAIN
CMAIN:
PRINT_DEC 1,2
NEWLINE
reset_ebx:
mov ebx,2
loop2:
xor edx,edx
mov eax,[num]
div ebx
inc ebx
cmp ebx,[num+1]
je end
cmp edx,0
je loop2
cmp edx,0
jne prime
prime:
PRINT_DEC 8,[num]
NEWLINE
end:
mov eax,[num]
inc eax ; 3 - 10000
mov [num],eax
cmp eax,10001
jne reset_ebx
xor rax, rax
ret
section .data
num dq 3
max_ebx dq 0
const dq 2