Does AMOADD.W place the added result in rd?
No. AMOADD.W places the old memory value before the add in rd; the low 32-bit added result is written back to memory.
Atomically add a 32-bit word: read the old memory value into rd and write old value plus low 32 bits of rs2 back to the same address
AMOADD.W performs an atomic read-modify-write on the 32-bit word addressed by rs1: it reads the old memory value and sign-extends it into rd, adds that old word to the low 32 bits of rs2, and writes the low 32-bit sum back to the same address. The addition wraps as a 32-bit word; aq/rl bits affect memory ordering and do not change the arithmetic result.
Shows A-extension word atomic field decode, aq/rl ordering bits, memory read, and RMW state update.
A-extension word atomic instructions use a 32-bit encoding; the animation starts by splitting the fields.
AMOADD.W uses full 32-bit word addition and writes the low 32-bit result to memory; this view avoids per-bit equations that would hide the carry chain.
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.
AMOADD.W is commonly used for atomic counter-style updates. It returns the old memory value in rd while writing the 32-bit sum of old value and rs2 back to memory; do not mistake rd for the new sum.
Understand this scenario with real code like «amoadd.w a0, a1, (a2) # a0 = *a2; *a2 += a1».
Understand this scenario with real code like «amoadd.w a0, a1, (a2) # a0 = *a2; *a2 += a1».
Understand this scenario with real code like «amoadd.w a0, a1, (a2) # a0 = *a2; *a2 += a1».
No. AMOADD.W places the old memory value before the add in rd; the low 32-bit added result is written back to memory.
No. The word addition wraps at 32 bits, and the low 32-bit result is written back.