AMOCAS.D
Atomic Compare and Swap Doubleword
AMOCAS.D rd, rs2, (rs1)
Atomically compares 64-bit memory at rs1 with rd; if equal, writes rs2 to memory.
Encoding
Binary Layout
00101
31:27
aq
26
rl
25
rs2
24:20
rs1
19:15
011
14:12
rd
11:7
0101111
6:0
Operands
-
rd
Dest/Compare -
rs2
Swap Value -
rs1
Address
Example
AMOCAS.D t0, a1, (a0)
Related
More in Zacas
Reference
View in RISC-V Unprivileged ISA Specification ↗
RISC-V ISA Manual
Description
Atomically loads the 64-bit value at the address in rs1 and compares it with the 64-bit value in rd. If they are bitwise equal it stores the value in rs2 to that address. The value loaded from memory is always written to rd. On RV32 rd and rs2 each name an even/odd register pair.
Operation
atomic { temp = M[R[rs1]]; if (temp == R[rd]) M[R[rs1]] = R[rs2]; R[rd] = temp; }