BCF Bit Operations
Clear one bit of a file register.
| Syntax | BCF f, b |
|---|---|
| Operands | f: register address 0-127; b: bit number 0-7 |
| Operation | 0 → f<b> |
| Status bits | None |
| Words / cycles | 1 word, 1 cycle |
| Encoding | 01 00bb bfff ffff |
How it works
BCF clears bit b of register f and leaves the other bits alone. It is how you turn off an output pin, select bank 0 (BCF STATUS, RP0) or clear an interrupt flag.
Example
; BCF example from picsimulator.com/instructions/bcf.html
list p=16f84a
include <p16f84a.inc>
org 0
movlw 0xFF
movwf 0x20
bcf 0x20, 7 ; 0x20 = 0x7F
Only bit 7 changes.
Open this example in the simulator
Watch out for
- BCF reads the whole register, changes one bit and writes it back. On a port, the other pins are written with the levels read from the pins, which may differ from what was last written.