 sttl Interrupt Processing
 pag

*
* This routine handles all IRQ interrupts
*
IRQ_han
 ldu #TTY_ports scan terminal ports
 clrb start with terminal 0
10 ldy 0,u get device address
 lda status,y did this guy cause the interrupt?
 bpl 15f no - jump
 jsr tintr process interrupt
 bra 99f exit
15 incb next terminal
 leau 4,u next port
 cmpb #NUM_TTY any more terminals?
 bne 10b
* Check for FIO Mailbox interrupt
 lda #ist_reg0 see if mailbox interrupt
 jsr fio_get
 bitb #FIO_MIP Message interrupt pending?
 beq 99f no - exit
 ldx int_ptr input message pointer
 jsr fio_rcv get input byte
 stb ,x+ place in buffer
 stx int_ptr update pointer
 cmpx #int_ptr end of message?
 beq 20f yes -  go process it
 rti no - wait for more
20 ldy #int_buf get message from buffer
 lda 0,y -- Send interrupt command?
 anda #$F0
 cmpa #O_INTRPT
 bne 25f
 sty int_ptr reset pointer
 ldb 0,y get terminal #
 andb #$0F
 jsr send_int
 bra 99f exit
25 ldx #tsktab search for an available task
 ldb #MAX_TSK Number of tasks in system
30 lda tsstat,x
 cmpa #TFREE looking for a "free" task
 beq 40f
 leax TSKSIZ,x
 decb
 bne 30b
 pshs d,x
 ldx #00f
 jsr DB_pdata
 jsr DB_main
 puls d,x
 ldb #E_SYSBSY can't process - IOP saturated!
 jsr fio_send
 bra 99f exit
40 ldy #int_buf get message from buffer
 sty int_ptr reset pointer
 ldb ,y+ command byte
 stb tscmd,x save for task
 lda ,y+ sequence #
 sta tsseq,x
 ldb ,y+ command specific data
 stb tstval,x
 lda tscmd,x associate with terminal
 anda #$03
 sta tsdev,x
 jsr makrdy make task ready to run
99 rti return from interrupt
*
00 fcc '-- No tasks!',0
