-
Notifications
You must be signed in to change notification settings - Fork 82
/
irq
164 lines (164 loc) · 3.96 KB
/
irq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
.PAG 'INTERRUPT HANDLER'
;**********************************************
;* NIRQ - HANDLER FOR: 10/30/81 RSR *
;* 6525 IRQ'S:::::::::::::::::::::::::::::::::*
;* 6551 IRQ'S *
;* (RECEIVER,TRANSMITTER,DCD & DSR CHANGES) *
;* 6526 IRQ'S *
;* (ALARM, TIMERA, TIMERB) *
;* 6526 IRQ'S *
;* (2ND PROCESSOR) *
;* IEEE SRQ *
;* KEYBOARD SCAN (50/60HZ IRQ) *
;* *
;* ALSO AT PRESENT DOES NOT HANDLE ANY OF THE *
;* 6566 (VIC) INTERRUPTS. *
;* *
;**********************************************
NIRQ PHA ;SAVE REGISTERS
TXA
PHA
TYA
PHA
TSX ;CHECK FOR BRK...
LDA $104,X
AND #$10
BNE BRKIRQ ;YES...
PULS JMP (CINV)
BRKIRQ JMP (CBINV) ;YES...
;
YIRQ LDA I6509 ;SAVE INDIRECT SEGMENT #
PHA
; LDA PASS ;EXTERNAL BREAK HANDLER
; PHA
; LDA #0 ;CLEAR FOR NORMAL RETURN
; STA PASS
.SKI 2
CLD ;CLEAR DEC TO PREVENT FUTURE PROBLEMS
LDA TPI1+AIR
BNE IRQ000 ;HANDLE PRIORITY IRQ'S
;
; EXTERNAL IRQ (VIC AND OTHERS)
; (NO CODE!!!!!!!!!!)
;
JMP PRENDN
.SKI4
IRQ000 CMP #$10 ;FIND IRQ SOURCE
BEQ IRQ002 ;NOT 6551...
JMP IRQ100
;
; 6551 INTERRUPT HANDLER
;
IRQ002 LDA ACIA+SRSN ;FIND IRQ SOURCE
TAX
AND #$60 ;DCD/DSR CHANGES ??
TAY
EOR DCDSR
BEQ IRQ004 ;NO CHANGE...
TYA
STA DCDSR ;UPDATE OLD DSR/DCD STATUS
ORA RSSTAT ;UPDATE RS232 STATUS
STA RSSTAT
JMP IRQ900 ;DONE!
;
IRQ004 TXA
AND #$08 ;RECEIVER ??
BEQ IRQ010 ;NO...
;
; RECEIVER SERVICE
;
LDY RIDBE ;CHECK BUFFERS
INY
CPY RIDBS ;HAVE WE PASSED START?
BNE IRQ005 ;NO...
;
LDA #DOVERR ;INPUT BUFFER FULL ERROR
BNE IRQ007 ;BRA...SET STATUS
;
IRQ005 STY RIDBE ;MOVE END FOWARD
DEY
LDX RIBUF+2
STX I6509
LDA ACIA+DRSN
STA (RIBUF)Y ;DATA TO BUFFER
LDA ACIA+SRSN ;SET STATUS REGISTER
AND #$07
IRQ007 ORA RSSTAT ;SET STATUS
STA RSSTAT
.SKI 2
IRQ010 LDA ACIA+SRSN ;FIND IRQ SOURCE
AND #$10 ;TRANSMITTER ?
BEQ IRQ090 ;NO...
LDA ACIA+CDR ;CHECK FOR TRANSMITTER ON
AND #$0C
CMP #$04 ;BITS(32)=01 => XMITTER INT ENABLED
BNE IRQ090 ;OFF...
;
; TRANSMITTER SERVICE (NO INTERRRUPT DRIVEN TRANSMISSIONS)
;
LDA #%11110011 ;TURN OF TRANSMITTER
AND ACIA+CDR
STA ACIA+CDR
IRQ090 JMP IRQ900 ;EXIT..POP PRIORITY...
.SKI 3
IRQ100
CMP #$08 ;CHECK IF INTER-PROCESS IRQ
BNE IRQ110 ;NO...
LDA IPCIA+ICR ;CLEAR IRQ CONDITION
CLI ;THIS IRQ CAN BE INTERRUPTED
JSR IPSERV ;DO THE REQUEST
JMP IRQ900 ;DONE!
.SKI
IRQ110 CLI ;ALL OTHER IRQ'S MAY BE INTERRUPTED, TOO
CMP #$04 ;CHECK IF 6526
BNE IRQ200 ;NO...
;
; 6526 INTERRUPT RECONIZED
;
LDA CIA+ICR ;GET ACTIVE INTERRUPTS
ORA ALARM ;IN CASE WE LOSE SOMETHING
STA ALARM
;
; NOTHING TO DO AT PRESENT....NEED CODE ********
;
JMP IRQ900 ;...DUMP INTERRUPT
.SKI 3
IRQ200 CMP #$02 ;CHECK FOR IEEE SRQ
BNE IRQ300
;
; NEED CODE ************
;
JMP IRQ900 ;...DUMP INTERRUPT
.SKI 3
IRQ300 JSR KEY ;SCAN THE KEYBOARD
LDA TPI2+PC ;SET STOPKEY FLAG
STA STKEY ;IF KEY DOWN
;
; TEST FOR CASSETTE SWITCH
;
LDA TPI1+PB ;GET CASS SWITCH
BPL IRQ310 ;SWITCH IS DOWN...
LDY #0 ;FLAG MOTOR OFF...
STY CAS1
ORA #$40 ;TURN MOTOR OFF...
BNE IRQ320 ;JUMP
IRQ310 LDY CAS1 ;TEST FOR FLAG ON...
BNE IRQ900 ;YES COMPUTER CONTROL..LEAVE ALONE
AND #$FF-$40 ;TURN MOTOR ON...
IRQ320 STA TPI1+PB ;STORE MODS INTO PORT
.SKI 3
IRQ900 STA TPI1+AIR ;POP THE INTERRUPT...
PRENDN ;LDA PASS ;CHECK FOR FORIEGN CALL
; BNE SEGRTI ;YES...RETURN
; PLA
; STA PASS ;RESTORE INTERRUPTED INTERRUPT
PLA ;RESTORE REGISTERS
STA I6509
PREND PLA ;ENTRY POINT FOR REGISTER ONLY
TAY
PLA
TAX
PLA
RTI
;
.END