开发者

Endless loop with assember

OK, I'm new to PC Assembler. I"m trying to write an program, but it won't stop looping. I'm guessing the ECX register is being modified? How can I fix this? Thanks.

DATA SECTION
;
KEEP DD 0                   ;temporary p开发者_C百科lace to keep things
;
CODE SECTION
;
START:
MOV ECX,12
TOPOFLOOP:
PUSH -11                        ;STD_OUTPUT_HANDLE
CALL GetStdHandle           ;get, in eax, handle to active screen buffer
PUSH 0,ADDR KEEP            ;KEEP receives output from API
PUSH 5,'bruce'                  ;5=length of string
PUSH EAX                    ;handle to active screen buffer
CALL WriteFile
XOR EAX,EAX                 ;return eax=0 as preferred by Windows
LOOP TOPOFLOOP
ENDLABEL:
RET


In most x86 calling convention, including the stdcall convention used by Windows API functions, ECX is a caller-save register -- the called function is not required to make sure the value of the register is the same when it returns as when it was called. You have to save it somewhere safe in your own code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜