RLF Bit Operations
Rotate a register one bit left through the carry flag.
| Syntax | RLF f, d |
|---|---|
| Operands | f: register address 0-127 (bank bits come from STATUS); d: 0 or w puts the result in W, 1 or f puts it back in f |
| Operation | rotate f left through C: C → bit 0, bit 7 → C |
| Status bits | C |
| Words / cycles | 1 word, 1 cycle |
| Encoding | 00 1101 dfff ffff |
How it works
RLF shifts register f one place left. The old C goes into bit 0 and the old bit 7 comes out into C, so the rotation is 9 bits wide.
With C cleared first (BCF STATUS, C), RLF multiplies by 2. Chained RLFs shift multi-byte values, and running lights use RLF to walk a bit along a port.
Example
; RLF example from picsimulator.com/instructions/rlf.html
list p=16f84a
include <p16f84a.inc>
org 0
bcf STATUS, C ; clear carry first
movlw 0x81
movwf 0x20
rlf 0x20, f ; 0x20 = 0x02, C = 1 (bit 7 moved into C)
1000 0001 becomes 0000 0010 and the top bit lands in C.
Open this example in the simulator
Watch out for
- RLF is a rotate through C, not a plain shift: whatever is in C enters bit 0. Clear or set C first.
- Z is not affected.