As others have already stated, unfortunatly, the bit instructions can only accept a literal as the bit argument. Just not enough bits in the single word instruction format to store another variable address. Just one more trade off for a 1 cycle per instruction architecture. I resolved this by writing a macro equivelent for each of the bit instructions which take a variable as an arguemtn for the bit. Although these are implemented for the PIC17 series of processors, they should be easy to translate for the PIC16 series. A CHALLANGE TO THE OTHER MACRAO FANS ON THE LIST, HOW ABOUT EVERYONE POST THERE FAVORITE TIME SAVING MACRO! ;Note, variable should contain a number in the range 0..7 ;the table lookup will mask out the high 5 bits vbtfsc macro varDataByte,varBitPosition ;test bit position from variable and skip if bit clear movfw varBitPosition ;load bit position call BitMaskTbl ;convert to bit mask andwf varDataByte,w ;isolate bit being tested btfss ALUSTA,Z ;Z bit will bet set if bit being tested was clear endm vbtfss macro varDataByte,varBitPosition ;test bit position from variable and skip if bit set movfw varBitPosition ;load bit position call BitMaskTbl ;convert to bit mask andwf varDataByte,w ;isolate bit being tested btfsc ALUSTA,Z ;Z bit will bet set if bit being tested was clear endm vbcf macro varDataByte,varBitPosition ;clear bit position from variable movfw varBitPosition ;load bit position call BitMaskTbl ;convert to bit mask comf WREG,f ;complement mask so we can clear bit andwf varDataByte,f ;make sure target bit is clear endm vbsf macro varDataByte,varBitPosition ;set bit position from variable movfw varBitPosition ;load bit position call BitMaskTbl ;convert to bit mask andwf varDataByte,f ;make sure target bit is set endm ;You must include this table lookup in your program ;NOTE, INSURE THAT THIS TABKE DOESN'T CROSS A 256 BYTE PAGE BOUNDRY org 0x0E00 ;TABLE MUST BE COMPLETLY CONTAIN ED IN ONE 256 BYTE MEMORY PAGE BitMaskTbl andlw B'00000111' ;make sure we dont go outside ta ble bounds addwf PCL,f retlw B'00000001' retlw B'00000010' retlw B'00000100' retlw B'00001000' retlw B'00010000' retlw B'00100000' retlw B'01000000' retlw B'10000000' At 10:24 PM 99/05/08 -0500, you wrote: >Hello, I am trying to use a file register as a mask to clear a bit on >PORTB. I do get a warning when I compile: > > Warning[202] E:\PIC\CODE\test.ASM 113 : Argument out of range. Least >significant bits used. > >Here is the code: >Let's say test = 1 for argument's sake (I've tested this and it does) > movwf test ;save request > movlw .1 ;need to subtract 1 so range is from 0 to 7 > subwf test, W ;w = test - 1 > movwf test ;test = test - 1 test = 0 > bcf PORTB, test ;clear PORTB.0 > >It doesn't matter what bit I want to clear, bit five is the only one that >is ever cleared regardless of the value of test. I should point out that >test is in files register 0x015, so it makes sense why bit 5 (the lower >nybble) is the only one cleared, but why is it using it's address and not >it's value? > >Thanks, Jay > > Regards Bob Bullock KoolKits Electronics Ltd. bobb@koolkits.com www.koolkits.com