B boncker New Member Jun 12, 2006 #1 Hi guys, I'm working in a project at home and I need to do an "AND" operation with two bits in the same byte. For example, PORTA has 00011010. I need to do the "AND" operation with bits number 1 and 3 (1 and 1) and put the result in W. How can I do this code? Thanks!
Hi guys, I'm working in a project at home and I need to do an "AND" operation with two bits in the same byte. For example, PORTA has 00011010. I need to do the "AND" operation with bits number 1 and 3 (1 and 1) and put the result in W. How can I do this code? Thanks!
Nigel Goodwin Super Moderator Most Helpful Member Jun 12, 2006 #2 How about: Code: movf PortA, w andlw 'b00001010'
eblc1388 Active Member Jun 12, 2006 #3 Try this: Code: clrw ;clear W btfss PORTA,1 ;test bit 1 goto done btfss PORTA,3 ;test bit 3 goto done movlw d'1' done ; ;W=1 if both bit1 & bit3=1
Try this: Code: clrw ;clear W btfss PORTA,1 ;test bit 1 goto done btfss PORTA,3 ;test bit 3 goto done movlw d'1' done ; ;W=1 if both bit1 & bit3=1
Nigel Goodwin Super Moderator Most Helpful Member Jun 12, 2006 #4 Interesting variation on the same question!, we obviously both understood it differently?.