Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top