Having some problems with making loops work.. the example below doesnt work for me :(
(sry for any typos) btw i use masm32

mov ecx,5
loopy:
invoke MessageBox,NULL,offset msgtxt,offset msgcap,MB_OK
dec ecx
cmp ecx,0
jne loopy

(Note, this is a code snippet of the loop and is not supposed to reassemble a complete functional program) Seems logical to me, but this loop will loop forever. Dunno why, do you? :confused: Please explain for a sad newbian!
Posted on 2002-12-22 11:28:45 by kn9sk
api functions will only preserve ebx, esi and edi.
btw, you may leave out the 'cmp ecx,0' :)
Posted on 2002-12-22 11:48:12 by Tola

api functions will only preserve ebx, esi and edi.
btw, you may leave out the 'cmp ecx,0' :)


Hi Tola!

Thanks for your answer, Tola. May i skip the compair, why is that? Does the dec instruction compair the operand with 0 and sets the Z flag itself, or am i complete gone hehe
Posted on 2002-12-22 12:01:22 by kn9sk



Hi Tola!

Thanks for your answer, Tola. May i skip the compair, why is that? Does the dec instruction compair the operand with 0 and sets the Z flag itself, or am i complete gone hehe

yes, dec ecx will set the zero flag. :)
Posted on 2002-12-22 12:30:38 by Tola