Webcentive RISC-V Reference

rorw

Rotate right word (Register)

Extension
Zbb, Zbkb, Zk, Zkn, Zks
XLEN
RV64 only
Assembly (riscv-unified-db)
rorw xd, xs1, xs2
Length
32-bit

Encoding

31252420191514121176210
0110000rs2rs1101rd0111011

Match 0x6000503b, mask 0xfe00707f. Source: rorw rd rs1 rs2 31..25=0x30 14..12=5 6..2=0x0E 1..0=3 in riscv-opcodes/extensions/rv64_zbb.

FieldBitsriscv-opcodes name
rs224:20rs2
rs119:15rs1
rd11:7rd

Description

Performs a rotate right on the least-significant word of xs1 by the amount in least-significant 5 bits of xs2. The resultant word is sign-extended by copying bit 31 to all of the more-significant bits.

Description from riscv-unified-db, reformatted.

Operation

XReg xs1_word = X[xs1][31:0];
XReg shamt = X[xs2][4:0];

XReg unextended_result = (xs1_word >> shamt) | (xs1_word << (32 - shamt));
X[xd] = {{32{unextended_result[31]}}, unextended_result};

Pseudocode in riscv-unified-db’s IDL, quoted unchanged.

Specification and related pages