When an interrupt occurs, the event handler would typically perform the following steps: 1) find out what action needs to be taken, 2) perform the needed action, 3) perform whatever interface specific action is necessary to acknowledge the interrupt, and 4) re-enable interrupts with the ENABLE INTR command. The following example shows the typical sequence of statements used for interrupt set up and handling:
10 ON KBD CALL To_modem
20 ON INTR 9 CALL From_modem !Tell BASIC to interrupt
30 ENABLE INTR 9;1 !Tell interface to interrupt
40 LOOP
50 DISP TIME$(TIMEDATE) !Now free to do something
60 END LOOP !while you wait
70 END
80 SUB From_modem
90 WHILE BINAND(STATUS(9,10),1)
100 PRINT CHR$(STATUS(9,6)); !Interface dependent ack.
110 END WHILE
120 ENABLE INTR 9;1 !re-enable the interrupt
130 SUBEND
140 SUB To_modem
150 OUTPUT 9;KBD$;
160 SUBEND
|