我正在嘗試將3個參數傳遞給過程,添加它們並將它們返回到MASM中的納稅註冊表中。然而,結果是一個隨機的數字。我正在嘗試使用C風格的調用約定,我將3個變量傳遞給一個函數。我究竟做錯了什麼?這裏是我的代碼:將參數通過堆棧傳遞給MASM中的過程
INCLUDE PCMAC.INC
.MODEL SMALL
.586
.STACK 100h
.DATA
.CODE
EXTRN GetDec :NEAR, PutDDec : NEAR, PutHex : NEAR
Main PROC
_Begin
push 10
push 20
push 30
call Test1
call PutDDec
add esp, 12
_Exit
Main ENDP
Test1 PROC
; *** Standard subroutine prologue ***
push ebp
mov ebp, esp
sub esp, 4
push edi
push esi
; *** Subroutine Body ***
mov eax, [ebp+8] ; parameter 1/character
mov esi, [ebp+12] ; parameter 2/width
mov edi, [ebp+16] ; parameter 3/height
mov [ebp-4], edi
add [ebp-4], esi
add eax, [ebp-8]
add eax, [ebp-4]
; *** Standard subroutine epilogue ***
pop esi ; Recover register values
pop edi
mov esp, ebp ; Deallocate local variables
pop ebp ; Restore the caller’s base pointer value
ret
Test1 ENDP
End Main
謝謝您的回答。當我打電話給「打電話PutDDec」時,結果不是加法。你知道這個的原因嗎?謝謝 – user190494
我們不知道'PutDDec'如何期待這個論點,也許它也想要這個論點。在調用PutDDec之前添加'mov [esp],eax'值得一試。 – Jester
PutDDec打印出EAX寄存器的十進制版本 – user190494