潮声隔雨深 · 2020年01月05日

汇编指令 LDR 一个疑问

LDR a4, [pc, #TXILLDB_FIQ_STACK-.-8];

请问一下,这个符号 “-.-” 代表什么意思

1 个回答 得票排序 · 时间排序
一知半解 · 2020年01月05日

Hi,

" -.- ", " - "means minus. " . " means the address of current instruction. For example,

ldr r0, .

when the instruction is executed, you will see the instruction executed like this:

----> 0x00000068: e51f0008 .... LDR r0,[pc,#-8] ; [0x68] = 0xe51f0008

    0x0000006c:    e59f1014    ....    LDR      r1,[pc,#20] ; [0x88] = 0xe3a00000

    0x00000070:    ee110f10    ....    MRC      p15,#0x0,r0,c1,c0,#0

    0x00000074:    e3c00a01    ....    BIC      r0,r0,#0x1000

    0x00000078:    e3c00004    ....    BIC      r0,r0,#4

or you could write and disassemly your image to check.

To be mentioned, here pc = "the current instruction addr + 0x8/0x4", it depends on the processor's state, if ARM state, +0x8, thumb state +0x4. Here we assume the processor's state is in ARM state, then:

pc = 0x68 +0x8

LDR r0,[pc,#-8] ------> LDR r0,[0x68]

你的回答