树莓派之objdump [浙大嵌入式系统]
实验要求:
写一个a+b的程序,a和b有确定的初始值,printf输出a+b的值。编译后,用objdump对.o做反汇编,逐行解释汇编指令.
实验步骤:
1.写a+b程序,并且生成.o文件
2.用objdump进行反汇编
3.逐行解释汇编指令
00000000 <main>: 0: 55 push %ebp //将ebp寄存器中的内容入栈,保护ebp 1: 89 e5 mov %esp,%ebp //将esp存器中的内容存入ebp中 3: 83 e4 f0 and $0xfffffff0,%esp //0xfffffff0和esp寄存器中的值做与运算 6: 83 ec 20 sub $0x20,%esp //调整栈指针,向下移动20个字节,给局部变量留出空间 9: c7 44 24 18 01 00 00 movl $0x1,0x18(%esp) //将a的值1入栈 10: 00 11: c7 44 24 1c 02 00 00 movl $0x2,0x1c(%esp) //将b的值2入栈 18: 00 19: 8b 44 24 1c mov 0x1c(%esp),%eax //赋值eax=2 1d: 8b 54 24 18 mov 0x18(%esp),%edx //赋值edx=1 21: 01 c2 add %eax,%edx //执行a+b 结果存入edx 23: b8 00 00 00 00 mov $0x0,%eax //eax=0x0 28: 89 54 24 04 mov %edx,0x4(%esp) //将edx入栈 2c: 89 04 24 mov %eax,(%esp) //将eax入栈 2f: e8 fc ff ff ff call 30 <main+0x30> //调用printf函数 34: b8 00 00 00 00 mov $0x0,%eax //eax=0x0 39: c9 leave 3a: c3 ret //程序返回 |