简体   繁体   中英

Assembly Language - push instruction being skipped

I'm working on an assembly project and for some reason when I go into the debugger and look at this call statement being executed it is skipping the first push statement.

using call statement:

push offset strPrompt
push offset strNum
push offset iArray1
call inputArray
add esp, 12
mov iNumOfEntries, eax

call statement:

inputArray      proc
mov al, al
push ebp
mov ebp, esp
push ebx
push ecx
entryLoop1:
mov ebx, 0
mov ecx, 0
invoke putstring, [ebp+16]
invoke getstring, [ebp+12], 10
invoke ascint32, [ebp+12]
jc entryLoop1

cmp eax, -1
je endMethod

mov [[ebp+8][ecx]], eax
add ecx, 4
inc ebx
jmp entryLoop1
endMethod:
mov eax, 0
mov eax, ebx
pop ecx
pop ebx
pop ebp
ret
inputArray endp
inputArray      proc
mov al, al
push ebp
mov ebp, esp

When you use the PROC directive the assembler automatically generates the prologue/epilogue code. You should not write it yourself. This could well explain the output of the debugger that you did not expect.

The assembler automatically generates the prologue code when it encounters the first instruction or label after the PROC directive.
The assembler generates the epilogue code when it encounters a RET or IRET instruction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM