...;****	Interupt RXTX
RXTX:
	mov	DPTR,#RxTxRunning
	mov	09h,DPH
	mov	08h,DPL
	mov	SP,#09h		;Set new return address
;---
	setb	TR0		;Turn timer0 on...
	setb	RxTxTimerBit	;Start Timer
	mov	RxTxTimer,#0h	;Reset timer

	jbc	RI,Receive	
Transmit:
	clr	TI
	clr	TXRdy
	ajmp	RxTxEnd
Tx18:					;***  Send Display Type  ***
	mov	A,RxTxStepL
	cjne	A,(Tx18End-Tx18Start),Tx18_1
	mov	RxTxStepL,#0h
	mov	RxTxCode,#0h		
	ajmp	RxTxEnd		;All bytes sent
Tx18_1:
	mov	DPTR,#Tx18Start	;Send Data
	mov	A,RxTxStepL

	movc	A,@A+DPTR
	mov	SBUF,A	
	ajmp	RxTxEnd

Tx18Start:
	db	"  Hello from the display. "
Tx18End:	

Receive:
	mov	RxTxData,SBUF	;save the new data

	mov	A,RxTxCode	;Are we busy with receive. 	
	jz	Rx0		;jmp new batch

	cjne	A,#01h,RxTxCd2	;If Code = 01 then we are in memory dump mode
	ajmp	RxTest1		;
RxTxCd2:
	cjne	A,#02h,RxTxCd3	;If Code = 02 then we are writing a single address
	ajmp	RxTest2		;
RxTxCd3:
	cjne	A,#0ffh,RxTest1	;If Code = ff then we are in idle mode waiting
	mov	A,RxTxData	;for null to start incoming sequence.
	jz	RxNew		;
	ajmp	RxTxEnd		;Exit and wait...
	
RxTest1:			;Code 1 receive memory dump
	mov	A,RxTxStep
	jz	Rx1_0		;If step 0 of code 1 then jump and save High Step
	cjne	A,#1h,RxTest1_3
	ajmp	Rx1_1		;If step 1 of code 1 then jump and save Low Step
RxTest1_3:
	cjne	A,#2h,RxTest2
	ajmp	Rx1_2		;If step 2 of code 1 then jump to save data

RxTest2:			;Code 2 receive single address. 00 , 02 , add(h), add(l), data 
	mov	A,RxTxStep
	jz	Rx1_0		;If step 0 of code 1 then jump and save High address
	cjne	A,#1h,RxTest2_3
	ajmp	Rx1_1		;If step 1 of code 1 then jump and save Low address
RxTest2_3:
	cjne	A,#2h,RxTest2
	ajmp	Rx2_2		;If step 2 of code 1 then jump to save data

RxTxEndJmp:
	ajmp	RxTxEnd

RxTest18:
	cjne	A,#18h,RxTxEndJmp	
				;Send Display Type
	mov	RxTxCode,#18h
	mov	RxTxStepL,#0h
	ajmp	Tx18

RxNew:	mov	RxTxCode,#0h	;Set ready for new data coming
	mov	RxTxStep,#0h
	ajmp	RxTxEnd

Rx0:	
	mov	RxTxCode,RxTxData	;Save instruction
	ajmp	RxTxEnd

Rx1_0:
	mov	RxTxStepH,RxTxData	;Save second byte of code 1 as high byte
					;of number of address to receive.
	mov	RxTxStep,#1h		
	ajmp	RxTxEnd

Rx1_1:
	mov	RxTxStepL,RxTxData	;Save third byte of code 1 as low byte
				;of number of address to receive.
	mov	RxTxStep,#2h		
	ajmp	RxTxEnd
	
Rx1_2:
	mov	DPH,RxTxStepHx
	mov	DPL,RxTxStepLx

	mov	A,RxTxData

	clr EA 				;disable Interrupts during write

;	mov	B,WMCON
;	setb	EEMWE		;Enable EEPROM write
;	mov	WMCON,B		;and save
	mov	B,EECON
	setb	EEMWE		;Enable EEPROM write
	mov	EECON,B		;and save

VCCREADY1:
	mov	B, EECON
	jnb	B.0,Vccready1 ;Vcc is not high enough for EEPROM writes, just wait further

	movx	@DPTR,A		;WRITE EEPROM

WRITESTART1:
	mov	B, EECON
	jb	B.1,Writestart1 ; RDY/BSY=low

WAIT1:
	mov	B, EECON
	jnb	B.1,Wait1 ; RDY/BSY=high

;	mov	B,WMCON
;	clr	EEMWE		;Disable EEPROM write
;	mov	WMCON,B		;and save

	mov	B,EECON
	clr	EEMWE		;Disable EEPROM write
	mov	EECON,B		;and save

	setb EA 		;enable Interrupts after write

	inc	DPTR		;inc to next address to write to
	mov	RxTxStepLx,DPL	;and save
	mov	RxTxStepHx,DPH	;

	mov	A,DPL		;test if written to all address's
	cjne	A,RxTxStepL,RxTxEnd	;no jmp
	mov	A,DPH
	cjne	A,RxTxStepH,RxTxEnd	;no jmp
	reti

Rx2_0:	;same as Rx1_0
Rx2_1:	;same as Rx1_1
Rx2_2:
	mov	DPL,RxTxStepL	;Load EEProm address to write.
	mov	DPH,RxTxStepH

	mov	A,RxTxData	;Load new data

	clr EA 				;disable Interrupts during write

;	mov	B,WMCON
;	setb	EEMWE		;Enable EEPROM write
;	mov	WMCON,B		;and save		

	mov	B,EECON
	setb	EEMWE		;Enable EEPROM write
	mov	EECON,B		;and save		

VCCREADY2:
	mov	B, EECON
	jnb	B.0,Vccready2 ;Vcc is not high enough for EEPROM writes, just wait further

	movx	@DPTR,A

WRITESTART2:
	mov	B, EECON
	jb	B.1,Writestart2 ; RDY/BSY=low

WAIT2:
	mov	B, EECON
	jnb	B.1,Wait2 ; RDY/BSY=high

;	mov	B,WMCON
;	clr	EEMWE		;Disable EEPROM write
;	mov	WMCON,B		;and save

	mov	B,EECON
	clr	EEMWE		;Disable EEPROM write
	mov	EECON,B		;and save

	setb EA 		;enable Interrupts after write	
RxTxEnd:	
	reti		;Return from interupt
;*****
;---------------------------------------------
RxTxRunning:
	mov	A,#00000010b	;reset watchdog timer
;	orl	WMCON,A		;and save
	orl	WDTCON,A	;and save

	mov	A,#RxTxTimeOut
	cjne	A,RxTxTimer,RxTxRunning
	ajmp	Inis