James Aflred
James Aflred

Reputation: 97

Using a port for both input and output

I have started learning Intel's 8051 assembly programming. I wrote a a test calculator program. I am using only 3 ports out of four. I am wondering if I can use a port for both input and output in the same program.

For Example, in this program Port 3 is used for taking a flag bit as input and also to display output.

Here is some of the code:

 JB P3.4, DisplayResult

 DisplayResult:

 MOV P3, #00H
 MOV P3, R0

 Here:

 SJMP Here

Regards

Upvotes: 1

Views: 1210

Answers (1)

Tachyon
Tachyon

Reputation: 68

Yes. you can.

Try to understand why the MOV P3, #00H was written. If you want pin 0 of P3 to be O and pin 1 of P3 to be I so you would write MOV P3, # 00000010B and so on.

Upvotes: 2

Related Questions