程序代码:
2: int main()
3: {
00401020 push ebp
00401021 mov ebp,esp
00401023 sub esp,58h
00401026 push ebx
00401027 push esi
00401028 push edi
00401029 lea edi,[ebp-58h]
0040102C mov ecx,16h
00401031 mov eax,0CCCCCCCCh
00401036 rep stos dword ptr [edi]
4: int a,b,c;
5: int *p1=&a,*p2=&b,*p3=&c;
00401038 lea eax,[ebp-4] //这里是为变量a分配内存,它的地址即ebp-4=p1
0040103B mov dword ptr [ebp-10h],eax //将地址变量(指针p1)放到ebp-10h内存单元中即&p1=ebp-10h
0040103E lea ecx,[ebp-8] //同上p2=ebp-8
00401041 mov dword ptr [ebp-14h],ecx
00401044 lea edx,[ebp-0Ch] //p3=ebp-12
00401047 mov dword ptr [ebp-18h],edx
6: printf("请输入两个数字:\n");
0040104A push offset string "\xc7\xeb\xca\xe4\xc8\xeb\xc1\xbd\xb8\xf6\xca\xfd\xd7\xd6:\n" (00424014)
0040104F call printf (00401190)
00401054 add esp,4
7: scanf("%d %d %d",&a,&b,&c);
00401057 lea eax,[ebp-0Ch]
0040105A push eax
0040105B lea ecx,[ebp-8]
0040105E push ecx
0040105F lea edx,[ebp-4]
00401062 push edx
00401063 push offset string "%d %d %d" (00424008)
00401068 call scanf (0040fa20)
上面是一段用VC++6.0反汇编得到的代码。
可以看到p1=ebp-4,p2=ebp-8,p3=ebp-12
这样应该好理解了吧