通过参考参数从C++传递参数到x86巨星
我正在尝试通过引用将参数从C ++传递到汇编中编写的函数,但是我似乎实际上无法更改汇编功能中的值。我在这里做错了什么?
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;
}
在上面的程序中,我只是试图更改变量的值。我真的不明白我在这里做错了什么,似乎在网上其他任何地方都找不到我的问题的任何答案。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论