AMOXOR.B

RISC-V AMOXOR.B Instruction Details

Instruction ManualAMO-type

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

Instruction Syntax

amoxor.b rd, rs2, (rs1)

Syntax is rd, rs2, (rs1). The three fields select x0–x31 or ABI names, with no offset immediate or rs3.

32-bit encoding: funct5=00100, funct3=000, opcode=0101111; aq is bit26 and rl is bit25.

RV32/RV64 Zabha (requires Zaamo): rd receives sign-extended old 8-bit memory; memory receives old memory XOR the low 8 rs2 bits.

The region must support this AMO width and operation. Every byte address is naturally aligned.

Sources use pre-execution values; rd=x0 discards only register writeback and memory still undergoes read-modify-write. aq/rl orders only the accessed memory/I/O domain; suffixes are .aq, .rl and .aqrl.

ZabhaAtomic

Instruction Behavior

AMOXOR.B is a Zabha (and therefore Zaamo) AMO. It atomically loads the byte at rs1, sign-extends it into rd, then writes old_byte XOR rs2[7:0]; aq/rl annotate memory ordering.

AMOXOR.B Atomic Decode And Execute Animation

Shows Zabha (requires Zaamo) byte atomic field decode, aq/rl ordering bits, a memory read, and RMW state update.

rd
rs2
rs1
amoxor.b
,
,(
)
Execution Context
31..27
26
25
24..20
19..15
14..12
11..7
6..0
00100
funct5
0
aq
0
rl
01011
rs2
01010
rs1
000
funct3
00101
rd
0101111
opcode
Atomic Data Path
instruction
0x20B502AF
opcode
0101111 -> AMO
funct3
000 -> byte width
funct5
00100 -> AMOXOR.B
aq / rl
0/0 -> unordered
rd / rs2 / rs1
t0(x5) / a1(x11)[7:0]=0x0F / a0(x10)=0x00001000
memory read
mem[0x00001000] -> old byte 0xAA
RMW
Not computed
rd / memory
t0(x5) = unspecified initial value; mem[0x00001000] = 0xAA
Current Step

Concept Step: receive the 32-bit atomic instruction encoding

Zabha depends on Zaamo; Zabha-extension byte atomic instructions use a 32-bit encoding; the animation starts by splitting the fields.

encoding: 0x20B502AF
syntax : amoxor.b t0(x5), a1(x11), (a0(x10))
Pending result : Not computed
Current architectural state
t0(x5) = unspecified initial value; mem[0x00001000] = 0xAA

Assumes Zabha and Zaamo at the selected XLEN, successful fetch, a region supporting this width and operation, and a successful access. A misaligned halfword requires the stated PMA condition. Sources use pre-execution values; aq/rl orders only the accessed domain. Steps are a teaching sequence.

Quick Understanding & Search Notes

AMOXOR.B is a Zabha 8-bit atomic XOR 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.
Zabha depends on Zaamo; a byte address is naturally aligned, and aq/rl can provide optional release-consistency ordering.

Common Usage Scenarios

Atomic & Sync

RV32/RV64 Zabha+Zaamo, a1=0x1000, old memory=5 and a2=3; assuming a supporting region and successful access, a0 receives old value 5 and the 8-bit memory operand becomes 6.

Pre-Use Checklist

Syntax Check
  • Syntax is rd, rs2, (rs1). The three fields select x0–x31 or ABI names, with no offset immediate or rs3.
  • 32-bit encoding: funct5=00100, funct3=000, opcode=0101111; aq is bit26 and rl is bit25.
Semantic Check
  • RV32/RV64 Zabha (requires Zaamo): rd receives sign-extended old 8-bit memory; memory receives old memory XOR the low 8 rs2 bits.
  • The region must support this AMO width and operation. Every byte address is naturally aligned.
  • Sources use pre-execution values; rd=x0 discards only register writeback and memory still undergoes read-modify-write. aq/rl orders only the accessed memory/I/O domain; suffixes are .aq, .rl and .aqrl.

Pitfalls / Common Confusions

rd returns old memory value (sign-extended to XLEN), not the operation result
AMOXOR.B applies bitwise XOR only at 8-bit width between the old memory value and rs2[7:0], then writes the target byte.
Zabha depends on Zaamo; a byte is naturally aligned at every byte address, and aq/rl can provide optional release-consistency ordering.

FAQ

Does AMOXOR.B return the post-operation value?

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

Can AMOXOR.B affect neighboring bytes?

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