; Timing (turbo) : [99.9% of time] 14 cycles ; [0.1% of time] 17/39/45 cycles (or less) ; + 1 if bank select needed ;
;
BANK clock ;select clock register bank MOV W,#int_period ;load period between interrupts ADD time_base_lo,W ;add it to time base SNC ;skip ahead if no underflow INC time_base_hi ;yes overflow, adjust high byte MOV W,#tick_hi ;check for 1 msec click MOV W,time_base_hi-W ;Is high byte above or equal? MOV W,#tick_lo ;load instr. count low byte SNZ ;If hi byte equal, skip ahead MOV W,time_base_lo-W ;check low byte vs. time base SC ;skip ahead if low ;commented out because of path_switcher/pushbutton routines which use msec count
;
JMP :done_clock ;If not, end clock routine JMP done_pbs ;If not, end clock routine :got_tick CLR time_base_hi ;Yes, adjust time_base reg.'s SUB time_base_lo,#tick_lo    ; leaving time remainder INCSZ msec_lo ;And adjust msec count DEC msec_hi ; making sure to adjust high INC msec_hi ; byte as necessary IF clock_type>0 ;do we want sec, min, hours? MOV W,#mspersec_hi ;check for 1000 msec (1 sec tick) MOV W,msec_hi-W ;Is high byte above or equal? MOV W,#mspersec_lo ;load #1000 low byte SNZ ;If hi byte equal, skip ahead MOV W,msec_lo-W ;check low byte vs. msec count SC ;skip ahead if low 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
;
;****** Virtual Peripheral: Path Switch
;
; This routine allows alternating execution of multiple modules which don't
; need to be run during every interrupt pass in order to reduce the overall
; execution time of the interrupt on any given pass (i.e. it helps the code
; run faster).
; This version runs with the software clock virtual peripheral msec_lo variable
; allowing altenation between the switch positions once each millisecond.
;