JMP :done_clock ;If not, end clock routine INC seconds ;increment seconds count CLR msec_lo ;clear msec counters CLR msec_hi ; MOV W,#60 ;60 seconds per minute MOV W,seconds-W ;are we at minute tick yet JNZ :done_clock ;if not, jump INC minutes ;increment minutes count CLR seconds ;clear seconds count MOV W,#60 ;60 minutes/hour MOV W,minutes-W ;are we at hour tick yet? JNZ :done_clock ;if not, jump INC hours ;increment hours count CLR minutes ;clear minutes count ENDIF ;<if> we wanted sec, min, hours IF clock_type>1 ;do we want to count days? MOV W,#24 ;24 hours per day MOV W,hours-W ;are we at midnight? JNZ :done_clock ;if not, jump INC days ;increment days count CLR hours ;clear hours count ENDIF ;<if> we wanted day count :done_clock
;
done_int
mov     w,#-int_period      ;interrupt every 'int_period' clocks retiw                       ;exit interrupt ;
;****** End of interrupt sequence
;
;************************** RESET ENTRY POINT *****************************
;
reset_entry
;
PAGE start ;Set page bits and then ; JMP start ; jump to start of code ;
;*********************
;* Main Program Code *
;*********************
;
start
;
mov     !rb,#%00001111          ;Set RB in/out directions CLR     FSR                     ;reset all ram starting at 08h :zero_ram SB      FSR.4                                                                                     ;are we on low half of bank?
SETB    FSR.3                   ;If so, don't touch regs 0-7
CLR     IND                     ;clear using indirect addressing
IJNZ    FSR,:zero_ram           ;repeat until done
MOV     !OPTION,#%10011111      ;enable rtcc interrupt ;
; Main loop
;
:loop
;
BANK    Clock ;set clock bank ;
;
<main program code goes here> ; JMP     :loop ;back to main loop ;
;***************
END                             ;End of program code