编译器视变量名为地址,这你看上面我给的编译结果就知道了。
授人以渔,不授人以鱼。
; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.30319.01 TITLE C:\Users\TonyDeng\Documents\Visual Studio 2010\Projects\test4\test4\test.cpp .686P .XMM include listing.inc .model flat INCLUDELIB OLDNAMES EXTRN @__security_check_cookie@4:PROC EXTRN __imp__printf:PROC EXTRN __imp___getwch:PROC $SG-5 DB 'a = %d, &a[0] = %d, &a = %d, d = %d, d[0] = %d', 0aH, 00H PUBLIC __$ArrayPad$ PUBLIC _main EXTRN ___security_cookie:DWORD EXTRN @_RTC_CheckStackVars@8:PROC EXTRN __RTC_CheckEsp:PROC ; Function compile flags: /Odtp /RTCsu ; File c:\users\tonydeng\documents\visual studio 2010\projects\test4\test4\test.cpp _TEXT SEGMENT _y$ = -64 ; size = 4 _x$ = -60 ; size = 4 _d$ = -56 ; size = 4 _a$ = -48 ; size = 40 __$ArrayPad$ = -4 ; size = 4 _main PROC ; 5 : { 00000 55 push ebp 00001 8b ec mov ebp, esp 00003 83 ec 40 sub esp, 64 ; 00000040H 00006 56 push esi 00007 57 push edi 00008 8d 7d c0 lea edi, DWORD PTR [ebp-64] 0000b b9 10 00 00 00 mov ecx, 16 ; 00000010H 00010 b8 cc cc cc cc mov eax, -858993460 ; ccccccccH 00015 f3 ab rep stosd 00017 a1 00 00 00 00 mov eax, DWORD PTR ___security_cookie 0001c 33 c5 xor eax, ebp 0001e 89 45 fc mov DWORD PTR __$ArrayPad$[ebp], eax ; 6 : int a[10] = {0x10, 0x11}; 00021 c7 45 d0 10 00 00 00 mov DWORD PTR _a$[ebp], 16 ; 00000010H 00028 c7 45 d4 11 00 00 00 mov DWORD PTR _a$[ebp+4], 17 ; 00000011H 0002f 33 c0 xor eax, eax 00031 89 45 d8 mov DWORD PTR _a$[ebp+8], eax 00034 89 45 dc mov DWORD PTR _a$[ebp+12], eax 00037 89 45 e0 mov DWORD PTR _a$[ebp+16], eax 0003a 89 45 e4 mov DWORD PTR _a$[ebp+20], eax 0003d 89 45 e8 mov DWORD PTR _a$[ebp+24], eax 00040 89 45 ec mov DWORD PTR _a$[ebp+28], eax 00043 89 45 f0 mov DWORD PTR _a$[ebp+32], eax 00046 89 45 f4 mov DWORD PTR _a$[ebp+36], eax ; 7 : int (*d)[10]; ; 8 : int x = 0x20; 00049 c7 45 c4 20 00 00 00 mov DWORD PTR _x$[ebp], 32 ; 00000020H ; 9 : int y; ; 10 : ; 11 : d = &a; 00050 8d 4d d0 lea ecx, DWORD PTR _a$[ebp] 00053 89 4d c8 mov DWORD PTR _d$[ebp], ecx ; 12 : y = x; 00056 8b 55 c4 mov edx, DWORD PTR _x$[ebp] 00059 89 55 c0 mov DWORD PTR _y$[ebp], edx ; 13 : printf("a = %d, &a[0] = %d, &a = %d, d = %d, d[0] = %d\n", a, &a[0], &a, d, d[0]); 0005c 8b f4 mov esi, esp 0005e 8b 45 c8 mov eax, DWORD PTR _d$[ebp] 00061 50 push eax 00062 8b 4d c8 mov ecx, DWORD PTR _d$[ebp] 00065 51 push ecx 00066 8d 55 d0 lea edx, DWORD PTR _a$[ebp] 00069 52 push edx 0006a 8d 45 d0 lea eax, DWORD PTR _a$[ebp] 0006d 50 push eax 0006e 8d 4d d0 lea ecx, DWORD PTR _a$[ebp] 00071 51 push ecx 00072 68 00 00 00 00 push OFFSET $SG-5 00077 ff 15 00 00 00 00 call DWORD PTR __imp__printf 0007d 83 c4 18 add esp, 24 ; 00000018H 00080 3b f4 cmp esi, esp 00082 e8 00 00 00 00 call __RTC_CheckEsp ; 14 : _getwch(); 00087 8b f4 mov esi, esp 00089 ff 15 00 00 00 00 call DWORD PTR __imp___getwch 0008f 3b f4 cmp esi, esp 00091 e8 00 00 00 00 call __RTC_CheckEsp ; 15 : } 00096 33 c0 xor eax, eax 00098 52 push edx 00099 8b cd mov ecx, ebp 0009b 50 push eax 0009c 8d 15 00 00 00 00 lea edx, DWORD PTR $LN5@main 000a2 e8 00 00 00 00 call @_RTC_CheckStackVars@8 000a7 58 pop eax 000a8 5a pop edx 000a9 5f pop edi 000aa 5e pop esi 000ab 8b 4d fc mov ecx, DWORD PTR __$ArrayPad$[ebp] 000ae 33 cd xor ecx, ebp 000b0 e8 00 00 00 00 call @__security_check_cookie@4 000b5 83 c4 40 add esp, 64 ; 00000040H 000b8 3b ec cmp ebp, esp 000ba e8 00 00 00 00 call __RTC_CheckEsp 000bf 8b e5 mov esp, ebp 000c1 5d pop ebp 000c2 c3 ret 0 000c3 90 npad 1 $LN5@main: 000c4 01 00 00 00 DD 1 000c8 00 00 00 00 DD $LN4@main $LN4@main: 000cc d0 ff ff ff DD -48 ; ffffffd0H 000d0 28 00 00 00 DD 40 ; 00000028H 000d4 00 00 00 00 DD $LN3@main $LN3@main: 000d8 61 DB 97 ; 00000061H 000d9 00 DB 0 _main ENDP _TEXT ENDS END