]> git.sur5r.net Git - cc65/blob - libsrc/cbm610/kirq.s
TGI Implementation
[cc65] / libsrc / cbm610 / kirq.s
1 ;
2 ; Ullrich von Bassewitz, 28.09.1998
3 ;
4 ; IRQ routine for the 610.
5 ;
6
7         .export         irq, nmi, k_irq, k_nmi
8         .import         k_scnkey, k_udtim, k_rs232
9         .importzp       tpi1
10
11         .include        "cbm610.inc"
12
13
14 ; -------------------------------------------------------------------------
15 ; This is the mapping of the active irq register of the 6525 (tpi1):
16 ;
17 ; Bit   7       6       5       4       3       2       1       0
18 ;                               |       |       |       |       ^ 50 Hz
19 ;                               |       |       |       ^ SRQ IEEE 488
20 ;                               |       |       ^ cia
21 ;                               |       ^ IRQB ext. Port
22 ;                               ^ acia
23
24
25
26 ; -------------------------------------------------------------------------
27 ; IRQ entry point
28
29 .proc   irq
30
31         pha
32         txa
33         pha
34         tya
35         pha
36         tsx
37         lda     $104,x                  ; Get the flags from the stack
38         and     #$10                    ; Test break flag
39         bne     L1
40         jmp     (IRQVec)
41 L1:     jmp     (BRKVec)
42
43 .endproc
44
45 ; -------------------------------------------------------------------------
46 ; NMI entry point
47
48 .proc   nmi
49
50         jmp     (NMIVec)
51
52 .endproc
53
54
55 ; -------------------------------------------------------------------------
56 ; Kernal irq entry point. The IRQvec points here (usually).
57
58 k_irq:
59         lda     IndReg                  ; Ind. Segment retten
60         pha
61         cld
62         lda     #$0F
63         sta     IndReg
64         ldy     #tpiActIntReg
65         lda     (tpi1),y                ; Interrupt Register 6525
66         beq     noirq
67
68 ; -------------------------------------------------------------------------
69 ; 50/60Hz interrupt
70
71         cmp     #%00000001              ; ticker irq?
72         bne     irq1
73         jsr     k_scnkey                ; Poll the keyboard
74         jsr     k_udtim                 ; Bump the time
75
76 ; -------------------------------------------------------------------------
77 ; UART interrupt
78
79 irq1:   cmp     #%00010000              ; interrupt from uart?
80         bne     irqend
81         jsr     k_rs232                 ; Read character from uart
82
83 ; -------------------------------------------------------------------------
84 ; Done
85
86 irqend: ldy     #tpiActIntReg
87         sta     (tpi1),y                ; Clear interrupt
88
89 noirq:  pla
90         sta     IndReg
91         pla
92         tay
93         pla
94         tax
95         pla
96 k_nmi:  rti
97
98