lr.w

Load reserved (word)

Loads the word at the address in the second register into the first and reserves that address for a following sc.w.

RISC-V manual: lr.w

Forms

  • lr.w , ()

Operands

t1
Any integer register, x0 to x31, or its named alias, such as zero, t0 or t6.
t2
An integer register. It may be the same register as t1.

Pair with sc.w to build an atomic read-modify-write that can be retried

# value is initialized and naturally aligned for this operation.
.data
value: .word 0x12345678
.text
la t0, value
# Reserve the aligned word at value; t2 receives 305419896.
lr.w t2, (t0)