ldr

Load Register PC-Relative (Thumb)

LDR <Rt>, <label>

Loads a word from a label (Thumb).

Details

Loads a 32-bit word from memory at a PC-relative address into a register. The effective address is computed by adding the 8-bit immediate (shifted left by 2) to the aligned PC. No condition flags are affected. This is a Thumb 16-bit instruction available in all Thumb-capable processors.

Pseudocode Operation

address ← Align(PC, 4) + (imm8 << 2)
Rt ← [address]

Example

LDR r3, label

Encoding

Binary Layout
01001
Rt
imm8
 
Format Thumb Load
Opcode 0x4800
Extension T32 (Thumb)

Operands

  • Rt
    Transfer general-purpose register (load/store)
  • label
    Label

Reference (Arm AArch32 ISA)

Instruction Forms

Encoding Instruction ISA Bit pattern
0x05100000 LDR{<c>}{<q>} <Rt>, [<Rn> {, #{+/-}<imm>}] A32 cond | 010 | 1 | U | 0 | 0 | 1 | Rn | Rt | imm12
0x04100000 LDR{<c>}{<q>} <Rt>, [<Rn>], #{+/-}<imm> A32 cond | 010 | 0 | U | 0 | 0 | 1 | Rn | Rt | imm12
0x05300000 LDR{<c>}{<q>} <Rt>, [<Rn>, #{+/-}<imm>]! A32 cond | 010 | 1 | U | 0 | 1 | 1 | Rn | Rt | imm12
0x6800 LDR{<c>}{<q>} <Rt>, [<Rn> {, #{+}<imm>}] T32 011 | 0 | 1 | imm5 | Rn | Rt
0x9800 LDR{<c>}{<q>} <Rt>, [SP{, #{+}<imm>}] T32 1001 | 1 | Rt | imm8
0xF8D00000 LDR{<c>}.W <Rt>, [<Rn> {, #{+}<imm>}] T32 111110001 | 10 | 1 | Rn | Rt | imm12
0xF8500C00 LDR{<c>}{<q>} <Rt>, [<Rn> {, #-<imm>}] T32 111110000 | 10 | 1 | Rn | Rt | 1 | 1 | 0 | 0 | imm8
0xF8500900 LDR{<c>}{<q>} <Rt>, [<Rn>], #{+/-}<imm> T32 111110000 | 10 | 1 | Rn | Rt | 1 | 0 | U | 1 | imm8
0xF8500D00 LDR{<c>}{<q>} <Rt>, [<Rn>, #{+/-}<imm>]! T32 111110000 | 10 | 1 | Rn | Rt | 1 | 1 | U | 1 | imm8
0x041F0000 LDR{<c>}{<q>} <Rt>, <label> A32 cond | 010 | P | U | 0 | W | 1 | 1111 | Rt | imm12
0x4800 LDR{<c>}{<q>} <Rt>, <label> T32 01001 | Rt | imm8
0xF85F0000 LDR{<c>}.W <Rt>, <label> T32 11111000 | U | 10 | 1 | 1111 | Rt | imm12
0x07100000 LDR{<c>}{<q>} <Rt>, [<Rn>, {+/-}<Rm>{, <shift>}] A32 cond | 011 | 1 | U | 0 | 0 | 1 | Rn | Rt | imm5 | stype | 0 | Rm
0x06100000 LDR{<c>}{<q>} <Rt>, [<Rn>], {+/-}<Rm>{, <shift>} A32 cond | 011 | 0 | U | 0 | 0 | 1 | Rn | Rt | imm5 | stype | 0 | Rm

Description

Load Register (literal) calculates an address from the PC value and an immediate offset, loads a word from memory, and writes it to a register. For information about memory accesses see Memory accesses.

Operation

if ConditionPassed() then
    EncodingSpecificOperations();
    base = Align(PC,4);
    address = if add then (base + imm32) else (base - imm32);
    data = MemU[address,4];
    if t == 15 then
        if address<1:0> == '00' then
            LoadWritePC(data);
        else
            UNPREDICTABLE;
    else
        R[t] = data;