Subversion Repositories MB01 Project

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 - 1
  Tue Jul 17 11:00:18 2018                                                                                               Page    1
2
 
3
 
4
 
5
 
6
 
7
 
8
 
9
          2500 A.D. 65816 Macro Assembler #26960 - Version 5.02g
10
          -----------------------------------------------------
11
 
12
                       Input  Filename : src\F8\sp.asm
13
                       Output Filename : obj\F8\sp.obj
14
                       Listing Has Been Relocated
15
 
16
 
17
 2605                        	.LIST		on
18
 2606
19
 2607  F8FFB1                		.INCLUDE INC\DIRP00.INC
20
 2608                        	;----------------------------------------------------------
21
 2609                        	; DIRP00.ASM
22
 2610                        	; PROGETTO: B1601
23
 2611                        	;
24
 2612                        	; Variabili in Direct Page $00
25
 2613                        	;----------------------------------------------------------
26
 2614
27
 2615                        	; sezione COMMON -- questo permette di includere il file in piu' file
28
 2616
29
 2617                        	.LIST on
30
 2618
31
 2619                        	DIRP00:	.SECTION page0, ref_only, common	;Direct-Page 00
32
 2620
33
 2621  000000                		.ABSOLUTE		;; inizia sempre da $00
34
 2622  000000                		.ORG		0x00
35
 2623  000000
36
 2624  000000  0000          	JiffyClk	.DW			; contatore 10ms 32 bit
37
 2625  000002  0000          			.DW
38
 2626  000004                	SysTmr		.DS	SYSTMRCNT	; system timer 0 (10ms)
39
 2627  000008                	SysTMF		.DS	SYSTMRCNT	; flag timer (80 -> start)
40
 2628  00000C  00            	Bnk0Flag	.DB			; <7>: flag test RAM banco 0 ok
41
 2629                        						; <6>: flag warm reset
42
 2630  00000D  00            	RTCFlag		.DB
43
 2631
44
 2632  00000E                	diskstat	.DS	2	; flag device on ata bus #0 & #1
45
 2633                        					; <7>: device ready
46
 2634                        					; <6>: compact flash device (C.F.)
47
 2635                        					; <5>: device identification ok
48
 2636                        					; <4>: MBR loaded
49
 2637                        					; <3>: valid signature in MBR
50
 2638                        					; <2>: first partition found&active
51
 2639                        					; <1>:
52
 2640                        					; <0>: valid partition flag
53
 2641
54
 2642                        					; <7>: device ready
55
 2643                        					; <6>: USB device
56
 2644                        					; <5>: compact flash device (C.F.)
57
 2645                        					; <4>: device identification ok
58
 2646                        					; <3>: MBR loaded
59
 2647                        					; <2>: first partition found&active
60
 2648                        					; <1>: always 1
61
 2649                        					; <0>: valid partition flag
62
 2650  000010
63
  Tue Jul 17 11:00:18 2018                                                                                               Page    2
64
 
65
 
66
 
67
 
68
 2651
69
 2652          00000E        	atadev		.EQU	diskstat
70
 2653
71
 2654  000010                	usbdev		.DS	2	; flag flash disk on usb bus #0
72
 2655                        					; <7>: device plugged and ready
73
 2656                        					; <6>: always 1
74
 2657                        					; <5>: device identification ok
75
 2658                        					; <4>: MBR loaded
76
 2659                        					; <3>: valid signature in MBR
77
 2660                        					; <2>: first partition found&active
78
 2661                        					; <1>:
79
 2662                        					; <0>: valid partition flag
80
 2663
81
 2664  000012                	diskmax		.DS	16	; disk max. sector's
82
 2665          000012        	atasec		.EQU	diskmax
83
 2666          00001A        	usbsec		.EQU	diskmax+8
84
 2667
85
 2668
86
 2669  000022                	atambr		.DS	8	; data for first partition found in mbr
87
 2670                        					; first 3 bytes for start sector of partition
88
 2671                        					; last byte for partition type
89
 2672  00002A                	usbmbr		.DS	8
90
 2673
91
 2674  000032                	ataprt		.DS	8	; total sec's of first partition
92
 2675  00003A                	usbprt		.DS	8	; total sec's of first partition
93
 2676
94
 2677
95
 2678  000042  00            	usb0ch		.DB	; usb0 (ch375/ch376) flag
96
 2679                        				; <7>: module on
97
 2680                        				; <6>: ch376 flag
98
 2681                        				; <5:0>: chip version
99
 2682
100
 2683  000043  00            	usb0st		.DB	; usb0 status
101
 2684                        				; <7>: usb0 host mode ok
102
 2685                        				; <6>: flash disk attached flag
103
 2686                        				; <5>: usb device attached
104
 2687
105
 2688  000044  00            	fdcdrv		.DB		; phisycal drive status (drive #0)
106
 2689                        					; <7>: disk format established in bit 0&1
107
 2690                        					; <6>: double step seek done
108
 2691                        					; <5>: trust format bit's (set after ok r/w)
109
 2692                        					; <4>: write protect bit (if disk in drive)
110
 2693                        					; <3>: don't care
111
 2694                        					; <2>: don't care
112
 2695                        					; <1>: HD disk if set else DD disk
113
 2696                        					; <0>: CBM format if set else IBM format
114
 2697
115
 2698  000045  00            	vdrive		.DB		; virtual drive status (ram disk, drive #1)
116
 2699                        					; <7>: disk format established in bit 0&1
117
 2700                        					; <6>: change disk simulation (after format)
118
 2701                        					; <5>: don't care
119
 2702                        					; <4>: write protect bit (under sw control)
120
 2703                        					; <3>: don't care
121
 2704                        					; <2>: don't care
122
 2705                        					; <1>: HD disk if set else DD disk
123
 2706                        					; <0>: CBM format if set else IBM format
124
 2707
125
  Tue Jul 17 11:00:18 2018                                                                                               Page    3
126
 
127
 
128
 
129
 
130
 2708  000046  00            	fdcctl		.DB		; fdc controller status
131
 2709                        					; <7>: drive is attached
132
 2710                        					; <6>: drive need recalibration (restore)
133
 2711                        					; <5>: FDC controller ok
134
 2712                        					; <4>: motor on
135
 2713                        					; <3>: dma is active
136
 2714                        					; <2>: dma chip ok (post routine)
137
 2715                        					; <1>: clock rate (1=HD,0=DD)
138
 2716                        					; <0>: disk ready
139
 2717
140
 2718  000047  00            	fdctrk		.DB		; fd: current seek track
141
 2719  000048  00            	fdcerr		.DB		; fd: last error code
142
 2720  000049  00            	ataerr		.DB		; ata: last error code
143
 2721  00004A  00            	ataxer		.DB		; ata: last extended error code
144
 2722
145
 2723  00004B  00            	CtrlBrk		.DB		; flag CTRL+BREAK (NMI)
146
 2724
147
 2725  00004C  0000          	MemTop		.DW		; top memoria RAM
148
 2726  00004E  00            			.DB		; banco top mem
149
 2727
150
 2728  00004F  00            	DflTxtIn	.DB		; device di default text input
151
 2729  000050  00            	DflTxtOut	.DB		; device di default text output
152
 2730
153
 2731  000051                	COPPtr		LP		; long pointer for COP decoding
154
 2732  000054  00            	COPIdx		.DB		; COP signature/index
155
 2733
156
 2734  000055  00            	BiosEnt		.DB		; flag accesso a bios setup
157
 2735
158
 2736                        	; variabili utilizzate da ACIA
159
 2737  000056                	spwrk		.DS	$30
160
 2738
161
 2739                        	; bios mem
162
 2740  000086  0000          	nsize		.DW	; dimensione blocco da allocare
163
 2741                        	;bsize		.DW	; dimensione vera blocco free
164
 2742  000088  0000          	splitsz		.DW	; dimensione blocco splittato
165
 2743  00008A  0000          	bfree		.DW	; puntatore blocco free
166
 2744  00008C  0000          	hdrptr		.DW	; puntatore header heap
167
 2745
168
 2746  00008E  0000          	pbrklv		.DW	; current break level of current process
169
 2747  000090  0000          	pbrkmin		.DW	; minimum breal level of current process
170
 2748  000092  0000          	pbrkmax		.DW	; maximum breal level of current process
171
 2749  000094
172
 2750                        	; bios temp. work area
173
 2751  000094                	bwrktmp		.DS	$28
174
 2752
175
 2753  0000BC  00            	coptmp		.DB	; temp. used while cop
176
 2754
177
 2755  0000BD  00            	tstser		.DB	; check ser/usb test board post
178
 2756                        				; <7>: VIA2 ok
179
 2757                        				; <6>: PICRAM ok
180
 2758                        				; <1>: UART 16C550 ok
181
 2759                        				; <0>: R65C51 ok
182
 2760
183
 2761
184
 2762                        	;crc16		.DW
185
 2763
186
 2764  0000BD                		.RELATIVE
187
  Tue Jul 17 11:00:18 2018                                                                                               Page    4
188
 
189
 
190
 
191
 
192
 2765
193
 2766                        		.ENDS
194
 2767
195
 2768          [01]          	.IFDEF		_ACIA_INC_
196
 2769  F8FFB1                		.INCLUDE INC\SP.INC
197
 2770                        	;;
198
 2771                        	;; Copyright (c) 2016 Marco Granati <mg@unet.bz>
199
 2772                        	;;
200
 2773                        	;; Permission to use, copy, modify, and distribute this software for any
201
 2774                        	;; purpose with or without fee is hereby granted, provided that the above
202
 2775                        	;; copyright notice and this permission notice appear in all copies.
203
 2776                        	;;
204
 2777                        	;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
205
 2778                        	;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
206
 2779                        	;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
207
 2780                        	;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
208
 2781                        	;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
209
 2782                        	;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
210
 2783                        	;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
211
 2784                        	;;
212
 2785
213
 2786                        	;; name: sp.inc
214
 2787                        	;; rev.: 2016/07/28
215
 2788                        	;; bios C816 version v1.0
216
 2789
217
 2790                        	.LIST on
218
 2791
219
 2792          000001        	SOH		.EQU	$01
220
 2793          000002        	STX		.EQU	$02
221
 2794          000003        	ETX		.EQU	$03
222
 2795          000004        	EOT		.EQU	$04
223
 2796          000005        	ENQ		.EQU	$05
224
 2797          000006        	ACK		.EQU	$06
225
 2798          000010        	DLE		.EQU	$10
226
 2799          000016        	SYN		.EQU	$16
227
 2800
228
 2801          002000        	SOBUFSIZ	.EQU	$2000	; dimensione coda TX1/TX2 ACIA (8K)
229
 2802                        	;SOBUFSIZ	.EQU	$0100	; dimensione coda TX1/TX2 ACIA (8K)
230
 2803          004000        	SIBUFSIZ	.EQU	$4000	; dimensione coda RX1/RX2 ACIA (16K)
231
 2804                        	;SIBUFSIZ	.EQU	$0100	; dimensione coda RX1/RX2 ACIA (16K)
232
 2805
233
 2806          000080        	NGUARD1		.EQU	$80	; numero bytes di guardia buffer RX XON/XOFF
234
 2807          000040        	NGUARD2		.EQU	$40	; numero bytes di guardia buffer RX handshake
235
 2808                        	;NGUARD1		.EQU	$40	; numero bytes di guardia buffer RX XON/XOFF
236
 2809                        	;NGUARD2		.EQU	$20	; numero bytes di guardia buffer RX handshake
237
 2810          001000        	NFREE1		.EQU	$1000	; minimo posto in coda RX per cancellare pausa remota
238
 2811          000800        	NFREE2		.EQU	$0800
239
 2812                        	;NGUARD3		.EQU	$F0
240
 2813                        	;NGUARD4		.EQU	$F8
241
 2814
242
 2815                        	;---------------------------------------------------------------------------
243
 2816                        	; direct page var's for serial ports handling
244
 2817                        	;---------------------------------------------------------------------------
245
 2818
246
 2819                        	DPSP:	.SECTION page0, common, ref_only, offset spwrk	;ACIA D.P.
247
 2820
248
 2821  000056                	_DPSP_START	.DS	0
249
  Tue Jul 17 11:00:18 2018                                                                                               Page    5
250
 
251
 
252
 
253
 
254
 2822
255
 2823                        	; WARNING: not change order and type of the following variables
256
 2824
257
 2825                        	; acia 1 var's
258
 2826  000056  00            	splin		.DB		; interrupt status register
259
 2827  000057  00            	spcsr		.DB		; control status register
260
 2828  000058  00            	spfr		.DB		; format register
261
 2829  000059  00            	spout		.DB		; XON/XOFF send flag
262
 2830
263
 2831                        	; acia 2 var's
264
 2832  00005A  00            	splin2		.DB		; interrupt status register
265
 2833  00005B  00            	spcsr2		.DB		; control status register
266
 2834  00005C  00            	spfr2		.DB		; format register
267
 2835  00005D  00            	spout2		.DB		; XON/XOFF send flag
268
 2836
269
 2837                        	; serial port's mode & status
270
 2838  00005E  00            	spmode		.DB		; <7>: 0=no handshake, 1=handshake
271
 2839                        					; <6>: 0=software/1=hardware handshake
272
 2840                        					; <5>: not used
273
 2841                        					; <4>: baud rate: 0=19200, 1=38400
274
 2842                        					; <3>: 0=odd parity, 1=even parity
275
 2843                        					; <2>: 0=no parity, 1=parity as specified
276
 2844                        					;      by bit <3>
277
 2845                        					; <1>: interface type: 0=RS232, 1=RS485
278
 2846                        					; <0>: RS232: uplink flow control (RTS/DCD)
279
 2847                        					;      RS485: 120 ohm termination on
280
 2848                        					; if bit 7=1 and bit 1=1, bit 6 is forced to 0
281
 2849  00005F
282
 2850  00005F  00            	spstat		.DB		; serial port status
283
 2851                        					; <7>: rx error (data discarded)
284
 2852                        					; <6>: rx buffer overflow
285
 2853                        					; <5>: remote disconnession (DSR line = 1)
286
 2854                        					; <4>: output buffer overflow
287
 2855                        					; <3>: not used
288
 2856                        					; <2>: framing error
289
 2857                        					; <1>: parity error
290
 2858                        					; <0>: overrun error
291
 2859
292
 2860  000060  00            	sppause		.DB		; local/remote pause flag's
293
 2861                        					; <7>: remote pause (sent an XON or set RTS=1)
294
 2862                        					; <6>: local pause (received an XON or CTS=1)
295
 2863
296
 2864  000061  00            	sptmp		.DB		; temp. byte used while get data
297
 2865
298
 2866                        	; serial port's mode & status
299
 2867  000062  00            	spmode2		.DB		; <7>: 0=no handshake, 1=handshake
300
 2868                        					; <6>: 0=software/1=hardware handshake
301
 2869                        					; <5>: not used
302
 2870                        					; <4>: baud rate: 0=19200, 1=38400
303
 2871                        					; <3>: 0=odd parity, 1=even parity
304
 2872                        					; <2>: 0=no parity, 1=parity as specified
305
 2873                        					;      by bit <3>
306
 2874                        					; <1>: interface type: 0=RS232, 1=RS485
307
 2875                        					; <0>: RS232: uplink flow control (RTS/DCD)
308
 2876                        					;      RS485: 120 ohm termination on
309
 2877                        					; if bit 7=1 and bit 1=1, bit 6 is forced to 0
310
 2878  000063
311
  Tue Jul 17 11:00:18 2018                                                                                               Page    6
312
 
313
 
314
 
315
 
316
 2879  000063  00            	spstat2		.DB		; serial port status
317
 2880                        					; <7>: rx error (data discarded)
318
 2881                        					; <6>: rx buffer overflow
319
 2882                        					; <5>: remote disconnession (DSR line = 1)
320
 2883                        					; <4>: output buffer overflow
321
 2884                        					; <3>: not used
322
 2885                        					; <2>: framing error
323
 2886                        					; <1>: parity error
324
 2887                        					; <0>: overrun error
325
 2888
326
 2889  000064  00            	sppause2	.DB		; local/remote pause flag's
327
 2890                        					; <7>: remote pause (sent XOFF/XON or RTS=1/0)
328
 2891                        					; <6>: local pause (rx XOFF/XON or CTS=0/1)
329
 2892
330
 2893  000065  00            	sppost		.DB		; after POST must hold $C0
331
 2894
332
 2895  000066  0000          	ibuftail	.DW		; pointer to tail of input buffer
333
 2896  000068  0000          	ibufhead	.DW		; pointer to head of input buffer
334
 2897  00006A  0000          	ibuftail2	.DW
335
 2898  00006C  0000          	ibufhead2	.DW
336
 2899
337
 2900  00006E  0000          	obuftail	.DW		; pointer to tail of output buffer
338
 2901  000070  0000          	obufhead	.DW		; pointer to head of output buffer
339
 2902  000072  0000          	obuftail2	.DW
340
 2903  000074  0000          	obufhead2	.DW
341
 2904
342
 2905  000076  0000          	ibufcnt		.DW		; count of bytes in input buffer
343
 2906  000078  0000          	obufcnt		.DW		; count of bytes in output buffer
344
 2907  00007A  0000          	ibufcnt2	.DW
345
 2908  00007C  0000          	obufcnt2	.DW
346
 2909
347
 2910  00007E  0000          	icntmin		.DW		; min. count for clear remote pause
348
 2911  000080  0000          	icntmax		.DW		; max. count for set remote pause
349
 2912  000082  0000          	icntmin2	.DW
350
 2913  000084  0000          	icntmax2	.DW
351
 2914
352
 2915  000086                	_DPSP_END	.DS	0
353
 2916          000030        	DPSPSIZ		.EQU	(_DPSP_END - _DPSP_START)
354
 2917
355
 2918
356
 2919                        		.ENDS
357
 2920
358
 2921          00005F        	ACIArxe_1	.EQU	spstat
359
 2922          000063        	ACIArxe_2	.EQU	spstat2
360
 2923          00005E        	ACIAhsk_1	.EQU	spmode
361
 2924          000062        	ACIAhsk_2	.EQU	spmode2
362
 2925          000060        	ACIAPause_1	.EQU	sppause
363
 2926          000064        	ACIAPause_2	.EQU	sppause2
364
 2927          000057        	ACIAcsr_1	.EQU	spcsr
365
 2928          00005B        	ACIAcsr_2	.EQU	spcsr2
366
 2929          000058        	ACIAfr_1	.EQU	spfr
367
 2930          00005C        	ACIAfr_2	.EQU	spfr2
368
 2931          000060        	ACIAOut_1	.EQU	sppause
369
 2932          000064        	ACIAOut_2	.EQU	sppause2
370
 2933          000076        	ACIAICnt_1	.EQU	ibufcnt
371
 2934          00007A        	ACIAICnt_2	.EQU	ibufcnt2
372
 2935          000068        	ACIAIHead_1	.EQU	ibufhead
373
  Tue Jul 17 11:00:18 2018                                                                                               Page    7
374
 
375
 
376
 
377
 
378
 2936          00006C        	ACIAIHead_2	.EQU	ibufhead2
379
 2937          000066        	ACIAITail_1	.EQU	ibuftail
380
 2938          00006A        	ACIAITail_2	.EQU	ibuftail2
381
 2939          000078        	ACIAOCnt_1	.EQU	obufcnt
382
 2940          00007C        	ACIAOCnt_2	.EQU	obufcnt2
383
 2941          000070        	ACIAOHead_1	.EQU	obufhead
384
 2942          000074        	ACIAOHead_2	.EQU	obufhead2
385
 2943          00006E        	ACIAOTail_1	.EQU	obuftail
386
 2944          000072        	ACIAOTail_2	.EQU	obuftail2
387
 2945
388
 2946          002000        	ACIAOBUFLEN	.EQU	SOBUFSIZ
389
 2947          004000        	ACIAIBUFLEN	.EQU	SIBUFSIZ
390
 2948          050000        	ACIAOUTBUF1	.EQU	SPOUTBUFF
391
 2949          052000        	ACIAOUTBUF2	.EQU	SPOUTBUFF2
392
 2950          054000        	ACIAINBUF1	.EQU	SPINBUFF
393
 2951          058000        	ACIAINBUF2	.EQU	SPINBUFF2
394
 2952
395
 2953          000061        	ACIATmp		.EQU	sptmp
396
 2954
397
 2962                        	.LIST	on
398
 2963
399
 2964                        	; page 0 local var's (declared in bios temp. work area)
400
 2965                        	_P0BTMP:	.SECTION page0, ref_only, offset bwrktmp	; DP Tmp. BIOS
401
 2966
402
 2967  000094  0000          	crc16		.DW
403
 2968  000096  0000          	bycnt		.DW		; data packet lenght
404
 2969  000098  0000          	byndx		.DW		; data buffer index
405
 2970  00009A  00            	pkttyp		.DB		; expected packet type
406
 2971  00009B  00            	pktnum		.DB		; current packet number
407
 2972  00009C  00            	expect		.DB		; expected packet number
408
 2973  00009D  00            	tmpx		.DB
409
 2974
410
 2975                        		.ENDS
411
 2976
412
 2977                        		.CODEF8
413
 2978  F8045B
414
 2979                        		.LONGA	off
415
 2980                        		.LONGI	off
416
 2981
417
 2982                        	; X=serial port
418
 2983  F8045B                	_spget0:
419
 2984  F8045B  8A            		txa
420
 2985  F8045C  D0 55         		bne	_spget1
421
 2986  F8045E
422
 2987  F8045E                		SPGETB	0
423
 2988          [01]          		.IFZ	0
424
 2989          000000        	k	.SET	0
425
 2990          054000        	SIBUFADDR	.SET	SPINBUFF
426
 2991          [01]          		.ELSE
427
 2992                        	k	.SET	4
428
 2993                        	SIBUFADDR	.SET	SPINBUFF2
429
 2994          [00]          		.ENDIF
430
 2995
431
 2996  F8045E  78            		sei			; disable interrupt
432
 2997  F8045F  38            		sec			; assume error
433
 2998  F80460  86 61         		stx	sptmp		; save X reg.
434
 2999  F80462  A5 5F         		lda	spstat+k	; rx pending error?
435
  Tue Jul 17 11:00:18 2018                                                                                               Page    8
436
 
437
 
438
 
439
 
440
 3000  F80464  30 47         		bmi	?done		; yes, exit
441
 3001  F80466  A9 00         		lda	#0		; assume no data available
442
 3002  F80468  A8            		tay			; Y = 0
443
 3003  F80469                		INDEX16
444
 3004                        		.MLIST
445
 3005  F80469  C2 10         		rep	#PXFLAG
446
 3006                        		.LONGI	on
447
 3007                        		.MNLIST
448
 3008  F8046B  A6 76         		ldx	ibufcnt+k	; available new data?
449
 3009  F8046D  F0 3E         		beq	?done		; input queue is empty (exit with CF=1, A=0)
450
 3010  F8046F  CA            		dex			; update count
451
 3011  F80470  86 76         		stx	ibufcnt+k
452
 3012  F80472  A6 68         		ldx	ibufhead+k	; head input buffer pointer
453
 3013  F80474  BF 00 40 05   		lda	>SIBUFADDR,x	; get byte from queue
454
 3014  F80478  E8            		inx			; update head pointer
455
 3015  F80479  E0 00 40      		cpx	#SIBUFSIZ
456
 3016  F8047C  90 01         		bcc	?upd
457
 3017  F8047E  BB            		tyx			; circular queue
458
 3018  F8047F  86 68         	?upd:	stx	ibufhead+k
459
 3019  F80481  24 60         		bit	sppause+k	; remote pause is on?
460
 3020  F80483  10 27         		bpl	?ok		; no
461
 3021  F80485  A6 76         		ldx	ibufcnt+k
462
 3022  F80487  E4 7E         		cpx	icntmin+k	; can clear remote pause?
463
 3023  F80489  B0 21         		bcs	?ok		; no
464
 3024  F8048B  24 5E         		bit	spmode+k	; handshake is on?
465
 3025  F8048D  10 1D         		bpl	?ok		; no
466
 3026  F8048F  EB            		xba			; save data
467
 3027  F80490  70 10         		bvs	?hw		; hardware handshake
468
 3028  F80492  A9 11         		lda	#SPXON		; software handshake: send an XON
469
 3029  F80494  2C 51 FD      		bit	.ABS.ACIACSR+k	; check TUR bit
470
 3030  F80497  50 05         		bvc	?def		; can't send an XON at this time
471
 3031  F80499  8D 53 FD      		sta	.ABS.ACIATDR+k	; send now an XON
472
 3032  F8049C  80 09         		bra	?crp		; clear remote pause flag
473
 3033  F8049E  85 59         	?def:	sta	spout+k		; XON is deffered
474
 3034  F804A0  80 09         		bra	?xba
475
 3035  F804A2  A5 58         	?hw:	lda	spfr+k		; hardware handshake: set RTS=0
476
 3036  F804A4  8D 51 FD      		sta	.ABS.ACIAFR+k
477
 3037  F804A7  A9 80         	?crp:	lda	#$80
478
 3038  F804A9  14 60         		trb	sppause+k	; clear remote pause flag
479
 3039  F804AB  EB            	?xba:	xba			; recover data
480
 3040  F804AC  18            	?ok:	clc
481
 3041  F804AD                	?done:	INDEX08
482
 3042                        		.MLIST
483
 3043  F804AD  E2 10         		sep	#PXFLAG
484
 3044                        		.LONGI	off
485
 3045                        		.MNLIST
486
 3046  F804AF  A6 61         		ldx	sptmp		; restore X reg.
487
 3047  F804B1  58            		cli
488
 3048  F804B2  60            		rts			; CF=1 & A=0 mean: no data available
489
 3049  F804B3                		.ENDM
490
 3050  F804B3
491
 3051  F804B3                	_spget1:
492
 3052  F804B3                		SPGETB	1
493
 3053
494
 3054                        		.MLIST
495
 3055          [01]          		.IFZ	1
496
 3056                        	k	.SET	0
497
  Tue Jul 17 11:00:18 2018                                                                                               Page    9
498
 
499
 
500
 
501
 
502
 3057                        	SIBUFADDR	.SET	SPINBUFF
503
 3058          [01]          		.ELSE
504
 3059          000004        	k	.SET	4
505
 3060          058000        	SIBUFADDR	.SET	SPINBUFF2
506
 3061          [00]          		.ENDIF
507
 3062
508
 3063  F804B3  78            		sei			; disable interrupt
509
 3064  F804B4  38            		sec			; assume error
510
 3065  F804B5  86 61         		stx	sptmp		; save X reg.
511
 3066  F804B7  A5 63         		lda	spstat+k	; rx pending error?
512
 3067  F804B9  30 47         		bmi	?done		; yes, exit
513
 3068  F804BB  A9 00         		lda	#0		; assume no data available
514
 3069  F804BD  A8            		tay			; Y = 0
515
 3070  F804BE                		INDEX16
516
 3071                        		.MLIST
517
 3072  F804BE  C2 10         		rep	#PXFLAG
518
 3073                        		.LONGI	on
519
 3074                        		.MNLIST
520
 3075  F804C0  A6 7A         		ldx	ibufcnt+k	; available new data?
521
 3076  F804C2  F0 3E         		beq	?done		; input queue is empty (exit with CF=1, A=0)
522
 3077  F804C4  CA            		dex			; update count
523
 3078  F804C5  86 7A         		stx	ibufcnt+k
524
 3079  F804C7  A6 6C         		ldx	ibufhead+k	; head input buffer pointer
525
 3080  F804C9  BF 00 80 05   		lda	>SIBUFADDR,x	; get byte from queue
526
 3081  F804CD  E8            		inx			; update head pointer
527
 3082  F804CE  E0 00 40      		cpx	#SIBUFSIZ
528
 3083  F804D1  90 01         		bcc	?upd
529
 3084  F804D3  BB            		tyx			; circular queue
530
 3085  F804D4  86 6C         	?upd:	stx	ibufhead+k
531
 3086  F804D6  24 64         		bit	sppause+k	; remote pause is on?
532
 3087  F804D8  10 27         		bpl	?ok		; no
533
 3088  F804DA  A6 7A         		ldx	ibufcnt+k
534
 3089  F804DC  E4 82         		cpx	icntmin+k	; can clear remote pause?
535
 3090  F804DE  B0 21         		bcs	?ok		; no
536
 3091  F804E0  24 62         		bit	spmode+k	; handshake is on?
537
 3092  F804E2  10 1D         		bpl	?ok		; no
538
 3093  F804E4  EB            		xba			; save data
539
 3094  F804E5  70 10         		bvs	?hw		; hardware handshake
540
 3095  F804E7  A9 11         		lda	#SPXON		; software handshake: send an XON
541
 3096  F804E9  2C 55 FD      		bit	.ABS.ACIACSR+k	; check TUR bit
542
 3097  F804EC  50 05         		bvc	?def		; can't send an XON at this time
543
 3098  F804EE  8D 57 FD      		sta	.ABS.ACIATDR+k	; send now an XON
544
 3099  F804F1  80 09         		bra	?crp		; clear remote pause flag
545
 3100  F804F3  85 5D         	?def:	sta	spout+k		; XON is deffered
546
 3101  F804F5  80 09         		bra	?xba
547
 3102  F804F7  A5 5C         	?hw:	lda	spfr+k		; hardware handshake: set RTS=0
548
 3103  F804F9  8D 55 FD      		sta	.ABS.ACIAFR+k
549
 3104  F804FC  A9 80         	?crp:	lda	#$80
550
 3105  F804FE  14 64         		trb	sppause+k	; clear remote pause flag
551
 3106  F80500  EB            	?xba:	xba			; recover data
552
 3107  F80501  18            	?ok:	clc
553
 3108  F80502                	?done:	INDEX08
554
 3109                        		.MLIST
555
 3110  F80502  E2 10         		sep	#PXFLAG
556
 3111                        		.LONGI	off
557
 3112                        		.MNLIST
558
 3113  F80504  A6 61         		ldx	sptmp		; restore X reg.
559
  Tue Jul 17 11:00:18 2018                                                                                               Page   10
560
 
561
 
562
 
563
 
564
 3114  F80506  58            		cli
565
 3115  F80507  60            		rts			; CF=1 & A=0 mean: no data available
566
 3116  F80508                		.ENDM
567
 3117
568
 3118                        	; X=serial port
569
 3119                        		.PUBLIC _spput0
570
 3120  F80508                	_spput0:
571
 3121  F80508  9B            		txy
572
 3122  F80509  D0 6D         		bne	_spput1
573
 3123  F8050B
574
 3124  F8050B                		SPPUTB	0
575
 3125
576
 3126                        		.MLIST
577
 3127          [01]          		.IFZ	0
578
 3128          000000        	k	.SET	0
579
 3129          050000        	SOBUFADDR	.SET	SPOUTBUFF
580
 3130          [01]          		.ELSE
581
 3131                        	k	.SET	4
582
 3132                        	SOBUFADDR	.SET	SPOUTBUFF2
583
 3133          [00]          		.ENDIF
584
 3134
585
 3135  F8050B  78            		sei			; disable interrupt
586
 3136  F8050C  86 61         		stx	sptmp		; save X reg.
587
 3137  F8050E  A0 00         		ldy	#0		; Y = 0
588
 3138  F80510                		INDEX16
589
 3139                        		.MLIST
590
 3140  F80510  C2 10         		rep	#PXFLAG
591
 3141                        		.LONGI	on
592
 3142                        		.MNLIST
593
 3143  F80512  A6 78         		ldx	obufcnt+k
594
 3144  F80514  E0 00 20      		cpx	#SOBUFSIZ	; output buffer is full?
595
 3145  F80517  90 07         		bcc	?str		; no, store byte
596
 3146  F80519  24 56         		bit	splin+k
597
 3147  F8051B  10 55         		bpl	?done		; exit with CF=1, Y=0: output buffer is full
598
 3148  F8051D  88            		dey
599
 3149  F8051E  80 52         		bra	?done		; exit with CF=1, Y=$FF: remote terminal off
600
 3150  F80520  E8            	?str:	inx			; update count
601
 3151  F80521  86 78         		stx	obufcnt+k
602
 3152  F80523  A6 6E         		ldx	obuftail+k	; output buffer tail pointer
603
 3153  F80525  9F 00 00 05   		sta	>SOBUFADDR,x	; store byte in output buffer
604
 3154  F80529  E8            		inx			; update tail pointer
605
 3155  F8052A  E0 00 20      		cpx	#SOBUFSIZ
606
 3156  F8052D  90 01         		bcc	?upd
607
 3157  F8052F  BB            		tyx			; circular queue
608
 3158  F80530  86 6E         	?upd:	stx	obuftail+k
609
 3159  F80532  2C 51 FD      		bit	.ABS.ACIACSR+k	; check TUR bit: try to free output buffer
610
 3160  F80535  50 3A         		bvc	?ok		; can't send now: send by ISR
611
 3161  F80537  EB            		xba			; save data
612
 3162  F80538  A5 59         		lda	spout+k		; XON/XOFF send pending?
613
 3163  F8053A  F0 17         		beq	?snd		; no
614
 3164  F8053C  8D 53 FD      		sta	.ABS.ACIATDR+k	; send an XON/XOFF
615
 3165  F8053F  C9 11         		cmp	#SPXON
616
 3166  F80541  D0 08         		bne	?xon
617
 3167  F80543  A9 80         		lda	#$80
618
 3168  F80545  04 60         		tsb	sppause+k	; set remote pause
619
 3169  F80547  64 59         		stz	spout+k		; clear XOFF flag
620
 3170  F80549  80 25         		bra	?xba		; done
621
  Tue Jul 17 11:00:18 2018                                                                                               Page   11
622
 
623
 
624
 
625
 
626
 3171  F8054B  A9 80         	?xon:	lda	#$80
627
 3172  F8054D  14 60         		trb	sppause+k	; clear remote pause
628
 3173  F8054F  64 59         		stz	spout+k		; clear XON flag
629
 3174  F80551  80 1D         		bra	?xba		; done
630
 3175  F80553  24 60         	?snd:	bit	sppause+k
631
 3176  F80555  70 19         		bvs	?xba		; local pause is on, can't send at this time
632
 3177  F80557  A6 78         		ldx	obufcnt+k
633
 3178  F80559  F0 15         		beq	?xba		; output buffer is empty
634
 3179  F8055B  CA            		dex			; update count
635
 3180  F8055C  86 78         		stx	obufcnt+k
636
 3181  F8055E  A6 70         		ldx	obufhead+k
637
 3182  F80560  BF 00 00 05   		lda	>SOBUFADDR,x	; get data from output buffer
638
 3183  F80564  8D 53 FD      		sta	.ABS.ACIATDR+k	; send data
639
 3184  F80567  E8            		inx			; update head pointer
640
 3185  F80568  E0 00 20      		cpx	#SOBUFSIZ
641
 3186  F8056B  90 01         		bcc	?upd2
642
 3187  F8056D  BB            		tyx			; circular queue
643
 3188  F8056E  86 70         	?upd2:	stx	obufhead+k
644
 3189  F80570  EB            	?xba:	xba			; return A = sent data
645
 3190  F80571  18            	?ok:	clc			; no error
646
 3191  F80572                	?done:	INDEX08
647
 3192                        		.MLIST
648
 3193  F80572  E2 10         		sep	#PXFLAG
649
 3194                        		.LONGI	off
650
 3195                        		.MNLIST
651
 3196  F80574  A6 61         		ldx	sptmp		; restore X reg.
652
 3197  F80576  58            		cli
653
 3198  F80577  60            		rts
654
 3199  F80578                		.ENDM
655
 3200  F80578
656
 3201  F80578                	_spput1:
657
 3202  F80578                		SPPUTB	1
658
 3203
659
 3204                        		.MLIST
660
 3205          [01]          		.IFZ	1
661
 3206                        	k	.SET	0
662
 3207                        	SOBUFADDR	.SET	SPOUTBUFF
663
 3208          [01]          		.ELSE
664
 3209          000004        	k	.SET	4
665
 3210          052000        	SOBUFADDR	.SET	SPOUTBUFF2
666
 3211          [00]          		.ENDIF
667
 3212
668
 3213  F80578  78            		sei			; disable interrupt
669
 3214  F80579  86 61         		stx	sptmp		; save X reg.
670
 3215  F8057B  A0 00         		ldy	#0		; Y = 0
671
 3216  F8057D                		INDEX16
672
 3217                        		.MLIST
673
 3218  F8057D  C2 10         		rep	#PXFLAG
674
 3219                        		.LONGI	on
675
 3220                        		.MNLIST
676
 3221  F8057F  A6 7C         		ldx	obufcnt+k
677
 3222  F80581  E0 00 20      		cpx	#SOBUFSIZ	; output buffer is full?
678
 3223  F80584  90 07         		bcc	?str		; no, store byte
679
 3224  F80586  24 5A         		bit	splin+k
680
 3225  F80588  10 55         		bpl	?done		; exit with CF=1, Y=0: output buffer is full
681
 3226  F8058A  88            		dey
682
 3227  F8058B  80 52         		bra	?done		; exit with CF=1, Y=$FF: remote terminal off
683
  Tue Jul 17 11:00:18 2018                                                                                               Page   12
684
 
685
 
686
 
687
 
688
 3228  F8058D  E8            	?str:	inx			; update count
689
 3229  F8058E  86 7C         		stx	obufcnt+k
690
 3230  F80590  A6 72         		ldx	obuftail+k	; output buffer tail pointer
691
 3231  F80592  9F 00 20 05   		sta	>SOBUFADDR,x	; store byte in output buffer
692
 3232  F80596  E8            		inx			; update tail pointer
693
 3233  F80597  E0 00 20      		cpx	#SOBUFSIZ
694
 3234  F8059A  90 01         		bcc	?upd
695
 3235  F8059C  BB            		tyx			; circular queue
696
 3236  F8059D  86 72         	?upd:	stx	obuftail+k
697
 3237  F8059F  2C 55 FD      		bit	.ABS.ACIACSR+k	; check TUR bit: try to free output buffer
698
 3238  F805A2  50 3A         		bvc	?ok		; can't send now: send by ISR
699
 3239  F805A4  EB            		xba			; save data
700
 3240  F805A5  A5 5D         		lda	spout+k		; XON/XOFF send pending?
701
 3241  F805A7  F0 17         		beq	?snd		; no
702
 3242  F805A9  8D 57 FD      		sta	.ABS.ACIATDR+k	; send an XON/XOFF
703
 3243  F805AC  C9 11         		cmp	#SPXON
704
 3244  F805AE  D0 08         		bne	?xon
705
 3245  F805B0  A9 80         		lda	#$80
706
 3246  F805B2  04 64         		tsb	sppause+k	; set remote pause
707
 3247  F805B4  64 5D         		stz	spout+k		; clear XOFF flag
708
 3248  F805B6  80 25         		bra	?xba		; done
709
 3249  F805B8  A9 80         	?xon:	lda	#$80
710
 3250  F805BA  14 64         		trb	sppause+k	; clear remote pause
711
 3251  F805BC  64 5D         		stz	spout+k		; clear XON flag
712
 3252  F805BE  80 1D         		bra	?xba		; done
713
 3253  F805C0  24 64         	?snd:	bit	sppause+k
714
 3254  F805C2  70 19         		bvs	?xba		; local pause is on, can't send at this time
715
 3255  F805C4  A6 7C         		ldx	obufcnt+k
716
 3256  F805C6  F0 15         		beq	?xba		; output buffer is empty
717
 3257  F805C8  CA            		dex			; update count
718
 3258  F805C9  86 7C         		stx	obufcnt+k
719
 3259  F805CB  A6 74         		ldx	obufhead+k
720
 3260  F805CD  BF 00 20 05   		lda	>SOBUFADDR,x	; get data from output buffer
721
 3261  F805D1  8D 57 FD      		sta	.ABS.ACIATDR+k	; send data
722
 3262  F805D4  E8            		inx			; update head pointer
723
 3263  F805D5  E0 00 20      		cpx	#SOBUFSIZ
724
 3264  F805D8  90 01         		bcc	?upd2
725
 3265  F805DA  BB            		tyx			; circular queue
726
 3266  F805DB  86 74         	?upd2:	stx	obufhead+k
727
 3267  F805DD  EB            	?xba:	xba			; return A = sent data
728
 3268  F805DE  18            	?ok:	clc			; no error
729
 3269  F805DF                	?done:	INDEX08
730
 3270                        		.MLIST
731
 3271  F805DF  E2 10         		sep	#PXFLAG
732
 3272                        		.LONGI	off
733
 3273                        		.MNLIST
734
 3274  F805E1  A6 61         		ldx	sptmp		; restore X reg.
735
 3275  F805E3  58            		cli
736
 3276  F805E4  60            		rts
737
 3277  F805E5                		.ENDM
738
 3278  F805E5
739
 3279                        	; A=mode, X=serial #
740
 3280  F805E5                	spset:
741
 3281  F805E5  9B            		txy
742
 3282  F805E6  F0 02         		beq	?sr0		; serial #0
743
 3283  F805E8  A2 04         		ldx	#4		; serial #1
744
 3284  F805EA  78            	?sr0:	sei			; disable interrupt
745
  Tue Jul 17 11:00:18 2018                                                                                               Page   13
746
 
747
 
748
 
749
 
750
 3285  F805EB  95 5E         		sta	spmode,x
751
 3286  F805ED  A8            		tay
752
 3287  F805EE  A9 7F         		lda	#$7F		; disable all interrupts
753
 3288  F805F0  9D 50 FD      		sta	.ABS.ACIAIER,x
754
 3289  F805F3  BD 53 FD      		lda	.ABS.ACIARDR,x	; discard any pending received data
755
 3290  F805F6  BD 50 FD      		lda	.ABS.ACIAISR,x	; read current interrupt status
756
 3291  F805F9  BD 51 FD      		lda	.ABS.ACIACSR,x	; save current control status
757
 3292  F805FC  95 57         		sta	spcsr,x
758
 3293  F805FE  98            		tya			; mode
759
 3294  F805FF  29 0C         		and	#00001100B	; mask on bits 3 & 2 (parity mode)
760
 3295  F80601  09 E0         		ora	#11100000B	; 8 data bits, RTS=DTR=low
761
 3296  F80603  95 58         		sta	spfr,x		; value of format register
762
 3297                        		;ora	#00000011B
763
 3298  F80605  9D 51 FD      		sta	.ABS.ACIAFR,x	; set format register: RTS=DTR=1
764
 3299  F80608  98            		tya
765
 3300  F80609  A0 4E         		ldy	#01001110B	; access to ACR, one stop bit, 38400
766
 3301  F8060B  89 10         		bit	#00010000B
767
 3302  F8060D  D0 02         		bne	?br		; select baud rate=38400
768
 3303  F8060F  A0 4D         		ldy	#01001101B	; access to ACR, one stop bit, 19200
769
 3304  F80611  98            	?br:	tya
770
 3305  F80612  9D 51 FD      		sta	.ABS.ACIACR,x	; set control register
771
 3306  F80615  9E 52 FD      		stz	.ABS.ACIAACR,x	; set aux. control reg. (normal tx, parity)
772
 3307  F80618  A9 80         		lda	#$80
773
 3308  F8061A  0C 1F FD      		tsb	VIA1+VIAPRANH	; enble RS232
774
 3309  F8061D  A9 02         		lda	#00000010B	; check RS485
775
 3310  F8061F  34 5E         		bit	spmode,x
776
 3311  F80621  F0 1B         		beq	?cnt		; interface type: RS232
777
 3312  F80623  B5 5E         		lda	spmode,x
778
 3313  F80625  29 BF         		and	#10111111B	; software handshake only for RS485
779
 3314  F80627  95 5E         		sta	spmode,x
780
 3315  F80629  A9 80         		lda	#$80
781
 3316  F8062B  1C 1F FD      		trb	VIA1+VIAPRANH	; enble RS485 interface
782
 3317  F8062E  A9 40         		lda	#$40
783
 3318  F80630  1C 0F FD      		trb	VIA0+VIAPRANH	; disable 120 ohm termination
784
 3319  F80633  A9 01         		lda	#00000001B	; check termination status
785
 3320  F80635  34 5E         		bit	spmode,x
786
 3321  F80637  F0 05         		beq	?cnt		; termination off
787
 3322  F80639  A9 40         		lda	#$40
788
 3323  F8063B  0C 0F FD      		tsb	VIA0+VIAPRANH	; enable 120 ohm termination
789
 3324  F8063E  74 60         	?cnt:	stz	sppause,x	; init work area
790
 3325  F80640  74 59         		stz	spout,x
791
 3326  F80642  74 5F         		stz	spstat,x
792
 3327  F80644  34 5E         		bit	spmode,x
793
 3328  F80646                		CPU16			; init buffer's pointer's
794
 3329                        		.MLIST
795
 3330  F80646  C2 30         		rep	#(PMFLAG.OR.PXFLAG)
796
 3331                        		.LONGA	on
797
 3332                        		.LONGI	on
798
 3333                        		.MNLIST
799
 3334  F80648  70 08         		bvs	?hw		; hardware handshake
800
 3335  F8064A  A9 80 00      		lda	#NGUARD1
801
 3336  F8064D  A0 00 10      		ldy	#NFREE1
802
 3337  F80650  80 06         		bra	?do
803
 3338  F80652  A9 40 00      	?hw:	lda	#NGUARD2
804
 3339  F80655  A0 00 08      		ldy	#NFREE2
805
 3340  F80658  95 80         	?do:	sta	icntmax,x
806
 3341  F8065A  94 7E         		sty	icntmin,x
807
  Tue Jul 17 11:00:18 2018                                                                                               Page   14
808
 
809
 
810
 
811
 
812
 3342  F8065C  38            		sec
813
 3343  F8065D  A9 00 40      		lda	#SIBUFSIZ
814
 3344  F80660  F5 80         		sbc	icntmax,x
815
 3345  F80662  95 80         		sta	icntmax,x
816
 3346  F80664  74 66         		stz	ibuftail,x
817
 3347  F80666  74 68         		stz	ibufhead,x
818
 3348  F80668  74 76         		stz	ibufcnt,x
819
 3349  F8066A  74 6E         		stz	obuftail,x
820
 3350  F8066C  74 70         		stz	obufhead,x
821
 3351  F8066E  74 78         		stz	obufcnt,x
822
 3352  F80670                		CPU08
823
 3353  F80670  E2 30         		sep	#(PMFLAG.OR.PXFLAG)
824
 3354                        		.LONGA	off
825
 3355                        		.LONGI	off
826
 3356                        		.MNLIST
827
 3357  F80672  BD 53 FD      		lda	.ABS.ACIARDR,x	; discard any pending received data
828
 3358  F80675  BD 50 FD      		lda	.ABS.ACIAISR,x	; read current interrupt status
829
 3359  F80678  BD 51 FD      		lda	.ABS.ACIACSR,x	; save current control status
830
 3360  F8067B  95 57         		sta	spcsr,x
831
 3361  F8067D  29 3B         		and	#00111011B	; mask lines level
832
 3362  F8067F  89 08         		bit	#00001000B	; check DSR line level
833
 3363  F80681  F0 02         		beq	?sav		; DSR is low
834
 3364  F80683  09 40         		ora	#01000000B	; DSR is high
835
 3365  F80685  0A            	?sav:	asl	a		; 7:DSR, 6:CTS, 5:DCD, 2:DTR, 1:RTS
836
 3366  F80686  95 56         		sta	splin,x		; save lines level
837
 3367  F80688  A9 F9         		lda	#$F9		; enable interrupts
838
 3368  F8068A  9D 50 FD      		sta	.ABS.ACIAIER,x
839
 3369  F8068D  58            		cli
840
 3370  F8068E  60            		rts
841
 3371
842
 3372                        	; X=serial #
843
 3373  F8068F                	spres:
844
 3374  F8068F  9B            		txy
845
 3375  F80690  F0 02         		beq	?sr0		; serial #0
846
 3376  F80692  A2 04         		ldx	#4		; serial #1
847
 3377  F80694  78            	?sr0:	sei			; disable interrupt
848
 3378  F80695  A9 7F         		lda	#$7F		; disable all interrupts
849
 3379  F80697  9D 50 FD      		sta	.ABS.ACIAIER,x
850
 3380  F8069A  B5 58         		lda	spfr,x
851
 3381  F8069C  09 03         		ora	#00000011B	; set RTS=DTR=1
852
 3382  F8069E  9D 51 FD      		sta	.ABS.ACIAFR,x
853
 3383  F806A1  BD 53 FD      		lda	.ABS.ACIARDR,x	; discard any pending received data
854
 3384  F806A4  BD 50 FD      		lda	.ABS.ACIAISR,x	; read current interrupt status
855
 3385  F806A7  BD 51 FD      		lda	.ABS.ACIACSR,x	; save current control status
856
 3386  F806AA  95 57         		sta	spcsr,x
857
 3387  F806AC  58            		cli
858
 3388  F806AD  60            		rts
859
 3389
860
 3390                        	;---- TRANSFER
861
 3391
862
 3392                        	; X=port (0 or 4)
863
 3393                        	; get byte with timeout
864
 3394  F806AE                	sptget:
865
 3395  F806AE  A9 20         		lda	#$20		; set T2 count PB6 pulse (1ms)
866
 3396  F806B0  0C 0B FD      		tsb	.ABS.VIA0+VIAACR
867
 3397  F806B3  9C 08 FD      		stz	.ABS.VIA0+VIAT2CL
868
 3398  F806B6  A9 04         		lda	#4		; set 1024ms timeout
869
  Tue Jul 17 11:00:18 2018                                                                                               Page   15
870
 
871
 
872
 
873
 
874
 3399  F806B8  8D 09 FD      		sta	.ABS.VIA0+VIAT2CH
875
 3400  F806BB  20 5B 04      	?lp:	jsr	_spget0		; get byte within timeout
876
 3401  F806BE  90 0C         		bcc	?exit		; ok, data available
877
 3402  F806C0  A8            		tay			; CF=1 here
878
 3403  F806C1  D0 09         		bne	?exit		; some rx error(s)
879
 3404  F806C3  A9 20         		lda	#T2IFRB
880
 3405  F806C5  2C 0D FD      		bit	.ABS.VIA0+VIAIFR
881
 3406  F806C8  F0 F1         		beq	?lp		; no timeout: loop
882
 3407  F806CA  A9 08         		lda	#$08		; set timeout error - CF=1 here
883
 3408  F806CC  60            	?exit:	rts
884
 3409
885
 3410  F806CD                	sndnack:
886
 3411                        		;ldy	#NACK
887
 3412  F806CD  80 02         		bra	sndack2
888
 3413  F806CF
889
 3414  F806CF                	sndack:
890
 3415  F806CF  A0 06         		ldy	#ACK
891
 3416  F806D1
892
 3417  F806D1                	sndack2:
893
 3418  F806D1  84 9D         		sty	tmpx
894
 3419  F806D3  A9 16         		lda	#SYN
895
 3420  F806D5  20 00 07      		jsr	sptput
896
 3421  F806D8  B0 48         		bcs	exit1
897
 3422  F806DA  A5 9D         		lda	tmpx
898
 3423  F806DC  20 00 07      		jsr	sptput
899
 3424  F806DF  B0 41         		bcs	exit1
900
 3425  F806E1  A5 9B         		lda	pktnum
901
 3426
902
 3427  F806E3                	spxput:
903
 3428  F806E3  C9 16         		cmp	#SYN
904
 3429  F806E5  F0 0C         		beq	?esc
905
 3430  F806E7  C9 11         		cmp	#SPXON
906
 3431  F806E9  F0 08         		beq	?esc
907
 3432  F806EB  C9 13         		cmp	#SPXOFF
908
 3433  F806ED  F0 04         		beq	?esc
909
 3434  F806EF  C9 10         		cmp	#DLE
910
 3435  F806F1  D0 0D         		bne	sptput
911
 3436  F806F3  49 20         	?esc:	eor	#$20
912
 3437  F806F5  85 9D         		sta	tmpx
913
 3438  F806F7  A9 10         		lda	#DLE
914
 3439  F806F9  20 00 07      		jsr	sptput
915
 3440  F806FC  B0 24         		bcs	exit1
916
 3441  F806FE  A5 9D         		lda	tmpx
917
 3442
918
 3443                        	; X=port (0 or 4)
919
 3444                        	; put byte with timeout
920
 3445  F80700                	sptput:
921
 3446  F80700  A8            		tay			; Y=data
922
 3447  F80701  A9 20         		lda	#$20		; set T2 count PB6 pulse (1ms)
923
 3448  F80703  0C 0B FD      		tsb	.ABS.VIA0+VIAACR
924
 3449  F80706  9C 08 FD      		stz	.ABS.VIA0+VIAT2CL
925
 3450  F80709  A9 04         		lda	#4		; set 1024ms timeout
926
 3451  F8070B  8D 09 FD      		sta	.ABS.VIA0+VIAT2CH
927
 3452  F8070E  98            	?lp:	tya			; byte to send
928
 3453  F8070F  20 08 05      		jsr	_spput0		; put byte within timeout
929
 3454  F80712  90 0E         		bcc	exit1		; ok
930
 3455  F80714  C8            		iny			; Y=$FF if remote disconnession
931
  Tue Jul 17 11:00:18 2018                                                                                               Page   16
932
 
933
 
934
 
935
 
936
 3456  F80715  F0 09         		beq	?err		; remote terminal disconnected
937
 3457  F80717  A8            		tay			; Y=data
938
 3458  F80718  A9 20         		lda	#T2IFRB
939
 3459  F8071A  2C 0D FD      		bit	.ABS.VIA0+VIAIFR
940
 3460  F8071D  F0 EF         		beq	?lp		; no timeout: loop
941
 3461  F8071F  98            		tya			; restore data
942
 3462  F80720  A0 80         	?err:	ldy	#$80		; timeout or remote disconnession
943
 3463  F80722  60            	exit1:	rts
944
 3464
945
 3465                        	; frame alignment
946
 3466                        	; A=expected packet type (SOH or STX)
947
 3467                        	; X=0 (serial port 0)
948
 3468                        	; exit with CF=0 if no error (ZF=0 if STX/SOH, ZF=1 if EOT)
949
 3469  F80723                	fndsyn:
950
 3470  F80723  85 9A         		sta	pkttyp
951
 3471  F80725  20 AE 06      		jsr	sptget
952
 3472  F80728  B0 26         		bcs	?done		; error
953
 3473  F8072A  C9 16         		cmp	#SYN
954
 3474  F8072C  D0 F5         		bne	fndsyn		; skip bytes until find start of trame
955
 3475  F8072E  20 AE 06      	?lp:	jsr	sptget		; next byte
956
 3476  F80731  B0 1D         		bcs	?done		; error
957
 3477  F80733  C9 16         		cmp	#SYN		; discard further consecutive sync's
958
 3478  F80735  F0 F7         		beq	?lp
959
 3479  F80737  C5 9A         		cmp	pkttyp		; expected SOH, STX or EOT
960
 3480  F80739  D0 08         		bne	?eot
961
 3481  F8073B  A9 FF         		lda	#$FF		; initialize crc computation
962
 3482  F8073D  85 94         		sta	crc16
963
 3483  F8073F  85 95         		sta	crc16+1		; if received STX or SOH exit with ZF=0
964
 3484  F80741  18            	?ok:	clc			; no error
965
 3485  F80742  60            		rts
966
 3486  F80743  A4 9A         	?eot:	ldy	pkttyp		; when expect STX, an EOT is legal
967
 3487  F80745  C0 02         		cpy	#STX
968
 3488  F80747  D0 04         		bne	?err		; unexpected packet type
969
 3489  F80749  C9 04         		cmp	#EOT		; received an EOT?
970
 3490  F8074B  F0 F4         		beq	?ok		; exit with ZF=1 (EOT)
971
 3491  F8074D  A9 10         	?err:	lda	#$10		; unexpected packet type error
972
 3492  F8074F  38            		sec
973
 3493  F80750  60            	?done:	rts
974
 3494
975
 3495                        	; get escaped byte
976
 3496                        	; X=serial port
977
 3497  F80751                	spxget:
978
 3498  F80751  20 AE 06      		jsr	sptget
979
 3499  F80754  B0 10         		bcs	?done
980
 3500  F80756  C9 16         		cmp	#SYN		; here a SYN is an error
981
 3501  F80758  F0 0C         		beq	?done		; exit
982
 3502  F8075A  C9 10         		cmp	#DLE
983
 3503  F8075C  D0 07         		bne	?ok
984
 3504  F8075E  20 AE 06      		jsr	sptget
985
 3505  F80761  B0 03         		bcs	?done
986
 3506  F80763  49 20         		eor	#$20
987
 3507  F80765  18            	?ok:	clc
988
 3508  F80766  60            	?done:	rts
989
 3509
990
 3510  F80767                	updcrc:
991
 3511  F80767  A8            		tay
992
 3512  F80768  45 95         		eor 	crc16+1		; quick CRC computation with lookup tables
993
  Tue Jul 17 11:00:18 2018                                                                                               Page   17
994
 
995
 
996
 
997
 
998
 3513  F8076A  AA            		tax			; index for lookup table
999
 3514  F8076B  A5 94         		lda 	crc16
1000
 3515  F8076D  5F BC 09 F8   		eor 	>crchi,x
1001
 3516  F80771  85 95         		sta 	crc16+1
1002
 3517  F80773  BF BC 08 F8   		lda 	>crclo,x
1003
 3518  F80777  85 94         		sta 	crc16
1004
 3519  F80779  98            		tya
1005
 3520  F8077A  60            		rts
1006
 3521
1007
 3522                        	; X=serial port (0 or 4)
1008
 3523  F8077B                	getdat:
1009
 3524  F8077B                		ACC16
1010
 3525  F8077B  C2 20         		rep	#PMFLAG
1011
 3526                        		.LONGA	on
1012
 3527                        		.MNLIST
1013
 3528  F8077D  A9 00 02      		lda	#$200
1014
 3529  F80780  A4 9A         		ldy	pkttyp
1015
 3530  F80782  C0 02         		cpy	#STX
1016
 3531  F80784  F0 03         		beq	?st
1017
 3532  F80786  A9 10 00      		lda	#$10
1018
 3533  F80789  85 96         	?st:	sta	bycnt
1019
 3534  F8078B  64 98         		stz	byndx
1020
 3535  F8078D                		ACC08
1021
 3536  F8078D  E2 20         		sep	#PMFLAG
1022
 3537                        		.LONGA	off
1023
 3538                        		.MNLIST
1024
 3539  F8078F  20 51 07      	?lp:	jsr	spxget
1025
 3540  F80792  B0 2A         		bcs	?err
1026
 3541  F80794  20 67 07      		jsr	updcrc
1027
 3542  F80797                		INDEX16
1028
 3543  F80797  C2 10         		rep	#PXFLAG
1029
 3544                        		.LONGI	on
1030
 3545                        		.MNLIST
1031
 3546  F80799  A6 98         		ldx	byndx
1032
 3547  F8079B  9F 00 9A 01   		sta	>SPBUF,x
1033
 3548  F8079F  E8            		inx
1034
 3549  F807A0  86 98         		stx	byndx
1035
 3550  F807A2  E4 96         		cpx	bycnt
1036
 3551  F807A4                		INDEX08
1037
 3552  F807A4  E2 10         		sep	#PXFLAG
1038
 3553                        		.LONGI	off
1039
 3554                        		.MNLIST
1040
 3555  F807A6  A2 00         		ldx	#0
1041
 3556  F807A8  90 E5         		bcc	?lp
1042
 3557  F807AA  20 51 07      		jsr	spxget
1043
 3558  F807AD  B0 0F         		bcs	?err
1044
 3559  F807AF  C5 94         		cmp	crc16
1045
 3560  F807B1  D0 0B         		bne	?err
1046
 3561  F807B3  20 51 07      		jsr	spxget
1047
 3562  F807B6  B0 06         		bcs	?err
1048
 3563  F807B8  C5 95         		cmp	crc16+1
1049
 3564  F807BA  D0 02         		bne	?err
1050
 3565  F807BC  18            		clc
1051
 3566  F807BD  60            		rts
1052
 3567  F807BE  38            	?err:	sec
1053
 3568  F807BF  60            		rts
1054
 3569  F807C0
1055
  Tue Jul 17 11:00:18 2018                                                                                               Page   18
1056
 
1057
 
1058
 
1059
 
1060
 3570                        	; X=serial port (0 or 4)
1061
 3571  F807C0                	getpkt:
1062
 3572  F807C0  A9 02         		lda	#STX
1063
 3573  F807C2  20 23 07      		jsr	fndsyn
1064
 3574  F807C5  B0 1E         		bcs	?done
1065
 3575  F807C7  20 51 07      		jsr	spxget
1066
 3576  F807CA  B0 19         		bcs	?done
1067
 3577  F807CC  85 9B         		sta	pktnum
1068
 3578  F807CE  20 51 07      		jsr	spxget
1069
 3579  F807D1  B0 12         		bcs	?done
1070
 3580  F807D3  49 FF         		eor	#$FF
1071
 3581  F807D5  C5 9B         		cmp	pktnum
1072
 3582  F807D7  D0 0C         		bne	?err
1073
 3583  F807D9  C5 9C         		cmp	expect
1074
 3584  F807DB  D0 08         		bne	?err
1075
 3585  F807DD  20 7B 07      		jsr	getdat
1076
 3586  F807E0  B0 03         		bcs	?err
1077
 3587
1078
 3588                        		; send positive ACK
1079
 3589  F807E2  4C CF 06      		jmp	sndack
1080
 3590  F807E5
1081
 3591  F807E5                	?err:
1082
 3592  F807E5  60            	?done:	rts
1083
 3593
1084
 3594  F807E6
1085
 3595                        	;------------------
1086
 3596
1087
 3597  F807E6                	lspget:
1088
 3598                        		.PUBLIC lspget
1089
 3599  F807E6  0B            		phd			; save DP
1090
 3600  F807E7  8B            		phb			; save DBR
1091
 3601  F807E8  F4 00 00      		pea	#0		; set DP = $0000
1092
 3602  F807EB  2B            		pld
1093
 3603  F807EC  A0 00         		ldy	#0		; set DBR = $00
1094
 3604  F807EE  5A            		phy
1095
 3605  F807EF  AB            		plb
1096
 3606  F807F0  20 5B 04      		jsr	_spget0
1097
 3607  F807F3  AB            		plb
1098
 3608  F807F4  2B            		pld
1099
 3609  F807F5  6B            		rtl
1100
 3610  F807F6
1101
 3611  F807F6                	lspput:
1102
 3612                        		.PUBLIC lspput
1103
 3613  F807F6  0B            		phd			; save DP
1104
 3614  F807F7  8B            		phb			; save DBR
1105
 3615  F807F8  F4 00 00      		pea	#0		; set DP = $0000
1106
 3616  F807FB  2B            		pld
1107
 3617  F807FC  A0 00         		ldy	#0		; set DBR = $00
1108
 3618  F807FE  5A            		phy
1109
 3619  F807FF  AB            		plb
1110
 3620  F80800  20 08 05      		jsr	_spput0
1111
 3621  F80803  AB            		plb
1112
 3622  F80804  2B            		pld
1113
 3623  F80805  6B            		rtl
1114
 3624
1115
 3625  F80806                	lspset:
1116
 3626                        		.PUBLIC lspset
1117
  Tue Jul 17 11:00:18 2018                                                                                               Page   19
1118
 
1119
 
1120
 
1121
 
1122
 3627  F80806  0B            		phd			; save DP
1123
 3628  F80807  8B            		phb			; save DBR
1124
 3629  F80808  F4 00 00      		pea	#0		; set DP = $0000
1125
 3630  F8080B  2B            		pld
1126
 3631  F8080C  A0 00         		ldy	#0		; set DBR = $00
1127
 3632  F8080E  5A            		phy
1128
 3633  F8080F  AB            		plb
1129
 3634  F80810  20 E5 05      		jsr	spset
1130
 3635  F80813  AB            		plb
1131
 3636  F80814  2B            		pld
1132
 3637  F80815  6B            		rtl
1133
 3638
1134
 3639  F80816                	lspres:
1135
 3640                        		.PUBLIC lspres
1136
 3641  F80816  0B            		phd			; save DP
1137
 3642  F80817  8B            		phb			; save DBR
1138
 3643  F80818  F4 00 00      		pea	#0		; set DP = $0000
1139
 3644  F8081B  2B            		pld
1140
 3645  F8081C  A0 00         		ldy	#0		; set DBR = $00
1141
 3646  F8081E  5A            		phy
1142
 3647  F8081F  AB            		plb
1143
 3648  F80820  20 8F 06      		jsr	spres
1144
 3649  F80823  AB            		plb
1145
 3650  F80824  2B            		pld
1146
 3651  F80825  6B            		rtl
1147
 3652
1148
 3653  F80826                	crc16a:
1149
 3654  F80826  EB            		xba
1150
 3655  F80827  A9 00         		lda	#0
1151
 3656  F80829  A2 08         		ldx	#8
1152
 3657  F8082B                		ACC16
1153
 3658  F8082B  C2 20         		rep	#PMFLAG
1154
 3659                        		.LONGA	on
1155
 3660                        		.MNLIST
1156
 3661  F8082D  45 94         		eor	crc16
1157
 3662  F8082F  0A            	?lp:	asl	a
1158
 3663  F80830  90 03         		bcc	?skp
1159
 3664  F80832  49 21 10      		eor	#$1021
1160
 3665  F80835  CA            	?skp:	dex
1161
 3666  F80836  D0 F7         		bne	?lp
1162
 3667  F80838  85 94         		sta	crc16
1163
 3668  F8083A                		ACC08
1164
 3669  F8083A  E2 20         		sep	#PMFLAG
1165
 3670                        		.LONGA	off
1166
 3671                        		.MNLIST
1167
 3672  F8083C  60            		rts
1168
 3673
1169
 3674  F8083D                	crc16b:
1170
 3675  F8083D  A2 08         		ldx	#8
1171
 3676  F8083F  A8            	?lp:	tay
1172
 3677  F80840  45 94         		eor	crc16
1173
 3678  F80842  4A            		lsr	a
1174
 3679  F80843                		ACC16
1175
 3680  F80843  C2 20         		rep	#PMFLAG
1176
 3681                        		.LONGA	on
1177
 3682                        		.MNLIST
1178
 3683  F80845  08            		php
1179
  Tue Jul 17 11:00:18 2018                                                                                               Page   20
1180
 
1181
 
1182
 
1183
 
1184
 3684  F80846  A5 94         		lda	crc16
1185
 3685  F80848  4A            		lsr	a
1186
 3686  F80849  28            		plp
1187
 3687  F8084A  90 03         		bcc	?nxt
1188
 3688  F8084C  49 08 84      		eor	#$8408
1189
 3689  F8084F  85 94         	?nxt:	sta	crc16
1190
 3690  F80851                		ACC08
1191
 3691  F80851  E2 20         		sep	#PMFLAG
1192
 3692                        		.LONGA	off
1193
 3693                        		.MNLIST
1194
 3694  F80853  98            		tya
1195
 3695  F80854  4A            		lsr	a
1196
 3696  F80855  CA            		dex
1197
 3697  F80856  D0 E7         		bne	?lp
1198
 3698  F80858  60            		rts
1199
 3699  F80859
1200
 3700  F80859                	crccalc:
1201
 3701  F80859  0B            		phd
1202
 3702  F8085A  F4 00 00      		pea	#0
1203
 3703  F8085D  2B            		pld
1204
 3704  F8085E  86 FF         		stx	$ff
1205
 3705
1206
 3706  F80860  A9 FF         		lda	#$FF
1207
 3707  F80862  85 94         		sta	crc16
1208
 3708  F80864  85 95         		sta	crc16+1
1209
 3709  F80866  20 99 08      		jsr	crctb
1210
 3710  F80869                		ACC16
1211
 3711  F80869  C2 20         		rep	#PMFLAG
1212
 3712                        		.LONGA	on
1213
 3713                        		.MNLIST
1214
 3714  F8086B  A5 94         		lda	crc16
1215
 3715  F8086D  85 F0         		sta	$f0
1216
 3716  F8086F                		ACC08
1217
 3717  F8086F  E2 20         		sep	#PMFLAG
1218
 3718                        		.LONGA	off
1219
 3719                        		.MNLIST
1220
 3720  F80871  A9 00         		lda	#$00
1221
 3721  F80873  85 94         		sta	crc16
1222
 3722  F80875  A9 00         		lda	#$00
1223
 3723  F80877  85 95         		sta	crc16+1
1224
 3724  F80879  20 99 08      		jsr	crctb
1225
 3725  F8087C                		ACC16
1226
 3726  F8087C  C2 20         		rep	#PMFLAG
1227
 3727                        		.LONGA	on
1228
 3728                        		.MNLIST
1229
 3729  F8087E  A5 94         		lda	crc16
1230
 3730  F80880  85 F2         		sta	$f2
1231
 3731  F80882                		ACC08
1232
 3732  F80882  E2 20         		sep	#PMFLAG
1233
 3733                        		.LONGA	off
1234
 3734                        		.MNLIST
1235
 3735  F80884  A9 0F         		lda	#$0F
1236
 3736  F80886  85 94         		sta	crc16
1237
 3737  F80888  A9 1D         		lda	#$1D
1238
 3738  F8088A  85 95         		sta	crc16+1
1239
 3739  F8088C  20 99 08      		jsr	crctb
1240
 3740  F8088F                		ACC16
1241
  Tue Jul 17 11:00:18 2018                                                                                               Page   21
1242
 
1243
 
1244
 
1245
 
1246
 3741  F8088F  C2 20         		rep	#PMFLAG
1247
 3742                        		.LONGA	on
1248
 3743                        		.MNLIST
1249
 3744  F80891  A5 94         		lda	crc16
1250
 3745  F80893  85 F4         		sta	$f4
1251
 3746  F80895                		ACC08
1252
 3747  F80895  E2 20         		sep	#PMFLAG
1253
 3748                        		.LONGA	off
1254
 3749                        		.MNLIST
1255
 3750  F80897  2B            		pld
1256
 3751  F80898  6B            		rtl
1257
 3752
1258
 3753
1259
 3754  F80899                	crctb:
1260
 3755  F80899  64 FE         		stz	$fe
1261
 3756  F8089B                	?lp:
1262
 3757  F8089B  A6 FE         		ldx	$fe
1263
 3758  F8089D  E4 FF         		cpx	$ff
1264
 3759  F8089F  B0 1A         		bcs	?end
1265
 3760  F808A1  BF 00 00 10   		lda	>$100000,x
1266
 3761  F808A5  E8            		inx
1267
 3762  F808A6  86 FE         		stx	$fe
1268
 3763
1269
 3764  F808A8  45 95         		eor 	crc16+1 		; Quick CRC computation with lookup tables
1270
 3765  F808AA  AA            	       	tax		 	; updates the two bytes at crc & crc+1
1271
 3766  F808AB  A5 94         	       	lda 	crc16		; with the byte send in the "A" register
1272
 3767  F808AD  5F BC 09 F8   	       	eor 	>crchi,x
1273
 3768  F808B1  85 95         	       	sta 	crc16+1
1274
 3769  F808B3  BF BC 08 F8   	      	lda 	>crclo,x
1275
 3770  F808B7  85 94         	       	sta 	crc16
1276
 3771  F808B9
1277
 3772  F808B9  80 E0         	       	bra	?lp
1278
 3773  F808BB                	?end:
1279
 3774  F808BB  60            		rts			; y=82 on exit
1280
 3775
1281
 3776  F808BC                	crclo
1282
 3777  F808BC  00 21 42 63 84 	 .byte $00,$21,$42,$63,$84,$A5,$C6,$E7,$08,$29,$4A,$6B,$8C,$AD,$CE,$EF
1283
               A5 C6 E7 08 29
1284
               4A 6B 8C AD CE
1285
               EF
1286
 3778  F808CC  31 10 73 52 B5 	 .byte $31,$10,$73,$52,$B5,$94,$F7,$D6,$39,$18,$7B,$5A,$BD,$9C,$FF,$DE
1287
               94 F7 D6 39 18
1288
               7B 5A BD 9C FF
1289
               DE
1290
 3779  F808DC  62 43 20 01 E6 	 .byte $62,$43,$20,$01,$E6,$C7,$A4,$85,$6A,$4B,$28,$09,$EE,$CF,$AC,$8D
1291
               C7 A4 85 6A 4B
1292
               28 09 EE CF AC
1293
               8D
1294
 3780  F808EC  53 72 11 30 D7 	 .byte $53,$72,$11,$30,$D7,$F6,$95,$B4,$5B,$7A,$19,$38,$DF,$FE,$9D,$BC
1295
               F6 95 B4 5B 7A
1296
               19 38 DF FE 9D
1297
               BC
1298
 3781  F808FC  C4 E5 86 A7 40 	 .byte $C4,$E5,$86,$A7,$40,$61,$02,$23,$CC,$ED,$8E,$AF,$48,$69,$0A,$2B
1299
               61 02 23 CC ED
1300
               8E AF 48 69 0A
1301
               2B
1302
 3782  F8090C  F5 D4 B7 96 71 	 .byte $F5,$D4,$B7,$96,$71,$50,$33,$12,$FD,$DC,$BF,$9E,$79,$58,$3B,$1A
1303
  Tue Jul 17 11:00:18 2018                                                                                               Page   22
1304
 
1305
 
1306
 
1307
 
1308
               50 33 12 FD DC
1309
               BF 9E 79 58 3B
1310
               1A
1311
 3783  F8091C  A6 87 E4 C5 22 	 .byte $A6,$87,$E4,$C5,$22,$03,$60,$41,$AE,$8F,$EC,$CD,$2A,$0B,$68,$49
1312
               03 60 41 AE 8F
1313
               EC CD 2A 0B 68
1314
               49
1315
 3784  F8092C  97 B6 D5 F4 13 	 .byte $97,$B6,$D5,$F4,$13,$32,$51,$70,$9F,$BE,$DD,$FC,$1B,$3A,$59,$78
1316
               32 51 70 9F BE
1317
               DD FC 1B 3A 59
1318
               78
1319
 3785  F8093C  88 A9 CA EB 0C 	 .byte $88,$A9,$CA,$EB,$0C,$2D,$4E,$6F,$80,$A1,$C2,$E3,$04,$25,$46,$67
1320
               2D 4E 6F 80 A1
1321
               C2 E3 04 25 46
1322
               67
1323
 3786  F8094C  B9 98 FB DA 3D 	 .byte $B9,$98,$FB,$DA,$3D,$1C,$7F,$5E,$B1,$90,$F3,$D2,$35,$14,$77,$56
1324
               1C 7F 5E B1 90
1325
               F3 D2 35 14 77
1326
               56
1327
 3787  F8095C  EA CB A8 89 6E 	 .byte $EA,$CB,$A8,$89,$6E,$4F,$2C,$0D,$E2,$C3,$A0,$81,$66,$47,$24,$05
1328
               4F 2C 0D E2 C3
1329
               A0 81 66 47 24
1330
               05
1331
 3788  F8096C  DB FA 99 B8 5F 	 .byte $DB,$FA,$99,$B8,$5F,$7E,$1D,$3C,$D3,$F2,$91,$B0,$57,$76,$15,$34
1332
               7E 1D 3C D3 F2
1333
               91 B0 57 76 15
1334
               34
1335
 3789  F8097C  4C 6D 0E 2F C8 	 .byte $4C,$6D,$0E,$2F,$C8,$E9,$8A,$AB,$44,$65,$06,$27,$C0,$E1,$82,$A3
1336
               E9 8A AB 44 65
1337
               06 27 C0 E1 82
1338
               A3
1339
 3790  F8098C  7D 5C 3F 1E F9 	 .byte $7D,$5C,$3F,$1E,$F9,$D8,$BB,$9A,$75,$54,$37,$16,$F1,$D0,$B3,$92
1340
               D8 BB 9A 75 54
1341
               37 16 F1 D0 B3
1342
               92
1343
 3791  F8099C  2E 0F 6C 4D AA 	 .byte $2E,$0F,$6C,$4D,$AA,$8B,$E8,$C9,$26,$07,$64,$45,$A2,$83,$E0,$C1
1344
               8B E8 C9 26 07
1345
               64 45 A2 83 E0
1346
               C1
1347
 3792  F809AC  1F 3E 5D 7C 9B 	 .byte $1F,$3E,$5D,$7C,$9B,$BA,$D9,$F8,$17,$36,$55,$74,$93,$B2,$D1,$F0
1348
               BA D9 F8 17 36
1349
               55 74 93 B2 D1
1350
               F0
1351
 3793
1352
 3794                        	; hi byte CRC lookup table (should be page aligned)
1353
 3795  F809BC                	crchi
1354
 3796  F809BC  00 10 20 30 40 	 .byte $00,$10,$20,$30,$40,$50,$60,$70,$81,$91,$A1,$B1,$C1,$D1,$E1,$F1
1355
               50 60 70 81 91
1356
               A1 B1 C1 D1 E1
1357
               F1
1358
 3797  F809CC  12 02 32 22 52 	 .byte $12,$02,$32,$22,$52,$42,$72,$62,$93,$83,$B3,$A3,$D3,$C3,$F3,$E3
1359
               42 72 62 93 83
1360
               B3 A3 D3 C3 F3
1361
               E3
1362
 3798  F809DC  24 34 04 14 64 	 .byte $24,$34,$04,$14,$64,$74,$44,$54,$A5,$B5,$85,$95,$E5,$F5,$C5,$D5
1363
               74 44 54 A5 B5
1364
               85 95 E5 F5 C5
1365
  Tue Jul 17 11:00:18 2018                                                                                               Page   23
1366
 
1367
 
1368
 
1369
 
1370
               D5
1371
 3799  F809EC  36 26 16 06 76 	 .byte $36,$26,$16,$06,$76,$66,$56,$46,$B7,$A7,$97,$87,$F7,$E7,$D7,$C7
1372
               66 56 46 B7 A7
1373
               97 87 F7 E7 D7
1374
               C7
1375
 3800  F809FC  48 58 68 78 08 	 .byte $48,$58,$68,$78,$08,$18,$28,$38,$C9,$D9,$E9,$F9,$89,$99,$A9,$B9
1376
               18 28 38 C9 D9
1377
               E9 F9 89 99 A9
1378
               B9
1379
 3801  F80A0C  5A 4A 7A 6A 1A 	 .byte $5A,$4A,$7A,$6A,$1A,$0A,$3A,$2A,$DB,$CB,$FB,$EB,$9B,$8B,$BB,$AB
1380
               0A 3A 2A DB CB
1381
               FB EB 9B 8B BB
1382
               AB
1383
 3802  F80A1C  6C 7C 4C 5C 2C 	 .byte $6C,$7C,$4C,$5C,$2C,$3C,$0C,$1C,$ED,$FD,$CD,$DD,$AD,$BD,$8D,$9D
1384
               3C 0C 1C ED FD
1385
               CD DD AD BD 8D
1386
               9D
1387
 3803  F80A2C  7E 6E 5E 4E 3E 	 .byte $7E,$6E,$5E,$4E,$3E,$2E,$1E,$0E,$FF,$EF,$DF,$CF,$BF,$AF,$9F,$8F
1388
               2E 1E 0E FF EF
1389
               DF CF BF AF 9F
1390
               8F
1391
 3804  F80A3C  91 81 B1 A1 D1 	 .byte $91,$81,$B1,$A1,$D1,$C1,$F1,$E1,$10,$00,$30,$20,$50,$40,$70,$60
1392
               C1 F1 E1 10 00
1393
               30 20 50 40 70
1394
               60
1395
 3805  F80A4C  83 93 A3 B3 C3 	 .byte $83,$93,$A3,$B3,$C3,$D3,$E3,$F3,$02,$12,$22,$32,$42,$52,$62,$72
1396
               D3 E3 F3 02 12
1397
               22 32 42 52 62
1398
               72
1399
 3806  F80A5C  B5 A5 95 85 F5 	 .byte $B5,$A5,$95,$85,$F5,$E5,$D5,$C5,$34,$24,$14,$04,$74,$64,$54,$44
1400
               E5 D5 C5 34 24
1401
               14 04 74 64 54
1402
               44
1403
 3807  F80A6C  A7 B7 87 97 E7 	 .byte $A7,$B7,$87,$97,$E7,$F7,$C7,$D7,$26,$36,$06,$16,$66,$76,$46,$56
1404
               F7 C7 D7 26 36
1405
               06 16 66 76 46
1406
               56
1407
 3808  F80A7C  D9 C9 F9 E9 99 	 .byte $D9,$C9,$F9,$E9,$99,$89,$B9,$A9,$58,$48,$78,$68,$18,$08,$38,$28
1408
               89 B9 A9 58 48
1409
               78 68 18 08 38
1410
               28
1411
 3809  F80A8C  CB DB EB FB 8B 	 .byte $CB,$DB,$EB,$FB,$8B,$9B,$AB,$BB,$4A,$5A,$6A,$7A,$0A,$1A,$2A,$3A
1412
               9B AB BB 4A 5A
1413
               6A 7A 0A 1A 2A
1414
               3A
1415
 3810  F80A9C  FD ED DD CD BD 	 .byte $FD,$ED,$DD,$CD,$BD,$AD,$9D,$8D,$7C,$6C,$5C,$4C,$3C,$2C,$1C,$0C
1416
               AD 9D 8D 7C 6C
1417
               5C 4C 3C 2C 1C
1418
               0C
1419
 3811  F80AAC  EF FF CF DF AF 	 .byte $EF,$FF,$CF,$DF,$AF,$BF,$8F,$9F,$6E,$7E,$4E,$5E,$2E,$3E,$0E,$1E
1420
               BF 8F 9F 6E 7E
1421
               4E 5E 2E 3E 0E
1422
               1E
1423
 
1424
 
1425
             Lines Assembled : 3473                  Errors : 0
1426
 
1427
 
1428