Program Listing ;******************************************************************************
;       Push Buttons & Path Switcher (with real time clock)
;
;
;       Length: >=74 bytes (depends upon number of buttons & clock type)
;       Author: Craig Webb
;       Written: 98/8/17
;
;
This program implements a software time clock virtual peripheral ; that keeps a 16 bit count of elapsed time in milliseconds. ; The option is available to include seconds, minutes, hours and even ; days to this clock if desired. ; The code takes advantage of the SX's internal RTCC-driven interrupt ; to operate in the background while the main program loop is executing. ;
;******************************************************************************
;
;****** Assembler directives
;
; uses: SX28AC, 2 pages of program memory, 8 banks of RAM, high speed osc.
;       operating in turbo mode, with 8-level stack & extended option reg.
;
DEVICE  pins28,pages2,banks8,oschs
DEVICE  turbo,stackx,optionx
ID      'Buttons'
;program ID label RESET   reset_entry ;set reset/boot address ;
;******************************* Program Variables ***************************
;
;****** Program Parameters
;
clock_type
= 0 ;16 bit msec count only ;clock_type = 1 ;include sec, min, hours ;clock_type = 2 ;include day counter ;
num_buttons
= 2 ;number of buttons (1-4) ;
;****** Program Constants
;
int_period
= 163 ;period between interrupts ;
hold_bit
= 4-(num_buttons/2) ;debounce period = 2^hold_bit msec ;
tick_lo
= 80 ;50000 = msec instruction count tick_hi = 195 ; for 50MHz, turbo, prescaler=1 ;
mspersec_hi
= 1000/256 ;msec per second hi count mspersec_lo = 1000-(mspersec_hi*256)  ;msec per second lo count ;
;****** Port definitions
;
button0
EQU RB.0 ;Push button 0 button1 EQU RB.1 ;Push button 1 button2 EQU RB.2 ;Push button 2 button3 EQU RB.3 ;Push button 3 ;
;****** Register definitions
;
ORG 8 ;start of program registers main            = $ ;main bank ;
temp            DS
1 ;temporary storage temp2 DS 1 ;