Search This Blog

Port Programming 8051(Assembly language) | EXAMPLE 1

Port Programming 8051(Assembly language)|EXAMPLE 1

Write a program to read status of the pin P 2.1 and send its complement to the pin P 1.0

Algorithm:

Step 1: Configure P 2.1 as an input port.
Step 2: Read status of pin P 2.1 into carry flag
Step 3:Complement the status
Step 4:Send complement of the status to the pin P 1.0


Code:

ORG 0000H

SETB P2.1
HERE:MOV C,P2.1
CPL C
MOV P1.0,C
SJMP HERE
END




Note:


Always remember this :


The carry flag in PSW is considered as Boolean Accumulator.


No comments

Popular Posts

Followers