AMOAND.B

RISC-V AMOAND.B Instruction Details

Instruction ManualR-type

Atomic byte AND: rd = *rs1 (sign-ext), *rs1 &= rs2[7:0]

Instruction Syntax

amoand.b 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

AMOAND.B (Zabha extension) atomically loads a byte from the address in rs1 into rd (sign-extended), ANDs with the low byte of rs2, and stores back. Supports aq/rl bits.

Quick Understanding & Search Notes

AMOAND.B is a Zabha 8-bit atomic AND instruction. It atomically reads the old memory value, performs the read-modify-write at 8-bit width, and writes the sign-extended old value to rd.

Only the 8-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 «amoand.b a0, a2, (a1)».

Network & Byte Order

Understand this scenario with real code like «amoand.b 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
Bit-clearing mask must be correct; side effects are irreversible
Atomicity depends on natural alignment and implementation support

FAQ

Does AMOAND.B return the post-operation value?

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

Can AMOAND.B affect neighboring bytes?

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