How do I tell whether AMOCAS.Q succeeded?
Compare the old value returned in rd with the 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.
AMOCAS.Q atomically loads a 128-bit memory value, compares it bitwise with the compare value supplied in rd, stores the rs2 swap value on equality, and always writes the old memory value back to rd.
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 with the 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.