XPERM8

RISC-V XPERM8 Instruction Details

Instruction ManualR-type

byte crossbar permutation (Zbkx).

Instruction Syntax

xperm8 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.
ZbkxBit Manipulation

Instruction Behavior

XPERM8 (Zbkx) treats rs1 as a table of 8-bit elements and each 8-bit element of rs2 as an index. For each result position, if the index is less than XLEN/8, the corresponding 8-bit element from rs1 is written to rd; otherwise that result element is written as zero. It is used for constant-time S-boxes, permutations, and cryptographic bit manipulation.

Quick Understanding & Search Notes

XPERM8 is a Zbkx cross-register permutation instruction; this page follows the official B-extension operation.

When available on RV32/RV64, operation width follows XLEN.
Do not modulo-wrap rs2 indexes; out-of-range result elements are zero.

Common Usage Scenarios

Immediates & Constants

Understand this scenario with real code like «xperm8 a0, a1, a2».

Network & Byte Order

Understand this scenario with real code like «xperm8 a0, a1, a2».

Vector Operations

Understand this scenario with real code like «xperm8 a0, a1, a2».

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

Indexes come from each 8-bit element of rs2; rs1 is the table source.
Out-of-range indexes produce zero; they do not wrap modulo the element count.
The instruction is only a permutation/table-lookup primitive; algorithm security still depends on the whole implementation.
Indexes come from rs2 and rs1 is the lookup table; out-of-range indexes produce zero rather than wrapping.

FAQ

Does XPERM8 access memory?

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

Which extension contains XPERM8?

It belongs to the Zbkx crossbar-permutation extension.