AMOADD.W

Atomic Add Word

AMOADD.W rd, rs2, (rs1)

Atomically adds a value to a word in memory.

Encoding

Binary Layout
00000
31:27
aq
26
rl
25
rs2
24:20
rs1
19:15
010
14:12
rd
11:7
0101111
6:0
 
Format R-Type (Atomic)
Opcode 0x0000202F
Extension A

Operands

  • rd
    Dest (Old Value)
  • rs2
    Value to Add
  • rs1
    Address

Example

AMOADD.W x10, x11, (x12)

// Atomically adds x11 to memory at x12. Old value stored in x10.

Related

Across architectures

Atomic Fetch and Add : how x86, ARM, RISC-V, and PowerISA each do this.

More in A

Description

AMOADD.W atomically loads a word from the address in rs1 into rd, then adds rs2 to it, and stores the result back to that address.

Operation

temp = M[R[rs1]]; M[R[rs1]] = temp + R[rs2]; R[rd] = temp;