;considor following

;I am storing received bytes at RAM address 0x40 onwards pointed by R0
;bit 00h indicates reception is going on

Valid_ID: DB 30h,34h,31h,35h,44h,38h,41h,31h,46h,31h   ;Is this correct???
                                                     ;this is a valid tag ID

RX_ID: ds 10	;ONLY IF I DONT HAVE COMPLETE COMMAND OVER CODE

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

;If I have total command over program I will do something like this
        MOV R0,#40h    ;init counter
;If I dont have total command then I will do something like this
		MOV R0,#RX_ID

        SETB P2.0                ;the LED must be in off state

WAIT_RX:
		JNB RI, WAIT_RX

		MOV A, SBUF
		MOV R2, A
		CLR RI
		CJNE A,#0Dh,READ_NXT
		ACALL COMPARE
		SJMP WAIT_RX

READ_NXT:
		CJNE A, #0Ah, START_RX
		SETB 00h
		SJMP WAIT_RX

START_RX:
		JNB 00h, WAIT_RX
		CJNE R0, #4Ah, NO_SAVE	;or CJNE R0, #RX_ID + 0Ah, NO_SAVE
		MOV @R0, A
NO_SAVE:
		INC R0
		SJMP WAIT_RX

COMPARE:
		CJNE R0, #4Ah,NO_MATCH	;or CJNE R0, #RX_ID + 0Ah, NO_MATCH
									;if total bytes received in not 10 then mismatch
		MOV R2,#00h
		MOV R0,#40h ;or MOV R0,#RX_ID
		MOV DPTR,#Valid_ID

CMP_NXT:
		MOV A,R2
		MOVC A,@A+DPTR
		CJNE A,@R0,NO_MATCH

		INC R0
		INC R2
		CJNE R2,#0Ah,CMP_NXT

		CLR P2.0					;GLOW LED

NO_MATCH:
		CLR 00h
		RET

END
