Home/Instructions/Pack Low Bytes
PACKH

RISC-V PACKH Instruction Details

Instruction ManualR-type

pack low bytes (Zbkb).

Instruction Syntax

packh 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.
ZbkbBit Manipulation

Instruction Behavior

PACKH (Zbkb) places the low byte of rs1 into rd[7:0], the low byte of rs2 into rd[15:8], and clears all remaining high bits of rd. It does not pack the high halves of the source registers.

PACKH Decode & Execute Animation

Shows only specification-defined encodings, conditions, and architectural state; it does not model pipelines, cache coherence, or platform policy.

packh a0, a1, a2
Execution Context
Instruction Encoding
31..25
funct7
0000100
24..20
rs2
a2
19..15
rs1
a1
14..12
funct3
111
11..7
rd
a0
6..0
opcode
0110011 (OP)
Decode fixed fields
Fixed encoding fields identify the instruction and operand roles.
x[a0] <- 0x0000000000008088
Architectural state has not been committed.

Quick Understanding & Search Notes

PACKH 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

Crypto & Security

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

Logical Operations

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

Pre-Use Checklist

Syntax Check
  • Verify rd, rs1, rs2 (and rs3) are valid GPRs.
  • Confirm funct3 and funct7 encoding is correct.
Semantic Check
  • Check if the result affects subsequent branches or address calculations.
  • Ensure the rd register is not overwritten by another instruction.

Pitfalls / Common Confusions

The H in PACKH refers to the halfword-sized result, not the high half of the source registers.
Bits above bit 15 of the result are zeroed.

FAQ

Does PACKH access memory?

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

Which extension contains PACKH?

It belongs to the Zbkb cryptographic bit-manipulation extension.