【发布时间】:2016-05-03 20:14:15
【问题描述】:
我正在尝试将 3 个参数传递给一个过程,添加它们,然后将它们返回到 MASM 的税务登记册中。但是,结果是随机的巨大数字。我正在尝试使用 C 风格的调用约定,我将 3 个变量传递给一个函数。我究竟做错了什么?这是我的代码:
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
【问题讨论】: