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
rd: receives the XLEN-bit result with each byte's bit order reversed.
rs1: supplies the XLEN-bit source grouped into 8-bit bytes.
Bits 31..20 are fixed to 011010000111; this is the BREV8 encoding selector, not an assembly immediate.
ZbkbBit Manipulation

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.

BREV8 Decode & Execute Animation

Shows only official encodings, conditions, and architectural results; it does not imply a microarchitecture.

brev8 a0, a1
Execution context
x[a0] <- 0x80C4A2E691D5B3F7
Encoding fields
31..20
imm[11:0]
011010000111
19..15
rs1
01011
14..12
funct3
101
11..7
rd
01010
6..0
opcode
0010011
Encoding fields identify the instruction.
0x0123456789ABCDEF -> 0x80C4A2E691D5B3F7 (each byte reverses independently)
x[a0] <- 0x80C4A2E691D5B3F7
Architectural state has not been committed.

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

byte-local bit permutation

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

per-byte bit reversal

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

Pre-Use Checklist

Syntax Check
  • Confirm the assembly operands are only rd, rs1; bits 31..20 value 011010000111 is a fixed encoding selector, not an immediate.
  • Confirm the target implements Zbkb and reads rs1 and writes rd at the current XLEN.
Semantic Check
  • Confirm each 8-bit byte reverses bit[7:0] independently; no byte positions are exchanged.
  • Confirm this is a register-only bit permutation: it neither accesses memory nor treats the fixed encoding bits as runtime input.

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 within each byte of an integer register.

Which extension contains BREV8?

It belongs to the Zbkb cryptographic bit-manipulation extension.