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指令 –