從下面的代碼可以看出,事實也是++,--都比*優先級別高,實際執行a先自加1,為6,再自減1,為5,在經行乘法運算
測試代碼
int main()
{
int a=5,b; b=++a*--a;
printf("%d\n", b);
}
匯編代碼
main:
leal 4(%esp), %ecx
andl $-16, %esp
pushl -4(%ecx)
pushl %ebp
movl %esp, %ebp
pushl %ecx
subl $36, %esp
movl $5, -12(%ebp)
addl $1, -12(%ebp)
subl $1, -12(%ebp)
movl -12(%ebp), %eax
imull -12(%ebp), %eax
movl %eax, -8(%ebp)
movl -8(%ebp), %eax
movl %eax, 4(%esp)
movl $.LC0, (%esp)
call printf
addl $36, %esp
popl %ecx
popl %ebp
leal -4(%ecx), %esp
ret
.size main, .-main
.ident "GCC: (GNU) 4.1.2 20070502 (Red Hat 4.1.2-12)"
.section .note.GNU-stack,"",@progbits