You can't use a variable in a BCF. Here is a simple flow, untested, but the logic makes sense: MOVLW h'fe' ; all bits but 0 set MOVWF work1 ; mask variable MOVFW position ; the bit position BTFSC STATUS,Z ; if position is zero, the mask is good GOTO ZBIT BITLOOP ; roll mask 'position' bits BSF STATUS,CARRY RLF work1,F DECFSZ position,F GOTO BITLOOP ZBIT MOVFW PORTB ; PORTB in W ANDWF WORK1,W ; turn off 1 bit MOVWF PORTB ; back in port The same idea to toggle a port: MOVLW h'01' ; all bits but 0 clear MOVWF work1 ; mask variable MOVFW position ; bit position BTFSC STATUS,Z ; if position is zero, mask is good GOTO ZBIT BITLOOP ; roll mask 'position' bits BCF STATUS,CARRY RLF work1,F DECFSZ position,F GOTO BITLOOP ZBIT MOVFW PORTB ; port B in W XORWF WORK1,W ; toggle 1 bit MOVWF PORTB ; back in port I think this is shorter than most examples I've seen. There is no test for 'position' > 7. I use similar logic to toggle a static bit: MOVFW PORTB XORLW 1< http://www.sni.net/cedardell