PIC18 cheatsheet

RRCF

Detailed reference for the RRCF instruction in PIC18 ISA.

Description

Rotate the contents of a byte‑oriented file register f one bit to the right through the Carry flag.

  • a = 0 → use the Access Bank for f.
  • a = 1 → use the Banked memory for f.

The least‑significant bit of f is moved into the Carry flag; the original Carry entry is shifted into bit 7 of the register. The new value is written back to f.

Examples

; a=0  → rotate in Access bank
RRCF 0x20, 0 ; 0x20 = (0x20 >> 1) | (C << 7)
; a=1  → rotate in Banked address
RRCF 0x20, 1 ; 0x20 = (0x20 >> 1) | (C << 7)
; Load 0x3 into 0x20 then rotate, a=0
MOVLW 0x3
MOVWF 0x20, 0
RRCF 0x20, 0 ; 0x20 = (0x03 >> 1) | (C << 7)
; Load 0x80 into 0x20 then rotate, a=1
MOVLW 0x80
MOVWF 0x20, 1
RRCF 0x20, 1 ; 0x20 = (0x80 >> 1) | (C << 7)
; Load 0xFF into 0x30 then rotate, a=0
MOVLW 0xFF
MOVWF 0x30, 0
RRCF 0x30, 0 ; 0x30 = (0xFF >> 1) | (C << 7)