Store conditional (double word) : Store t2 as a double word at the address in t3 only if that address is still reserved by an lr.d, then set t1 to 0 on success or 1 on failure. Always branch on t1 and retry from the lr.d when it fails (64bit)
sc.d
Operands
reg, reg, (reg)Variants
- Store conditional (double word) : Store t2 as a double word at the address in t3 only if that address is still reserved by an lr.d, then set t1 to 0 on success or 1 on failure. Always branch on t1 and retry from the lr.d when it fails (64bit) sc.d t1, t2, (t3)
This example runs on RV64.
# value is initialized and naturally aligned for this operation.
.data
value: .dword 0x0000000012345678
.text
la t0, value
# lr reserves value. The first sc.d succeeds (t2=0); the next has no fresh reservation (t4=1).
li t1, 42
lr.d t3, (t0)
sc.d t2, t1, (t0)
li t1, 99
sc.d t4, t1, (t0)
# t4=1 reports failure; value remains 42 rather than changing to 99.