-
Notifications
You must be signed in to change notification settings - Fork 82
/
ieee
235 lines (235 loc) · 5.23 KB
/
ieee
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
.PAGE 'IEEE 04/29/83'
; COMMAND IEEE-488 DEVICE TO TALK
;
NTALK ORA #TLKR ;MAKE A TALK ADR
BNE LIST1 ;ALWAYS GO TO LIST1
.SKIP 4
; COMMAND IEEE-488 DEVICE TO LISTEN
;
NLISTN ORA #LSTNR ;MAKE A LISTEN ADR
;
LIST1 PHA ;SAVE DEVICE AND TALK/LISTEN
;
LDA #TDDB ;SET CONTROL FOR ATN/DATA OUT
STA TPI1+DDPA
;
LDA #$FF ;SET DIRECTION FOR TRANSMITT *
STA CIA+PRA ;SET DATA *
STA CIA+DDRA ;SET DATA DIRECTION OUT *
LDA #$FF-DC-REN ;ENABLE TRANSMITT
STA TPI1+PA
LDA C3PO ;GET IEEE FLAGS
BPL LIST2 ;IF DATA IN BUFFER
;
LDA TPI1+PA ;SEND EOI
AND #$FF-EOI
STA TPI1+PA
;
LDA BSOUR ;GET BYTE TO SEND
JSR TBYTE ;SEND LAST CHARACTER
;
LDA C3PO ;CLEAR BYTE IN BUFFER FLAG
AND #$FF-DIBF
STA C3PO
;
LDA TPI1+PA ;CLEAR EOI
ORA #EOI
STA TPI1+PA
;
LIST2 LDA TPI1+PA ;ASSERT ATN
AND #$FF-ATN
STA TPI1+PA
;
PLA ;GET TALK/LISTEN ADDRESS
JMP TBYTE
.SKIP 4
; SEND SECONDARY ADDRESS AFTER LISTEN
;
NSECND JSR TBYTE ;SEND IT
;
; RELEASE ATTENTION AFTER LISTEN
;
SCAT1
;
SCATN LDA TPI1+PA ;DE-ASSERT ATN
ORA #ATN
STA TPI1+PA
RTS
.SKIP 4
; TALK SECOND ADDRESS
;
NTKSA JSR TBYTE ;SEND SECONDARY ADDRESS
;
TKATN
LDA #$FF-NRFD-NDAC-TE-REN ;PULL NRFD AND NDAC LOW
AND TPI1+PA
SETLNS ;EXIT ENTRY FOR UNTALK/UNLISTEN
STA TPI1+PA
LDA #RDDB ;SET CONTROL LINES FOR INPUT
STA TPI1+DDPA
LDA #$00 ;SET DATA LINES FOR RECIEVE
STA CIA+DDRA
BEQ SCATN
.SKIP 4
;
; BUFFERED OUTPUT TO IEEE-488
;
NCIOUT PHA ;SAVE DATA
LDA C3PO ;GET IEEE FLAGS
BPL CI1 ;IF NO DATA IN BUFFER
LDA BSOUR ;GET DATA IN BUFFER
JSR TBYTE ;TRANSMIT BYTE
LDA C3PO ;GET IEEE FLAGS
;
CI1 ORA #DIBF ;SET DATA IN BUFFER FLAG
STA C3PO
;
PLA ;GET NEW DATA
STA BSOUR
RTS
.SKIP 4
; SEND UNTALK COMMAND ON IE
;
NUNTLK
LDA #UTLKR ;UNTALK COMMAND
BNE UNLS1 ;ALWAYS
.SKIP 4
; SEND UNLISTEN COMMAND ON IEEE-488
;
NUNLSN LDA #ULSTN ;UNLISTEN COMMAND
UNLS1 JSR LIST1 ;SEND IT
LDA #$FF-TE-REN ;SET FOR RECIEVE ALL LINES HIGH
JMP SETLNS ;GO SETUP PROPER EXIT STATE
;
.SKIP 4
; TBYTE -- OUTPUT BYTE ONTO IEEE BUS.
;
; ENTRY A = DATA BYTE TO BE OUTPUT.
;
; USES A REGISTER.
; 1 BYTE OF STACK SPACE.
;
TBYTE
EOR #$FF ;COMPLIMENT DATA
STA CIA+PRA
;
LDA TPI1+PA
ORA #DAV+TE ;SAY DATA NOT VALID, TE=DATA OUT
STA TPI1+PA
;
BIT TPI1+PA ;TEST NRFD & NDAC IN HIGH STATE
BVC TBY2 ;EITHER NRFD OR NDAC LOW => OK
BPL TBY2
;
TBY1 LDA #NODEV ;SET NO-DEVICE BIT IN STATUS
JSR UDST
BNE TBY7 ;ALWAYS EXIT
;
TBY2 LDA TPI1+PA
BPL TBY2 ;IF NRFD IS HIGH
;
AND #$FF-DAV
STA TPI1+PA
;
TBY3 JSR TIMERO ;SET TIMEOUT
BCC TBY4 ;C-CLEAR MEANS FIRST TIME THROUGH
TBY3T SEC ;C-SET IS SECOND TIME
;
TBY4 BIT TPI1+PA
BVS TBY6 ;IF NDAC HI
LDA CIA+ICR
AND #$02 ;TIMER B POSISTION (CIA)
BEQ TBY4 ;IF NO TIMEOUT
LDA TIMOUT ;TIMEOUT SELECTION FLAG
BMI TBY3 ;NO - LOOP
BCC TBY3T ;WAIT FULL 64US
;
TBY5 LDA #TOOUT ;SET TIMEOUT ON OUTPUT IN STATUS
JSR UDST ;UPDATE STATUS
;
TBY6 LDA TPI1+PA ;RELEASE DAV
ORA #DAV
STA TPI1+PA
;
TBY7 LDA #$FF ;RELEASE DATA BUS
STA CIA+PRA ;BUS FAILURE EXIT
RTS
.SKIP 4
; RBYTE -- INPUT BYTE FROM IEEE BUS.
;
; USES A REGISTER.
; 1 BYTE OF STACK SPACE.
;
; EXIT A = INPUT DATA BYTE.
;
NACPTR ;********************************
NRBYTE
LDA TPI1+PA ;SET CONTROL LINES
AND #$FF-TE-NDAC-REN ;PULL NDAC LOW, TE=DATA IN
ORA #NRFD+DC ;SAY READ FOR DATA
STA TPI1+PA
;
RBY1 JSR TIMERO ;RETURN C-CLEAR FOR CBMII
BCC RBY2 ;C-CLEAR IS FIRST TIME THROUGH
RBY1T SEC ;C-SET IS SECOND TIME THROUGH
;
RBY2 LDA TPI1+PA ;GET IEEE CONTROL LINES
AND #DAV
BEQ RBY4 ;IF DATA AVAILABLE
LDA CIA+ICR
AND #$02 ;TIMER B (CIA)
BEQ RBY2 ;IF NOT TIMED OUT
LDA TIMOUT ;GET TIMEOUT FLAG
BMI RBY1 ;LOOP
BCC RBY1T ;GO THROUGH TWICE
;
RBY3 LDA #TOIN ;SET TIMEOUT ON INPUT IN STATUS
JSR UDST
LDA TPI1+PA
AND #$FF-NRFD-NDAC-TE ;NRFD & NDAC LO ON ERROR
STA TPI1+PA
LDA #CR ;RETURN NULL INPUT
RTS
.SKIP 2
RBY4
LDA TPI1+PA ;SAY NOT READ FOR DATA
AND #$FF-NRFD
STA TPI1+PA
AND #EOI
BNE RBY5 ;IF NOT EOI
LDA #EOIST ;SET EOI IN STATUS
JSR UDST
;
RBY5 LDA CIA+PRA ;GET DATA
EOR #$FF
;
RBY6 PHA ;SAVE DATA
LDA TPI1+PA ;SAY DATA ACCEPTED
ORA #NDAC
STA TPI1+PA
;
RBY7 LDA TPI1+PA ;GET IEEE CONTROL LINES
AND #DAV
BEQ RBY7 ;IF DAV HIGH
;
LDA TPI1+PA ;SAY DAT NOT ACCPTED
AND #$FF-NDAC
STA TPI1+PA
PLA ;RETURN DATA IN A
RTS
;
; SET UP FOR TIMEOUT (6526)
;
.IFE SYSTEM <
TIMERO LDA #$FF ;SET TIMER FOR AT LEAST 32US
>
.IFN SYSTEM <
TIMERO LDA #$80 ;SET TIME FOR AT LEAST 32US
>
STA CIA+TBHI
LDA #$11 ;TURN ON TIMER CONTINOUS IN CASE OF OTHER IRQ'S
STA CIA+CRB
LDA CIA+ICR ;CLEAR INTERRUPT
CLC
RTS
.END