;----------------------------------------------------------------- ; EX83.ASM Using the TRAP Interrupt. ; ; C.P. Diduch, 2001 ; ; This program uses the single step or trap interrupt to branch ; control to an interrupt handler that writes the return address ; to output port 0x0003. ; ; Author(s): ; Signature(s): Date: ;----------------------------------------------------------------- ; .ORG 0x0000 ; "assign to RAM" .DS 1 ; "interrupt vector 0" .DS 1 ; "interrupt vector 1" ; MAIN PROGRAM ; void main(void) { ; .ORG 0x8000 ; "assign the following to ROM" ; ADDL R0, NULL, 1 ; "initialize interrupt vector" ADDL R1, NULL, SS ; DSTOREM (R0), R1 ; ORL# FL, FL, 0x0020 ; "set TF" ; do { M0: NOP ; NOP ; "each of these instructions NOP ; is interrupted" NOP ; NOP ; JMP M0 ; } ;----------------------------------------------------------------- ; void interrupt SS(void) ; ; Single step or Trap interrupt handler, SS, displays the return ; address at output port 0x0003 with each interrupt. ; SS: ; void interrupt SS(void) { STOREP 0x0003, RAI ; outport(3, RAI) ; CALL DELAY, RA ; "wait long enough to see RETI ; display" ; ;----------------------------------------------------------------- ; void DELAY(void) ; ; Procedure DELAY() implements a software delay via a 'nested' ; decrement of registers R0 and R1. The procedure modifies ; registers R1, R0 and FL. ; DELAY: ; void DELAY(void) { ADDL R1, NULL, 0x800 ; D0: ADDL R0, NULL, 0x040 ; D1: SUBL R0, R0, 1 ; JMPNZ D1 ; SUBL R1, R1, 1 ; JMPNZ D0 ; DJMP (RA) ;