在程序集 x64 中将 dword 参数推送到堆栈时出现问题 [重复]

问题描述 投票:0回答:0

在我的 C++ 主函数中,我将 6 个 int 参数传递给一个用汇编 x64 编写的子例程。前四个参数在寄存器中,但我正在努力从堆栈中获取最后两个参数。这是我的代码:

.code
myProc1 proc a:DWORD, b:DWORD, c:DWORD, d:DWORD, e:DWORD, f:DWORD
 push rbp
 mov rbp, rsp
 sub rsp, 32  ; allocate shadow space 'padding'
 sub rsp, 16  ; allocate space for fifth and sixth argument
 mov DWORD PTR [rsp + 20h], e  ; push fifth argument
 mov DWORD PTR [rsp + 24h], f  ; push sixth argument
 mov rsp, rbp
 pop rbp
 ret
myProc1 endp
end

当我尝试将 e i f 压入堆栈时,我得到“无效指令操作数”。而且我只是不知道如何尝试将 dword 推入堆栈。

我试过在 qwords 上使用 push 和 pop,但是 e 和 f 的值不是应该的。我猜这是因为 int 和 qword 的大小不同。

assembly stack x86-64 subroutine
© www.soinside.com 2019 - 2024. All rights reserved.