PIC code to do "AND" with two bits

Status
Not open for further replies.

boncker

New Member
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!
 
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
 
Interesting variation on the same question!, we obviously both understood it differently?.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…