ldr r0,=0x20200000
Shouldn't the LDR be a MOV?
ldr r0,=0x20200000
Shouldn't the LDR be a MOV?
(http://www.woodmann.com/fravia/The%20ARM%20Processor.htm)
> The ARM assembler also supports a similar pseudo operation. The construct LDR rd,=value is used to load value into register rd. The LDR pseudo instruction uses the MOV or MOV instructions, or it places the constant in memory and uses program counter relative addressing to load the constant.
(http://sourceware.org/binutils/docs/as/ARM-Opcodes.html)
> If expression evaluates to a numeric constant then a MOV or MVN instruction will be used in place of the LDR instruction, if the constant can be generated by either of these instructions. Otherwise the constant will be placed into the nearest literal pool (if it not already there) and a PC relative LDR instruction will be generated.
Example, using a simple input:
.globl _start
_start:
ldr r0, =0x20200000
Disassembles to: .globl _start
_start:
ldr r0, [pc, #-4]
.word 0x20200000Your literal pool has a high degree of spacial locality WRT the instruction that references it. You can take measures to optimize this (see the ltorg directive) making I$ hits very likely.
In the end, the assembler is free to pick and choose which method is best for the target CPU and input code.
The immediate pseudo-instruction:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc....
The regular form:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc....