theinterruptroutine.dbg 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ;export symbols
  2. XDEF RTI_ISR
  3. XREF __SEG_END_SSTACK,TON,TOFF,PRESSED,PORT_T,COUNTER
  4. RTI_ISR:
  5. PSHA ;preserve registers
  6. PSHB
  7. PSHX
  8. PSHY
  9. TheInterruptMain:
  10. LDAA COUNTER ;load the counter from the instructions into Acc. A
  11. INCA ;increment A
  12. STAA COUNTER ;now the counter has been incremented
  13. CMPA TON ;compare the (already incremented) counter to TON
  14. BLE SetTAndReturn ;branch if less than or equal to TON
  15. ;continue if the count is greater then TON
  16. CMPA #15 ;check if the count (still in A) is less than or equal to 15
  17. BLE ClearTAndReturn ;branch if Acc. A (the count) is less than or equal to 15
  18. ;continue if the count is greater than 15
  19. BSET COUNTER,#$00 ;clear the count
  20. BRA Return ;exit the interrupt routine
  21. ClearTAndReturn:
  22. BCLR PORT_T,#%00001000 ;clear bit 3 of Port T
  23. BRA Return ;exit the interrupt
  24. SetTAndReturn:
  25. BSET PORT_T,#%00001000 ;set bit 3 of Port T
  26. BRA Return ;exit the interrupt routine
  27. Return:
  28. PULY ;restore the registers
  29. PULX
  30. PULB
  31. PULA
  32. RTI