《Linux内核分析》MOOC课程之从汇编语言角度看计算机是如何工作的
2015-03-08 00:00
267 查看
piratezgw 原创作品转载请注明出处 《Linux内核分析》MOOC课程http://mooc.study.163.com/course/USTC-1000029000
其实写这个就是为了应付MOOC课程的作业,所在环境无法随时接触互联网,所以提交的都比较晚,废话不多说,进入正题。
一、实验的操作
这方面主要是在Linux环境下使用vi + gcc 编写C程序代码,然后编译成汇编代码,如下图所示
![](http://static.oschina.net/uploads/space/2015/0308/232354_FdHG_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/232600_m4qo_1169027.png)
二、代码分析
由于原汇编代码的动态链接并且符号表没有去除,所以去除它们,得到纯汇编代码:
现在从寄存器的角度进行分析,如图:
![](http://static.oschina.net/uploads/space/2015/0308/233156_jFOI_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233215_6Isz_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233216_HuvP_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233216_ivc6_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233216_tuRB_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233216_qcRx_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233217_TSiY_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233217_n7Q8_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233217_1w11_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233217_5oHG_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233217_STBH_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233218_9uaL_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233218_xo7Y_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233218_2f1Y_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233218_UcIR_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233218_UuUl_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233218_YivG_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233219_X5jd_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233219_O3HD_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233219_wfMQ_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233219_Xy4P_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233219_rbKz_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233219_zzxw_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233220_5Nho_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233220_4Cxh_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233220_B3KI_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233220_9Dwx_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233220_Efa4_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233220_naWH_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233221_svNQ_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233221_k54k_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233221_bgAT_1169027.png)
其实写这个就是为了应付MOOC课程的作业,所在环境无法随时接触互联网,所以提交的都比较晚,废话不多说,进入正题。
一、实验的操作
这方面主要是在Linux环境下使用vi + gcc 编写C程序代码,然后编译成汇编代码,如下图所示
![](http://static.oschina.net/uploads/space/2015/0308/232354_FdHG_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/232600_m4qo_1169027.png)
二、代码分析
由于原汇编代码的动态链接并且符号表没有去除,所以去除它们,得到纯汇编代码:
g: pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax addl $2, %eax popl %ebp ret f: pushl %ebp movl %esp, %ebp subl $4, %esp movl 8(%ebp), %eax movl %eax, (%esp) call g leave ret main: pushl %ebp movl %esp, %ebp subl $4, %esp movl $9, (%esp) call f addl $1, %eax leave ret
现在从寄存器的角度进行分析,如图:
![](http://static.oschina.net/uploads/space/2015/0308/233156_jFOI_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233215_6Isz_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233216_HuvP_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233216_ivc6_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233216_tuRB_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233216_qcRx_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233217_TSiY_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233217_n7Q8_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233217_1w11_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233217_5oHG_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233217_STBH_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233218_9uaL_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233218_xo7Y_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233218_2f1Y_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233218_UcIR_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233218_UuUl_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233218_YivG_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233219_X5jd_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233219_O3HD_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233219_wfMQ_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233219_Xy4P_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233219_rbKz_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233219_zzxw_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233220_5Nho_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233220_4Cxh_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233220_B3KI_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233220_9Dwx_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233220_Efa4_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233220_naWH_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233221_svNQ_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233221_k54k_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233221_bgAT_1169027.png)
![](http://static.oschina.net/uploads/space/2015/0308/233221_MRUA_1169027.png)
相关文章推荐
- 从汇编语言角度看C语言代码,理解计算机如何工作
- Linux内核分析课程--通过反汇编一个简单的c程序,分析汇编代码并理解计算机如何工作的
- 《Linux内核分析》之图解汇编代码以分析计算机是如何工作的
- 反汇编程序分析计算机是如何工作的
- 云课堂 Linux内核分析 通过反汇编一个简单的C程序,分析汇编代码理解计算机是如何工作的
- 通过分析汇编代码了解计算机是如何工作
- 通过汇编一个简单的C程序,分析汇编代码理解计算机是如何工作的
- 图解分析汇编代码以理解计算机是如何工作的
- 通过反汇编一个简单的C程序,分析汇编代码理解计算机是如何工作的(原创)
- linux内核分析作业:以一简单C程序为例,分析汇编代码理解计算机如何工作
- 分析一个简单C程序的汇编代码,理解计算机是如何工作的
- 大学计算机课程复习--汇编语言
- 通过分析汇编代码理解计算机如何工作
- (作业1)将一个简单的C程序编译成汇编代码,讨论计算机是如何工作的进行
- 计算机是如何工作的———高级语言转变为机器语言的过程(20135304 刘世鹏)
- Linux内核分析课程1_计算机是如何工作的
- 分析汇编代码理解计算机如何工作
- 第一次作业 图解汇编代码以及分析计算机是如何工作的
- 魏昊卿——《Linux内核分析》第一周作业:从分析简单的汇编代码了解计算机是怎样工作的
- 大学计算机课程复习--汇编语言