list p=16f628a
#include <p16f628a.inc>
__config _CP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_OFF &_INTRC_OSC_NOCLKOUT & _MCLRE_ON & _LVP_OFF
ERRORLEVEL -302
;add these two lines of text
Variable Sim1
Sim1 SET .1 ;if '1' its running in the Simulator, else '0'
;
cblock 20h ;establish variables
x,y,z
endc
;Your Source here...........
;test only
lp1: call Delay
goto lp1
;Running a program with long delays in the Simulator can be 'slow'
;by adding a Variable say, Sim1 and setting it to either '0' or '1' and then
;testing that Variable during assembly will direct the assembler to
;generate code that gives a shortened delay for Simulation
;or the required delay for a PIC.
;
;
Delay:
if Sim1 == 0x01 ;assembler conditional assembly
movlw .1 ;this is for the Sim, just 1 loop
else
movlw 03h ;set value of counter2
endif
movwf y ;assign to varible y
Loop2:
if Sim1 == 0x01
movlw .1 ;this is for the Sim, just 1 loop
else
movlw 10h ;set value of counter
endif
movwf x ;assign to varible x
Loop1
decfsz x,1 ;This second loop keeps the LED
goto Loop1 ;on for a moment
decfsz y,1
goto Loop2
return
end