代码
int n = 1;
printf("%d, %d, %d, %d\n", n, n++, n++, n);
GCC 4.5.3(运行结果:3, 2, 1, 3)
movl $1, -12(%ebp) ==> -12(%ebp) = 1;
movl -12(%ebp), %edx ==> %edx = 1
addl $1, -12(%ebp) ==> 执行++,-12(%ebp) = 2
movl -12(%ebp), %eax ==> %eax = 2
addl $1, -12(%ebp) ==> 执行++,-12(%ebp) = 3
movl -12(%ebp), %ecx ==> %ecx = 3
movl %ecx, 16(%esp) ==> 把%ecx(3)放到printf第5个参数位置,也就是最后一个n
movl %edx, 12(%esp) ==> 把%edx(1)放到printf第4个参数位置,第2个n++
movl %eax, 8(%esp) ==> 把%eax(2)放到printf第3个参数位置,第1个n++
movl -12(%ebp), %eax ==> %eax = 3
movl %eax, 4(%esp) ==> 把%eax(3)放到printf第2个参数位置,也就是第1个n
movl $LC0, (%esp) ==> 把格式串"%d, %d, %d, %d\n"放在第1个参数位置
call _printf ==> 调用printf
GCC 3.4.4(运行结果:3, 2, 1, 1)
movl $1, -16(%ebp) ==> -16(%ebp) = 1
movl -16(%ebp), %eax ==> %eax = 1
movl %eax, 16(%esp) ==> 把%eax(1)放在printf第5个参数位置
movl -16(%ebp), %eax ==> %eax = 1
movl %eax, 12(%esp) ==> 把%eax(1)放在printf第4个参数位置
leal -16(%ebp), %eax ==> %eax = -16(%ebp)
incl (%eax) ==> ++,-16(%ebp) = 2
movl -16(%ebp), %eax ==> %eax = 2
movl %eax, 8(%esp) ==> 把%eax(2)放到printf第3个参数位置
leal -16(%ebp), %eax ==> %eax = -16(%ebp)
incl (%eax) ==> ++,-16(%ebp) = 3
movl -16(%ebp), %eax ==> %eax = 3
movl %eax, 4(%esp) ==> 把%eax(2)放到printf第2个参数位置
movl $LC2, (%esp) ==> 把格式串"%d, %d, %d, %d\n"放在第1个参数位置
call _printf ==> 调用printf