PIC18 cheatsheet

CPFSEQ

Detailed reference for the CPFSEQ instruction in PIC18 ISA.

Description

Compare file register f with the contents of WREG. If the two values are equal, the next instruction is skipped.

  • a = 0 → Access‑bank addressing.
  • a = 1 → Banked addressing.

Examples

; a=0 – compare register in access bank, skip if equal
CPFSEQ 0x20, 0 ; skips next if W = 0x20
; a=1 – compare register in banked address, skip if equal
CPFSEQ 0x62, 1 ; skips next if W = value at 0x62 in banked area
; Load literal into WREG then compare access bank
MOVLW 0x20
CPFSEQ 0x20, 0 ; skips next if W = 0x20 (equal)
; Load literal into WREG then compare banked address
MOVLW 0x20
CPFSEQ 0x62, 1 ; skips next if W = 0x20 (equal)
; Load literal into WREG, compare with different register value – no skip
MOVLW 0x10
CPFSEQ 0x20, 0 ; W = 0x10, f = 0x20 – next instruction executed