Código:
LIST P=16F84A
INCLUDE <P16F84A.INC>
CBLOCK 0x0C ; In this position starts user´s RAM.
ENDC
#DEFINE LED PORTB,0
;**********************************************************************************************
ORG 0x00
INICIO
bsf STATUS,RP0 ; Access to bank 1
bcf LED ; LED line configurated like OUTPUT
bcf STATUS,RP0 ; Access to Bank 0.
PRINCIPAL
bsf LED ; Turn on the LED
call Retardo_200ms ; while the sum of this time
call Retardo_200ms
bcf LED ; It turns off while the sum of the next retardos
call Retardo_200ms
call Retardo_100ms
goto PRINCIPAL
; Subrutinas "Retardo_200ms" y "Retardo_100ms"-------------------------------------------
CBLOCK
R_ContA ; Counters for the retardos
R_ContB
ENDC
Retardo_200ms ; The named "call" aports 2 machine cycles.
movlw d'200' ; It Aports 1 machine cycle. This is the value of "M".
goto Retardos_ms ; It aports 2 machine cycles.
Retardo_100ms ; The named "call" aports 2 machine cycles.
movlw d'100' ; It aports 1 machine cycle.This is the value of "M".
goto Retardos_ms ; It aport 2 machine cycles.
Retardo_1ms ; The named "call" aports 2 machine cycles.
movlw d'1' ; It aports 1 machine cycle. This is the value of "M".
Retardos_ms
movwf R_ContB ; It aports 1 machine cycle.
R1ms_BucleExterno
movlw d'249' ; It aports Mx1 machine cycles. This is the value of "K".
movwf R_ContA ; It aports Mx1 machine cycles.
R1ms_BucleInterno
nop ; It aports KxMx1 machine cycles.
decfsz R_ContA,F ; (K-1)xMx1 cm (when it doesn´t jump) + Mx2 cm (when it jumps).
goto R1ms_BucleInterno ; It aports (K-1)xMx2 machine cycles.
decfsz R_ContB,F ; (M-1)x1 cm (when it doesn´t jump) + 2 cm (when it jumps).
goto R1ms_BucleExterno ; It aports (M-1)x2 machine cycles.
return ; The return Jump aports 2 machine cycles.
END