AMOMIN.W

RISC-V AMOMIN.W Instruction Details

Instruction ManualR-type

Atomic 32-bit word signed minimum: rd returns the old memory word, while memory receives the 32-bit result of signed min(oldWord, rs2LowWord)

Instruction Syntax

amomin.w rd, rs2, (rs1)
Operand Breakdown
Destination rd: register receiving the operation result.
Source rs1: register holding the first operand.
Source rs2: register holding the second operand.
AZaamoAtomic

Instruction Behavior

AMOMIN.W performs an atomic read-modify-write on the 32-bit word addressed by rs1: it first reads the old memory word and sign-extends it into rd, then compares the old word and the low 32 bits of rs2 as signed 32-bit values and writes back the smaller word. The resulting 32-bit word is written back to the same address. aq/rl bits affect memory ordering only; they do not change the signed minimum data result.

AMOMIN.W Atomic Decode And Execute Animation

Shows A-extension word atomic field decode, aq/rl ordering bits, memory read, and RMW state update.

rd
rs2
rs1
amomin.w
,
,(
)
Execution Context
31..27
26
25
24..20
19..15
14..12
11..7
6..0
10000
funct5
0
aq
0
rl
01011
rs2
01010
rs1
010
funct3
00101
rd
0101111
opcode
Atomic Data Path
instruction
0x80B522AF
opcode
0101111 -> AMO
funct3
010 -> word width
funct5
10000 -> AMOMIN.W
aq / rl
0/0 -> unordered
rd / rs2 / rs1
t0(x5) / a1(x11)=0x00000001 / a0(x10)=0x00001000
memory read
mem[0x00001000] -> old word 0x80000000
RMW
-2147483648 <= 1 -> 0x80000000
rd / memory
t0(x5) = 0x80000000; mem[0x00001000] = 0x80000000
Current Step

Concept Step: receive the 32-bit atomic instruction encoding

A-extension word atomic instructions use a 32-bit encoding; the animation starts by splitting the fields.

encoding: 0x80B522AF
syntax : amomin.w t0(x5), a1(x11), (a0(x10))
result : t0(x5) = 0x80000000; mem[0x00001000] = 0x80000000
Signed 32-bit Word Comparison
old word
0x80000000 (-2147483648)
rs2 word
0x00000001 (1)
comparison
old <= rs2 -> old value
memory result
0x80000000

AMOMIN.W selects the memory writeback word using a signed 32-bit comparison; this is not a per-bit logical operation.

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.

Quick Understanding & Search Notes

AMOMIN.W is used for atomic signed minimum updates. The value returned in rd is always the old memory word; the new 32-bit word after the signed minimum operation is written only to memory.

funct5=10000, funct3=010, and opcode=0101111 identify AMOMIN.W; aq/rl bits do not change the data calculation.
rd receives the old memory word before the operation; memory receives the 32-bit result of signed min(oldWord, rs2LowWord).
AMO.W is a word-width AMO; on RV64, the old word in rd is sign-extended to XLEN.
AMOMIN.W is a word comparison operation; comparison uses signed 32-bit values, not a per-bit logical operation.

Common Usage Scenarios

Atomic & Sync

Understand this scenario with real code like «amomin.w a0, a1, (a2) # a0 = old *a2; *a2 = signed min(old, a1)».

Bounded Updates

Understand this scenario with real code like «amomin.w a0, a1, (a2) # a0 = old *a2; *a2 = signed min(old, a1)».

Pre-Use Checklist

Syntax Check
  • Confirm the current instruction format is R-type.
  • Confirm the operand order matches the example.
Semantic Check
  • Ensure the destination register usage is compatible with the calling convention.
  • Confirm this is not the lower-level form of a pseudo-instruction expansion.

Pitfalls / Common Confusions

rd holds the old memory word before the operation, not the new signed minimum memory result.
AMO.W atomically accesses a 32-bit word; on RV64, the old word loaded into rd is sign-extended to XLEN.
Only the low 32-bit word of rs2 participates in the calculation, and memory receives a 32-bit word result.
aq/rl constrain memory ordering only; they do not change the value of signed min(oldWord, rs2LowWord).

FAQ

Does AMOMIN.W place the new memory result in rd?

No. AMOMIN.W places the old memory word before the operation in rd; the result of signed min(oldWord, rs2LowWord) is written back to memory.

Do aq/rl bits change the signed minimum result of AMOMIN.W?

No. aq/rl only affect memory-ordering constraints; they do not change this AMO.W instruction's 32-bit data result.