
ORG 0000

       jmp Main             

ORG 100H

Main:   clr   P1.0          ; Always start with LED ON

Loop:   mov  DPTR,  #10000  ; Load value for 10 secs.
        call MsecDly
        cpl  P1.0           ; Control LED
        jmp  Loop           ; Keep doing till reset

; MsecDly routine produces a delay of 1 x (value loaded in DPTR ) Milliseconds
; Call after loading DPTR with required delay in Secs x 1000
; Destroys B Register. 

MsecDly: mov   A,DPL        
         orl   A,DPH	    ; DPTR*1000 microsec  approx.
	 jz    Exit
	 setb  C
	 mov   A,DPL
	 subb  A,#0
	 mov   DPL,A
	 mov   A,DPH
	 subb  A,#0
	 mov   DPH,A
	 call  SDly
	 jmp  MsecDly
Exit: 	 ret               ; Delay over. Get back 

SDly:	 mov   B, #0C4H    
         nop
SDlyL:   nop
	 nop
	 nop
	 djnz  B,SDlyL
	 ret
