zoukankan      html  css  js  c++  java
  • 树莓派之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

    //0xfffffff0esp寄存器中的值做与运算

       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                 //程序返回

     

     

  • 相关阅读:
    1. Deep Q-Learning
    Ⅶ. Policy Gradient Methods
    Ⅴ. Temporal-Difference Learning
    idea在service窗口中显示多个服务
    pycharm下运行flask框架的脚本时报错
    windows下部署 flask (win10+flask+nginx)
    pip install selenium报错解决方法
    pip 及 selenium安装命令
    动作捕捉系统用于模仿学习
    柔性微创手术机器人性能实验验证
  • 原文地址:https://www.cnblogs.com/zxRPI/p/2988265.html
Copyright © 2011-2022 走看看