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