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.

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
  • 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

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.