written 6.0 years ago by
teamques10
★ 69k
|
•
modified 5.9 years ago
|
The program
#include< regx51.h>
void main(void)
{
unsigned char a,b;
P2=0xFFH; $ \ \ \ \ \ \ \ $ //set port 2 as an input
P3=0xFFH; $ \ \ \ \ \ \ \ $//set port 1 as an input
a=P2; $ \ \ \ \ \ \ \ $ //read status of bits from P2
b=P3; $ \ \ \ \ \ \ \ $//read status of bits from P3
a=a>>3; $ \ \ \ \ \ \ \ $ //shift P2 bits to right by 3 bits
P0=a; $ \ \ \ \ \ \ \ $ //send to port 0
b=b>>4; $ \ \ \ \ \ \ \ $ //shift P3 bits to left by 4 bits
P1=b; $ \ \ \ \ \ \ \ $ //send to port 1
}