zoukankan      html  css  js  c++  java
  • C++ &参数与 *参数 在汇编代码中的分析

    C++代码:

    1 int Add(int* a, int &b) {
    2     return *a + b;
    3 }
    4 
    5 int a = 3;
    6 int b = 4;
    7 int c = Add(&a, b);

    汇编代码:

     1 00950030  /$  55                 push    ebp                     ; INT .Add(a,b)
     2 00950031  |.  8BEC               mov     ebp, esp
     3 00950033  |.  8B45 08            mov     eax, dword ptr [ebp+8]
     4 00950036  |.  8B00               mov     eax, dword ptr [eax]
     5 00950038  |.  8B4D 0C            mov     ecx, dword ptr [ebp+0C]
     6 0095003B  |.  0301               add     eax, dword ptr [ecx]
     7 0095003D  |.  5D                 pop     ebp
     8 0095003E  .  C3                 retn
     9 
    10 
    11 00950056  |.  C745 F8 03000000   mov     dword ptr [ebp-8], 3       ; int a = 3;
    12 0095005D  |.  C745 FC 04000000   mov     dword ptr [ebp-4], 4       ; int b = 4;
    13 00950064  |.  8D45 FC            lea     eax, [ebp-4]
    14 00950067  |.  50                 push    eax                        ; /b => offset LOCAL.1
    15 00950068  |.  8D4D F8            lea     ecx, [ebp-8]               ; |
    16 0095006B  |.  51                 push    ecx                        ; |a => offset LOCAL.2
    17 0095006C  |.  E8 BFFFFFFF        call    .Add       ; Add

    结论:在汇编代码中,二者并无区别。

  • 相关阅读:
    map
    01背包和完全背包 POJ
    并查集 计算节点数量
    set
    map,vector,queue 图 综合运用
    并查集 hdu-1325 Is It A Tree?
    js中的ajax
    java算法
    MySql在Window上的安装
    微信开发账号要求
  • 原文地址:https://www.cnblogs.com/gchen/p/5138801.html
Copyright © 2011-2022 走看看