The bit manipulation insturctions (BTFxx, BSF and BCF) all include the bit number as an immediate value within the instruction. You cannot pass a bit number to these instructions in a register. However, you can get the same effect by using a bit _mask_ rather than a bit _number_ and using the ANDWF or IORWF instructions. You can convert a bit number to a bit mask using a short table lookup function. Bob Ammerman RAm Systems (high performance, high function, low-level software) ----- Original Message ----- From: Russell Farnhill To: Sent: Monday, June 26, 2000 6:17 AM Subject: [PIC]: asm question > Hi all, > > I have just started learning asm and playing around with a 16f84. I've > already read > a couple of tutorials from the net and now have a question. How do I create > a function > that uses a bit orientated command and pass its arguments via a register. I > have > included a small piece of code to try and illustrate. > > #include "p16f84.inc" > #DEFINE PAGE0 bcf STATUS,5 > #DEFINE PAGE1 bsf STATUS,5 > > RBpin equ 0x0C ; Port B pin number > > > org 4 > goto start > > start > clrf PORTB ; clear portb > PAGE1 ; select bank 1 > clrf PORTB ; portb all output's > PAGE0 ; select bank 0 > > loop movlw 0 ; bit 0 portb > movwf RBpin ; move bit select into register > call foobar ; test function > goto loop > > foobar > > bsf PORTB,RBpin > return > > END > > When I compile this I get the error "Argument out of range. Least > significant bits used". > I guess this is because bsf expects a single bit arg but I pass it a byte. I > tried loading > W with my bit number and then read W from within my function which worked > fine, but if I > need to pass 2 args I can't use W as one arg overwrites the other. > > Any suggestions ? > > Thanks Russell.