AMOMIN.H

RISC-V AMOMIN.H Instruction Details

Instruction ManualR-type

Atomic halfword signed min: rd = *rs1 (sign-ext), *rs1 = min(*rs1, rs2[15:0])

Instruction Syntax

amomin.h 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.
ZabhaAtomic

Instruction Behavior

AMOMIN.H (Zabha extension) atomically loads a halfword from the address in rs1 into rd (sign-extended), compares with the low 16 bits of rs2, stores signed minimum back. Supports aq/rl bits.

Quick Understanding & Search Notes

AMOMIN.H is a Zabha 16-bit signed atomic minimum instruction. It atomically reads the old memory value, performs the read-modify-write at 16-bit width, and writes the sign-extended old value to rd.

Only the 16-bit subword is operated on; upper bits of rs2 are ignored.
rd receives the old memory value sign-extended to XLEN, not the newly updated value.
The address must be naturally aligned to the operand size; aq/rl bits can provide release-consistency ordering semantics.

Common Usage Scenarios

Atomic & Sync

Understand this scenario with real code like «amomin.h a0, a2, (a1)».

Network & Byte Order

Understand this scenario with real code like «amomin.h a0, a2, (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 returns old memory value (sign-extended to XLEN), not the operation result
Signed minimum comparison; note difference from AMOMINU (signed vs unsigned)
Atomicity depends on natural alignment and implementation support

FAQ

Does AMOMIN.H return the post-operation value?

No. Like A-extension AMOs, rd receives the old value loaded from memory.

Can AMOMIN.H affect neighboring bytes?

Architecturally it modifies only the halfword operand; Zabha provides native halfword-granule atomic read-modify-write operations.