My assembly program is acting strange in debugging mode. I am using Visual Studio 2017 to run a loop, which I expect to break when ecx
equals 0. However, in debugging mode, the loop continues decrementing ecx
after it equals 0. I tried many different values for ecx
and the outcome was the same. The loop works fine when I run the program without debugging. Would appreciate any tips on getting my program to work in debugging mode.
Include Irvine32.inc
.data
edward BYTE "edward cox",0
array BYTE 0,1
dat BYTE ?
.code
main proc
call ReadChar
sub eax,48 ; convert char to int
mov ecx, eax
sub ecx, 1 ; loop will run ecx-1 times
mov bl, 2 ; next value in fib sequence
L1: ; continues looping after ecx = 0
loop L1
mov edx, OFFSET edward
call WriteString
call crlf
invoke ExitProcess,0
main endp
end main