AMOSWAP.W
Atomic Swap Word
AMOSWAP.W rd, rs2, (rs1)
Atomically swaps a value in memory with a register.
Encoding
Binary Layout
00001
31:27
aq
26
rl
25
rs2
24:20
rs1
19:15
010
14:12
rd
11:7
0101111
6:0
Operands
-
rd
Dest (Old Value) -
rs2
New Value -
rs1
Address
Example
AMOSWAP.W x10, x11, (x12)
// Writes x11 to memory at x12, loads old memory value into x10.
Related
More in A
Reference
View in RISC-V Unprivileged ISA Specification ↗
RISC-V ISA Manual
Description
AMOSWAP.W atomically loads a word from the address in rs1 into rd and stores the value of rs2 to that address.
Operation
temp = M[R[rs1]]; M[R[rs1]] = R[rs2]; R[rd] = temp;