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.

RORIW Decode And Execute Animation

Starts with machine-code field decoding, then shows operand reads, instruction-specific execution, and ISA-visible state update.

rd
rs1
shamt
roriw
,
,
Execution Context
t1(x6)
0x0000000000000014
31..25
24..20
19..15
14..12
11..7
6..0
0110000
fixed imm[11:5]
01000
shamt[4:0]
00110
rs1
101
funct3
00101
rd
0011011
opcode
Execution Data Path
instruction
0x6083529B
opcode
0011011 -> OP-IMM-32
funct3
101 -> RORIW
imm[11:5]
imm[11:5]=0110000 fixed; shamt[4:0]=01000
rd / rs1
t0(x5) / t1(x6)
imm[11:5] + shamt[4:0]
imm[11:5]=0110000 fixed; shamt[4:0]=01000
32-bit rotate right
0x00000014 rotr 8 -> low 32 bits 0x14000000 -> sext.w 0x0000000014000000
x5
t0(x5) = 0x0000000014000000
Current Step

Concept Step: receive the 32-bit instruction encoding

The machine code is split by the current instruction format; the animation starts from encoding/decode.

encoding: 0x6083529B
syntax : roriw t0(x5), t1(x6), 8
result : t0(x5) = 0x0000000014000000
Architectural Result
t0(x5) = 0x0000000014000000

This animation shows ISA-visible decode and state changes, not any specific CPU pipeline, cache, prediction, or timing implementation.

Quick Understanding & Search Notes

RORIW is RV64-only: it rotates rs1[31:0], then sign-extends result bit 31 to XLEN.

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
  • Verify the immediate field is within the valid range.
  • Confirm source register rs1 points to the correct operand.
Semantic Check
  • Check if the immediate sign-extension matches expectations.
  • Ensure the result register rd has a clear purpose.

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.
The rotate amount is the immediate encoded in shamt[4:0]; encodings with shamt[5]=1 are reserved.

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?

RORIW rotates rs1[31:0]; bit 31 of the 32-bit result is copied into the upper bits written to rd.