ORG 000H

;===================================baudrate==========================================

MOV      SCON,#50H           ; receive enable, 8-BIT, 1 STOP BIT.
MOV      TMOD,#20H           ; timer 1 in 8-bit auto reload.
MOV      TH1,#0FDH           ; baud rate 9600.
SETB     TR1                 ; Start Timer 1
ANL      PCON, #01111111B    ; SMOD = 0
;======================================================================================

MOV      R0,#25
MOV      DPTR,#TABLE

NEXT:
MOV      A,#0
MOVC     A,@A+DPTR
CLR      TI                  ;Clear TI.
MOV      SBUF,A              ;Send the content of ACC to Serial port
JNB      TI,$                ;Pause until the TI bit is set.
INC      DPTR
DJNZ     R0,NEXT

MOV      R2,#25

NEXT1:
JNB      RI,$                ;Wait for 8051 to set the RI flag.
MOV      A,SBUF              ;Read the character from the serial port.
MOV      P2,A                ;Echo the content of ACC to P2
CALL     DELAY
CLR      RI                  ;Set the RI=0 for getting the next byte
DJNZ     R2,NEXT1

;==============================
; DELAY 0.5S
;==============================
DELAY:
MOV     R5,#5
DL2:
MOV     R6,#200
DL1:
MOV     R7,#249
DJNZ    R7,$
DJNZ    R6,DL1
DJNZ    R5,DL2
RET

;==============================
TABLE:  DB 7EH,00H,00H,00H,33H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,1AH,00H,00H,00H,00H,00H,00H,00H,4EH
END 