i=4,p = (++i) + (i++) + (i++);语句的结果为啥是17?汇编代码分析如何与源代码对应?
程序代码:
void f05_1(){ int p = 0, i = 4; p = (++i) + (i++) + (i++); printf("p = %d,i = %d\n", p, i); }
程序代码:
f05_1: .LFB10: .cfi_startproc endbr64 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 subq $16, %rsp movl $0, -8(%rbp) movl $4, -4(%rbp) addl $1, -4(%rbp) movl -4(%rbp), %eax leal 1(%rax), %edx movl %edx, -4(%rbp) movl -4(%rbp), %edx leal (%rax,%rdx), %ecx movl -4(%rbp), %eax leal 1(%rax), %edx movl %edx, -4(%rbp) addl %ecx, %eax movl %eax, -8(%rbp) movl -4(%rbp), %edx movl -8(%rbp), %eax movl %eax, %esi leaq .LC0(%rip), %rdi movl $0, %eax call printf@PLT nop leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE10: .size f05_1, .-f05_1 .globl f05_2 .type f05_2, @function
汇编代码中第十二句的
movl -4(%rbp), %eax
是对应C语言表达式中的保存第一个(i++)的值吗