Home/Instructions/OR with Complement
ORN

RISC-V ORN Instruction Details

Instruction ManualR-type

OR with inverted operand: rd = rs1 | ~rs2

Instruction Syntax

orn 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

ORN uses opcode 0110011 (0x33), funct3 110, 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: 110 (0x6)
funct7: 0100000 (0x20)

Instruction Behavior

Bitwise OR of rs1 with the bitwise inversion of rs2: rd = rs1 | ~rs2. Part of Zbb and Zbkb.

Quick Understanding & Search Notes

ORN is a B/Zbb instruction for bitwise rs1 OR not rs2. This page is checked against the official B extension semantics, with emphasis on XLEN, W suffixes, .uw suffixes, and bitwise or rotate boundaries.

The second source rs2 is inverted; rs1 is not.
The result is an XLEN-wide bitwise value, not a comparison or conditional branch.

Common Usage Scenarios

Bit Operations & Masks

Understand this scenario with real code like «orn x10, x11, x12 ; x10 = x11 | ~x12».

Crypto & Security

Understand this scenario with real code like «orn 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

Note distinction from regular OR: second operand is inverted first

FAQ

Does ORN 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 ORN?

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.