Home/Instructions/Rotate Right Immediate
RORI

RISC-V RORI Instruction Details

Instruction ManualI-type

Rotate right by immediate

Instruction Syntax

rori 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 ManipulationInteger Operation

Instruction Behavior

Rotates rs1 right by shamt (immediate). Range 0-31 (RV32) or 0-63 (RV64). Part of Zbb and Zbkb.

RORI 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
rori
,
,
Execution Context
t1(x6)
0x00000014
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
0010011
opcode
Execution Data Path
instruction
0x60835293
opcode
0010011 -> OP-IMM
funct3
101 -> RORI
imm[11:5]
imm[11:5]=0110000 fixed
rd / rs1
t0(x5) / t1(x6)
imm[11:5] + shamt[4:0]
imm[11:5]=0110000 fixed; shamt[4:0]=01000
rotate right
(0x00000014 >> 8) | (0x00000014 << 24) -> 0x14000000
x5
t0(x5) = 0x14000000
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: 0x60835293
syntax : rori t0(x5), t1(x6), 8
result : t0(x5) = 0x14000000
Architectural Result
t0(x5) = 0x14000000

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

Quick Understanding & Search Notes

RORI rotates rs1 right by shamt and writes an XLEN-wide result to rd. RV32 permits only a 5-bit shift amount; RV64 uses 6 bits.

The immediate uses a 5-bit amount on RV32 and a 6-bit amount on RV64.
On RV32, encodings with shamt[5]=1 are reserved; on RV64, bit 25 is shamt[5].

Common Usage Scenarios

Crypto & Security

Understand this scenario with real code like «rori x10, x11, 16 ; x10 = rotr(x11, 16)».

Shift & Rotate

Understand this scenario with real code like «rori x10, x11, 16 ; x10 = rotr(x11, 16)».

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

shamt limited to 31 on RV32

FAQ

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

RORI writes the XLEN-wide rotated result to rd; it neither first truncates to 32 bits nor sign-extends a word result.