程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> 從匯編看c++的new和delete

從匯編看c++的new和delete

編輯:C++入門知識

 xx = ~* xp = 

  :     X* xp = new X
        
        ??@YAPAXI@Z                
        esp, 
        DWORD PTR $T2579[ebp], eax
        DWORD PTR $T2579[ebp], 
        SHORT $LN3@main
        
        ecx, DWORD PTR $T2579[ebp]
                                  
        ??0X@@QAE@H@Z                
        DWORD PTR tv70[ebp], eax
        SHORT $LN4@main
$
        DWORD PTR tv70[ebp], 
$
        eax, DWORD PTR tv70[ebp]
        DWORD PTR _xp$[ebp], eax

 :     delete xp
        ecx, DWORD PTR _xp$[ebp]
        DWORD PTR $T2591[ebp], ecx
        edx, DWORD PTR $T2591[ebp]
        DWORD PTR $T2590[ebp], edx
        DWORD PTR $T2590[ebp], 
        SHORT $LN5@main
         0 只調用析構函數,不調用釋放堆空間(在多重繼承時有用)
ecx, DWORD PTR $T2590[ebp] ??_GX@@QAEPAXI@Z DWORD PTR tv75[ebp], eax SHORT $LN1@main $ DWORD PTR tv75[ebp], $

 

??_GX@@QAEPAXI@Z PROC                    
        ecx
        DWORD PTR _this$[ebp], ecx
        ecx, DWORD PTR _this$[ebp]
        ??1X@@QAE@XZ                
        eax, DWORD PTR ___flags$[ebp]
        eax, 
SHORT $LN1@scalar ecx, DWORD PTR _this$[ebp] ecx ??@YAXPAX@Z esp, $ eax, DWORD PTR _this$[ebp] ;做為返回值

 xx = ~* xp =  X[

 

   X* xp = new X[]          0Ch 
                          
                          
          operator new 
           esp, 
           dword ptr [ebp-0F8h],eax
           dword ptr [ebp-],             dword ptr [ebp-0F8h],  
            main+97h (0F03617h)  
           eax,dword ptr [ebp-0F8h]  
           dword ptr [eax],  
          offset :~X (0F011DBh) 
          offset :`default constructor closure (0F011E5h)  
           edx,dword ptr [ebp-0F8h]  
           edx,  
             main+0A1h (0F03621h)  
           dword ptr [ebp-10Ch],  
               dword ptr [ebp-             dword ptr [ebp-14h],ecx  

           dword ptr [ebp-20h],  
           dword ptr [ebp-],  
           dword ptr [ebp-1Ch],  
           `eh vector constructor iterator           ecx,dword ptr [ebp+]  
          dword ptr [ebp+14h] 
           edx,dword ptr [ebp+]  
           edx,dword ptr [ebp+0Ch] 
           dword ptr [ebp+],edx 
           `eh vector constructor iterator

delete [] xp           eax,dword ptr [ebp-14h]
                                             
               dword ptr [ebp-0ECh],ecx  
           dword ptr [ebp-0ECh],  
            main+0F0h (0A23670h) 
            
                         
           ecx,dword ptr [ebp-0ECh]  
          :`vector deleting destructor00A23668  mov         dword ptr [ebp-10Ch],eax  
00A2366E  jmp         main+0FAh (0A2367Ah)  
00A23670  mov         dword ptr [ebp-10Ch],0  
    13:   
    14: }

 

:`vector deleting destructor+61h (0A21B71h)
                                                                    
          offset :~X (0A211DBh)
           eax,dword ptr [this] 
           ecx,dword ptr [eax-]  
                                             
          ecx  
            
           edx,dword ptr [this]  
          edx 
          `eh vector destructor iterator+59h (0A21B69h)  
                                                                      
           eax,dword ptr [this]  
           eax,  
          eax  
          operator delete (0A21087h) 
           esp,  
           eax,dword ptr [this]
           eax,  
           :`vector deleting destructor+7Dh (0A21B8Dh)  
                                                                      
           eax,dword ptr [this]  
          eax  
          operator delete (0A21087h)  
           esp,  
           eax,dword ptr [this] 
                    @ILT+                 

         ecx,dword ptr [ebp+0Ch]  
          ecx,dword ptr [ebp+10h]  
                                               
                                               
           ecx,dword ptr [ebp+]  
                                             
                                             
           dword ptr [ebp+],ecx  
           dword ptr [ebp-],  
           edx,dword ptr [ebp+10h]  
           edx,  
           dword ptr [ebp+10h],edx 
            `eh vector destructor iterator+51h (0A236F1h)


基本數據類型

 xx =  ~ yy =  ~ Z :  X,  zz =  ~* ip1 =  [* ip2 =  

 :     * ip1 = new []            
          operator new (141177h) 
           esp,  
           dword ptr [ebp-104h],eax  
                                                
             dword ptr [ip1],eax  
    :     delete [] ip1           eax,dword ptr [ip1]  
           dword ptr [ebp-0F8h],eax  
            ecx  
          operator delete (141082h)  
           esp,  
    :     * ip2 = new            
          operator new (141177h)
           esp,  
           dword ptr [ebp-0ECh],eax  
                                                
             dword ptr [ip2],eax  
    :     delete ip2           eax,dword ptr [ip2]  
           dword ptr [ebp-0E0h],eax   
            ecx  
          operator delete (141082h)
           esp, 

 

 

 

 

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved