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 81hROR 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.
MOV AL, 81h ; 1000 0001CALL SHOWBINROR AL, 1 ; bit 0 comes in at the topCALL SHOWBIN ; 1100 0000CALL SHOWCFMOV CL, 3ROR AL, CLCALL SHOWBIN ; 0001 1000SHOWBIN PROC NEAR ; print AL as 8 binary digits and a spacePUSHF ; keep the caller's flagsPUSH AXPUSH BXPUSH CXPUSH DXMOV BL, ALMOV CX, 8NEXTBIT:SHL BL, 1 ; the top bit falls into CFMOV DL, "0"ADC DL, 0 ; "0" + CF = "0" or "1"MOV AH, 02hINT 21hLOOP NEXTBITMOV DL, " "MOV AH, 02hINT 21hPOP DXPOP CXPOP BXPOP AXPOPFRETSHOWBIN ENDPSHOWCF PROC NEAR ; print "CF=0" or "CF=1" and a spacePUSHFPUSH AXPUSH DXMOV DL, "0"ADC DL, 0 ; "0" + CF, before anything changes CFPUSH DXMOV AH, 09hMOV DX, OFFSET CFTXTINT 21hPOP DXMOV AH, 02hINT 21hMOV DL, " "MOV AH, 02hINT 21hPOP DXPOP AXPOPFRETSHOWCF ENDPCFTXT 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.