How do I tell whether AMOCAS.Q succeeded?
Compare the old value returned in rd/rd+1 with the complete 128-bit expected value; equality indicates that the swap store occurred.
RV64 atomic compare-and-swap quadword: compare 128-bit rd/rd+1, store rs2/rs2+1 on match, return old value in rd/rd+1
AMOCAS.Q (Zacas extension) is defined only for RV64. It atomically loads a 128-bit quadword from the address in rs1 and bitwise-compares it with the 128-bit compare value in the even rd/rd+1 pair; on a match it stores the 128-bit swap value from the even rs2/rs2+1 pair. The old memory value is written back to rd/rd+1. rd and rs2 must be even; odd encodings are reserved. aq/rl ordering bits are supported.
Shows Zacas quadword atomic field decode, aq/rl ordering bits, memory read, and CAS state update.
Zacas-extension quadword atomic instructions use a 32-bit encoding; the animation starts by splitting the fields.
This animation shows ISA-visible atomic read-modify-write, compare-and-swap, LR/SC reservation state, and ordering bits, not any specific CPU cache-coherence implementation, pipeline, or timing.
AMOCAS.Q atomically loads a 128-bit memory value, compares it bitwise with the compare value supplied in the rd/rd+1 register pair, stores the rs2/rs2+1 swap value on equality, and always writes the old memory value back to rd/rd+1.
Understand this scenario with real code like «amocas.q a0, a2, (a1)».
Understand this scenario with real code like «amocas.q a0, a2, (a1)».
Compare the old value returned in rd/rd+1 with the complete 128-bit expected value; equality indicates that the swap store occurred.
No. rs2 supplies the new value to store on success; the compare value comes from rd before execution, or from the rd register pair.