PIC18 cheatsheet

TSTFSZ

Detailed reference for the TSTFSZ instruction in PIC18 ISA.

Description

Test the contents of a file register f; if the register contains zero, the CPU skips the following instruction.

  • a = 0 → Access‑bank addressing.
  • a = 1 → Banked addressing. The instruction does not modify any registers. It only affects the program counter.

Examples

; a=0, register zero – next instruction skipped
TSTFSZ 0x20, 0 ; if 0x20 == 0 skip the following instruction
; a=0, register non‑zero – instruction proceeds
TSTFSZ 0x20, 0 ; if 0x20 != 0 execute the following instruction
; a=1, register zero – next instruction skipped
TSTFSZ 0x20, 1 ; if 0x20 == 0 (banked address) skip the following instruction
; a=1, register non‑zero – instruction proceeds
TSTFSZ 0x20, 1 ; if 0x20 != 0 (banked address) execute the following instruction