;export symbols XDEF RTI_ISR XREF __SEG_END_SSTACK,TON,TOFF,PRESSED,PORT_T,COUNTER RTI_ISR: PSHA ;preserve registers PSHB PSHX PSHY TheInterruptMain: LDAA COUNTER ;load the counter from the instructions into Acc. A INCA ;increment A STAA COUNTER ;now the counter has been incremented CMPA TON ;compare the (already incremented) counter to TON BLE SetTAndReturn ;branch if less than or equal to TON ;continue if the count is greater then TON CMPA #15 ;check if the count (still in A) is less than or equal to 15 BLE ClearTAndReturn ;branch if Acc. A (the count) is less than or equal to 15 ;continue if the count is greater than 15 BSET COUNTER,#$00 ;clear the count BRA Return ;exit the interrupt routine ClearTAndReturn: BCLR PORT_T,#%00001000 ;clear bit 3 of Port T BRA Return ;exit the interrupt SetTAndReturn: BSET PORT_T,#%00001000 ;set bit 3 of Port T BRA Return ;exit the interrupt routine Return: PULY ;restore the registers PULX PULB PULA RTI