
                       org    2010h

	FIRMWARE_BIT equ 010h   ;flag for checking whether the program is 
			      ; exceuting for the forst time or not	
			      ; 0 for first time executing 
	
	mov	r4, #080h	; LSB of 3200h
	mov	r5, #0c0h	; MSB of 3200h

	acall	FLASH_SUBROUTINE

		org  3200h
	sjmp	START

FLASH_SUBROUTINE:
	push	ie
	clr	ea
	mov	a, cmod	; for checking of watch dog
	mov	r2, a
	jnb	acc.6, CLEARED_WATCHDOG
	anl	cmod, #0bfh

CLEARED_WATCHDOG:
	anl	fcf, #0fch ; enable boot sector
	jb	FIRMWARE_BIT, READ_FWARE ; if initially program has runned then user 
					  ; has changed the firmware passoword.
	mov	r1, #02h	; for writing  flash
	sjmp	AHEAD

READ_FWARE:
	mov	r1, #03h ; reading flash byte

AHEAD:
	mov	dpl, #r4
	mov	dph, #r5

	<b>;Question now is ... with the use of above statement
	; is my subroutine ie. START will be called and the control
	; is transfered to START or what is else is happening here
	</b>
	
	mov	a, r7
	
	<b>; here is my question is ... if I have to write more numbers
	     ; take for eg ... 1, 2, 3, 4 then how can I be writing using 
	     ; one single register. if I can use more registers then in a single
	     ; accumulator register how can i acomodate it.
	     ; will I have to call the IAP for four times, unlike I have 
	     ' called once below		
	
	</b>

	call	01ff0h
	mov	cmod, r2
	orl	fcf, #001h
	pop	ie
	ret

;************************************************

START:
	jb   FIRMWARE_BIT, AHEAD

	routines for lcd and matrix keyboard	
