1 year ago
#365864
Bryson Weeks
Passing parameters by reference from C++ to x86 MASM
I'm trying to pass parameters by reference from C++ to a function written in assembly, but I can't seem to actually change the value within the assembly function. What am I doing wrong here?
void __declspec(naked) asmChange(int&){
__asm{
mov [esp+4], 5
ret
}
}
int main (){
int a = 12;
cout << "Before: " << a << endl;
asmChange(a);
cout << "After: " << a << endl;
return 0;
}
In the program above I'm simply trying to change the value of a variable. I don't really understand what I'm doing wrong here and can't seem to find any answers to my issue anywhere else online.
c++
assembly
masm
0 Answers
Your Answer