gpt4 book ai didi

assembly - 用 MASM 汇编语言定义带参数的函数

转载 作者:行者123 更新时间:2023-12-04 05:07:25 27 4
gpt4 key购买 nike

我正在尝试用 x86 汇编语言编写一个接受三个参数的函数。是否可以用 MASM 汇编语言定义一个具有多个参数的函数?

//this is pseudocode: I'm trying to convert this to a valid macro in MASM
//if var1 is equal to var2, jump to the label jumpToHere
function jumpIfEqual(var1, var2, jumpToHere){
cmp var1, var2;
je jumpToHere;
}

如果我可以编写一个有效的函数来执行此操作,那么 jumpIfEqual(5, 5, jumpToHere) 将等同于

cmp 5, 5;
je jumpToHere;

最佳答案

Yes, you can .

例如:

jumpIfEqual PROC var1:DWORD, var2:DWORD, jmpAddress:DWORD
mov eax,var1
cmp eax,var2
jne skip
pop eax
push jmpAddress
skip:
ret
jumpIfEqual ENDP

....

push OFFSET jumpToHere
mov eax, 5
push eax
push eax
call jumpIfEqual

关于assembly - 用 MASM 汇编语言定义带参数的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15345645/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com