PIC18 cheatsheet

DECF

Detailed reference for the DECF instruction in PIC18 ISA.

Description

Decrement the contents of file register f by 1.

  • d = 0 → result is stored in WREG.
  • d = 1 → result is stored back into register f.
  • a = 0 → Access‑bank addressing.
  • a = 1 → Banked addressing.

Examples

; d=0, a=0  → result in WREG, Access bank
DECF 0x20, 0, 0   ; W = 0x20-1
; d=0, a=1  → result in WREG, Banked address
DECF 0x20, 0, 1   ; W = 0x20-1
; d=1, a=0  → result back to file register, Access bank
DECF 0x20, 1, 0   ; 0x20 = 0x20-1
; d=1, a=1  → result back to file register, Banked address
DECF 0x20, 1, 1   ; 0x20 = 0x20-1
; Pre-load WREG with literal, decrement f, result in WREG (Access bank)
MOVLW 0x10
DECF 0x20, 0, 0   ; W = 0x20-1