ror

Rotate right

Rotates the destination right by the given count; bits shifted out of the bottom re-enter at the top.

8086 and later

Intel's reference: RCL/RCR/ROL/ROR

CFPFAFZFSFDFOF ●–––––?
  • ● set from the result
  • ? undefined afterwards
  • – not changed
  • OF Defined only for a count of 1.
  • A count of 0 leaves every flag unchanged.

Forms

Operands

r/m
A general-purpose register or memory location matching the operation’s size, for example rax or qword [rbp-8]. The byte registers ah, bh, ch and dh cannot be used with a REX prefix, including when the memory address uses r8–r15.
imm8
An 8-bit immediate, -128 to 255. Instructions that sign-extend it to a wider operand interpret the byte as -128 to 127; shift counts do not use this sign extension.

CF receives the last bit rotated out, and OF is defined only for a count of one.

The count comes from an immediate or cl. It is first masked to six bits for a 64-bit operand or five bits for smaller operands, then reduced modulo the operand width for the rotation. A 64-bit rotation by 32 therefore exchanges the two 32-bit halves; a count of 64 masks to zero.

global _start

section .text
_start:
        mov rax, 12
        mov rbx, 5
        mov rcx, 3
        mov rsi, 9

        ror rax, 1

        mov rax, 60         ; syscall 60: exit
        xor rdi, rdi
        syscall