RORIW

RISC-V RORIW Instruction Details

Instruction ManualI-type

Rotate right word by immediate (RV64)

Instruction Syntax

roriw rd, rs1, shamt
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.
BZbbBit Manipulation

Instruction Behavior

Rotates lower 32 bits of rs1 right by shamt (0-31), result sign-extended to XLEN. RV64. Part of Zbb and Zbkb. shamt[5]=1 encodings reserved.

Quick Understanding & Search Notes

RORIW is a B/Zbb instruction for rotate-right word and sign-extend. This page is checked against the official B extension semantics, with emphasis on XLEN, W suffixes, .uw suffixes, and bitwise or rotate boundaries.

The W-suffixed form operates only on the low 32 bits of rs1 and uses a 5-bit amount.
The 32-bit result is sign-extended from bit 31 to XLEN; it is not an ordinary 64-bit rotate.

Common Usage Scenarios

Crypto & Security

Understand this scenario with real code like «roriw x10, x11, 8 ; x10 = sign_ext(rotr(x11[31:0], 8))».

Immediates & Constants

Understand this scenario with real code like «roriw x10, x11, 8 ; x10 = sign_ext(rotr(x11[31:0], 8))».

Pre-Use Checklist

Syntax Check
  • Confirm the current instruction format is I-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

RV64 only
Operates on lower 32 bits
W-suffix instructions produce a 32-bit result and sign-extend bit 31 to XLEN; do not treat them as ordinary 64-bit operations.
They exist in RV64/RV128-like environments, not RV32.

FAQ

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

Except that W-suffixed forms produce a 32-bit result then sign-extend and .uw forms first extract a 32-bit unsigned operand, the result is written to rd at XLEN width.