One would certainly use the logic instructions when the bits to be tweaked are not known at compile time. If two bits need to be changed you can use either two BCF/BSF's or a single logic instruction with the following two caveats: 1: Two consecutive BSF/BCF to the same port is often a poor idea. If there is a relatively large capacitive load you can get into trouble. See the Microchip datasheet's discussion of 'read-modify-write' to ports. 2: If both pins are supposed to toggle at the same time you should stick to the logic instruction. Bob Ammerman RAm Systems (high performance, high function, low-level software) ----- Original Message ----- From: Andre Abelian To: Sent: Wednesday, July 05, 2000 4:07 PM Subject: [PIC]: using logic instructions > Hi to all engineers, > > after looking at applications notes I noticed some engineers used > logic instructions a lot to set and clear bits and others used BSF,BCF > instead. > > for examples: > ;*********************************************** > to set up to 8 bits at once the example is for one only > ;*********************************************** > movlw b'00000001' ; 1 is used to set > iorwf PORTD,f ; any port > > ;*********************************************** > to clear up to 7 bits at once : for 8 bit better use clrf > ;*********************************************** > movlw b'11111110' ; 0 is used to clear > andwf PORTD,f ; any port > > ;*********************************************** > to compare can be done by using xor or subtract > ;*********************************************** > movlw b'00001111' ; unknown value > xorlw b'00001111' ; compare with this value > bz same > not goto not > same goto same > ;*********************************************** > > my question is this: > other then setting more then one bit at a time is there any other reason > using > logic OR, AND instead of BSF,BCF. Does any body know any other examples > that might be useful by using logic instructions. > > Andre Abelian > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements