LW

Load Word

LW rd, offset(rs1)

Loads a 32-bit word from memory and sign-extends it to 64 bits.

Details

LW loads a 32-bit word from memory at address rs1+sext(offset). In RV32I the result is written directly to rd; in RV64I it is sign-extended to 64 bits before being written.

Pseudocode Operation

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

Example

LW x6, 12(x2)

Encoding

Binary Layout
imm[11:0]
31:20
rs1
19:15
010
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