Home/Instructions/Byte Reverse
REV8

RISC-V REV8 Instruction Details

Instruction ManualI-type

Byte-reverse register (endianness conversion)

Instruction Syntax

rev8 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.
BZbbZbkbBit ManipulationInteger Operation

Instruction Behavior

Byte-reverse: reverses the byte order of rs. RV32: rev8(0xAABBCCDD)=0xDDCCBBAA. REV8 uses different fixed imm[11:0] selectors in RV32 and RV64. Part of Zbb and Zbkb.

REV8 Decode And Execute Animation

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

rd
rs
rev8
,
Execution Context
t1(x6)
0x00000014
31..20
19..15
14..12
11..7
6..0
011010011000
fixed imm[11:0]
00110
rs1
101
funct3
00101
rd
0010011
opcode
Execution Data Path
instruction
0x69835293
opcode
0010011 -> OP-IMM
funct3
101 -> REV8
fixed imm[11:0]
011010011000 -> REV8 RV32 selector
rd / rs
t0(x5) / t1(x6)=0x00000014
fixed imm[11:0]
011010011000 -> REV8 RV32 selector (not an arithmetic immediate)
reverse byte order
0x00000014 -> 0x14000000 across 4 bytes
x5
t0(x5) = 0x14000000
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: 0x69835293
syntax : rev8 t0(x5), t1(x6)
result : t0(x5) = 0x14000000
Architectural Result
t0(x5) = 0x14000000

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

Quick Understanding & Search Notes

REV8 is a B/Zbb instruction for reverse byte order across XLEN. This page is checked against the official B extension semantics, with emphasis on XLEN, W suffixes, .uw suffixes, and bitwise or rotate boundaries.

RV32 reverses 4 bytes and RV64 reverses 8 bytes.
REV8 swaps byte positions; do not confuse it with BREV8, which reverses bits within each byte.

Common Usage Scenarios

Network & Byte Order

Understand this scenario with real code like «rev8 x10, x11 ; byte-reverse x11 (bswap)».

Pre-Use Checklist

Syntax Check
  • Verify the immediate field is within the valid range.
  • Confirm source register rs1 points to the correct operand.
Semantic Check
  • Check if the immediate sign-extension matches expectations.
  • Ensure the result register rd has a clear purpose.

Pitfalls / Common Confusions

Behavior differs between RV32 and RV64 (byte count)

FAQ

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

REV8 operates across the complete XLEN-wide register and writes an equally wide result: four bytes in RV32 and eight bytes in RV64.