|
发表于 2018-6-2 14:24:11
|
显示全部楼层
#include <stdio.h>
int main(void)
{
int i, j, p, q;
i = 5, j = 5;
p = (i++) + (i++) + (i++);
q = (++j) + (++j) + (++j);
printf("i=%d j=%d p=%d q=%d\n", i, j, p, q);
return 0;
}
int main(void)
{
010A7700 push ebp
010A7701 mov ebp,esp
010A7703 sub esp,0F0h
010A7709 push ebx
010A770A push esi
010A770B push edi
010A770C lea edi,[ebp-0F0h]
010A7712 mov ecx,3Ch
010A7717 mov eax,0CCCCCCCCh
010A771C rep stos dword ptr es:[edi]
int i, j, p, q;
i = 5, j = 5;
010A771E mov dword ptr [i],5
010A7725 mov dword ptr [j],5
p = (i++) + (i++) + (i++);
010A772C mov eax,dword ptr [i]
010A772F add eax,dword ptr [i]
010A7732 add eax,dword ptr [i]
010A7735 mov dword ptr [p],eax
010A7738 mov ecx,dword ptr [i]
010A773B add ecx,1
010A773E mov dword ptr [i],ecx
010A7741 mov edx,dword ptr [i]
010A7744 add edx,1
010A7747 mov dword ptr [i],edx
010A774A mov eax,dword ptr [i]
010A774D add eax,1
010A7750 mov dword ptr [i],eax
q = (++j) + (++j) + (++j);
010A7753 mov eax,dword ptr [j]
010A7756 add eax,1
010A7759 mov dword ptr [j],eax
010A775C mov ecx,dword ptr [j]
010A775F add ecx,1
010A7762 mov dword ptr [j],ecx
010A7765 mov edx,dword ptr [j]
010A7768 add edx,1
010A776B mov dword ptr [j],edx
010A776E mov eax,dword ptr [j]
010A7771 add eax,dword ptr [j]
010A7774 add eax,dword ptr [j]
010A7777 mov dword ptr [q],eax
printf("i=%d j=%d p=%d q=%d\n", i, j, p, q);
010A777A mov eax,dword ptr [q]
010A777D push eax
010A777E mov ecx,dword ptr [p]
010A7781 push ecx
010A7782 mov edx,dword ptr [j]
010A7785 push edx
010A7786 mov eax,dword ptr [i]
010A7789 push eax
010A778A push offset string "i=%d j=%d p=%d q=%d\n" (01133E50h)
010A778F call _printf (0109BD9Bh)
010A7794 add esp,14h
return 0;
010A7797 xor eax,eax
}
010A7799 pop edi
010A779A pop esi
010A779B pop ebx
010A779C add esp,0F0h
010A77A2 cmp ebp,esp
010A77A4 call __RTC_CheckEsp (0109A383h)
010A77A9 mov esp,ebp
010A77AB pop ebp
010A77AC ret
#include <stdio.h>
int main(void)
{
int i, j, p, q;
i = 5, j = 5;
// *******************************
p = i + i + i;
i++;
i++;
i++;
p = (i++) + (i++) + (i++);
// *******************************
++j;
++j;
++j;
q = j + j + j;
q = (++j) + (++j) + (++j);
// *******************************
printf("i=%d j=%d p=%d q=%d\n", i, j, p, q);
return 0;
}
int main(void)
{
00C37700 push ebp
00C37701 mov ebp,esp
00C37703 sub esp,0F0h
00C37709 push ebx
00C3770A push esi
00C3770B push edi
00C3770C lea edi,[ebp-0F0h]
00C37712 mov ecx,3Ch
00C37717 mov eax,0CCCCCCCCh
00C3771C rep stos dword ptr es:[edi]
int i, j, p, q;
i = 5, j = 5;
00C3771E mov dword ptr [i],5
00C37725 mov dword ptr [j],5
// *******************************
p = i + i + i;
00C3772C mov eax,dword ptr [i]
00C3772F add eax,dword ptr [i]
00C37732 add eax,dword ptr [i]
00C37735 mov dword ptr [p],eax
i++;
00C37738 mov eax,dword ptr [i]
00C3773B add eax,1
00C3773E mov dword ptr [i],eax
i++;
00C37741 mov eax,dword ptr [i]
00C37744 add eax,1
00C37747 mov dword ptr [i],eax
i++;
00C3774A mov eax,dword ptr [i]
00C3774D add eax,1
00C37750 mov dword ptr [i],eax
p = (i++) + (i++) + (i++);
00C37753 mov eax,dword ptr [i]
00C37756 add eax,dword ptr [i]
00C37759 add eax,dword ptr [i]
00C3775C mov dword ptr [p],eax
00C3775F mov ecx,dword ptr [i]
00C37762 add ecx,1
00C37765 mov dword ptr [i],ecx
00C37768 mov edx,dword ptr [i]
00C3776B add edx,1
00C3776E mov dword ptr [i],edx
00C37771 mov eax,dword ptr [i]
00C37774 add eax,1
00C37777 mov dword ptr [i],eax
// *******************************
++j;
00C3777A mov eax,dword ptr [j]
00C3777D add eax,1
00C37780 mov dword ptr [j],eax
++j;
00C37783 mov eax,dword ptr [j]
00C37786 add eax,1
00C37789 mov dword ptr [j],eax
++j;
00C3778C mov eax,dword ptr [j]
++j;
00C3778F add eax,1
00C37792 mov dword ptr [j],eax
q = j + j + j;
00C37795 mov eax,dword ptr [j]
00C37798 add eax,dword ptr [j]
00C3779B add eax,dword ptr [j]
00C3779E mov dword ptr [q],eax
q = (++j) + (++j) + (++j);
00C377A1 mov eax,dword ptr [j]
00C377A4 add eax,1
00C377A7 mov dword ptr [j],eax
00C377AA mov ecx,dword ptr [j]
00C377AD add ecx,1
00C377B0 mov dword ptr [j],ecx
00C377B3 mov edx,dword ptr [j]
00C377B6 add edx,1
00C377B9 mov dword ptr [j],edx
00C377BC mov eax,dword ptr [j]
00C377BF add eax,dword ptr [j]
00C377C2 add eax,dword ptr [j]
00C377C5 mov dword ptr [q],eax
// *******************************
printf("i=%d j=%d p=%d q=%d\n", i, j, p, q);
00C377C8 mov eax,dword ptr [q]
00C377CB push eax
00C377CC mov ecx,dword ptr [p]
00C377CF push ecx
00C377D0 mov edx,dword ptr [j]
00C377D3 push edx
00C377D4 mov eax,dword ptr [i]
00C377D7 push eax
00C377D8 push offset string "i=%d j=%d p=%d q=%d\n" (0CC3E50h)
00C377DD call _printf (0C2BD9Bh)
// *******************************
printf("i=%d j=%d p=%d q=%d\n", i, j, p, q);
00C377E2 add esp,14h
return 0;
00C377E5 xor eax,eax
}
00C377E7 pop edi
00C377E8 pop esi
00C377E9 pop ebx
00C377EA add esp,0F0h
00C377F0 cmp ebp,esp
00C377F2 call __RTC_CheckEsp (0C2A383h)
00C377F7 mov esp,ebp
00C377F9 pop ebp
00C377FA ret
可以看到 p = i + i + i;
i++;
i++;
i++;
相当于p = (i++) + (i++) + (i++);
++j;
++j;
++j;
q = j + j + j;
相当于q = (++j) + (++j) + (++j);
|
|