I'm trying to write in in-line assembly language whether the iteration from 2 to 200 is prime, given we're doing i2+1 on each iteration. I have started writing it, but it just computes every second number from 2 - 200.
I know I have my logic messed up in the prime loop, as it obviously isn't correctly checking whether than number is prime, but do not have nearly enough experience with Assembly to understand what I am doing wrong.
Any help would be greatly appreciated. Here is my code for reference:
#include <stdio.h>
int main() {
int i = 2, prime;
int c = 2;
__asm {
top: mov eax, i
cmp eax, 200
jg done
mul i
add eax, 1
prime: mov edx, 0
div c
cmp edx, 0
je done
mov prime, 1
cmp prime, 1
jne done
}
printf("%d\n", i);
__asm {
add i, 2
loop top
done: nop
}
}
The proper run of the program should compute : 2, 4, 6, 10, 14 ...