简体   繁体   中英

What does the hash (#) value associated with the ARM LDR instruction mean?

I'm trying to debug a crash I am experiencing in my application. The stack trace is pointing to an LDR instruction with the following format (thanks disassembler):

LDR R3, [R0,#4]

My question is in regards to the source component. What does the #4 in the second parameter mean? I'm assuming it is some kind of offset, but I haven't found documentation supporting that for the LDR instruction.

It loads R3 from the address in R0 + 4 bytes. So, yes, it is a byte offset. See this explanation of the addressing modes .

它将R0中的值加4,并将其用作将32位值加载到寄存器R3中的地址

In GNU gas, the hash # is only required for ARMv7 when not using .syntax unified

For example, you can write it without # for ARMv8 aarch64-linux-gnu-as :

LDR x0, [x0,4]

or if use .syntax unified in arm-linux-gnueabihf-as :

.syntax unified
LDR x0, [x0,4]

More details at: Is the hash required for immediate values in ARM assembly?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM