 START:								   
            ORG 2000H	
	    LJMP MAIN			
	
	    ORG 2003H        ;A15-Enable the decoder and A0=1,A1=A2=A3=0;
	    MOV DPTR,#0001H  ;convertion data is received from this address;
	    MOVX A,@DPTR     	
	    RETI
	   		
	    ORG 2030H  
MAIN:  
	   ACALL SERIAL
           MOV IE,#10000001B  ;external interrupt0
	   SETB TCON.0        ;edge triggered

HERE:      MOV A,#07H         ;select analog input8(A0=A1=A2=1)
	   MOV DPTR,#0001H
	   MOVX @DPTR,A       ;Latch the input
	   ACALL HEXTODEC
	   ACALL DECTOASCII
           SJMP HERE
SERIAL:
           MOV TMOD,#20H
	   MOV TH1,#0F6H
	   MOV SCON,#50H
	   SETB TR1
	   RET  	  
HEXTODEC:	              ;hex to decimal convertion
            MOV R0,#40H
	    MOV B,#10
	    DIV AB
	    MOV @R0,B
	    INC R0
	    MOV B,#10
	    DIV AB
	    MOV @R0,B
	    INC R0
	    MOV @R0,A
	    RET                ;decimal to ascii convertion
DECTOASCII:    
            MOV R0,#42H
	    MOV R1,#3
H1:	    MOV A,@R0
	    ORL A,#30H
	    ACALL TX
	    DEC R0
	    DJNZ R1,H1
            RET 

TX:	    CLR TI            ;display the data on serialport
            MOV SBUF,A
L5:	    JNB TI,L5
	    RET
	    END 