Well, here goes... I'm stumped. Apologies if I'm missing something really obvious.
Code:
;Based on original 'Tutorial 2.1' by Nigel Goodwin
LIST p=16F628 ;tell assembler what chip we are using
include "P16F628.inc" ;include the defaults for the chip
__config 0x3D18 ;sets the configuration settings (oscillator type etc.)
LEDPORT Equ PORTA ;set constant LEDPORT = 'PORTA'
SWPORT Equ PORTA ;set constant SWPORT = 'PORTA'
LEDTRIS Equ TRISA ;set constant for TRIS register
SW1 Equ 7 ;set constants for the switches
SW2 Equ 6
SW3 Equ 5
SW4 Equ 4
LED1 Equ 3 ;and for the LED's
LED2 Equ 2
LED3 Equ 1
LED4 Equ 0
;// START - DEFs from the delay generator
cblock
d1
d2
d3
endc
;// END - DEFs from the delay generator
;end of defines
org 0x0000 ; org sets the origin, 0x0000 for the 16F628,
; this is where the program starts running
movlw 0x07
movwf CMCON ; turn comparators off (make it like a 16F84)
bsf STATUS, RP0 ; select bank 1
movlw b'11110000' ; set PortA 4 inputs, 4 outputs
movwf LEDTRIS
bcf STATUS, RP0 ; select bank 0
clrf LEDPORT ; set all outputs low
MainLoop
btfss SWPORT, SW1 ; Loop until reset / power on is triggered
goto PowerOnTimer ;If pushed, jump into the power on timer
goto MainLoop ; Loop back to the top of the main loop
ResetDelay
;4999993 cycles
movlw 0x2C
movwf d1
movlw 0xE7
movwf d2
movlw 0x0B
movwf d3
retlw 0x00
PowerOnTimer
goto ResetDelay ; Reset the delay values back to 5 seconds
clrf LEDPORT ; turn all LED's off
bsf SWPORT, LED1 ; turn LED1 on
goto Delay_0 ; Jump into the delay loop
clrf LEDPORT ; turn all LED's back off
retlw 0x00
Delay_0
btfss SWPORT, SW1 ; Check for button push, and reset if necessary
call ResetDelay ; This line gets skipped over if the switch isn't pushed
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;3 cycles
goto $+1
nop
;4 cycles (including call)
return
end