当前位置: 代码迷 >> 汇编语言 >> 用汇编来解释c++函数调用!该怎么解决
  详细解决方案

用汇编来解释c++函数调用!该怎么解决

热度:3915   发布时间:2013-02-26 00:00:00.0
用汇编来解释c++函数调用!!
先看c++的代码!
C/C++ code
#include<iostream>using namespace std;class Myclass{    public:       Myclass(int n) { number=n;}    private:        int number;};int main(){     Myclass obj3(2);      return 0;}










下是汇编代码!



C/C++ code
12:   int main()13:   {00401030   push        ebp00401031   mov         ebp,esp00401033   sub         esp,44h00401036   push        ebx00401037   push        esi00401038   push        edi00401039   lea         edi,[ebp-44h]0040103C   mov         ecx,11h00401041   mov         eax,0CCCCCCCCh00401046   rep stos    dword ptr [edi]14:15:      Myclass obj3(2);00401048   push        20040104A   lea         ecx,[ebp-4]   //这里我不明白?,ebp-4指向的不是ebx的值吗,因为:(00401036 push ebx)0040104D   call        @ILT+15(Myclass::Myclass) (00401014)16:17:      return 0;00401052   xor         eax,eax18:   }00401054   pop         edi00401055   pop         esi00401056   pop         ebx00401057   add         esp,44h0040105A   cmp         ebp,esp0040105C   call        __chkesp (00408190)00401061   mov         esp,ebp00401063   pop         ebp00401064   ret


------解决方案--------------------------------------------------------
探讨
先看c++的代码!

C/C++ code

#include<iostream>
using namespace std;
class Myclass
{
public:
Myclass(int n) { number=n;}
private:
int number;
};


int main()
{

……
  相关解决方案