[C++基础]011_#define的代码生成的汇编码在哪里

现在有一段源码:

 

 1 #include <iostream>
 2 using namespace std;
 3 
 4 #define  DefFunc  cout<<"Hello, Define function."<<endl;\
 5     cout<<"This is a defined function"<<endl;
 6 
 7 int main(){
 8     DefFunc
 9     DefFunc
10     DefFunc
11     system("pause");
12     return 0;
13 }

 

如书中所说,通过查看汇编码,我们可以看到宏定义的函数被完全的嵌入进main函数了,如下:

    DefFunc
00BA14C6  mov         esi,esp  
00BA14C8  mov         eax,dword ptr [__imp_std::endl (0BAA314h)]  
00BA14CD  push        eax  
00BA14CE  push        offset string "Hello, Define function." (0BA7858h)  
00BA14D3  mov         ecx,dword ptr [__imp_std::cout (0BAA318h)]  
00BA14D9  push        ecx  
00BA14DA  call        std::operator<<<std::char_traits<char> > (0BA1145h)  
00BA14DF  add         esp,8  
00BA14E2  mov         ecx,eax  
00BA14E4  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (0BAA300h)]  
00BA14EA  cmp         esi,esp  
00BA14EC  call        @ILT+400(__RTC_CheckEsp) (0BA1195h)  
00BA14F1  mov         esi,esp  
00BA14F3  mov         eax,dword ptr [__imp_std::endl (0BAA314h)]  
00BA14F8  push        eax  
00BA14F9  push        offset string "This is a defined function" (0BA7838h)  
00BA14FE  mov         ecx,dword ptr [__imp_std::cout (0BAA318h)]  
00BA1504  push        ecx  
00BA1505  call        std::operator<<<std::char_traits<char> > (0BA1145h)  
00BA150A  add         esp,8  
00BA150D  mov         ecx,eax  
00BA150F  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (0BAA300h)]  
00BA1515  cmp         esi,esp  
00BA1517  call        @ILT+400(__RTC_CheckEsp) (0BA1195h)  
    DefFunc
00BA151C  mov         esi,esp  
00BA151E  mov         eax,dword ptr [__imp_std::endl (0BAA314h)]  
00BA1523  push        eax  
00BA1524  push        offset string "Hello, Define function." (0BA7858h)  
00BA1529  mov         ecx,dword ptr [__imp_std::cout (0BAA318h)]  
00BA152F  push        ecx  
00BA1530  call        std::operator<<<std::char_traits<char> > (0BA1145h)  
00BA1535  add         esp,8  
00BA1538  mov         ecx,eax  
00BA153A  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (0BAA300h)]  
00BA1540  cmp         esi,esp  
00BA1542  call        @ILT+400(__RTC_CheckEsp) (0BA1195h)  
00BA1547  mov         esi,esp  
00BA1549  mov         eax,dword ptr [__imp_std::endl (0BAA314h)]  
00BA154E  push        eax  
00BA154F  push        offset string "This is a defined function" (0BA7838h)  
00BA1554  mov         ecx,dword ptr [__imp_std::cout (0BAA318h)]  
00BA155A  push        ecx  
00BA155B  call        std::operator<<<std::char_traits<char> > (0BA1145h)  
00BA1560  add         esp,8  
00BA1563  mov         ecx,eax  
00BA1565  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (0BAA300h)]  
00BA156B  cmp         esi,esp  
00BA156D  call        @ILT+400(__RTC_CheckEsp) (0BA1195h)  
    DefFunc
00BA1572  mov         esi,esp  
00BA1574  mov         eax,dword ptr [__imp_std::endl (0BAA314h)]  
00BA1579  push        eax  
00BA157A  push        offset string "Hello, Define function." (0BA7858h)  
00BA157F  mov         ecx,dword ptr [__imp_std::cout (0BAA318h)]  
00BA1585  push        ecx  
00BA1586  call        std::operator<<<std::char_traits<char> > (0BA1145h)  
00BA158B  add         esp,8  
00BA158E  mov         ecx,eax  
00BA1590  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (0BAA300h)]  
00BA1596  cmp         esi,esp  
00BA1598  call        @ILT+400(__RTC_CheckEsp) (0BA1195h)  
00BA159D  mov         esi,esp  
00BA159F  mov         eax,dword ptr [__imp_std::endl (0BAA314h)]  
00BA15A4  push        eax  
00BA15A5  push        offset string "This is a defined function" (0BA7838h)  
00BA15AA  mov         ecx,dword ptr [__imp_std::cout (0BAA318h)]  
00BA15B0  push        ecx  
00BA15B1  call        std::operator<<<std::char_traits<char> > (0BA1145h)  
00BA15B6  add         esp,8  
00BA15B9  mov         ecx,eax  
00BA15BB  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (0BAA300h)]  
00BA15C1  cmp         esi,esp  
00BA15C3  call        @ILT+400(__RTC_CheckEsp) (0BA1195h)  
    system("pause");

 

 

转载于:https://www.cnblogs.com/alephsoul-alephsoul/archive/2012/10/09/2717602.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值