I've been tasked with creating a program that will list composite numbers within a user identified range. To determine if a number is composite I will be dividing it and checking for a remainder of zero. My actual problem is trying to print the variable called "current" in my code. current is initialized to 3 and then incremented every loop, so I expect the number 4 to be printed first but 2 prints first. How is this possible, current never even gets to 2, it only increases from 3.
mov ecx, terms
trial:
inc current
mov eax, current
cdq
mov ebx, 2
div ebx
cmp edx, 0
je composite
cmp edx, 0
jg below
composite:
mov edx, OFFSET current
call WriteDec
call CrLf
below:
loop trial
If I input 9 I expect 4, 6 and 8 to print because these all leave a remainder of 0 when divided by 2. instead I get 2, 3, 4, 5 and 6 printed.