3.4.5. LDR, PC‑relative

Load register from memory.

Syntax

LDR{type}{cond} Rt, label
LDRD{cond} Rt, Rt2, label         ; Load two words

Where:

type

Is one of:

B

Unsigned byte, zero extend to 32 bits.

SB

Signed byte, sign extend to 32 bits.

H

Unsigned halfword, zero extend to 32 bits.

SH

Signed halfword, sign extend to 32 bits.

Omit, for word.

cond

Is an optional condition code. See Conditional execution.

Rt

Is the register to load or store.

Rt2

Is the second register to load or store.

label

Is a PC‑relative expression. See PC‑relative expressions.

Operation

LDR loads a register with a value from a PC-relative memory address. The memory address is specified by a label or by an offset from the PC.

The value to load or store can be a byte, halfword, or word. For load instructions, bytes and halfwords can either be signed or unsigned. See Address alignment.

label must be within a limited range of the current instruction. Table 3.7 shows the possible offsets between label and the PC.

Table 3.7. Offset ranges

Instruction typeOffset range
Word, halfword, signed halfword, byte, signed byte−4095 to 4095
Two words−1020 to 1020

Note

You might have to use the .W suffix to get the maximum offset range. See Instruction width selection.

Restrictions

In these instructions:

  • Rt can be SP or PC only for word loads.

  • Rt2 must not be SP and must not be PC.

  • Rt must be different from Rt2.

When Rt is PC in a word load instruction:

  • Bit[0] of the loaded value must be 1 for correct execution, and a branch occurs to this halfword-aligned address.

  • If the instruction is conditional, it must be the last instruction in the IT block.

Condition flags

These instructions do not change the flags.

Examples

    LDR     R0, LookUpTable   ; Load R0 with a word of data from an address
                              ; labelled as LookUpTable.
    LDRSB   R7, localdata     ; Load a byte value from an address labelled
                              ; as localdata, sign extend it to a word
                              ; value, and put it in R7.

Copyright © 2015, 2018 Arm. All rights reserved.ARM DUI 0646C
Non-ConfidentialID121118