I'm trying to write a function in x86 assembly language that will accept three parameters. Is it possible to define a function in MASM assembly language with multiple parameters?
//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;
}
If I could write a valid function to do this, then jumpIfEqual(5, 5, jumpToHere) would be equivalent to
cmp 5, 5;
je jumpToHere;
Yes, you can.
For example:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With