0
我只是试图打印数组的元素。从输出我可以看到,循环超出了我的数组分配的内存。为什么这个循环无限?
.386 ; 386 Processor Instruction Set
.model flat,stdcall
option casemap:none
include \masm32\include\masm32rt.inc
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
.data
array DWORD 72,50,22,0
asd DWORD ?
start:
mov ecx, 4
mov edi, 0
//-- loop start--//
loop_start:
mov eax, [array + edi * 4]
push offset asd
push eax
call dwtoa
Invoke StdOut, addr asd
inc edi //incrementing edi
dec ecx // decrementing ecx
cmp ecx,0 // comparing ecx against 0
jne loop_start // if not equal loop again
//--loop end--//
invoke ExitProcess, 0
end start
这里是输出 http://s7.directupload.net/images/140107/2nxsljtc.png http://s7.directupload.net/images/140107/snpycplx.png
编辑:试图在年底
cmp ecx,0
je loop_end
loop_end:
Invoke ExitProcess,0
没有这些努力的补充。
在此先感谢。
这看起来像是loop_start和DEC ECX之间倒是ECX?您是否尝试过在CALL之前推送它,然后在之后弹出? –
you mean,push ecx, dec ecx, pop ecx, ? – ddacot
'dec'和'inc'会影响ZF,因此您可以减少compare-with-0指令 –