XNOR

RISC-V XNOR Instruction Details

Instruction ManualR-type

Exclusive NOR: rd = ~(rs1 ^ rs2)

Instruction Syntax

xnor rd, rs1, rs2
Operand Breakdown
Destination rd: register receiving the operation result.
Source rs1: register holding the first operand.
Source rs2: register holding the second operand.
ZbbZbkbBit ManipulationInteger Operation

Instruction Behavior

Bitwise exclusive-NOR: rd = ~(rs1 ^ rs2). Part of Zbb and Zbkb.

XNOR Decode And Execute Animation

Starts with machine-code field decoding, then shows operand reads, instruction-specific execution, and ISA-visible state update.

rd
rs1
rs2
xnor
,
,
Execution Context
t1(x6)
0x00000014
t2(x7)
0x00000007
31..25
24..20
19..15
14..12
11..7
6..0
0100000
funct7
00111
rs2
00110
rs1
100
funct3
00101
rd
0110011
opcode
Execution Data Path
instruction
0x407342B3
opcode
0110011 -> OP
funct3
100 -> XNOR
funct7
0100000 -> XNOR selector
rd / rs1 / rs2
t0(x5) / t1(x6) / t2(x7)
bitwise ALU
~(0x00000014 ^ 0x00000007) = 0xFFFFFFEC
x5
t0(x5) = 0xFFFFFFEC
Current Step

Concept Step: receive the 32-bit instruction encoding

The machine code is split by the current instruction format; the animation starts from encoding/decode.

encoding: 0x407342B3
syntax : xnor t0(x5), t1(x6), t2(x7)
result : t0(x5) = 0xFFFFFFEC
Architectural Result
t0(x5) = 0xFFFFFFEC

This animation shows ISA-visible decode and state changes, not any specific CPU pipeline, cache, prediction, or timing implementation.

Quick Understanding & Search Notes

XNOR inverts the XOR of each rs1/rs2 bit and writes the XLEN-wide result to rd. It is listed in both Zbb and Zbkb.

XNOR means ~(rs1 ^ rs2), not NOR.
Bits are computed independently: equal bits produce 1 and different bits produce 0.

Common Usage Scenarios

Comparison & Detection

Understand this scenario with real code like «xnor x10, x11, x12 ; x10 = ~(x11 ^ x12)».

Crypto & Security

Understand this scenario with real code like «xnor x10, x11, x12 ; x10 = ~(x11 ^ x12)».

Bit Manipulation

Understand this scenario with real code like «xnor x10, x11, x12 ; x10 = ~(x11 ^ x12)».

Pre-Use Checklist

Syntax Check
  • Verify rd, rs1, rs2 (and rs3) are valid GPRs.
  • Confirm funct3 and funct7 encoding is correct.
Semantic Check
  • Check if the result affects subsequent branches or address calculations.
  • Ensure the rd register is not overwritten by another instruction.

Pitfalls / Common Confusions

XNOR is not NOR
The result is a per-bit equality mask; only an all-one rd means the XLEN-bit patterns are wholly equal

FAQ

Does XNOR access memory?

No. It operates only on integer registers.

What is the result width of XNOR?

XNOR writes the XLEN-wide ~(rs1 ^ rs2) result to rd; each output bit depends only on its corresponding two input bits.