INCF Arithmetic
Add 1 to a file register.
| Syntax | INCF 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 | (f) + 1 → destination |
| Status bits | Z |
| Words / cycles | 1 word, 1 cycle |
| Encoding | 00 1010 dfff ffff |
How it works
INCF adds 1 to register f. When the register wraps from 0xFF to 0x00, Z is set. Unlike ADDWF, INCF does not touch C or DC.
Example
; INCF example from picsimulator.com/instructions/incf.html
list p=16f84a
include <p16f84a.inc>
org 0
movlw 0xFF
movwf 0x20
incf 0x20, f ; wraps to 0: Z = 1, C unchanged
The register rolls over to 0 and Z is set; C keeps its earlier value.
Open this example in the simulator
Watch out for
- Don't test C after INCF to detect the wrap: use Z, or INCFSZ.