BTFSS Bit Operations

Test a bit and skip the next instruction if it is set.

SyntaxBTFSS f, b
Operandsf: register address 0-127; b: bit number 0-7
Operationskip the next instruction if f<b> = 1
Status bitsNone
Words / cycles1 word, 1 (2 if it skips) cycles
Encoding01 11bb bfff ffff

How it works

BTFSS ("bit test f, skip if set") skips the next instruction when bit b of register f is 1. Polling loops use it to wait for a flag: BTFSS reg, bit / GOTO $-1 loops until the bit sets.

Example

; BTFSS example from picsimulator.com/instructions/btfss.html
    list p=16f84a
    include <p16f84a.inc>

    org 0
    clrf 0x21
    movlw 0x01
    movwf 0x20        ; bit 0 of 0x20 is set
    btfss 0x20, 0     ; set, so skip
    incf 0x21, f      ; skipped
    incf 0x21, f      ; runs: 0x21 = 1

Bit 0 is 1, so the first INCF is skipped.

Open this example in the simulator

Related instructions