

;I am storing received bytes at RAM address 0x40 onwards pointed by R0
;bit 00h indicates reception is going on
;bit 01h indicates reception of full tag ID
Valid_ID: DB 30h,34h,31h,35h,44h,38h,41h,31h,46h,31h   ;this is a valid tag ID


AJMP START

START:  MOV TMOD,#20h
        MOV SCON,#50h
        MOV TH1,#0F4h          ;UART is configured for desired BAUD
        MOV TL1,#0F4h
        MOV SP,#60h    ;Initialise Stack Pointer 
        SETB TR1                       ;Run T1 for BAUDRATE Generation

        MOV R0,#40h    ;init counter

        SETB P2.0                ;the LED must be in off state

WAIT_RX:
               JNB RI, WAIT_RX

               MOV A, SBUF
               CLR RI
               CJNE A,#0Dh,READ_NXT
               SETB 01h                     
               SJMP CHECK

READ_NXT:
               CJNE A,#0Ah, START_RX
               SETB 00h
               SJMP WAIT_RX

START_RX:
               JNB 00h, WAIT_RX
               MOV @R0,A
               CJNE R0,#4Ah,INC
               
INC:
               INC R0
               SJMP WAIT_RX

CHECK:  JNB 01h,WAIT_RX
        SJMP GLOW_LED

GLOW_LED:       CLR P2.0
                SJMP GLOW_LED
END
