
 #include<reg51.h>
 
 #define adc P1
 
 sbit cs=P2^2;
 sbit wr=P2^1;
 sbit rd=P2^7;
 sbit intr=P2^0;

 void cnd(unsigned char value); /*function to convert 
                                  the HEX o/p to decimal*/
 void main()                     
{unsigned char value;
 
 cs=1;
 intr=1;
 rd=1;
 wr=1;
 cs=0;
 wr=0;
 wr=1;
 adc=0x08;
 cs=1;
 adc=0xFF;

 while(intr==1);
 cs=0;
 wr=1;
 rd=0;
 rd=1;
 cs=1;
 value=adc;

 cnd(value);      //converting and displaying the output.

 for(;;);         //coverting analog to digital only once.
 }
