ISR
ORG 0x004 ;interrupt vector location
movwf w_temp ;save off current W register contents
movf STATUS,w ;move status register into W register
movwf status_temp ;save off contents of STATUS register
CheckUSART
banksel PIR1
btfss PIR1,RCIF ;see if UART caused interrupt
goto CheckTMR1
banksel RCREG
movf RCREG,W ;get the received byte & clear RCIF
movwf BusRx
bsf Events,BusBytePending
goto ISREnd
CheckTMR1
btfss PIR1,TMR1IF
goto ISREnd
bcf PIR1,TMR1IF ;clear the interrupt flag
movf RelockTimer,f ;set Z if zero
btfss STATUS,Z
decf RelockTimer,f
movf BeepTimer,f
btfss STATUS,Z
decf BeepTimer,f
movf BellLockoutTimer,f
btfss STATUS,Z
decf BellLockoutTimer,f
banksel TMR1H
movlw 0x1F ;reload the timer
movwf TMR1H
clrf TMR1L
ISREnd
movf status_temp,w ;retrieve copy of STATUS register
movwf STATUS ;restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ;restore pre-isr W register contents
retfie ;return from interrupt