1.
can somebody please tell me why this results in a infinite loop:
.386
.model flat,stdcall ; FLAT memory model & STDCALL calling
option casemap:none ; set code to case sensitive
include \masm32\include\masm32rt.inc
.stack 4096 ; reserve 4096-byte stack
.data ; reserve storage for data
.code ; start of main program code
start:
mov ecx,96
s:
inc ecx
inc ecx
cmp ecx, 9
je e
print " ",97,13,10
jmp s
e:
invoke ExitProcess, 0 ; return 0;
PUBLIC start
end start ; end of source code
thanks in advance
mis-type:
cmp ecx, 9
shoudl be
cmp ecx, 99
still infinite loop.
Using higl level loop
mov ecx,96
.REPEAT
statements
.UNTILCXZ
mov ecx,96
.REPEAT
inc ecx
inc ecx
cmp ecx, 99
mov ecx, 0
print " ",97,10,13
.UNTILCXZ
still infinite loop, anything I did wrong???
Hello:
If you start at ecx = 96
inc ecx : now is 97
inc ecx : now is 98
cmp to 99 : nope so loop again
inc ecx : now is 99
inc ecx : now is 100
cmp to 99 : nope so loop again
over and over
Take out one of the inc ecx statements. Also, if you set ecx to zero every time through the loop, you will get infinite loop syndrome.
Regards,
SS
thanks...i took out one of the inc...
mov ecx,96
.REPEAT
inc ecx
cmp ecx, 99
mov ecx, 0
print " ",97,10,13
.UNTILCXZ
this still gives me infinite loope
Take out mov ecx,0
SS
mov ecx,96
.REPEAT
inc ecx
cmp ecx, 99
print " ",97,10,13
.UNTILCXZ
still gives infinite loop...thanks
Hello:
Well thats a real noodle baker then. I am not familiar with the Print macro. Is it trashing the ecx register? Try and step through your code with a debugger, you will see what is going on. I use Ollydbg for debugging purposes.
Regards,
SS
ecx is a scratch register that needs to be preserved when calling subroutines. (macro print calls StdOut which calls WriteFile).
mov ecx,96
.REPEAT
inc ecx
push ecx
print " ",97,10,13
pop ecx
.UNTIL ecx == 99
THANKS A lot, that worked..... :bg