BSF Bit Operations
Set one bit of a file register.
| Syntax | BSF f, b |
|---|---|
| Operands | f: register address 0-127; b: bit number 0-7 |
| Operation | 1 → f<b> |
| Status bits | None |
| Words / cycles | 1 word, 1 cycle |
| Encoding | 01 01bb bfff ffff |
How it works
BSF sets bit b of register f. Typical uses: turn on an output pin, select bank 1 with BSF STATUS, RP0, or enable an interrupt with BSF INTCON, GIE.
Example
; BSF example from picsimulator.com/instructions/bsf.html
list p=16f84a
include <p16f84a.inc>
org 0
clrf 0x20
bsf 0x20, 0
bsf 0x20, 4 ; 0x20 = 0x11
Bits 0 and 4 are set: 0001 0001.
Open this example in the simulator
Watch out for
- Bit names such as RP0, GIE or T0IF are just numbers (5, 7, 2...). Make sure the bit name matches the register: BSF PORTB, RP0 sets RB5.