Home/Instructions/Rotate Right Word by Immediate
RORIW

RISC-V RORIW Instruction Details

Instruction ManualI-type

Rotate right word by immediate (RV64)

Instruction Syntax

roriw rd, rs1, shamt
Operand Breakdown
rd, rs1: integer registers x0–x31; shamt is 0–31, without sign extension.
32-bit OP-IMM-32: opcode=0011011, funct3=101, imm[11:5]=0110000; shamt occupies bits24:20.
RV64 only; requires enabled Zbb or Zbkb; B includes Zbb.
Rotate right within rs1[31:0], then sign-extend result bit31 to 64 bits, including when the rotate amount is zero.
x0 is always zero and discards writes; rd may overlap a source, using values before writeback. Only integer registers are operated on, with no data-memory access.
BZbbZbkbBit Manipulation

Instruction Behavior

RV64 only: rotate rs1[31:0] right by shamt (0–31), then sign-extend result bit 31 to XLEN. Requires Zbb or Zbkb.

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

Assumes Zbb or Zbkb is enabled at the selected XLEN, with the fixed register values below and PC=0x2000; fetch succeeds and no asynchronous interrupt occurs. Steps are a teaching decomposition.

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
Not computed
x5
t0(x5) = 0x0000000000003001; pc = 0x0000000000002000
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: Not computed
Current architectural state
t0(x5) = 0x0000000000003001; pc = 0x0000000000002000

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

Rotate right

RV64 with Zbb (or Zbkb), x11=0x1234567880000001: roriw x10, x11, 1 rotates to word 0xC0000000, then writes x10=0xFFFFFFFFC0000000.

Pre-Use Checklist

Syntax Check
  • rd, rs1: integer registers x0–x31; shamt is 0–31, without sign extension.
  • 32-bit OP-IMM-32: opcode=0011011, funct3=101, imm[11:5]=0110000; shamt occupies bits24:20.
Semantic Check
  • RV64 only; requires enabled Zbb or Zbkb; B includes Zbb.
  • Rotate right within rs1[31:0], then sign-extend result bit31 to 64 bits, including when the rotate amount is zero.
  • x0 is always zero and discards writes; rd may overlap a source, using values before writeback. Only integer registers are operated on, with no data-memory access.

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.
shamt occupies bits24:20; imm[11:5] is fixed to 0110000, not a signed 12-bit operand.

FAQ

Does RORIW access memory?

It does not access data memory; it reads integer source registers and writes the computed result to rd.

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.