1475
|
1 ********************************************************************
|
|
2 * SIO - CoCo Serial driver
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Edt/Rev YYYY/MM/DD Modified by
|
|
7 * Comment
|
|
8 * ------------------------------------------------------------------
|
|
9 * 9 ????/??/?? ???
|
|
10 * Original Tandy L2 distribution version.
|
|
11 *
|
|
12 * 10 ????/??/?? ???
|
|
13 * Added baud delay table for NitrOS-9.
|
|
14 *
|
|
15 * 11 2003/12/15 Boisy G. Pitre
|
|
16 * Merged Level 1 and Level 2 sources for now.
|
|
17
|
|
18 nam SIO
|
|
19 ttl CoCo Serial driver
|
|
20
|
|
21 * Disassembled 98/08/23 20:58:36 by Disasm v1.6 (C) 1988 by RML
|
|
22
|
|
23 ifp1
|
|
24 use defsfile
|
|
25 endc
|
|
26
|
|
27 tylg set Drivr+Objct
|
|
28 atrv set ReEnt+rev
|
|
29 rev set $00
|
|
30 edition set 9
|
|
31
|
|
32 mod eom,name,tylg,atrv,start,size
|
|
33
|
|
34 fcb UPDAT.
|
|
35
|
|
36 name fcs /SIO/
|
|
37 fcb edition
|
|
38
|
|
39 IFGT Level-1
|
|
40
|
|
41 u0000 rmb 29
|
|
42 u001D rmb 1
|
|
43 u001E rmb 1
|
|
44 u001F rmb 1
|
|
45 u0020 rmb 2
|
|
46 u0022 rmb 2
|
|
47 u0024 rmb 1
|
|
48 u0025 rmb 1
|
|
49 size equ .
|
|
50
|
|
51 * Baud Rate Delay Table
|
|
52 DelayTbl
|
|
53 IFEQ H6309
|
|
54 * 6809 delay values (1.89MHz)
|
|
55 fdb $090C 110 baud
|
|
56 fdb $034C 300 baud
|
|
57 fdb $01A2 600 baud
|
|
58 fdb $00CE 1200 baud
|
|
59 fdb $0062 2400 baud
|
|
60 fdb $002E 4800 baud
|
|
61 fdb $0012 9600 baud
|
|
62 fdb $0003 32000 baud
|
|
63 ELSE
|
|
64 * 6309 native mode delay values (1.89MHz)
|
|
65 fdb $090C 110 baud (Unchanged, unknown)
|
|
66 fdb $03D0 300 baud
|
|
67 fdb $01A2 600 baud (Unchanged, unknown)
|
|
68 fdb $00F0 1200 baud
|
|
69 fdb $0073 2400 baud
|
|
70 fdb $0036 4800 baud
|
|
71 fdb $0017 9600 baud
|
|
72 fdb $0003 32000 baud (Unchanged, unknown)
|
|
73 ENDC
|
|
74
|
|
75 start lbra Init
|
|
76 lbra Read
|
|
77 lbra Write
|
|
78 lbra GetStat
|
|
79 lbra SetStat
|
|
80 lbra Term
|
|
81
|
|
82 * Init
|
|
83 *
|
|
84 * Entry:
|
|
85 * Y = address of device descriptor
|
|
86 * U = address of device memory area
|
|
87 *
|
|
88 * Exit:
|
|
89 * CC = carry set on error
|
|
90 * B = error code
|
|
91 *
|
|
92 Init pshs cc
|
|
93 orcc #IntMasks
|
|
94 ldx #PIA1Base
|
|
95 clr $01,x
|
|
96 ldd <IT.COL,y get col/row bytes
|
|
97 std <u0024,u
|
|
98 lda #$FE
|
|
99 sta ,x
|
|
100 lda #$36
|
|
101 sta $01,x
|
|
102 lda ,x
|
|
103 ldd <IT.PAR,y get parity/baud
|
|
104 lbsr L0148
|
|
105 puls cc
|
|
106 clrb
|
|
107
|
|
108 * Term
|
|
109 *
|
|
110 * Entry:
|
|
111 * U = address of device memory area
|
|
112 *
|
|
113 * Exit:
|
|
114 * CC = carry set on error
|
|
115 * B = error code
|
|
116 *
|
|
117 Term rts
|
|
118
|
|
119 * Read
|
|
120 *
|
|
121 * Entry:
|
|
122 * Y = address of path descriptor
|
|
123 * U = address of device memory area
|
|
124 *
|
|
125 * Exit:
|
|
126 * A = character read
|
|
127 * CC = carry set on error
|
|
128 * B = error code
|
|
129 *
|
|
130 Read bsr L00AC
|
|
131 bcs L00C8
|
|
132 ldb #$08
|
|
133 pshs b,cc
|
|
134 tst <u001E,u
|
|
135 beq L0066
|
|
136 dec $01,s
|
|
137 L0066 bra L0077
|
|
138 L0068 lda <PD.BAU,y
|
|
139 anda #$0F
|
|
140 cmpa #$07
|
|
141 beq L0077
|
|
142 ldx #$0001
|
|
143 os9 F$Sleep
|
|
144 L0077 pshs y
|
|
145 ldy #$FFFF
|
|
146 L007D lda >PIA1Base+2
|
|
147 leay -$01,y
|
|
148 beq L008B
|
|
149 lsra
|
|
150 bcs L007D
|
|
151 puls y
|
|
152 bra L0090
|
|
153 L008B puls y
|
|
154 lsra
|
|
155 bcs L0068
|
|
156 L0090 orcc #IntMasks
|
|
157 clra
|
|
158 bsr L00D5
|
|
159 L0095 bsr L00CE
|
|
160 ldb >PIA1Base+2
|
|
161 lsrb
|
|
162 rora
|
|
163 dec $01,s
|
|
164 bne L0095
|
|
165 bsr L00D5
|
|
166 tst <u001E,u
|
|
167 beq L00A8
|
|
168 lsra
|
|
169 L00A8 puls b,cc
|
|
170 clrb
|
|
171 rts
|
|
172 L00AC pshs a
|
|
173 lda <PD.BAU,y
|
|
174 anda #$0F
|
|
175 cmpa #$08
|
|
176 bcc L00C4
|
|
177 lsla
|
|
178 leax >DelayTbl,pcr
|
|
179 ldd a,x
|
|
180 std <u0020,u
|
|
181 clrb
|
|
182 puls pc,a
|
|
183 L00C4 ldb #E$BMode
|
|
184 puls a
|
|
185 L00C8 orcc #Carry
|
|
186 rts
|
|
187 L00CB stb >PIA1Base
|
|
188 L00CE pshs b,a
|
|
189 ldd <u0020,u
|
|
190 bra L00DC
|
|
191 L00D5 pshs b,a
|
|
192 ldd <u0020,u
|
|
193 lsra
|
|
194 rorb
|
|
195 L00DC subd #$0001
|
|
196 bne L00DC
|
|
197 puls pc,b,a
|
|
198
|
|
199 * Write
|
|
200 *
|
|
201 * Entry:
|
|
202 * A = character to write
|
|
203 * Y = address of path descriptor
|
|
204 * U = address of device memory area
|
|
205 *
|
|
206 * Exit:
|
|
207 * CC = carry set on error
|
|
208 * B = error code
|
|
209 *
|
|
210 Write bsr L00AC
|
|
211 bcs L00C8
|
|
212 ldb #$09
|
|
213 pshs b,cc
|
|
214 orcc #IntMasks
|
|
215 tst <u001E,u
|
|
216 beq L00F4
|
|
217 dec $01,s
|
|
218 L00F4 andcc #^Carry
|
|
219 L00F6 ldb #$02
|
|
220 bcs L00FB
|
|
221 clrb
|
|
222 L00FB bsr L00CB
|
|
223 lsra
|
|
224 dec $01,s
|
|
225 bne L00F6
|
|
226 ldb <u001D,u
|
|
227 beq L010B
|
|
228 andb #$FE
|
|
229 bsr L00CB
|
|
230 L010B ldb #$02
|
|
231 bsr L00CB
|
|
232 tst <u001F,u
|
|
233 beq L0118
|
|
234 ldb #$02
|
|
235 bsr L00CB
|
|
236 L0118 puls pc,b,cc
|
|
237
|
|
238 * GetStat
|
|
239 *
|
|
240 * Entry:
|
|
241 * A = function code
|
|
242 * Y = address of path descriptor
|
|
243 * U = address of device memory area
|
|
244 *
|
|
245 * Exit:
|
|
246 * CC = carry set on error
|
|
247 * B = error code
|
|
248 *
|
|
249 GetStat cmpa #SS.EOF
|
|
250 bne L0120
|
|
251 L011E clrb
|
|
252 rts
|
|
253 L0120 ldx PD.RGS,y
|
|
254 cmpa #SS.ScSiz
|
|
255 beq L0131
|
|
256 cmpa #SS.ComSt
|
|
257 bne L017E
|
|
258 ldd <u0022,u
|
|
259 std R$Y,x
|
|
260 bra L011E
|
|
261 L0131 ldx PD.RGS,y
|
|
262 clra
|
|
263 ldb <u0024,u
|
|
264 std R$X,x
|
|
265 ldb <u0025,u
|
|
266 std R$Y,x
|
|
267 bra L011E
|
|
268
|
|
269 * SetStat
|
|
270 *
|
|
271 * Entry:
|
|
272 * A = function code
|
|
273 * Y = address of path descriptor
|
|
274 * U = address of device memory area
|
|
275 *
|
|
276 * Exit:
|
|
277 * CC = carry set on error
|
|
278 * B = error code
|
|
279 *
|
|
280 SetStat cmpa #SS.ComSt
|
|
281 bne L017E
|
|
282 ldx PD.RGS,y
|
|
283 ldd R$Y,x
|
|
284 L0148 std <u0022,u
|
|
285 clra
|
|
286 clrb
|
|
287 std <u001D,u
|
|
288 sta <u001F,u
|
|
289 ldd <u0022,u
|
|
290 tstb
|
|
291 bpl L015C
|
|
292 inc <u001F,u
|
|
293 L015C bitb #$40
|
|
294 bne L017A
|
|
295 bitb #$20
|
|
296 beq L0167
|
|
297 inc <u001E,u
|
|
298 L0167 bita #$20
|
|
299 beq L0179
|
|
300 bita #$80
|
|
301 beq L017A
|
|
302 inc <u001D,u
|
|
303 bita #$40
|
|
304 bne L0179
|
|
305 inc <u001D,u
|
|
306 L0179 rts
|
|
307 L017A comb
|
|
308 ldb #E$BMode
|
|
309 rts
|
|
310 L017E comb
|
|
311 ldb #E$UnkSvc
|
|
312 rts
|
|
313
|
|
314 emod
|
|
315 eom equ *
|
|
316 end
|
|
317
|
|
318 ELSE
|
|
319
|
|
320 rmb V.SCF
|
|
321 u001D rmb 1
|
|
322 u001E rmb 1
|
|
323 u001F rmb 1
|
|
324 BaudCnt rmb 2 baud rate counter
|
|
325 u0022 rmb 2
|
|
326 u0024 rmb 1
|
|
327 u0025 rmb 1
|
|
328 size equ .
|
|
329
|
|
330 BaudTbl fdb $0482 110 baud
|
|
331 fdb $01A2 300 baud
|
|
332 fdb $00CD 600 baud
|
|
333 fdb $0063 1200 baud
|
|
334 fdb $002D 2400 baud
|
|
335 fdb $0013 4800 baud
|
|
336 fdb $0005 9600 baud
|
|
337
|
|
338 start lbra Init
|
|
339 lbra Read
|
|
340 lbra Write
|
|
341 lbra GetStat
|
|
342 lbra SetStat
|
|
343 lbra Term
|
|
344
|
|
345 * Init
|
|
346 *
|
|
347 * Entry:
|
|
348 * Y = address of device descriptor
|
|
349 * U = address of device memory area
|
|
350 *
|
|
351 * Exit:
|
|
352 * CC = carry set on error
|
|
353 * B = error code
|
|
354 *
|
|
355 Init pshs cc
|
|
356 orcc #IntMasks
|
|
357 ldx #PIA1Base
|
|
358 clr $01,x
|
|
359 ldd <IT.COL,y get col/row bytes
|
|
360 std <u0024,u
|
|
361 lda #$FE
|
|
362 sta ,x
|
|
363 lda #$36
|
|
364 sta $01,x
|
|
365 lda ,x
|
|
366 ldd <IT.PAR,y get parity/baud
|
|
367 lbsr L014D
|
|
368 puls cc
|
|
369 clrb
|
|
370
|
|
371 * Term
|
|
372 *
|
|
373 * Entry:
|
|
374 * U = address of device memory area
|
|
375 *
|
|
376 * Exit:
|
|
377 * CC = carry set on error
|
|
378 * B = error code
|
|
379 *
|
|
380 Term rts
|
|
381
|
|
382 * Read
|
|
383 *
|
|
384 * Entry:
|
|
385 * Y = address of path descriptor
|
|
386 * U = address of device memory area
|
|
387 *
|
|
388 * Exit:
|
|
389 * A = character read
|
|
390 * CC = carry set on error
|
|
391 * B = error code
|
|
392 *
|
|
393 Read bsr L00B1
|
|
394 bcs L00CD
|
|
395 ldb #$08
|
|
396 pshs b,cc
|
|
397 tst <u001E,u
|
|
398 beq L0066
|
|
399 dec $01,s
|
|
400 L0066 bra L006E
|
|
401 L0068 ldx #$0001
|
|
402 os9 F$Sleep
|
|
403 L006E lda >PIA1Base+2
|
|
404 lsra
|
|
405 pshs x,a
|
|
406 lda >$FF69
|
|
407 bpl L0091
|
|
408 lda >PIA1Base+3
|
|
409 bita #$01
|
|
410 beq L0091
|
|
411 bita #$80
|
|
412 beq L0091
|
|
413 orcc #Entire
|
|
414 leax <L0091,pcr
|
|
415 pshs x
|
|
416 pshs u,y,x,dp,b,a,cc
|
|
417 jmp [D.SvcIRQ]
|
|
418 L0091 puls x,a
|
|
419 bcs L0068
|
|
420 orcc #IntMasks
|
|
421 clra
|
|
422 bsr L00DA
|
|
423 L009A bsr L00D3
|
|
424 ldb >PIA1Base+2
|
|
425 lsrb
|
|
426 rora
|
|
427 dec $01,s
|
|
428 bne L009A
|
|
429 bsr L00DA
|
|
430 tst <u001E,u
|
|
431 beq L00AD
|
|
432 lsra
|
|
433 L00AD puls b,cc
|
|
434 clrb
|
|
435 rts
|
|
436 L00B1 pshs a
|
|
437 lda <PD.BAU,y
|
|
438 anda #$0F mask out baud rate
|
|
439 cmpa #B19200
|
|
440 bcc L00C9
|
|
441 lsla
|
|
442 leax >BaudTbl,pcr
|
|
443 ldd a,x
|
|
444 std <BaudCnt,u
|
|
445 clrb
|
|
446 puls pc,a
|
|
447 L00C9 ldb #E$BMode
|
|
448 puls a
|
|
449 L00CD orcc #Carry
|
|
450 rts
|
|
451 L00D0 stb >PIA1Base
|
|
452 L00D3 pshs b,a
|
|
453 ldd <BaudCnt,u
|
|
454 bra L00E1
|
|
455 L00DA pshs b,a
|
|
456 ldd <BaudCnt,u
|
|
457 lsra
|
|
458 rorb
|
|
459 L00E1 subd #$0001
|
|
460 bne L00E1
|
|
461 puls pc,b,a
|
|
462
|
|
463 * Write
|
|
464 *
|
|
465 * Entry:
|
|
466 * A = character to write
|
|
467 * Y = address of path descriptor
|
|
468 * U = address of device memory area
|
|
469 *
|
|
470 * Exit:
|
|
471 * CC = carry set on error
|
|
472 * B = error code
|
|
473 *
|
|
474 Write bsr L00B1
|
|
475 bcs L00CD
|
|
476 ldb #$09
|
|
477 pshs b,cc
|
|
478 orcc #IntMasks
|
|
479 tst <u001E,u
|
|
480 beq L00F9
|
|
481 dec $01,s
|
|
482 L00F9 andcc #^Carry
|
|
483 L00FB ldb #$02
|
|
484 bcs L0100
|
|
485 clrb
|
|
486 L0100 bsr L00D0
|
|
487 lsra
|
|
488 dec $01,s
|
|
489 bne L00FB
|
|
490 ldb <u001D,u
|
|
491 beq L0110
|
|
492 andb #$FE
|
|
493 bsr L00D0
|
|
494 L0110 ldb #$02
|
|
495 bsr L00D0
|
|
496 tst <u001F,u
|
|
497 beq L011D
|
|
498 ldb #$02
|
|
499 bsr L00D0
|
|
500 L011D puls pc,b,cc
|
|
501
|
|
502 * GetStat
|
|
503 *
|
|
504 * Entry:
|
|
505 * A = function code
|
|
506 * Y = address of path descriptor
|
|
507 * U = address of device memory area
|
|
508 *
|
|
509 * Exit:
|
|
510 * CC = carry set on error
|
|
511 * B = error code
|
|
512 *
|
|
513 GetStat cmpa #SS.EOF
|
|
514 bne L0125
|
|
515 L0123 clrb
|
|
516 rts
|
|
517 L0125 ldx PD.RGS,y
|
|
518 cmpa #SS.ScSiz
|
|
519 beq L0136
|
|
520 cmpa #SS.ComSt
|
|
521 bne L0183
|
|
522 ldd <u0022,u
|
|
523 std R$Y,x
|
|
524 bra L0123
|
|
525 L0136 ldx PD.RGS,y
|
|
526 clra
|
|
527 ldb <u0024,u
|
|
528 std R$X,x
|
|
529 ldb <u0025,u
|
|
530 std R$Y,x
|
|
531 bra L0123
|
|
532
|
|
533 * SetStat
|
|
534 *
|
|
535 * Entry:
|
|
536 * A = function code
|
|
537 * Y = address of path descriptor
|
|
538 * U = address of device memory area
|
|
539 *
|
|
540 * Exit:
|
|
541 * CC = carry set on error
|
|
542 * B = error code
|
|
543 *
|
|
544 SetStat cmpa #SS.ComSt
|
|
545 bne L0183
|
|
546 ldx PD.RGS,y
|
|
547 ldd R$Y,x
|
|
548 L014D std <u0022,u
|
|
549 clra
|
|
550 clrb
|
|
551 std <u001D,u
|
|
552 sta <u001F,u
|
|
553 ldd <u0022,u
|
|
554 tstb
|
|
555 bpl L0161
|
|
556 inc <u001F,u
|
|
557 L0161 bitb #$40
|
|
558 bne L017F
|
|
559 bitb #$20
|
|
560 beq L016C
|
|
561 inc <u001E,u
|
|
562 L016C bita #$20
|
|
563 beq L017E
|
|
564 bita #$80
|
|
565 beq L017F
|
|
566 inc <u001D,u
|
|
567 bita #$40
|
|
568 bne L017E
|
|
569 inc <u001D,u
|
|
570 L017E rts
|
|
571 L017F comb
|
|
572 ldb <E$BMode
|
|
573 rts
|
|
574 L0183 comb
|
|
575 ldb #E$UnkSvc
|
|
576 rts
|
|
577
|
|
578 emod
|
|
579 eom equ *
|
|
580 end
|
|
581
|
|
582 ENDC
|