从C角度看 i = i+ 1本质
通过查看汇编指令可以得出 i = i+ 1; 会编译为很多指令
一、编译C语言程序,并查看汇编指令
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <stdio.h> int main() { //printf( "Hello world!\n" ); int i ; i = i+ 1; return 0; }
二、编译代码为.o 文件 : gcc -g -c hello.c
三、查看汇编指令:objdump -d hello.o
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
0000000000000000 <main>: 0: 55 push %rbp 1: 48 89 e5 mov %rsp,%rbp 4: 83 45 fc 01 addl $0x1,-0x4(%rbp) 8: b8 00 00 00 00 mov $0x0,%eax d: 5d pop %rbp e: c3 retq