ldrb

Load Register Byte (A32)

LDRB<c> <Rt>, [<Rn>, #+/-<imm>]

Loads a byte from memory (Zero extended).

Details

Loads an unsigned byte (8 bits) from memory and zero-extends it to 32 bits, storing the result in the destination register. The P and W bits control addressing mode. Condition flags are not affected. Execution is conditional based on the 4-bit condition code field; available in A32 only.

Pseudocode Operation

offset ← ZeroExtend(imm12);
if U == 1 then address ← Rn + offset else address ← Rn - offset;
if P == 1 then address ← address else address ← Rn;
Rt ← ZeroExtend(MemRead(address, 1));
if W == 1 then Rn ← address;

Example

LDRB r3, [r1, #+/-#16]

Encoding

Binary Layout
cond
010
1
U
1
1
1
Rn
Rt
imm12
 
Format Load/Store
Opcode 0x05700000
Extension A32 (Base)

Operands

  • Rt
    Transfer general-purpose register (load/store)
  • Rn
    First source / base general-purpose register

Reference (Arm AArch32 ISA)

Instruction Forms

Encoding Instruction ISA Bit pattern
0x05500000 LDRB{<c>}{<q>} <Rt>, [<Rn> {, #{+/-}<imm>}] A32 cond | 010 | 1 | U | 1 | 0 | 1 | Rn | Rt | imm12
0x04500000 LDRB{<c>}{<q>} <Rt>, [<Rn>], #{+/-}<imm> A32 cond | 010 | 0 | U | 1 | 0 | 1 | Rn | Rt | imm12
0x05700000 LDRB{<c>}{<q>} <Rt>, [<Rn>, #{+/-}<imm>]! A32 cond | 010 | 1 | U | 1 | 1 | 1 | Rn | Rt | imm12
0x7800 LDRB{<c>}{<q>} <Rt>, [<Rn> {, #{+}<imm>}] T32 011 | 1 | 1 | imm5 | Rn | Rt
0xF8900000 LDRB{<c>}.W <Rt>, [<Rn> {, #{+}<imm>}] T32 111110001 | 00 | 1 | Rn | Rt | imm12
0xF8100C00 LDRB{<c>}{<q>} <Rt>, [<Rn> {, #-<imm>}] T32 111110000 | 00 | 1 | Rn | Rt | 1 | 1 | 0 | 0 | imm8
0xF8100900 LDRB{<c>}{<q>} <Rt>, [<Rn>], #{+/-}<imm> T32 111110000 | 00 | 1 | Rn | Rt | 1 | 0 | U | 1 | imm8
0xF8100D00 LDRB{<c>}{<q>} <Rt>, [<Rn>, #{+/-}<imm>]! T32 111110000 | 00 | 1 | Rn | Rt | 1 | 1 | U | 1 | imm8
0x045F0000 LDRB{<c>}{<q>} <Rt>, <label> A32 cond | 010 | P | U | 1 | W | 1 | 1111 | Rt | imm12
0xF81F0000 LDRB{<c>}{<q>} <Rt>, <label> T32 11111000 | U | 00 | 1 | 1111 | Rt | imm12
0x07500000 LDRB{<c>}{<q>} <Rt>, [<Rn>, {+/-}<Rm>{, <shift>}] A32 cond | 011 | 1 | U | 1 | 0 | 1 | Rn | Rt | imm5 | stype | 0 | Rm
0x06500000 LDRB{<c>}{<q>} <Rt>, [<Rn>], {+/-}<Rm>{, <shift>} A32 cond | 011 | 0 | U | 1 | 0 | 1 | Rn | Rt | imm5 | stype | 0 | Rm
0x07700000 LDRB{<c>}{<q>} <Rt>, [<Rn>, {+/-}<Rm>{, <shift>}]! A32 cond | 011 | 1 | U | 1 | 1 | 1 | Rn | Rt | imm5 | stype | 0 | Rm
0x5C00 LDRB{<c>}{<q>} <Rt>, [<Rn>, {+}<Rm>] T32 0101 | 1 | 1 | 0 | Rm | Rn | Rt

Description

Load Register Byte (immediate) calculates an address from a base register value and an immediate offset, loads a byte from memory, zero-extends it to form a 32-bit word, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses.

Operation

if CurrentInstrSet() == InstrSet_A32 then
    if ConditionPassed() then
        EncodingSpecificOperations();
        offset_addr = if add then (R[n] + imm32) else (R[n] - imm32);
        address = if index then offset_addr else R[n];
        R[t] = ZeroExtend(MemU[address,1], 32);
        if wback then R[n] = offset_addr;
else
    if ConditionPassed() then
        EncodingSpecificOperations();
        offset_addr = if add then (R[n] + imm32) else (R[n] - imm32);
        address = if index then offset_addr else R[n];
        R[t] = ZeroExtend(MemU[address,1], 32);
        if wback then R[n] = offset_addr;