ROR moves every bit one place to the right, count times. The bit leaving bit 0 wraps around into the top bit and is also copied into CF. No bits are lost; rotating a byte by 8, or a word by 16, restores it. ROR by n is the same as ROL by the operand width minus n.

+---------------------------+
| |
+-> b7 b6 b5 b4 b3 b2 b1 b0 -+
|
CF <--+
1000 0001 81h
ROR 1 1100 0000 C0h, CF = 1

Forms and flags

Register or memory operand; count 1 or CL on the 8086. Only CF and OF change. CF is the bit that wrapped around, which is now the top bit. With a count of 1, OF is set when the two highest bits of the result differ, meaning the sign bit changed. For other counts OF is undefined. SF, ZF, PF and AF are not touched.

Idioms

Walk a single 1 bit through a byte, for example to select one of eight things in turn: start with 80h and ROR by 1 each step; after bit 0 it comes back to bit 7 by itself. Look at bit 0 without losing it: ROR AL, 1 then JC, and ROL AL, 1 to undo. Bring a field down to the bottom of a register: a rotate followed by AND with a mask extracts it, and the rotate in the other direction puts it back.

Prints 10000001 11000000 CF=1 00011000
MOV AL, 81h ; 1000 0001
CALL SHOWBIN
ROR AL, 1 ; bit 0 comes in at the top
CALL SHOWBIN ; 1100 0000
CALL SHOWCF
MOV CL, 3
ROR AL, CL
CALL SHOWBIN ; 0001 1000
SHOWBIN PROC NEAR ; print AL as 8 binary digits and a space
PUSHF ; keep the caller's flags
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV BL, AL
MOV CX, 8
NEXTBIT:
SHL BL, 1 ; the top bit falls into CF
MOV DL, "0"
ADC DL, 0 ; "0" + CF = "0" or "1"
MOV AH, 02h
INT 21h
LOOP NEXTBIT
MOV DL, " "
MOV AH, 02h
INT 21h
POP DX
POP CX
POP BX
POP AX
POPF
RET
SHOWBIN ENDP
SHOWCF PROC NEAR ; print "CF=0" or "CF=1" and a space
PUSHF
PUSH AX
PUSH DX
MOV DL, "0"
ADC DL, 0 ; "0" + CF, before anything changes CF
PUSH DX
MOV AH, 09h
MOV DX, OFFSET CFTXT
INT 21h
POP DX
MOV AH, 02h
INT 21h
MOV DL, " "
MOV AH, 02h
INT 21h
POP DX
POP AX
POPF
RET
SHOWCF ENDP
CFTXT DB "CF=$"

Later CPUs

On the 8086 the count in CL is used in full. The 80186 and later mask it to 5 bits and add an immediate count form, such as ROR AL, 3.