lw

Load word

Loads the 32-bit word at the address in t2 plus an offset into t1, sign-extended on RV64.

RISC-V manual: lw

Used in

Forms

  • lw , ()

Pseudo-instructions

The assembler turns these into one or more real instructions.

  • Set t1 to contents of memory word at label's address

  • Load from Address

Operands

t1
Any integer register, x0 to x31, or its named alias, such as zero, t0 or t6.
imm12
A signed 12-bit immediate, -2048 to 2047.
t2
An integer register. It may be the same register as t1.
imm
An immediate value: a signed 12-bit value (-2048 to 2047) or a 32-bit value (-2147483648 to 4294967295). The assembler chooses a supported encoding for the value and other operands; a pseudoinstruction may expand into several instructions.
label
A named address in the program, such as the start of a loop or a variable in .data.

This example runs on RV64.

# value is initialized and naturally aligned for this operation.
.data
value: .word 0x817fff80
.text
la t0, value
# The word 0x817FFF80 sign-extends in RV64; lw writes −2122317952 (0xFFFFFFFF817FFF80) to t2.
lw t2, 0(t0)