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.
BZbbBit ManipulationInteger Operation

Instruction Encoding

31..25
funct7
24..20
rs2
19..15
rs1
14..12
funct3
11..7
rd
6..0
opcode

XNOR uses opcode 0110011 (0x33), funct3 100, funct7 0100000. The rs1 and rs2 fields select the two source registers, and rd selects the destination register.

Format: R-type
opcode: 0110011 (0x33)
funct3: 100 (0x4)
funct7: 0100000 (0x20)

Instruction Behavior

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

Quick Understanding & Search Notes

XNOR is a B/Zbb instruction for bitwise XOR inverted result. This page is checked against the official B extension semantics, with emphasis on XLEN, W suffixes, .uw suffixes, and bitwise or rotate boundaries.

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)».

Stack & Frame

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

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

XNOR is not NOR
Equivalent to checking if every bit is equal

FAQ

Does XNOR access memory?

No. It only reads and writes integer registers; any memory access must be performed by a separate load or store instruction.

What is the result width of XNOR?

Except that W-suffixed forms produce a 32-bit result then sign-extend and .uw forms first extract a 32-bit unsigned operand, the result is written to rd at XLEN width.