LB

Load Byte

LB rd, offset(rs1)

Loads an 8-bit byte from memory and sign-extends it to the register width.

Details

LB loads a byte from memory at address rs1+sext(offset), sign-extends it to XLEN bits, and writes it to rd.

Pseudocode Operation

R[rd] = sext(M[R[rs1] + sext(offset)][7:0]);

Example

LB x10, 0(x2)

Encoding

Binary Layout
imm[11:0]
31:20
rs1
19:15
000
14:12
rd
11:7
0000011
6:0
 
Format I-Type
Opcode 0x03
Extension RV32I

Operands

  • rd
    Destination Register
  • rs1
    Base Address
  • offset
    Byte Offset