码迷,mamicode.com
首页 > 编程语言 > 详细

C++反汇编实例(1)-输出多行

时间:2015-04-01 12:51:33      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:

111

 1 //程序说明:输出多行内容,内容如下
 2 /*
 3    *
 4   ***
 5  *****
 6 *******
 7  *****
 8   ***
 9    *
10 */
11 #include <iostream>
12 using namespace std;
13 int main()
14 {
15     cout << "   *" << endl;
16     cout << "  ***" << endl;
17     cout << " *****" << endl;
18     cout << "*******" << endl;
19     cout << " *****" << endl;
20     cout << "  ***" << endl;
21     cout << "   *" << endl;
22     system("pause");
23     return 0;
24 }

debug版反汇编代码

int main()
{
00F55E70  push        ebp  //进入函数后的第一件事,保存栈底指针ebp,退出函数时还原栈底
00F55E71  mov         ebp,esp  //调整栈底指针到栈顶
00F55E73  sub         esp,0C0h  //为局部变量申请空间
00F55E79  push        ebx  
00F55E7A  push        esi  
00F55E7B  push        edi  //寄存器压栈,保存现场
00F55E7C  lea         edi,[ebp-0C0h]  //将为局部变量申请的空间(栈中)的首地址(偏移)放入edi中
00F55E82  mov         ecx,30h  //设置rep stos的循环次数
00F55E87  mov         eax,0CCCCCCCCh  //debug下,为调试方便,将局部变量初始化为OCCCCCCCCh。
00F55E8C  rep stos    dword ptr es:[edi]  //用eax的值初始化到es:[edi]指向的地址,以dword(4字节)为单位,循环次数为ecx的值。
    cout << "   *" << endl;
00F55E8E  mov         esi,esp  
00F55E90  push        0F513DEh  
00F55E95  push        0F5CC70h  
00F55E9A  mov         eax,dword ptr ds:[00F6009Ch]  
00F55E9F  push        eax  
00F55EA0  call        std::operator<<<std::char_traits<char> > (0F512A8h)  //调用cout对象的成员函数operator<<(重载操作符<<)。
00F55EA5  add         esp,8  
00F55EA8  mov         ecx,eax  
00F55EAA  call        dword ptr ds:[0F60090h]  
00F55EB0  cmp         esi,esp  
00F55EB2  call        __RTC_CheckEsp (0F5132Fh)  //debug下特有的函数,用来检测栈平衡,所有函数退出时,都使用该函数。
    cout << "  ***" << endl;
...............................
.................................
...............................
system("pause");
00F55FAD  mov         esi,esp  
00F55FAF  push        0F5CC94h  
00F55FB4  call        dword ptr ds:[0F601D0h]  
00F55FBA  add         esp,4  
00F55FBD  cmp         esi,esp  
00F55FBF  call        __RTC_CheckEsp (0F5132Fh)  
    return 0;
00F55FC4  xor         eax,eax  
}
00F55FC6  pop         edi  
00F55FC7  pop         esi  
00F55FC8  pop         ebx  //恢复现场。
00F55FC9  add         esp,0C0h  //C/C++的函数调用约定默认是_cdecl调用方式,由调用放平衡堆栈。
00F55FCF cmp ebp,esp 00F55FD1 call __RTC_CheckEsp (0F5132Fh) 
00F55FD6 mov esp,ebp 00F55FD8 pop ebp //还原栈底指针
00F55FD9 ret

release版反汇编代码

 

C++反汇编实例(1)-输出多行

标签:

原文地址:http://www.cnblogs.com/nitianbenbendan/p/4382970.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!