分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.youkuaiyun.com/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
假设我们写了一个C代码文件 code.c包含下面代码:
int accum = 0;
int sum(int x, int y)
{
int t = x + y;
accum += t;
return t;
}
int accum = 0;
int sum(int x, int y)
{
int t = x + y;
accum += t;
return t;
}
这是用echo命令输入源码的效果,简单的就是最好的:)

一、查看GCC生成的汇编代码
在命令行上用“-S”选项,就能看到C编译器产生的汇编代码:
#gcc -S code.c
注意:这里是大写的-S,如果用小写gcc会说找不到main函数
会在当前目录下生成code.s文件,直接打开即可
这段汇编代码没有经过优化:
.file "code.c"
.globl _accum
.bss
.align 4
_accum:
.space 4
.text
.globl _sum
.def _sum; .scl 2; .type 32; .endef
_sum:
pushl %ebp
movl %esp, %ebp
subl $4, %esp # 为局部变量t
.globl _accum
.bss
.align 4
_accum:
.space 4
.text
.globl _sum
.def _sum; .scl 2; .type 32; .endef
_sum:
pushl %ebp
movl %esp, %ebp
subl $4, %esp # 为局部变量t