ROR

Rotate Right

ROR rd, rs1, rs2

Rotates the bits in rs1 right by the amount in rs2.

Encoding

Binary Layout
0110000
31:25
rs2
24:20
rs1
19:15
101
14:12
rd
11:7
0110011
6:0
 
Format R-Type
Opcode 0x60005033
Extension Zbb

Operands

  • rd
    Destination register (integer)
  • rs1
    Source
  • rs2
    Rotate Amount

Example

ROR x10, x11, x12

// Bitwise rotation.

Related

Across architectures

Rotate Left : how x86, ARM, RISC-V, and PowerISA each do this.

More in Zbb

Description

ROR rotates rs1 right by the shift amount in the lower log2(XLEN) bits of rs2, writing the result to rd.

Operation

shamt = R[rs2] & (XLEN-1); R[rd] = (R[rs1] >> shamt) | (R[rs1] << (XLEN-shamt));