PIC18 cheatsheet

INCFSZ

Detailed reference for the INCFSZ instruction in PIC18 ISA.

Description

Increment the contents of file register f by one and skip the next instruction if the result is zero.

  • d = 0 → The incremented value is written to WREG; otherwise it is written back to f.
  • d = 1 → The incremented value is written back to f.
  • a = 0 → The operand f refers to the Access bank.
  • a = 1 → The operand f refers to the Banked register file.

Examples

; d=0, a=0  → result in WREG, Access bank
INCFSZ 0x07, 0, 0   ; 0x07 = 0x07 + 1 → result in WREG, skip if zero
; d=0, a=1  → result in WREG, Banked address
INCFSZ 0x100, 0, 1   ; 0x100 = 0x100 + 1 → result in WREG, skip if zero
; d=1, a=0  → result stored back in f, Access bank
INCFSZ 0x07, 1, 0   ; 0x07 = 0x07 + 1 → result in f, skip if zero
; d=1, a=1  → result stored back in f, Banked address
INCFSZ 0x100, 1, 1   ; 0x100 = 0x100 + 1 → result in f, skip if zero
; Load literal into WREG, then increment f with result written to WREG
MOVLW 0x10
INCFSZ 0x07, 0, 0   ; WREG = 0x07 + 1 after increment