汇编遇到不会的帮个吧

[复制链接]
查看11 | 回复1 | 2011-5-11 09:52:08 | 显示全部楼层 |阅读模式
#include
using namespace std;
int myfunction(int a,int b)
{

return a+b;
}
int main()
{

int a=3,b=4;

cout<<"a+b="<<myfunction(a,b);
}
我用codeBlocks写了简单的程序然后disassembly结果成这样了
00401318        push %ebp
00401319        mov
%esp,%ebp
0040131B        mov
0xc(%ebp),%eax
0040131E        mov
0x8(%ebp),%edx
00401321        lea
(%edx,%eax,1),%eax
00401324        leave
00401325        ret
这里的这3行不明白
0040131B        mov
0xc(%ebp),%eax
0040131E        mov
0x8(%ebp),%edx
00401321        lea
(%edx,%eax,1),%eax
那位大侠解释解释啊
具体 0xc(%ebp),

0x8(%ebp),

(%edx,%eax,1),这3个意思是什么?

回复

使用道具 举报

千问 | 2011-5-11 09:52:08 | 显示全部楼层
调用函数你首先要知道函数参数是怎么确定的默认的调用方式为c call,参数从右往左压入,由调用者清理堆栈。在函数调用时堆栈中的数据,从esp开始为 返回指针 第一个参数 第二个参数……返回值放到eax里面00401318push %ebp
//由于又一次入栈,所以从esp+4开始返回指针 第一个参
数 第二个参数00401319mov
%esp,%ebp
//堆栈指针存入0040131Bmov
0xc(%ebp),%eax //第一个参数a送入eax0040131Emov
0x8(%ebp),%edx//第二个参数b送入
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行