zoukankan      html  css  js  c++  java
  • ARM7ldr指令与ldr伪指令

    ldr伪指令的第二个操作数之前有个=,意思是第一个操作书 = 第二个操作数,相当明了

    核心就在于对于用.word指令在.text段里另外定义一段内存,用ldr r0,[pc + x(可以算出.text段里的内存地址)]这种基于PC的偏移量方式加载内存里的内容到寄存器

    看下源代码和反汇编的结果就清楚了

    伪指令用于大的常数:

     源代码:

    1 top:
    2 ldr r0,=12345678
    3 add r1,r2,r3
    4 eor r1,r2,r3
    5 eor r1,r2,r3
    6 bottom:
    7 b top

    反汇编:

    prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin$ ./arm-eabi-objdump -d test.o 
    
    test.o:     file format elf32-littlearm
    
    
    Disassembly of section .text:
    
    00000000 <top>:
       0:    e59f000c     ldr    r0, [pc, #12]    ; 14 <bottom+0x4>
       4:    e0821003     add    r1, r2, r3
       8:    e0221003     eor    r1, r2, r3
       c:    e0221003     eor    r1, r2, r3
    
    00000010 <bottom>:
      10:    eafffffa     b    0 <top>
      14:    00bc614e     .word    0x00bc614e

    伪指令用于标签:

    源代码:

    1 top:
    2 ldr r0,=bottom
    3 add r1,r2,r3
    4 eor r1,r2,r3
    5 eor r1,r2,r3
    6 bottom:
    7 b top

    反汇编:

    prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin$ ./arm-eabi-objdump -d test.o 
    
    test.o:     file format elf32-littlearm
    
    
    Disassembly of section .text:
    
    00000000 <top>:
       0:    e59f000c     ldr    r0, [pc, #12]    ; 14 <bottom+0x4>
        4:    e0821003     add    r1, r2, r3
        8:    e0221003     eor    r1, r2, r3
        c:    e0221003     eor    r1, r2, r3
     
     00000010 <bottom>:
       10:    eafffffa     b    0 <top>
       14:    00000010     .word    0x00000010

    ldr指令用于常数:

     源代码:

    1 top:
    2 ldr r0,[r0]
    3 add r1,r2,r3
    4 eor r1,r2,r3
    5 eor r1,r2,r3
    6 bottom:
    7 b top

    反汇编:

    prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin$ ./arm-eabi-objdump -d test.o 
    
    test.o:     file format elf32-littlearm
    
    
    Disassembly of section .text:
    
    00000000 <top>:
       0:    e5900000     ldr    r0, [r0]
       4:    e0821003     add    r1, r2, r3
       8:    e0221003     eor    r1, r2, r3
       c:    e0221003     eor    r1, r2, r3
    
    00000010 <bottom>:
      10:    eafffffa     b    0 <top>

    ldr指令用于标签:

    源代码:

    1 top:
    2 ldr r0,bottom
    3 add r1,r2,r3
    4 eor r1,r2,r3
    5 eor r1,r2,r3
    6 bottom:
    7 b top

    反汇编:

    prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin$ ./arm-eabi-objdump -d test.o 
    
    test.o:     file format elf32-littlearm
    
    
    Disassembly of section .text:
    
    00000000 <top>:
       0:    e59f0008     ldr    r0, [pc, #8]    ; 10 <bottom>
       4:    e0821003     add    r1, r2, r3
       8:    e0221003     eor    r1, r2, r3
       c:    e0221003     eor    r1, r2, r3
    
    00000010 <bottom>:
      10:    eafffffa     b    0 <top>
  • 相关阅读:
    关于研发核心团队建设的一些思考
    无法打开物理文件xxx.mdf操作系统错误 5:“5(拒绝访问。)” (Microsoft SQL Server,错误: 5120)的解决方法
    自适应网页设计(Responsive Web Design)
    css浮动与绝对定位小记
    WEB进度条控件
    GitHub上整理的一些工具
    雾里看花般的迷茫--货运APP
    揭秘史上最完美一步到位的搭建Andoriod开发环境
    我是如何在SQLServer中处理每天四亿三千万记录的
    货运APP产品魔力=卓越功能×情感诉求
  • 原文地址:https://www.cnblogs.com/cascle/p/5035207.html
Copyright © 2011-2022 走看看