以该程序为例:
#include <stdio.h>
int Add(int x, int y)
{
int z = 0;
z = x + y;
return z;
}
int main()
{
int a = 10;
int b = 20;
int ret = 0;
ret = Add(a, b);
printf("ret = %d\n", ret0);
return 0;
}
调用过程:
1.mainCRTStartup开辟一块自己的空间
2.
1)
2)
3)
4)
5)
从edi开始每次向下拷贝数据,每次拷贝空间dword(四个字节),拷贝ecx(19)次,
拷贝的内容为eax(CCCCCCCC)
3.
4.
1)
2)
进入Add函数:
1.
(过程与main函数的相似,就不具体写了)
2.
3.
1)把a'的值放到eax中
2)把b'的值与eax相加
3)把eax的值放到z中
4.
把z的值放到eax中
5.
1)
2)
3)
4)
ret指令跳到记录的地址
接进入Add函数之前:
3)
4)
把30放入ret中
后面的步骤与之前相同,不详细写出