看书刚学到的方法,用VS写一个c程序,然后编译,逐句调试,再点鼠标右键,选“转到反汇编”,就可以看到汇编的代码了。int Sum(int a,int b)
{
00991420 push ebp
00991421 mov ebp,esp
00991423 sub esp,0CCh
00991429 push ebx
0099142A push esi
0099142B push edi
0099142C lea edi,[ebp-0CCh]
00991432 mov ecx,33h
00991437 mov eax,0CCCCCCCCh
0099143C rep stos dword ptr es:[edi]
int c;
c=a+b;
0099143E mov eax,dword ptr [a]
00991441 add eax,dword ptr [b]
00991444 mov dword ptr [c],eax
return c;
00991447 mov eax,dword ptr [c]
}
0099144A pop edi
0099144B pop esi
0099144C pop ebx
0099144D mov esp,ebp
0099144F pop ebp
00991450 ret
int main()
{
009913A0 push ebp
009913A1 mov ebp,esp
009913A3 sub esp,0CCh
009913A9 push ebx
009913AA push esi
009913AB push edi
009913AC lea edi,[ebp-0CCh]
009913B2 mov ecx,33h
009913B7 mov eax,0CCCCCCCCh
009913BC rep stos dword ptr es:[edi]
int x;
x = Sum(3,2);
009913BE push 2
009913C0 push 3
009913C2 call @ILT+270(_Sum) (991113h)
009913C7 add esp,8
009913CA mov dword ptr [x],eax
printf("%d",x);
009913CD mov esi,esp
009913CF mov eax,dword ptr [x]
009913D2 push eax
009913D3 push offset string "%d" (99573Ch)
009913D8 call dword ptr [__imp__printf (99824Ch)]
009913DE add esp,8
009913E1 cmp esi,esp
009913E3 call @ILT+310(__RTC_CheckEsp) (99113Bh)
getch();
009913E8 call @ILT+130(__getch) (991087h)
}
009913ED xor eax,eax
009913EF pop edi
009913F0 pop esi
009913F1 pop ebx
009913F2 add esp,0CCh
009913F8 cmp ebp,esp
009913FA call @ILT+310(__RTC_CheckEsp) (99113Bh)
009913FF mov esp,ebp
00991401 pop ebp
00991402 ret
|