本文介绍了得到一个标签的地址在ARM寄存器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样写,这将有一个标签被引用放入寄存器地址的指令?


解决方案

有四种方式,三处的。我猜的标签是一样的东西,

 目标:
     。长0xfeadbeef


  1. ADR R0,目标

  2. ADRL R0,目标

  3. LDR R0,=目标

  4. 子R0,PC,#(。+ 8-目标)

前两个非常相似,生成子R0,PC,#偏移。 3 把一个长期处于的文字池通过 的并加载这个LDR R0,[PC,#OFFSET2] 或者可以使用 MOV 如果汇编发现它可以(通常是对齐的标签,就像在的为0x8000 的)。最后一个版本是手动计算它。

ADR 的区别ADRL 来自立即数。它们的 8位的由二的倍数旋转。因此,如果地址是到目前为止,您可能需要执行两个指令,通常会比3 LDR 变体得到充分的更快通过32位的数据缓存的或的内存

另请参阅:在汇编 搬迁

How do I write an instruction which will have the address a label is referencing put into a register?

There are four ways, three are documented at Sourceware's Gnu Assembler manual. I guess the label is something like,

 target:
     .long 0xfeadbeef
  1. adr r0,target
  2. adrl r0,target
  3. ldr r0,=target
  4. sub r0,pc,#(.+8-target)

The first two are very similar and generate sub r0,pc,#offset. The 3 puts a long in a literal pool and loads this via ldr r0,[pc,#offset2] or it may use a mov if the assembler finds it can (usually an aligned label, like at 0x8000). The last version is to manually calculated it.

The difference between adr and adrl comes from immediate operands. They are 8bits rotated by a multiple of two. So if the address is far, you may need to perform two instructions, which will usually be faster than the 3 ldr variant which get a full 32-bits via the data cache or memory.

See also: Relocation in assembler

这篇关于得到一个标签的地址在ARM寄存器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 05:36