2

我正在尝试用 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;
4

1 回答 1

3

是的,你可以

例如:

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
于 2013-03-11T20:12:18.653 回答