PIC18 cheatsheet

BTFSC

Detailed reference for the BTFSC instruction in PIC18 ISA.

Description

Test the bit value of a file register f at bit position b.

  • If the bit is clear (0), the CPU skips the next sequential instruction.
  • If the bit is set (1), the next instruction executes normally.
  • a = 0 → Addressing uses the access bank.
  • a = 1 → Addressing uses the banked file registers.

Examples

; Skip next instruction if RB2 is clear (Access bank)
BTFSC PORTB, 2     ; Skip IF bit 2 of PORTB is clear
CLRF  PORTC         ; Executed only if bit 2 of PORTB is set
; Test a banked register: skip if bit 5 of file register 0x78 is clear
BTFSC 0x78, 5, 1   ; Skip IF bit 5 of file register 0x78 is clear
CLRF  0x79          ; Executed only if bit 5 of 0x78 is set