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