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
结论:在汇编代码中,二者并无区别。