Home/Instructions/Pack Low 16-Bit Fields
PACKW

RISC-V PACKW Instruction Details

Instruction ManualR-type

RV64 pack low 16-bit fields (Zbkb), RV64-only.

Instruction Syntax

packw 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

PACKW (Zbkb, RV64) places rs1[15:0] into result bits [15:0], rs2[15:0] into bits [31:16], then sign-extends bit 31 into the upper 32 bits of rd.

PACKW Decode & Execute Animation

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

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

Quick Understanding & Search Notes

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

The official W form is defined only for RV64.
These instructions rearrange bit/byte fields and do not access memory.

Common Usage Scenarios

Crypto & Security

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

Logical Operations

Understand this scenario with real code like «packw 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

PACKW is defined only for RV64.
The result is the sign-extension of the packed 32-bit value, not zero-extension.
PACKW is RV64-only and sign-extends the packed 32-bit value.

FAQ

Does PACKW access memory?

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

Which extension contains PACKW?

It belongs to the Zbkb cryptographic bit-manipulation extension.