ldrsb

Load Register Signed Byte (A32)

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

Loads a byte and sign-extends it.

Details

Loads a signed byte (8 bits) from memory and sign-extends it to 32 bits, storing the result in the destination register. The 8-bit immediate (imm4H:imm4L) is shifted left by 0 bits to form the byte offset. The P and W bits control addressing mode. Condition flags are not affected. Execution is conditional; available in A32 only.

Pseudocode Operation

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

Example

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

Encoding

Binary Layout
cond
000
1
U
1
1
1
Rn
Rt
imm4H
1
10
1
imm4L
 
Format Load/Store
Opcode 0x017000D0
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
0x015000D0 LDRSB{<c>}{<q>} <Rt>, [<Rn> {, #{+/-}<imm>}] A32 cond | 000 | 1 | U | 1 | 0 | 1 | Rn | Rt | imm4H | 1 | 10 | 1 | imm4L
0x005000D0 LDRSB{<c>}{<q>} <Rt>, [<Rn>], #{+/-}<imm> A32 cond | 000 | 0 | U | 1 | 0 | 1 | Rn | Rt | imm4H | 1 | 10 | 1 | imm4L
0x017000D0 LDRSB{<c>}{<q>} <Rt>, [<Rn>, #{+/-}<imm>]! A32 cond | 000 | 1 | U | 1 | 1 | 1 | Rn | Rt | imm4H | 1 | 10 | 1 | imm4L
0xF9900000 LDRSB{<c>}{<q>} <Rt>, [<Rn> {, #{+}<imm>}] T32 111110011 | 00 | 1 | Rn | Rt | imm12
0xF9100C00 LDRSB{<c>}{<q>} <Rt>, [<Rn> {, #-<imm>}] T32 111110010 | 00 | 1 | Rn | Rt | 1 | 1 | 0 | 0 | imm8
0xF9100900 LDRSB{<c>}{<q>} <Rt>, [<Rn>], #{+/-}<imm> T32 111110010 | 00 | 1 | Rn | Rt | 1 | 0 | U | 1 | imm8
0xF9100D00 LDRSB{<c>}{<q>} <Rt>, [<Rn>, #{+/-}<imm>]! T32 111110010 | 00 | 1 | Rn | Rt | 1 | 1 | U | 1 | imm8
0x005F00D0 LDRSB{<c>}{<q>} <Rt>, <label> A32 cond | 000 | P | U | 1 | W | 1 | 1111 | Rt | imm4H | 1 | 10 | 1 | imm4L
0xF91F0000 LDRSB{<c>}{<q>} <Rt>, <label> T32 11111001 | U | 00 | 11111 | Rt | imm12
0x011000D0 LDRSB{<c>}{<q>} <Rt>, [<Rn>, {+/-}<Rm>] A32 cond | 000 | 1 | U | 0 | 0 | 1 | Rn | Rt | 0 | 0 | 0 | 0 | 1 | 10 | 1 | Rm
0x001000D0 LDRSB{<c>}{<q>} <Rt>, [<Rn>], {+/-}<Rm> A32 cond | 000 | 0 | U | 0 | 0 | 1 | Rn | Rt | 0 | 0 | 0 | 0 | 1 | 10 | 1 | Rm
0x013000D0 LDRSB{<c>}{<q>} <Rt>, [<Rn>, {+/-}<Rm>]! A32 cond | 000 | 1 | U | 0 | 1 | 1 | Rn | Rt | 0 | 0 | 0 | 0 | 1 | 10 | 1 | Rm
0x5600 LDRSB{<c>}{<q>} <Rt>, [<Rn>, {+}<Rm>] T32 0101 | 0 | 1 | 1 | Rm | Rn | Rt
0xF9100000 LDRSB{<c>}.W <Rt>, [<Rn>, {+}<Rm>] T32 111110010 | 00 | 1 | Rn | Rt | 000000 | imm2 | Rm

Description

Load Register Signed Byte (immediate) calculates an address from a base register value and an immediate offset, loads a byte from memory, sign-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 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] = SignExtend(MemU[address,1], 32);
    if wback then R[n] = offset_addr;