ASM不在堆栈上加载参数
我有一个可以使用两个整数作为参数的函数,但是每当我访问堆栈时,不在那里,我无法使用它们,因此我将随机内存值作为输出。据我了解,要调用一个函数,除了它的代码上,我不需要其他任何东西。这是Inline Intel ASM X86
#include <stdio.h>
int getNum1(int a);
int main()
{
int num1=0, num2 = 8;
__asm {
// push ebp
// mov ebp,esp
push num1
push num2
call getNum1
add esp,8
// pop ebp
mov num1,eax
}
printf("%d", num1);
return 0;
}
//this is only supossed to return the value of a, but i get random stuff
int getNum1(int a, int b)
{
__asm {
push ebp
mov ebp,esp
push ebx
mov ebx,[ebp+12]
mov eax,ebx
pop ebx
pop ebp
}
}
I have a function that is supossed to use two integers as parameters, but whenever I access to the stack, the aren't there and I cannot use them, so I get random memory values as output. As I understand, to call a function I don't need anything else apart from what its on my code. This is inline intel asm x86
#include <stdio.h>
int getNum1(int a);
int main()
{
int num1=0, num2 = 8;
__asm {
// push ebp
// mov ebp,esp
push num1
push num2
call getNum1
add esp,8
// pop ebp
mov num1,eax
}
printf("%d", num1);
return 0;
}
//this is only supossed to return the value of a, but i get random stuff
int getNum1(int a, int b)
{
__asm {
push ebp
mov ebp,esp
push ebx
mov ebx,[ebp+12]
mov eax,ebx
pop ebx
pop ebp
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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