0
2.7kviews
Write C language program to read P0 and P1. Add the content of P0 and P1 and store the result to P2.
1 Answer
0
255views

The program

#include < reg51.h>  
void main(void)  
{  
    unsigned char a,b,c;  
    P0=0xFFH; //set port 0 as an input port  
    P1=0xFFH; //set port 1 as an input port  
    a=P0; //read number from port 0  
    b=P1; //read second number from port 1  
    c=a+b; //add both numbers  
    P2=c; //send result to port 2  
}
Please log in to add an answer.