Home/Instructions/Bit Reverse Byte
BREV8

RISC-V BREV8 Instruction Details

Instruction ManualI-type

bit reverse in bytes (Zbkb).

Instruction Syntax

brev8 rd, rs1
Operand Breakdown
Destination rd: general-purpose register receiving the result.
Source rs1: register holding the first operand.
Immediate imm: 12-bit signed value, sign-extended before operation with rs1.
ZbkbBit Manipulation

Instruction Encoding

31..20
imm[11:0]
19..15
rs1
14..12
funct3
11..7
rd
6..0
opcode

BREV8 uses opcode 0010011 (0x13), funct3 101, funct7 0110100. The rs1 field selects the source register, the 12-bit immediate provides the second operand, and rd selects the destination.

Format: I-type
opcode: 0010011 (0x13)
funct3: 101 (0x5)
funct7: 0110100 (0x34)

Instruction Behavior

BREV8 reverses bits within each byte of rs1 (bit 0↔7, 1↔6, ... per byte), writing the result to rd. Part of the Zbkb scalar bit-manipulation extension.

Quick Understanding & Search Notes

BREV8 is a Zbkb cryptographic bit-manipulation instruction; this page follows the official B-extension operation.

When available on RV32/RV64, operation width follows XLEN.
These instructions rearrange bit/byte fields and do not access memory.

Common Usage Scenarios

Endianness conversion

Understand this scenario with real code like «brev8 a0, a1 # Reverse bits in each byte of a1».

Bit-order reversal

Understand this scenario with real code like «brev8 a0, a1 # Reverse bits in each byte of a1».

CRC algorithms

Understand this scenario with real code like «brev8 a0, a1 # Reverse bits in each byte of a1».

Pre-Use Checklist

Syntax Check
  • Confirm the current instruction format is I-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

Only reverses bits within each byte
Operates on low 32(RV32)/64(RV64) bits

FAQ

Does BREV8 access memory?

No. It only rearranges bit fields or performs register lookup within integer registers.

Which extension contains BREV8?

It belongs to the Zbkb cryptographic bit-manipulation extension.