|
发表于 2020-11-27 14:42:22
|
显示全部楼层
本帖最后由 小甲鱼的铁粉 于 2020-11-27 14:44 编辑
- 7: printf("第二个%d\n",(++a)+(a++)*(a--));
- 00401049 mov edx,dword ptr [ebp-4] ;edx = 99
- 0040104C add edx,1 ;edx = 99 + 1 = 100
- 0040104F mov dword ptr [ebp-4],edx ;a = edx = 100
- 00401052 mov eax,dword ptr [ebp-4] ;eax = a = 100
- 00401055 imul eax,dword ptr [ebp-4] ;eax = eax * a = 10000
- 00401059 mov ecx,dword ptr [ebp-4] ;ecx = a = 100
- 0040105C add ecx,eax ;ecx = ecx + eax = 10100
- 0040105E mov dword ptr [ebp-8],ecx ;b = ecx = 10100, b只是暂时的一个变量,方便理解
- 00401061 mov edx,dword ptr [ebp-8] ;edx = b = 10100
- 00401064 push edx
- 00401065 push offset string "\xb5\xda\xb6\xfe\xb8\xf6%d\n" (0042201c)
- 0040106A mov eax,dword ptr [ebp-4] ;eax = a = 100
- 0040106D sub eax,1 ;eax = eax - 1 = 99
- 00401070 mov dword ptr [ebp-4],eax ;a = eax = 99
- 00401073 mov ecx,dword ptr [ebp-4] ;ecx = a = 99
- 00401076 add ecx,1 ;ecx = ecx + 1 = 100
- 00401079 mov dword ptr [ebp-4],ecx ;a = ecx = 100
- 0040107C call printf (004010c0)
- 00401081 add esp,8
复制代码
这是printf("第二个%d\n",(++a)+(a++)*(a--));编译为汇编的代码,每一句后面的;之后的是注释
所以执行顺序是
++a --> a * a + a --> 输出 --> a-- --> a++ |
|