Subversion Repositories MB01 Project

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 - 1
  Tue Jul 17 11:00:23 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\FE\kcbm.asm
13
                       Output Filename : obj\FE\kcbm.obj
14
                       Listing Has Been Relocated
15
 
16
 
17
 2584                        	.LIST		on
18
 2585
19
 2586  F8FFB1                		.INCLUDE inc\dirp00.inc
20
 2587                        	;----------------------------------------------------------
21
 2588                        	; DIRP00.ASM
22
 2589                        	; PROGETTO: B1601
23
 2590                        	;
24
 2591                        	; Variabili in Direct Page $00
25
 2592                        	;----------------------------------------------------------
26
 2593
27
 2594                        	; sezione COMMON -- questo permette di includere il file in piu' file
28
 2595
29
 2596                        	.LIST on
30
 2597
31
 2598                        	DIRP00:	.SECTION page0, ref_only, common	;Direct-Page 00
32
 2599
33
 2600  000000                		.ABSOLUTE		;; inizia sempre da $00
34
 2601  000000                		.ORG		0x00
35
 2602  000000
36
 2603  000000  0000          	JiffyClk	.DW			; contatore 10ms 32 bit
37
 2604  000002  0000          			.DW
38
 2605  000004                	SysTmr		.DS	SYSTMRCNT	; system timer 0 (10ms)
39
 2606  000008                	SysTMF		.DS	SYSTMRCNT	; flag timer (80 -> start)
40
 2607  00000C  00            	Bnk0Flag	.DB			; <7>: flag test RAM banco 0 ok
41
 2608                        						; <6>: flag warm reset
42
 2609  00000D  00            	RTCFlag		.DB
43
 2610
44
 2611  00000E                	diskstat	.DS	2	; flag device on ata bus #0 & #1
45
 2612                        					; <7>: device ready
46
 2613                        					; <6>: compact flash device (C.F.)
47
 2614                        					; <5>: device identification ok
48
 2615                        					; <4>: MBR loaded
49
 2616                        					; <3>: valid signature in MBR
50
 2617                        					; <2>: first partition found&active
51
 2618                        					; <1>:
52
 2619                        					; <0>: valid partition flag
53
 2620
54
 2621                        					; <7>: device ready
55
 2622                        					; <6>: USB device
56
 2623                        					; <5>: compact flash device (C.F.)
57
 2624                        					; <4>: device identification ok
58
 2625                        					; <3>: MBR loaded
59
 2626                        					; <2>: first partition found&active
60
 2627                        					; <1>: always 1
61
 2628                        					; <0>: valid partition flag
62
 2629  000010
63
  Tue Jul 17 11:00:23 2018                                                                                               Page    2
64
 
65
 
66
 
67
 
68
 2630
69
 2631          00000E        	atadev		.EQU	diskstat
70
 2632
71
 2633  000010                	usbdev		.DS	2	; flag flash disk on usb bus #0
72
 2634                        					; <7>: device plugged and ready
73
 2635                        					; <6>: always 1
74
 2636                        					; <5>: device identification ok
75
 2637                        					; <4>: MBR loaded
76
 2638                        					; <3>: valid signature in MBR
77
 2639                        					; <2>: first partition found&active
78
 2640                        					; <1>:
79
 2641                        					; <0>: valid partition flag
80
 2642
81
 2643  000012                	diskmax		.DS	16	; disk max. sector's
82
 2644          000012        	atasec		.EQU	diskmax
83
 2645          00001A        	usbsec		.EQU	diskmax+8
84
 2646
85
 2647
86
 2648  000022                	atambr		.DS	8	; data for first partition found in mbr
87
 2649                        					; first 3 bytes for start sector of partition
88
 2650                        					; last byte for partition type
89
 2651  00002A                	usbmbr		.DS	8
90
 2652
91
 2653  000032                	ataprt		.DS	8	; total sec's of first partition
92
 2654  00003A                	usbprt		.DS	8	; total sec's of first partition
93
 2655
94
 2656
95
 2657  000042  00            	usb0ch		.DB	; usb0 (ch375/ch376) flag
96
 2658                        				; <7>: module on
97
 2659                        				; <6>: ch376 flag
98
 2660                        				; <5:0>: chip version
99
 2661
100
 2662  000043  00            	usb0st		.DB	; usb0 status
101
 2663                        				; <7>: usb0 host mode ok
102
 2664                        				; <6>: flash disk attached flag
103
 2665                        				; <5>: usb device attached
104
 2666
105
 2667  000044  00            	fdcdrv		.DB		; phisycal drive status (drive #0)
106
 2668                        					; <7>: disk format established in bit 0&1
107
 2669                        					; <6>: double step seek done
108
 2670                        					; <5>: trust format bit's (set after ok r/w)
109
 2671                        					; <4>: write protect bit (if disk in drive)
110
 2672                        					; <3>: don't care
111
 2673                        					; <2>: don't care
112
 2674                        					; <1>: HD disk if set else DD disk
113
 2675                        					; <0>: CBM format if set else IBM format
114
 2676
115
 2677  000045  00            	vdrive		.DB		; virtual drive status (ram disk, drive #1)
116
 2678                        					; <7>: disk format established in bit 0&1
117
 2679                        					; <6>: change disk simulation (after format)
118
 2680                        					; <5>: don't care
119
 2681                        					; <4>: write protect bit (under sw control)
120
 2682                        					; <3>: don't care
121
 2683                        					; <2>: don't care
122
 2684                        					; <1>: HD disk if set else DD disk
123
 2685                        					; <0>: CBM format if set else IBM format
124
 2686
125
  Tue Jul 17 11:00:23 2018                                                                                               Page    3
126
 
127
 
128
 
129
 
130
 2687  000046  00            	fdcctl		.DB		; fdc controller status
131
 2688                        					; <7>: drive is attached
132
 2689                        					; <6>: drive need recalibration (restore)
133
 2690                        					; <5>: FDC controller ok
134
 2691                        					; <4>: motor on
135
 2692                        					; <3>: dma is active
136
 2693                        					; <2>: dma chip ok (post routine)
137
 2694                        					; <1>: clock rate (1=HD,0=DD)
138
 2695                        					; <0>: disk ready
139
 2696
140
 2697  000047  00            	fdctrk		.DB		; fd: current seek track
141
 2698  000048  00            	fdcerr		.DB		; fd: last error code
142
 2699  000049  00            	ataerr		.DB		; ata: last error code
143
 2700  00004A  00            	ataxer		.DB		; ata: last extended error code
144
 2701
145
 2702  00004B  00            	CtrlBrk		.DB		; flag CTRL+BREAK (NMI)
146
 2703
147
 2704  00004C  0000          	MemTop		.DW		; top memoria RAM
148
 2705  00004E  00            			.DB		; banco top mem
149
 2706
150
 2707  00004F  00            	DflTxtIn	.DB		; device di default text input
151
 2708  000050  00            	DflTxtOut	.DB		; device di default text output
152
 2709
153
 2710  000051                	COPPtr		LP		; long pointer for COP decoding
154
 2711  000054  00            	COPIdx		.DB		; COP signature/index
155
 2712
156
 2713  000055  00            	BiosEnt		.DB		; flag accesso a bios setup
157
 2714
158
 2715                        	; variabili utilizzate da ACIA
159
 2716  000056                	spwrk		.DS	$30
160
 2717
161
 2718                        	; bios mem
162
 2719  000086  0000          	nsize		.DW	; dimensione blocco da allocare
163
 2720                        	;bsize		.DW	; dimensione vera blocco free
164
 2721  000088  0000          	splitsz		.DW	; dimensione blocco splittato
165
 2722  00008A  0000          	bfree		.DW	; puntatore blocco free
166
 2723  00008C  0000          	hdrptr		.DW	; puntatore header heap
167
 2724
168
 2725  00008E  0000          	pbrklv		.DW	; current break level of current process
169
 2726  000090  0000          	pbrkmin		.DW	; minimum breal level of current process
170
 2727  000092  0000          	pbrkmax		.DW	; maximum breal level of current process
171
 2728  000094
172
 2729                        	; bios temp. work area
173
 2730  000094                	bwrktmp		.DS	$28
174
 2731
175
 2732  0000BC  00            	coptmp		.DB	; temp. used while cop
176
 2733
177
 2734  0000BD  00            	tstser		.DB	; check ser/usb test board post
178
 2735                        				; <7>: VIA2 ok
179
 2736                        				; <6>: PICRAM ok
180
 2737                        				; <1>: UART 16C550 ok
181
 2738                        				; <0>: R65C51 ok
182
 2739
183
 2740
184
 2741                        	;crc16		.DW
185
 2742
186
 2743  0000BD                		.RELATIVE
187
  Tue Jul 17 11:00:23 2018                                                                                               Page    4
188
 
189
 
190
 
191
 
192
 2744
193
 2745                        		.ENDS
194
 2746
195
 2747          [01]          	.IFDEF		_ACIA_INC_
196
 2748                        		.INCLUDE INC\SP.INC
197
 2749          [00]          	.ENDIF
198
 2750
199
 2753                        		.LIST on
200
 2754  F8FFB1                		.INCLUDE inc\dpcbm.inc
201
 2755                        	;; cbm emulation
202
 2756
203
 2757                        	;;CBMP0	.EQU	$7F00
204
 2758
205
 2759                        	; sezione COMMON -- questo permette di includere il file in piu' file
206
 2760
207
 2761                        	DPCBM:	.SECTION page0, ref_only, common
208
 2762
209
 2763  000000                		.ABSOLUTE		;; inizia sempre da $00
210
 2764  000000                		.ORG	0x00
211
 2765
212
 2766                        	;;MAXLF	.EQU	$10		; max. logical files
213
 2767          00000B        	MAXLF	.EQU	11		; max. logical files
214
 2768          000008        	MAXVIEC	.EQU	8		; max. virtual iec device #
215
 2769  000000                			.DS	16
216
 2770  000010
217
 2771  000010  00            	subflg		.DB	; ($10)
218
 2772  000011  00            			.DB	; ($11)
219
 2773  000012  00            			.DB	; ($12)
220
 2774  000013  00            			.DB	; ($13)
221
 2775  000014  0000          	lineno		.DW	; ($14-$15) line number used by editor
222
 2776  000016  00            	tmppt		.DB	; ($16)
223
 2777  000017  00            	tcnt		.DB	; ($17) temp. counter/index
224
 2778  000018  0000          			.DW	; ($18-$19)
225
 2779  00001A  0000          			.DW	; ($1A-$1B)
226
 2780  00001C  0000          			.DW	; ($1C-$1D)
227
 2781  00001E  0000          			.DW	; ($1E-$1F)
228
 2782  000020  00            			.DB	; ($20)
229
 2783
230
 2784                        	; basic/p-code virtual machine work area
231
 2785  000021  0000          			.DW	; ($21-$22)
232
 2786  000023  0000          			.DW	; ($23-$24)
233
 2787  000025  0000          			.DW	; ($25-$26)
234
 2788  000027  0000          			.DW	; ($27-$28)
235
 2789  000029  0000          			.DW	; ($29-$2A)
236
 2790  00002B  0000          			.DW	; ($2B-$2C)
237
 2791  00002D  0000          			.DW	; ($2D-$2E)
238
 2792  00002F  0000          	arytab		.DW	; ($2F-$30)
239
 2793  000031  0000          	strend		.DW	; ($31-$32)
240
 2794  000033  0000          	freetop		.DW	; ($33-$34)
241
 2795  000035  0000          	freespc		.DW	; ($35-$36)
242
 2796  000037  0000          	memsiz		.DW	; ($37-$38)
243
 2797  000039  0000          	curline		.DW	; ($39-$3A) current line number in execution
244
 2798  00003B  0000          	oldline		.DW	; ($3B-$3C) previous line number in execution
245
 2799  00003D  0000          	oldtxt		.DW	; ($3D-$3E) saved pointer to text in basic execution
246
 2800  00003F  0000          	datlin		.DW	; ($3F-$40)
247
 2801  000041  0000          	datptr		.DW	; ($41-$42)
248
 2802  000043  0000          	inpptr		.DW	; ($43-$44)
249
  Tue Jul 17 11:00:23 2018                                                                                               Page    5
250
 
251
 
252
 
253
 
254
 2803  000045  0000          	varnam		.DW	; ($45-$46)
255
 2804  000047  0000          	varpnt		.DW	; ($47-$48)
256
 2805  000049  0000          	forpnt		.DW	; ($49-$4A) basic
257
 2806  00004B  0000          	opptr		.DW	; ($4B-$4C) basic
258
 2807  00004D  00            	opmask		.DB	; ($4D)
259
 2808  00004E  0000          	defpnt		.DW	; ($4E-$4F)
260
 2809  000050  0000          	dscpnt		.DW	; ($50-$51)
261
 2810  000052  00            	dsclen		.DB	; ($52)
262
 2811  000053  00            	prompt		.DB	; ($53) prompt flag/CMD channel - editor/basic ($13)
263
 2812
264
 2813                        	; equates for p-code virtual machine
265
 2814          00003B        	prtrap		.EQU	oldline		; ($3B) p-code trap errors flag
266
 2815          00003C        	pcstack		.EQU	oldline+1	; ($3C-$3D) p-code save stack
267
 2816          00003E        	prterr		.EQU	oldtxt+1	; ($3E) p-code run time error number
268
 2817          00003F        	psrline		.EQU	datlin		; ($3F-$40) pascal source line number
269
 2818          000041        	prseed		.EQU	datptr		; ($41-$42) p-code random generator
270
 2819          000043        	pbrkcnt		.EQU	inpptr		; ($43) p-code counter for break check
271
 2820          000044        	tmpy		.EQU	inpptr+1	; ($44) p-code temp. for save Y
272
 2821          000045        	inqidx		.EQU	varnam		; ($45) p-code index to input buffer
273
 2822          000046        	inqcnt		.EQU	varnam+1	; ($46) p-code input buffer counter
274
 2823          000047        	tmpv1		.EQU	varpnt		; ($47) p-code temp.
275
 2824          000048        	tmpv2		.EQU	varpnt+1	; ($48) p-code temp.
276
 2825          000049        	tmpa		.EQU	forpnt		; ($49) p-code temp. save A
277
 2826          00004A        	tmpwa		.EQU	forpnt+1	; ($4A) p-code tmp. save byte to write
278
 2827          00004B        	tmpx		.EQU	opptr		; ($4B) p-code tmp. save X when print
279
 2828          00004C        	pcterr		.EQU	opptr+1		; ($4C) p-code compiler error flag
280
 2829          00004D        	tmpdsk		.EQU	opmask		; ($4D) p-code default temp. disk unit
281
 2830          00004E        	defprn		.EQU	defpnt		; ($4E) p-code default printer #device
282
 2831          00004F        	pcdbg		.EQU	defpnt+1	; ($4F) p-code debug run after error
283
 2832          000050        	pcptr		.EQU	dscpnt		; ($50-$51) pointer to p-code (debug)
284
 2833          000052        	autolf		.EQU	dsclen		; ($52) p-code auto line feed flag
285
 2834
286
 2835  000054                	tmpwrk		.DS 4	; ($54-$57) temp. area editor/virtual iec
287
 2836  000058  00            	tmpb0		.DB	; ($58)
288
 2837  000059  00            	argbits		.DB	; ($59)	    FAC #1 guard bits
289
 2838  00005A  00            	tmpb2		.DB	; ($5A) tmp. byte - used by fpu
290
 2839  00005B  00            	txtlen		.DB	; ($5B) tmp. word length of text to insert in buffer
291
 2840  00005C  00            	tmpb1		.DB	; ($5C) tmp. byte used by editor and float point unit
292
 2841  00005D  0000          	tmpval		.DW	; ($5D-$5E) temp. word used by editor/fpu
293
 2842  00005F  0000          	tlnptr		.DW	; ($5F-$60) temp. line text pointer used by editor/fpu
294
 2843  000061  00            	facexp		.DB	; ($61)     FAC #1 exponent
295
 2844  000062                	facm		.DS 4	; ($62-$65) FAC #1 mantissa
296
 2845  000066  00            	facsgn		.DB	; ($66)     FAC #1 sign
297
 2846  000067  00            	sercnt		.DB	; ($67)     FAC #1 series evaluation
298
 2847  000068  00            	facov		.DB	; ($68)     FAC #1 overflow
299
 2848  000069  00            	argexp		.DB	; ($69)     FAC #2 exponent
300
 2849  00006A                	argm		.DS 4	; ($6A-$6D) FAC #2 mantissa
301
 2850  00006E  00            	argsgn		.DB	; ($6E)     FAC #2 sign
302
 2851  00006F  00            	arisgn		.DB	; ($6F)     FAC #1 & #2 sign comparison
303
 2852  000070  00            	facbits		.DB	; ($70)	    FAC #1 guard bits
304
 2853  000071  0000          	fbufpt		.DW	; ($71-$72) FAC series evaluation pointer
305
 2854  000073  00            	fbufpt2		.DB	; ($73)	    FAC series evaluation bank (progr. bank)
306
 2855
307
 2856                        	; tmp. variables (equates) used by float point unit
308
 2857          000054        	factmp		.EQU	tmpwrk		; ($54-$57) used by fpu mult/div
309
 2858          00005A        	cprmsk		.EQU	tmpb2		; ($5A) used by trigs. funcs.
310
 2859          00005B        	faclsb		.EQU	txtlen		; ($5B) used by float point unit
311
  Tue Jul 17 11:00:23 2018                                                                                               Page    6
312
 
313
 
314
 
315
 
316
 2860          00005D        	dccnt		.EQU	tmpval		; ($5D) digit count after decimal dot
317
 2861          00005E        	expval		.EQU	tmpval+1 	; ($5E) exponent value when convert
318
 2862          00005F        	dotfg		.EQU	tlnptr		; ($5F) flag decimal dot when convert
319
 2863          000060        	expsgn		.EQU	tlnptr+1 	; ($60) flag exponent sign when conver
320
 2864          000067        	sgnfg		.EQU	sercnt		; ($67) flag: minus sign when convert
321
 2865          000071        	decidx		.EQU	fbufpt		; ($71) string index when convert
322
 2866          000072        	s2fer		.EQU	fbufpt+1	; ($72) string to float flag error
323
 2867          000073        	decidx2		.EQU	fbufpt+2	; ($73) used when convert float to str
324
 2868
325
 2869  000074  0000          	s2fstk		.DW	; ($74-$75) save stack when string to float conversion
326
 2870  000076                	longp		LP	; ($76-$77-$78) temp. long pointer
327
 2871  000079  00            	s2fptr		.DB	; ($79) flag trap overflow err. string to float conv.
328
 2872
329
 2873  00007A  0000          	txtp		.DW	; ($7A-$7B) current pointer to text
330
 2874  00007C  00            	pcdsk		.DB	; ($7C) flag for pascal compiler
331
 2875                        				; <7> : compile in memory
332
 2876
333
 2877  00007D                	iecrp		LP	; ($7D) iec: pointer to read buffer for include file
334
 2878  000080  00            	iecalt		.DB	; ($80) iec: flag read from include file
335
 2879  000081                	iectp		LP	; ($81) iec: pointer to read main text buffer
336
 2880  000084  00            	iecndx		.DB	; ($84) iec: index main text buffer
337
 2881  000085  00            	ieceof		.DB	; ($85) iec: end of file flag main text buffer
338
 2882  000086                	iecwp		LP	; ($86) iec: pointer to write buffer
339
 2883  000089  00            	iecfg		.DB	; ($89)	iec: flag main text buffer
340
 2884  00008A  0000          	iecndx2		.DW	; ($8A) iec: index buffer include file
341
 2885  00008C  00            	iecbuf		.DB	; ($8C) iec: byte buffer
342
 2886  00008D  00            	svbnk		.DB	; ($8D) save vbnk when run pascal compiler
343
 2887  00008E  00            	ieceof2		.DB	; ($8E) iec: flag eof include file
344
 2888  00008F  00            	vxflag		.DB	; ($8F) flag valid text in x-bank
345
 2889  000090  00            	kstat		.DB	; ($90) CBM emulated IEC status
346
 2890  000091  00            	errno		.DB	; ($91) saved error number
347
 2891  000092  00            	keyfg		.DB	; ($92) keyboard flag: KbdFlag
348
 2892  000093  00            	keyctl		.DB	; ($93) flag control key from get key
349
 2893  000094  00            	keysh		.DB	; ($94) flag keyboard: KbdShift
350
 2894  000095  00            	keytg		.DB	; ($95) flag keyboard: KbdToggle
351
 2895  000096  00            	basic		.DB	; ($96) flag current 'basic' mode
352
 2896                        				; 	<7>: flag basic mode
353
 2897                        				; 	<6>: flag pascal compiler running
354
 2898  000097  00            	runf		.DB	; ($97) flag current run mode
355
 2899  000098  00            	ldtnd		.DB	; ($98) number of open files
356
 2900  000099  00            	dfltn		.DB	; ($99) default input device
357
 2901  00009A  00            	dflto		.DB	; ($9A) default output device
358
 2902  00009B  00            	skpbk		.DB	; ($9B) skip blank flag
359
 2903  00009C  00            	w2sf		.DB	; ($9C) integer to string flag conversion
360
 2904  00009D  00            	msgflg		.DB	; ($9D) flag message
361
 2905  00009E  00            	autof		.DB	; ($9E) flag auto-increment line numbering
362
 2906  00009F  0000          	wauto		.DW	; ($9F-$A0) auto-increment for line numbering
363
 2907  0000A1  00            	tbnk		.DB	; ($A1) bank that hold basic/pascal text
364
 2908  0000A2  00            	vbnk		.DB	; ($A2) bank that hold basic var/pascal pcode-stack
365
 2909  0000A3  00            	cbnk		.DB	; ($A3) compiler bank/temp. bank for exchange
366
 2910  0000A4  00            	jbnk		.DB	; ($A4) bank for obj, when compiling (3 bank max.)
367
 2911  0000A5  00            	xbnk		.DB	; ($A5) exchange bank for text buffer
368
 2912  0000A6  00            	dbnk		.DB	; ($A6) bank for ram disk (jbnk + 3)
369
 2913  0000A7  0000          	botmem		.DW	; ($A7-$A8) start of memory on the text bank
370
 2914  0000A9  0000          	topmem		.DW	; ($A9-$AA) top of memory on the text bank
371
 2915  0000AB  0000          	txtbeg		.DW	; ($AB-$AC) begin of text buffer
372
 2916  0000AD  0000          	txtend		.DW	; ($AD-$AE) end of text buffer + 1
373
  Tue Jul 17 11:00:23 2018                                                                                               Page    7
374
 
375
 
376
 
377
 
378
 2917  0000AF  0000          	txttop		.DW	; ($AF-$B0) top of memory + 1 reserved to text buffer
379
 2918  0000B1  0000          	varbeg		.DW	; ($B1-$B2) start of basic var/pcode
380
 2919  0000B3  0000          	vartop		.DW	; ($B3-$B4) top of basic var/pcode + 1
381
 2920  0000B5  0000          	xtop		.DW	; ($B5-$B6) top of text + 1 in x-bank
382
 2921  0000B7  00            	fnlen		.DB	; ($B7) length of current filename
383
 2922  0000B8  00            	lacur		.DB	; ($B8) current logical file number
384
 2923  0000B9  00            	sacur		.DB	; ($B9) current secondary address
385
 2924  0000BA  00            	facur		.DB	; ($BA) current device number
386
 2925  0000BB  0000          	fnadr		.DW	; ($BB-$BC) pointer to current filename
387
 2926  0000BD  00            	fnadr2		.DB	; ($BD) - bank that hold file name
388
 2927  0000BE  00            	objdsk		.DB	; ($BE) compiler: option '1' specified
389
 2928  0000BF  00            	truedsk		.DB	; ($BF) true disk for load pascal soource file
390
 2929  0000C0  0000          	curstk		.DW	; ($C0-$C1) current stack when in edit mode
391
 2930  0000C2  00            	pcodef		.DB	; ($C2) flag p-code present for execution
392
 2931
393
 2932  0000C3                	latb		.DS	MAXLF		; logical files table
394
 2933  0000CE                	fatb		.DS	MAXLF		; devices numbers table
395
 2934  0000D9                	satb		.DS	MAXLF		; secondary addresses table
396
 2935
397
 2936                        	;=============================================================
398
 2937
399
 2938  0000E4  0000          	cmdlin		.DW	; command line ptr for pscal program
400
 2939  0000E6  00            	fpcflag		.DB	; fpc flags (new style)
401
 2940                        				; <7>: new style compiler
402
 2941                        				; <6>: no save exec. file
403
 2942                        				; <5>: save obj. file
404
 2943
405
 2944  0000E6                		.RELATIVE
406
 2945                        		.ENDS
407
 2946
408
 2947                        	; basic work area starting at $FF00 of bank that hold text buffer
409
 2948                        	CBMHIM:	.SECTION ref_only, common
410
 2949  000000                		.ABSOLUTE
411
 2950  00FF00                		.ORG	$FF00
412
 2951                        	;	.ORG	0
413
 2952
414
 2953          0000A2        	TBUFMAX		.EQU	$A2	; size of input buffer
415
 2954          00AA55        	VALIDSGN	.EQU	$AA55	; valid signature
416
 2955
417
 2956  00FF00                	cbmwork		.DS	4	; first 4 bytes free for insert text line
418
 2957  00FF04                	TXTBUF		.DS	TBUFMAX	; input buffer for text insertion
419
 2958  00FFA6                	NUMSTR		.DS	32	; room for numeric string
420
 2959
421
 2960  00FFC6  0000          	TMPPTR		.DW		; temp. pointer
422
 2961  00FFC8  0000          			.DW
423
 2962  00FFCA  0000          			.DW
424
 2963  00FFCC  0000          			.DW
425
 2964  00FFCE  0000          			.DW
426
 2965  00FFD0                	GFNAME		.DS	32	; global file name
427
 2966  00FFF0                			.DS	8
428
 2967  00FFF8
429
 2968                        		;;.ORG	$FFF8
430
 2969  00FFF8  0000          	TXTEND2		.DW		; saved text end + 1
431
 2970  00FFFA  0000          	TXTVSGN		.DW		; valid text buffer signature
432
 2971  00FFFC  0000          	XTOP2		.DW		; saved text end + 1 in exchange bank
433
 2972  00FFFE  0000          	XBVSGN		.DW		; valid x-bank buffer signature
434
 2973
435
  Tue Jul 17 11:00:23 2018                                                                                               Page    8
436
 
437
 
438
 
439
 
440
 2974  00FFFE                		.RELATIVE
441
 2975                        		.ENDS
442
 2976
443
 2977                        	.COMMENT @
444
 2978                        	cbmwork		.EQU	$FF00	; first 4 bytes free for insert text line
445
 2979                        	TXTBUF		.EQU	$FF04	; input buffer for text insertion
446
 2980                        	NUMSTR		.EQU	$FFA6	; room for numeric string
447
 2981
448
 2982                        	TMPPTR		.EQU	$FFC6		; temp. pointer
449
 2983
450
 2984                        	TXTEND2		.EQU	$FFF8		; saved text end + 1
451
 2985                        	TXTVSGN		.EQU	$FFFA		; valid text buffer signature
452
 2986                        	XTOP2		.EQU	$FFFC		; saved text end + 1 in exchange bank
453
 2987                        	XBVSGN		.EQU	$FFFE		; valid x-bank buffer signature
454
 2988                        	@
455
 2989
456
 2990                        	; basic/pascal work area starting at $FF00 of bank that hold variables/p-code
457
 2991                        	CBMHIV:	.SECTION common, ref_only
458
 2992  000000                		.ABSOLUTE
459
 2993  00FF00                		.ORG	$FF00
460
 2994                        	;	.ORG	0
461
 2995
462
 2996          00005A        	QINSIZ		.EQU	$5A	; input buffer max. 90 chars.
463
 2997          000020        	NUMSIZ		.EQU	$20	; size of numeric buffer for conversion
464
 2998          000018        	MAX2LF		.EQU	((MAXLF + 1) * 2) ; size of p-code logical files table
465
 2999          000013        	MAXFNLEN	.EQU	19	; max. length of file name '@x:yyyyyyyyyyyyyyyy'
466
 3000
467
 3001  00FF00                	MINBUF		.DS	QINSIZ
468
 3002  00FF5A                	MNUMSTR		.DS	NUMSIZ
469
 3003  00FF7A  0000          	MTMPW0		.DW
470
 3004  00FF7C  0000          	MTMPW1		.DW
471
 3005  00FF7E  00            	MTMPB0		.DB
472
 3006  00FF7F                	MFNAME		.DS	16	; file name buffer
473
 3007  00FF8F                	MTMPNAM		.DS	15	; tmp. file name
474
 3008  00FF9E                	MPOW10		.DS	10	; power of 10 table
475
 3009  00FFA8                	MTRUE		.DS	6
476
 3010  00FFAE                	MFALSE		.DS	6
477
 3011  00FFB4                	MSTDF0		.DS	4	; descriptor for file #0 (consolle)
478
 3012  00FFB8                	MSTDF1		.DS	4	; descriptor for file #1 (disk command chann.)
479
 3013  00FFBC                	MSTDF2		.DS	4	; descriptor for file #2 (used by compiler)
480
 3014  00FFC0                	MMSET		.DS	16	; set variables
481
 3015  00FFD0                	MFILET		.DS	MAX2LF	; table of logical files: #0 consolle, #1 disk
482
 3016  00FFE8                	FAC1TMP		.DS	5	; these 3 used by float routines
483
 3017  00FFED                	FAC2TMP		.DS	5
484
 3018  00FFF2                	FAC3TMP		.DS	5
485
 3019  00FFF7                	FAC4TMP		.DS	5	; free to use
486
 3020  00FFFC  0000          	MTPTR		.DW		; used by new/dispose
487
 3021  00FFFE  0000          	MTMPW2		.DW
488
 3022
489
 3023  00FFFE                		.RELATIVE
490
 3024                        		.ENDS
491
 3025
492
 3026                        	.COMMENT @
493
 3027                        	MINBUF		.EQU	$FF00
494
 3028                        	MNUMSTR		.EQU	$FF5A
495
 3029                        	MTMPW0		.EQU	$FF7A
496
 3030                        	MTMPW1		.EQU	$FF7C
497
  Tue Jul 17 11:00:23 2018                                                                                               Page    9
498
 
499
 
500
 
501
 
502
 3031                        	MTMPB0		.EQU	$FF7E
503
 3032                        	MFNAME		.EQU	$FF7F	; file name buffer
504
 3033                        	MTMPNAM		.EQU	$FF8F	; tmp. file name
505
 3034                        	MPOW10		.EQU	$FF9E	; power of 10 table
506
 3035                        	MTRUE		.EQU	$FFA8
507
 3036                        	MFALSE		.EQU	$FFAE
508
 3037                        	MSTDF0		.EQU	$FFB4	; descriptor for file #0 (consolle)
509
 3038                        	MSTDF1		.EQU	$FFB8	; descriptor for file #1 (disk command chann.)
510
 3039                        	MSTDF2		.EQU	$FFBC	; descriptor for file #2 (used by compiler)
511
 3040                        	MMSET		.EQU	$FFC0	; set variables
512
 3041                        	MFILET		.EQU	$FFD0	; table of logical files: #0 consolle, #1 disk
513
 3042                        	FAC1TMP		.EQU	$FFE8	; these 3 used by float routines
514
 3043                        	FAC2TMP		.EQU	$FFED
515
 3044                        	FAC3TMP		.EQU	$FFF2
516
 3045                        	FAC4TMP		.EQU	$FFF7	; free to use
517
 3046                        	MTPTR		.EQU	$FFFC	; used by new/dispose
518
 3047                        	MTMPW2		.EQU	$FFFE
519
 3048                        	@
520
 3049
521
 3050                        	; temp. file names in x-bank
522
 3051          00FF00        	PASSRC		.EQU	$FF00
523
 3052          00FF20        	OBJDST		.EQU	$FF20
524
 3053          00FF40        	EXEDST		.EQU	$FF40
525
 3054          00FF60        	OBJDEL		.EQU	$FF60
526
 3055
527
 3056
528
 3057                        		.CODEFE
529
 3058                        		.LONGA off
530
 3059                        		.LONGI off
531
 3060
532
 3061                        		.EXTERN cbm_new2, cbm_res, cbm_rdy
533
 3062                        		.EXTERN vlsnopn, vsndcmd, vunlsnopn, viec8lsn, viec8tlk
534
 3063                        		.EXTERN viec8put, viec8get, v8unlsn, v8untlk, v8close
535
 3064                        		.EXTERN vopnlst
536
 3065
537
 3066                        	;---------------------------------------------------------------------------
538
 3067                        	; serial comm device
539
 3068                        	;---------------------------------------------------------------------------
540
 3069
541
 3070                        	; A = device #
542
 3071  FE9DAB                	seropen:
543
 3072  FE9DAB  A9 05         		lda	#$05
544
 3073  FE9DAD  38            		sec
545
 3074  FE9DAE  60            		rts
546
 3075
547
 3076  FE9DAF                	serclose:
548
 3077  FE9DAF  60            		rts
549
 3078
550
 3079                        	;---------------------------------------------------------------------------
551
 3080
552
 3081  FE9DB0                	iecopen:
553
 3082  FE9DB0  C9 08         		cmp	#$08
554
 3083  FE9DB2  90 13         		bcc	?er5
555
 3084  FE9DB4  24 7C         		bit	pcdsk
556
 3085  FE9DB6  30 13         		bmi	?pcc		; compiler in memory mode
557
 3086  FE9DB8  24 E6         		bit	fpcflag
558
 3087  FE9DBA  10 08         		bpl	?real		; old style: always on disk
559
  Tue Jul 17 11:00:23 2018                                                                                               Page   10
560
 
561
 
562
 
563
 
564
 3088  FE9DBC  A5 B9         		lda	sacur
565
 3089  FE9DBE  29 0F         		and	#$0F
566
 3090  FE9DC0  C9 04         		cmp	#4
567
 3091  FE9DC2  F0 13         		beq	?obj		; new style: obj. file in memory
568
 3092  FE9DC4  4C 4E 9E      	?real:	jmp	?dsk		; open real disk
569
 3093  FE9DC7  A9 05         	?er5:	lda	#$05
570
 3094  FE9DC9  38            		sec
571
 3095  FE9DCA  60            		rts
572
 3096  FE9DCB  A5 B9         	?pcc:	lda	sacur		; pascal compiler
573
 3097  FE9DCD  29 0F         		and	#$0F
574
 3098  FE9DCF  C9 0F         		cmp	#$0F
575
 3099  FE9DD1  F0 0C         		beq	?end0
576
 3100  FE9DD3  C9 04         		cmp	#$04		; obj. file?
577
 3101  FE9DD5  D0 0A         		bne	?tst		; no
578
 3102  FE9DD7  64 86         	?obj:	stz	iecwp		; setup buffer pointer for write obj. file
579
 3103  FE9DD9  64 87         		stz	iecwp+1
580
 3104  FE9DDB  A5 A4         		lda	jbnk		; obj. code in j-bank
581
 3105  FE9DDD  85 88         		sta	iecwp+2
582
 3106  FE9DDF  18            	?end0:	clc
583
 3107  FE9DE0  60            	?end:	rts
584
 3108  FE9DE1  C9 03         	?tst:	cmp	#$03		; read main source file?
585
 3109  FE9DE3  D0 18         		bne	?inc		; no
586
 3110  FE9DE5                		ACC16
587
 3111  FE9DE5  C2 20         		rep	#PMFLAG
588
 3112                        		.LONGA	on
589
 3113                        		.MNLIST
590
 3114  FE9DE7  A5 AB         		lda	txtbeg		; pointer to main text buffer
591
 3115  FE9DE9  85 81         		sta	iectp
592
 3116  FE9DEB  A4 A1         		ldy	tbnk		; bank
593
 3117  FE9DED  84 83         		sty	iectp+2
594
 3118  FE9DEF  A7 81         		lda	[iectp]		; check end of text
595
 3119  FE9DF1                		ACC08
596
 3120  FE9DF1  E2 20         		sep	#PMFLAG
597
 3121                        		.LONGA	off
598
 3122                        		.MNLIST
599
 3123  FE9DF3  F0 10         		beq	?er4		; empty buffer
600
 3124  FE9DF5  64 85         		stz	ieceof		; clear eof flag
601
 3125  FE9DF7  64 89         		stz	iecfg		; clear internal eof flag
602
 3126  FE9DF9  64 84         		stz	iecndx		; clear index
603
 3127  FE9DFB  18            		clc
604
 3128  FE9DFC  60            		rts
605
 3129  FE9DFD  C9 05         	?inc	cmp	#$05		; an include file?
606
 3130  FE9DFF  F0 08         		beq	?inc2		; yes
607
 3131  FE9E01  A9 06         		lda	#$06		; 'not input file' error
608
 3132  FE9E03  38            		sec
609
 3133  FE9E04  60            		rts
610
 3134  FE9E05  A9 04         	?er4:	lda	#$04		; 'file not found' error ($04)
611
 3135  FE9E07  38            		sec
612
 3136  FE9E08  60            		rts
613
 3137  FE9E09  64 7D         	?inc2:	stz	iecrp		; clear buffer pointer
614
 3138  FE9E0B  64 7E         		stz	iecrp+1
615
 3139  FE9E0D  A5 A6         		lda	dbnk
616
 3140  FE9E0F  85 7F         		sta	iecrp+2
617
 3141                        		;stz	iecalt		; include file flag
618
 3142  FE9E11  64 8E         		stz	ieceof2		; include fuile eof flag
619
 3143  FE9E13  64 8A         		stz	iecndx2		; buffer index
620
 3144  FE9E15  64 86         		stz	iecndx+2
621
  Tue Jul 17 11:00:23 2018                                                                                               Page   11
622
 
623
 
624
 
625
 
626
 3145  FE9E17
627
 3146                        		; open include file
628
 3147  FE9E17  DA            		phx
629
 3148  FE9E18  A5 BD         		lda	fnadr2		; set fname pointer
630
 3149  FE9E1A  48            		pha
631
 3150  FE9E1B  D4 BB         		pei	(fnadr)		; address of cmnd string
632
 3151  FE9E1D  A9 0E         		lda	#$0E
633
 3152  FE9E1F  48            		pha			; chnl
634
 3153  FE9E20                		CBMFSCMD		; send command
635
 3154  FE9E20  02 80         		cop	FN_CBMFSCMD
636
 3155                        		.MNLIST
637
 3156  FE9E22  FA            		plx
638
 3157  FE9E23  B0 E0         		bcs	?er4		; if error
639
 3158  FE9E25  DA            		phx
640
 3159  FE9E26  A5 7F         		lda	iecrp+2		; bank of buffer
641
 3160  FE9E28  48            		pha
642
 3161  FE9E29  D4 7D         		pei	(iecrp)		; address of buffer
643
 3162  FE9E2B  F4 FE FF      		pea	#$FFFE		; buffer size
644
 3163  FE9E2E  A9 0E         		lda	#$0E		; chnl
645
 3164  FE9E30  48            		pha
646
 3165  FE9E31                		CBMFSRD			; read buffer
647
 3166  FE9E31  02 81         		cop	FN_CBMFSRW
648
 3167  FE9E33  00            		.DB	$00
649
 3168                        		.MNLIST
650
 3169  FE9E34  08            		php
651
 3170  FE9E35  85 76         		sta	longp		; size
652
 3171  FE9E37  EB            		xba
653
 3172  FE9E38  85 77         		sta	longp+1
654
 3173  FE9E3A  A9 0E         		lda	#$0E
655
 3174  FE9E3C                		CBMFSCLS		; close chnl
656
 3175  FE9E3C  02 82         		cop	FN_CBMFSCLS
657
 3176                        		.MNLIST
658
 3177  FE9E3E  28            		plp
659
 3178  FE9E3F  FA            		plx
660
 3179  FE9E40  B0 C3         		bcs	?er4		; error
661
 3180  FE9E42                		INDEX16
662
 3181  FE9E42  C2 10         		rep	#PXFLAG
663
 3182                        		.LONGI	on
664
 3183                        		.MNLIST
665
 3184  FE9E44  A4 76         		ldy	longp
666
 3185  FE9E46  A9 00         		lda	#0
667
 3186  FE9E48  97 7D         		sta	[iecrp],y
668
 3187  FE9E4A                		INDEX08
669
 3188  FE9E4A  E2 10         		sep	#PXFLAG
670
 3189                        		.LONGI	off
671
 3190                        		.MNLIST
672
 3191  FE9E4C  18            		clc
673
 3192  FE9E4D  60            		rts
674
 3193
675
 3194                        	; real disk open
676
 3195  FE9E4E                	?dsk:
677
 3196  FE9E4E  DA            		phx
678
 3197  FE9E4F  A5 B9         		lda	sacur
679
 3198  FE9E51  29 0F         		and	#$0F
680
 3199  FE9E53  AA            		tax			; x = sa
681
 3200  FE9E54  A4 B7         		ldy	fnlen
682
 3201  FE9E56  D0 10         		bne	?sz		; string not empty
683
  Tue Jul 17 11:00:23 2018                                                                                               Page   12
684
 
685
 
686
 
687
 
688
 3202  FE9E58  E0 0F         		cpx	#$0F
689
 3203  FE9E5A  F0 18         		beq	?ret		; command without string
690
 3204  FE9E5C  A9 D0         		lda	#<GFNAME	; set dummy string pointer
691
 3205  FE9E5E  85 BB         		sta	fnadr
692
 3206  FE9E60  A9 FF         		lda	#>GFNAME
693
 3207  FE9E62  85 BC         		sta	fnadr+1
694
 3208  FE9E64  A5 A1         		lda	tbnk
695
 3209  FE9E66  85 BD         		sta	fnadr+2
696
 3210  FE9E68  A9 00         	?sz:	lda	#0
697
 3211  FE9E6A  97 BB         		sta	[fnadr],y	; terminate string
698
 3212  FE9E6C  A5 BD         		lda	fnadr+2		; param 1: command string
699
 3213  FE9E6E  48            		pha
700
 3214  FE9E6F  D4 BB         		pei	(fnadr)
701
 3215  FE9E71  DA            		phx			; channel
702
 3216  FE9E72                		CBMFSCMD		; send command (ignore error)
703
 3217  FE9E72  02 80         		cop	FN_CBMFSCMD
704
 3218                        		.MNLIST
705
 3219  FE9E74  FA            	?ret:	plx
706
 3220  FE9E75  B0 08         		bcs	?ext
707
 3221  FE9E77  E0 0F         		cpx	#$0F
708
 3222  FE9E79  F0 04         		beq	?ext
709
 3223  FE9E7B  22 EC 2A F9   		jsl	vopnlst
710
 3224  FE9E7F  18            	?ext:	clc
711
 3225  FE9E80  60            		rts
712
 3226  FE9E81
713
 3227  FE9E81                	iecclose:
714
 3228  FE9E81  A5 BA         		lda	facur
715
 3229  FE9E83  C9 08         		cmp	#$08
716
 3230  FE9E85  90 17         		bcc	?end		; no disk device
717
 3231  FE9E87  A5 B9         		lda	sacur
718
 3232  FE9E89  29 0F         		and	#$0F
719
 3233  FE9E8B  C9 0F         		cmp	#$0F
720
 3234  FE9E8D  F0 0E         		beq	?clc		; ignore close command channel
721
 3235  FE9E8F  24 7C         		bit	pcdsk
722
 3236  FE9E91  10 0C         		bpl	?dsk		; real disk
723
 3237  FE9E93  C9 05         		cmp	#$05		; ignore close file #2,#3,#4
724
 3238  FE9E95  90 07         		bcc	?end
725
 3239  FE9E97  64 8A         		stz	iecndx2		; clear include file index
726
 3240  FE9E99  64 8B         		stz	iecndx2+1
727
 3241  FE9E9B  64 8E         		stz	ieceof2		; clear include file eof flag
728
 3242  FE9E9D  18            	?clc:	clc
729
 3243  FE9E9E  60            	?end:	rts
730
 3244  FE9E9F  24 E6         	?dsk:	bit	fpcflag
731
 3245  FE9EA1  10 04         		bpl	?dsk2		; old style: always on disk
732
 3246  FE9EA3  C9 04         		cmp	#4
733
 3247  FE9EA5  F0 F6         		beq	?clc		; obj file new style: in memory
734
 3248  FE9EA7  22 8C 2E F9   	?dsk2:	jsl	v8close		; close file on real disk
735
 3249  FE9EAB  60            		rts
736
 3250  FE9EAC
737
 3251                        	; A=dev#, sacur=SA#
738
 3252  FE9EAC                	ieclsn:
739
 3253  FE9EAC  64 90         		stz	kstat
740
 3254  FE9EAE  C9 08         		cmp	#$08
741
 3255  FE9EB0  90 1D         		bcc	?end
742
 3256  FE9EB2  18            		clc
743
 3257  FE9EB3  24 7C         		bit	pcdsk
744
 3258  FE9EB5  30 18         		bmi	?end
745
  Tue Jul 17 11:00:23 2018                                                                                               Page   13
746
 
747
 
748
 
749
 
750
 3259  FE9EB7  A5 B9         		lda	sacur
751
 3260  FE9EB9  29 0F         		and	#$0F
752
 3261  FE9EBB  24 E6         		bit	fpcflag
753
 3262  FE9EBD  10 06         		bpl	?dsk
754
 3263  FE9EBF  C9 04         		cmp	#4
755
 3264  FE9EC1  D0 02         		bne	?dsk
756
 3265  FE9EC3  18            		clc
757
 3266  FE9EC4  60            		rts
758
 3267  FE9EC5  22 50 2B F9   	?dsk:	jsl	viec8lsn
759
 3268  FE9EC9  90 04         		bcc	?end
760
 3269  FE9ECB  A9 80         		lda	#$80
761
 3270  FE9ECD  85 90         		sta	kstat
762
 3271  FE9ECF  60            	?end:	rts
763
 3272
764
 3273  FE9ED0                	iecunlsn:
765
 3274  FE9ED0  A5 9A         		lda	dflto
766
 3275  FE9ED2  C9 08         		cmp	#$08
767
 3276  FE9ED4  90 13         		bcc	?end2
768
 3277  FE9ED6  24 7C         		bit	pcdsk
769
 3278  FE9ED8  30 0E         		bmi	?end
770
 3279  FE9EDA  24 E6         		bit	fpcflag
771
 3280  FE9EDC  10 06         		bpl	?dsk
772
 3281  FE9EDE  A5 B9         		lda	sacur
773
 3282  FE9EE0  C9 04         		cmp	#4
774
 3283  FE9EE2  F0 04         		beq	?end
775
 3284  FE9EE4  22 80 2D F9   	?dsk:	jsl	v8unlsn
776
 3285  FE9EE8  18            	?end:	clc
777
 3286  FE9EE9  60            	?end2:	rts
778
 3287
779
 3288                        	; A=dev#, sacur=SA#
780
 3289  FE9EEA                	iectlk:
781
 3290  FE9EEA  64 90         		stz	kstat
782
 3291  FE9EEC  C9 08         		cmp	#$08
783
 3292  FE9EEE  90 19         		bcc	?end
784
 3293  FE9EF0  18            		clc
785
 3294  FE9EF1  A5 B9         		lda	sacur
786
 3295  FE9EF3  24 7C         		bit	pcdsk
787
 3296  FE9EF5  30 13         		bmi	?tlk
788
 3297  FE9EF7  A5 B9         		lda	sacur
789
 3298  FE9EF9  22 B0 2B F9   		jsl	viec8tlk
790
 3299  FE9EFD  B0 06         		bcs	?er
791
 3300  FE9EFF  50 08         		bvc	?end
792
 3301  FE9F01  A9 40         		lda	#$40
793
 3302  FE9F03  80 02         		bra	?er2
794
 3303  FE9F05  A9 80         	?er:	lda	#$80
795
 3304  FE9F07  85 90         	?er2:	sta	kstat
796
 3305  FE9F09  60            	?end:	rts
797
 3306  FE9F0A  29 0F         	?tlk:	and	#$0F
798
 3307  FE9F0C  C9 0F         		cmp	#$0F
799
 3308  FE9F0E  64 80         		stz	iecalt		; if = 0 get from cmd. chnl
800
 3309  FE9F10  F0 09         		beq	?end2
801
 3310  FE9F12  38            		sec
802
 3311  FE9F13  66 80         		ror	iecalt		; <7>: get from main text buffer
803
 3312  FE9F15  C9 05         		cmp	#$05		; include file?
804
 3313  FE9F17  D0 02         		bne	?end2		; no
805
 3314  FE9F19  46 80         		lsr	iecalt		; <6>: get from include file
806
 3315  FE9F1B  18            	?end2:	clc
807
  Tue Jul 17 11:00:23 2018                                                                                               Page   14
808
 
809
 
810
 
811
 
812
 3316  FE9F1C  60            		rts
813
 3317
814
 3318  FE9F1D                	iecuntlk:
815
 3319  FE9F1D  A5 99         		lda	dfltn
816
 3320  FE9F1F  C9 08         		cmp	#$08
817
 3321  FE9F21  90 09         		bcc	?end2
818
 3322  FE9F23  24 7C         		bit	pcdsk
819
 3323  FE9F25  30 04         		bmi	?end
820
 3324  FE9F27  22 A4 2D F9   		jsl	v8untlk
821
 3325  FE9F2B  18            	?end:	clc
822
 3326  FE9F2C  60            	?end2:	rts
823
 3327
824
 3328                        	; A=data
825
 3329  FE9F2D                	iecout:
826
 3330  FE9F2D  85 8C         		sta	iecbuf
827
 3331  FE9F2F  A5 9A         		lda	dflto
828
 3332  FE9F31  C9 08         		cmp	#$08
829
 3333  FE9F33  90 17         		bcc	?no
830
 3334  FE9F35  A5 8C         		lda	iecbuf
831
 3335  FE9F37  24 7C         		bit	pcdsk
832
 3336  FE9F39  30 14         		bmi	?wr
833
 3337  FE9F3B  24 E6         		bit	fpcflag
834
 3338  FE9F3D  30 10         		bmi	?wr
835
 3339  FE9F3F  22 81 2C F9   		jsl	viec8put
836
 3340  FE9F43  90 17         		bcc	?end2
837
 3341  FE9F45  A9 80         		lda	#$80
838
 3342  FE9F47  85 90         		sta	kstat
839
 3343  FE9F49  A5 8C         		lda	iecbuf
840
 3344  FE9F4B  60            		rts
841
 3345  FE9F4C  A5 8C         	?no:	lda	iecbuf
842
 3346  FE9F4E  60            		rts
843
 3347  FE9F4F  87 86         	?wr:	sta	[iecwp]		; put to buffer obj. file
844
 3348  FE9F51  E6 86         		inc	iecwp		; update buffer pointer
845
 3349  FE9F53  D0 06         		bne	?end
846
 3350  FE9F55  E6 87         		inc	iecwp+1
847
 3351  FE9F57  D0 02         		bne	?end
848
 3352  FE9F59  E6 88         		inc	iecwp+2
849
 3353  FE9F5B  18            	?end:	clc
850
 3354  FE9F5C  60            	?end2:	rts
851
 3355  FE9F5D
852
 3356  FE9F5D                	iecin:
853
 3357  FE9F5D  A5 99         		lda	dfltn
854
 3358  FE9F5F  C9 08         		cmp	#$08
855
 3359  FE9F61  90 19         		bcc	?no
856
 3360  FE9F63  24 7C         		bit	pcdsk
857
 3361  FE9F65  30 18         		bmi	?rdt
858
 3362  FE9F67  22 F7 2C F9   		jsl	viec8get
859
 3363  FE9F6B  B0 0B         		bcs	?er
860
 3364  FE9F6D  50 08         		bvc	?xt		; no eof
861
 3365  FE9F6F  85 8C         		sta	iecbuf
862
 3366  FE9F71  A9 40         		lda	#$40
863
 3367  FE9F73  85 90         		sta	kstat
864
 3368  FE9F75  A5 8C         		lda	iecbuf
865
 3369  FE9F77  60            	?xt:	rts
866
 3370  FE9F78  A9 80         	?er:	lda	#$80
867
 3371  FE9F7A  85 90         		sta	kstat
868
 3372  FE9F7C  A9 0D         	?no:	lda	#$0D
869
  Tue Jul 17 11:00:23 2018                                                                                               Page   15
870
 
871
 
872
 
873
 
874
 3373  FE9F7E  60            		rts
875
 3374
876
 3375                        	; get byte from main text buffer
877
 3376  FE9F7F                	?rdt:
878
 3377  FE9F7F  A5 80         		lda	iecalt
879
 3378  FE9F81  F0 37         		beq	?ext		; cmd chnl
880
 3379  FE9F83  C9 40         		cmp	#$40
881
 3380  FE9F85  F0 35         		beq	?rda		; read include file
882
 3381  FE9F87  DA            		phx
883
 3382  FE9F88  5A            		phy
884
 3383  FE9F89  8B            		phb
885
 3384  FE9F8A  24 85         		bit	ieceof		; <6>: eof flag
886
 3385  FE9F8C  50 08         		bvc	?go		; no eof
887
 3386  FE9F8E  A9 0D         		lda	#$0D		; return CR if eof
888
 3387  FE9F90  A0 40         		ldy	#$40
889
 3388  FE9F92  84 90         		sty	kstat		; I/O status = eof
890
 3389  FE9F94  80 21         		bra	?end		; exit
891
 3390  FE9F96  A5 8D         	?go:	lda	svbnk		; local read buffer in real v-bank
892
 3391  FE9F98  48            		pha
893
 3392  FE9F99  AB            		plb			; set data bank
894
 3393  FE9F9A  24 89         		bit	iecfg		; <7>: flag buffer not empty
895
 3394  FE9F9C  30 03         		bmi	?get		; buffer ready
896
 3395  FE9F9E  20 E3 9F      		jsr	?ldt		; fill local read buffer
897
 3396  FE9FA1  A4 84         	?get:	ldy	iecndx		; current buffer index
898
 3397  FE9FA3  B9 00 FF      		lda	$FF00,y		; get byte from local buffer
899
 3398  FE9FA6  C8            		iny
900
 3399  FE9FA7  84 84         		sty	iecndx		; save new index
901
 3400  FE9FA9  C9 0A         		cmp	#$0A		; last byte of buffer?
902
 3401  FE9FAB  D0 0A         		bne	?end		; no -- return byte
903
 3402  FE9FAD  24 89         		bit	iecfg		; <6>: eof flag (VF)
904
 3403  FE9FAF  64 89         		stz	iecfg		; clear flag: next time must fill buffer
905
 3404  FE9FB1  50 04         		bvc	?end		; no eof
906
 3405  FE9FB3  A0 40         		ldy	#$40
907
 3406  FE9FB5  84 85         		sty	ieceof		; internal flag: end of file
908
 3407                        		;sty	kstat		; I/O status = eof
909
 3408  FE9FB7  AB            	?end:	plb
910
 3409  FE9FB8  7A            		ply
911
 3410  FE9FB9  FA            		plx
912
 3411  FE9FBA  18            	?ext:	clc
913
 3412  FE9FBB  60            		rts
914
 3413
915
 3414  FE9FBC  5A            	?rda:	phy
916
 3415  FE9FBD  24 8E         		bit	ieceof2		; <6>: eof flag
917
 3416  FE9FBF  50 08         		bvc	?go2		; no eof
918
 3417  FE9FC1  A9 40         		lda	#$40
919
 3418  FE9FC3  85 90         		sta	kstat
920
 3419  FE9FC5  A9 0D         		lda	#$0D		; return CR if eof
921
 3420  FE9FC7  80 17         		bra	?end2		; exit
922
 3421  FE9FC9                	?go2:	INDEX16
923
 3422  FE9FC9  C2 10         		rep	#PXFLAG
924
 3423                        		.LONGI	on
925
 3424                        		.MNLIST
926
 3425  FE9FCB  A4 8A         		ldy	iecndx2		; index
927
 3426  FE9FCD  B7 7D         		lda	[iecrp],y
928
 3427  FE9FCF  85 8C         		sta	iecbuf
929
 3428  FE9FD1  C8            		iny
930
 3429  FE9FD2  84 8A         		sty	iecndx2
931
  Tue Jul 17 11:00:23 2018                                                                                               Page   16
932
 
933
 
934
 
935
 
936
 3430  FE9FD4  B7 7D         		lda	[iecrp],y
937
 3431  FE9FD6                		INDEX08
938
 3432  FE9FD6  E2 10         		sep	#PXFLAG
939
 3433                        		.LONGI	off
940
 3434                        		.MNLIST
941
 3435  FE9FD8  D0 04         		bne	?ret
942
 3436  FE9FDA  A9 40         		lda	#$40
943
 3437  FE9FDC  85 8E         		sta	ieceof2
944
 3438  FE9FDE  A5 8C         	?ret:	lda	iecbuf
945
 3439  FE9FE0  7A            	?end2:	ply
946
 3440  FE9FE1  18            		clc
947
 3441  FE9FE2  60            		rts
948
 3442
949
 3443                        	; fill local buffer from main text buffer
950
 3444  FE9FE3                	?ldt:	ACC16
951
 3445  FE9FE3  C2 20         		rep	#PMFLAG
952
 3446                        		.LONGA	on
953
 3447                        		.MNLIST
954
 3448  FE9FE5  A0 02         		ldy	#$02
955
 3449  FE9FE7  B7 81         		lda	[iectp],y
956
 3450  FE9FE9  85 3F         		sta	psrline		; store current line number
957
 3451  FE9FEB                		ACC08
958
 3452  FE9FEB  E2 20         		sep	#PMFLAG
959
 3453                        		.LONGA	off
960
 3454                        		.MNLIST
961
 3455  FE9FED  A2 FF         		ldx	#$FF
962
 3456  FE9FEF  C8            		iny
963
 3457  FE9FF0  C8            	?llp:	iny
964
 3458  FE9FF1  E8            		inx
965
 3459  FE9FF2  B7 81         		lda	[iectp],y	; copy text line in local buffer
966
 3460  FE9FF4  9D 00 FF      		sta	!$FF00,x
967
 3461  FE9FF7  D0 F7         		bne	?llp
968
 3462  FE9FF9  A9 0D         		lda	#$0D
969
 3463  FE9FFB  9D 00 FF      		sta	!$FF00,x
970
 3464  FE9FFE  A9 0A         		lda	#$0A
971
 3465  FEA000  9D 01 FF      		sta	!$FF01,x
972
 3466  FEA003  A0 80         		ldy	#$80		; flag buffer is filled
973
 3467  FEA005                		ACC16
974
 3468  FEA005  C2 20         		rep	#PMFLAG
975
 3469                        		.LONGA	on
976
 3470                        		.MNLIST
977
 3471  FEA007  A7 81         		lda	[iectp]		; update pointer to next text line
978
 3472  FEA009  85 81         		sta	iectp
979
 3473  FEA00B  A7 81         		lda	[iectp]
980
 3474  FEA00D                		ACC08
981
 3475  FEA00D  E2 20         		sep	#PMFLAG
982
 3476                        		.LONGA	off
983
 3477                        		.MNLIST
984
 3478  FEA00F  D0 02         		bne	?ok		; no eof
985
 3479  FEA011  A0 C0         		ldy	#$C0		; flag filled buffer + end of file marker
986
 3480  FEA013  64 84         	?ok:	stz	iecndx		; clear current index
987
 3481  FEA015  84 89         		sty	iecfg
988
 3482  FEA017  60            		rts
989
 3483
990
 3484                        	;---------------------------------------------------------------------------
991
 3485                        	; virtual serial bus device
992
 3486                        	; device #4,#5: printer port's
993
  Tue Jul 17 11:00:23 2018                                                                                               Page   17
994
 
995
 
996
 
997
 
998
 3487                        	; device #6,#7: not present
999
 3488                        	; device #8: all drive's
1000
 3489                        	;
1001
 3490                        	; disk unit:
1002
 3491                        	;		#0..#7: physical drive's
1003
 3492                        	;		#8,#10: ram buffer (compiler only)
1004
 3493                        	;		#9,#11: text buffer (read only, compiler only)
1005
 3494                        	;---------------------------------------------------------------------------
1006
 3495
1007
 3496                        	;---------------------------------------------------------------------------
1008
 3497                        	; open virtual iec device
1009
 3498                        	;---------------------------------------------------------------------------
1010
 3499
1011
 3500                        	; open virtual iec device
1012
 3501                        	; A = device #, X = index to logical file table
1013
 3502                        	; output: CF = 1 if error, A = error code
1014
 3503                        	; implementation note---
1015
 3504                        	; for disk device (device #8) secondary address sacur have special meaning:
1016
 3505                        	; 	sacur<7>: 1 if write only file, 0 if read only file
1017
 3506                        	;	sacur<6>: 1 if read/write file
1018
 3507                        	; after openning, secondary address have in bit <3:0> the disk unit number
1019
 3508                        	; pascal compiler open at least 3 files: file #1 for chann. command,
1020
 3509                        	; file #3 (read only) for pascal source, file #4 (write only) for obj. code
1021
 3510                        	; file #2 reserved for printer/terminal listing when compiling
1022
 3511                        	; if source file contain an include directive (#filename) then open file #5
1023
 3512                        	; for read include file.
1024
 3513
1025
 3514                        	;---------------------------------------------------------------------------
1026
 3515                        	; close channel with iec device
1027
 3516                        	;---------------------------------------------------------------------------
1028
 3517  FEA018
1029
 3518                        	;---------------------------------------------------------------------------
1030
 3519                        	; logical file operations and input/output wrapper's
1031
 3520                        	;---------------------------------------------------------------------------
1032
 3521
1033
 3522                        	; wrapper for output routine
1034
 3523                        	; before call this, user must call _chkout routine
1035
 3524                        	; A = byte to send to device
1036
 3525  FEA018                	_chrout:
1037
 3526  FEA018  EB            		xba			; B = byte to send
1038
 3527  FEA019  A5 9A         		lda	dflto
1039
 3528  FEA01B  F0 0E         		beq	?04		; 0 -> keyboard, not out device
1040
 3529  FEA01D  C9 03         		cmp	#$03
1041
 3530  FEA01F  90 0D         		bcc	?06		; 1, 2 -> serial port
1042
 3531  FEA021  D0 04         		bne	?02		; 4..MAXVIEC
1043
 3532  FEA023  EB            		xba
1044
 3533  FEA024                		SCNCHAROUT		; 3 -> screen output
1045
 3534  FEA024  02 05         		cop	$05
1046
 3535                        		.MNLIST
1047
 3536  FEA026  60            		rts
1048
 3537  FEA027  C9 09         	?02:	cmp	#MAXVIEC+1
1049
 3538  FEA029  90 07         		bcc	?08		; 4..MAXVIEV -> virtual serial bus
1050
 3539  FEA02B  4C 98 A1      	?04:	jmp	SetErr09	; illegal device number
1051
 3540  FEA02E  EB            	?06:	xba			; output serial/parallel port
1052
 3541  FEA02F                		DEVCHAROUT
1053
 3542  FEA02F  02 15         		cop	$15
1054
 3543                        		.MNLIST
1055
  Tue Jul 17 11:00:23 2018                                                                                               Page   18
1056
 
1057
 
1058
 
1059
 
1060
 3544  FEA031  60            		rts
1061
 3545  FEA032  EB            	?08:	xba
1062
 3546  FEA033  4C 2D 9F      		jmp	iecout		; virtual iec output
1063
 3547
1064
 3548                        	; wrapper for get routine
1065
 3549                        	; before call this user must call _chkin routine
1066
 3550  FEA036                	_getin:
1067
 3551  FEA036  A5 99         		lda	dfltn
1068
 3552  FEA038  D0 0F         		bne	_chrin1
1069
 3553  FEA03A                		KBGETIN			; get from keyboard
1070
 3554  FEA03A  02 17         		cop	$17
1071
 3555                        		.MNLIST
1072
 3556  FEA03C  EB            		xba
1073
 3557  FEA03D  85 93         		sta	keyctl		; store control
1074
 3558  FEA03F  EB            		xba			; key code
1075
 3559  FEA040  18            		clc
1076
 3560  FEA041  60            		rts
1077
 3561  FEA042
1078
 3562                        	; wrapper for input routine
1079
 3563                        	; before call this user must call _chkin routine
1080
 3564  FEA042                	 _chrin:
1081
 3565  FEA042  A5 99         		lda	dfltn
1082
 3566  FEA044  D0 03         		bne	_chrin1
1083
 3567  FEA046                		KBCHARIN		; input from keyboard (editor)
1084
 3568  FEA046  02 0F         		cop	$0F
1085
 3569                        		.MNLIST
1086
 3570  FEA048  60            		rts
1087
 3571  FEA049                	_chrin1:
1088
 3572  FEA049  C9 03         		cmp	#$03
1089
 3573  FEA04B  90 02         		bcc	?01		; 1,2 -> serial ports
1090
 3574  FEA04D  D0 03         		bne	?02
1091
 3575  FEA04F                	?01:	DEVCHARIN		; input from screen (editor) or serial port
1092
 3576  FEA04F  02 16         		cop	$16
1093
 3577                        		.MNLIST
1094
 3578  FEA051  60            		rts
1095
 3579  FEA052  C9 09         	?02:	cmp	#MAXVIEC+1
1096
 3580  FEA054  90 03         		bcc	?06		; 8..15 -> virtual serial bus
1097
 3581  FEA056  4C 98 A1      	?04:	jmp	SetErr09	; illegal device number
1098
 3582  FEA059  A5 90         	?06:	lda	kstat		; virtual iec device
1099
 3583  FEA05B  D0 03         		bne	?08		; end of file or error
1100
 3584  FEA05D  4C 5D 9F      		jmp	iecin		; virtual serial bus input
1101
 3585  FEA060  A9 0D         	?08:	lda	#$0D		; return a CR
1102
 3586  FEA062  18            		clc
1103
 3587  FEA063  60            		rts
1104
 3588
1105
 3589                        	; wrapper for open routine
1106
 3590                        	; before call this user must set: lacur, facur, sacur, fnlen, fnadr, fnadr2
1107
 3591  FEA064                	_open:
1108
 3592  FEA064  A6 B8         		ldx	lacur
1109
 3593  FEA066  20 66 A1      		jsr	lfsrch
1110
 3594  FEA069  F0 33         		beq	?12		; file open
1111
 3595  FEA06B  A6 98         		ldx	ldtnd
1112
 3596  FEA06D  E0 0B         		cpx	#MAXLF
1113
 3597  FEA06F  B0 2A         		bcs	?11		; too many files
1114
 3598  FEA071  E6 98         		inc	ldtnd
1115
 3599                        		;stx	lxcur
1116
 3600  FEA073  A5 B8         		lda	lacur
1117
  Tue Jul 17 11:00:23 2018                                                                                               Page   19
1118
 
1119
 
1120
 
1121
 
1122
 3601  FEA075  95 C3         		sta	latb,x
1123
 3602  FEA077  A5 B9         		lda	sacur
1124
 3603  FEA079  95 D9         		sta	satb,x
1125
 3604  FEA07B  A5 BA         		lda	facur
1126
 3605  FEA07D  95 CE         		sta	fatb,x
1127
 3606  FEA07F  F0 18         		beq	?10		; 0 -> keyboard: OK
1128
 3607  FEA081  C9 03         		cmp	#$03
1129
 3608  FEA083  F0 14         		beq	?10		; 3 -> screen: OK
1130
 3609  FEA085  90 1A         		bcc	?15		; 1,2 -> serial ports
1131
 3610  FEA087  C9 09         		cmp	#MAXVIEC+1
1132
 3611  FEA089  90 09         		bcc	?07		; 4..MAXVIEC -> virtual serial bus
1133
 3612  FEA08B  B5 CE         	?05:	lda	fatb,x		; invalidate device #
1134
 3613  FEA08D  09 80         		ora	#$80
1135
 3614  FEA08F  95 CE         		sta	fatb,x
1136
 3615  FEA091  4C 98 A1      		jmp	SetErr09	; illegal device number
1137
 3616  FEA094  20 B0 9D      	?07:	jsr	iecopen		; A = error code if any error
1138
 3617  FEA097  B0 0D         		bcs	?17		; ok
1139
 3618  FEA099  18            	?10:	clc			; no error
1140
 3619  FEA09A  60            	?10a:	rts
1141
 3620  FEA09B  4C 80 A1      	?11:	jmp	SetErr01	; too many files
1142
 3621  FEA09E  4C 83 A1      	?12:	jmp	SetErr02	; file open
1143
 3622  FEA0A1  20 AB 9D      	?15:	jsr	seropen		; open serial port
1144
 3623  FEA0A4  90 F4         		bcc	?10a		; A = error code if any error
1145
 3624  FEA0A6  48            	?17:	pha			; save error code
1146
 3625                        		;ldx	lxcur
1147
 3626  FEA0A7  B5 CE         		lda	fatb,x		; invalidate device #
1148
 3627  FEA0A9  09 80         		ora	#$80
1149
 3628  FEA0AB  95 CE         		sta	fatb,x
1150
 3629  FEA0AD  68            		pla
1151
 3630  FEA0AE  4C 9D A1      	?20:	jmp	SetErr		; set error code
1152
 3631
1153
 3632                        	; wrapper for set file for input routine
1154
 3633                        	; before call this user must set X = logical file
1155
 3634  FEA0B1                	_chkin:
1156
 3635  FEA0B1  20 66 A1      		jsr	lfsrch
1157
 3636  FEA0B4  D0 1D         		bne	?11		; file not open
1158
 3637  FEA0B6  20 73 A1      		jsr	lfget
1159
 3638  FEA0B9  F0 14         		beq	?10a		; 0 -> keyboard - ok
1160
 3639  FEA0BB  30 08         		bmi	?05		; device not present
1161
 3640  FEA0BD  C9 04         		cmp	#$04
1162
 3641  FEA0BF  90 0E         		bcc	?10a		; 1,2,3 - ok
1163
 3642  FEA0C1  C9 09         		cmp	#MAXVIEC+1
1164
 3643  FEA0C3  90 03         		bcc	?10		; 6..MAXVIEC -> virtual serial bus ok
1165
 3644  FEA0C5  4C 8C A1      	?05:	jmp	SetErr05	; error: device not present
1166
 3645  FEA0C8  AA            	?10:	tax
1167
 3646  FEA0C9  20 EA 9E      		jsr	iectlk
1168
 3647  FEA0CC  B0 F7         		bcs	?05
1169
 3648  FEA0CE  8A            		txa
1170
 3649  FEA0CF  85 99         	?10a:	sta	dfltn		; ok - setup input device
1171
 3650  FEA0D1  18            		clc
1172
 3651  FEA0D2  60            		rts
1173
 3652  FEA0D3  4C 86 A1      	?11:	jmp	SetErr03	; error: file not open
1174
 3653  FEA0D6  4C 8F A1      	?12:	jmp	SetErr06	; error: not input file
1175
 3654
1176
 3655                        	; wrapper for set file for output routine
1177
 3656                        	; before call this user must set X = logical file
1178
 3657  FEA0D9                	_chkout:
1179
  Tue Jul 17 11:00:23 2018                                                                                               Page   20
1180
 
1181
 
1182
 
1183
 
1184
 3658  FEA0D9  20 66 A1      		jsr	lfsrch
1185
 3659  FEA0DC  D0 1D         		bne	?11		; file not open
1186
 3660  FEA0DE  20 73 A1      		jsr	lfget
1187
 3661  FEA0E1  F0 1B         		beq	?12		; 0 -> keyboard - not output device
1188
 3662  FEA0E3  30 08         		bmi	?05		; device not present
1189
 3663  FEA0E5  C9 04         		cmp	#$04
1190
 3664  FEA0E7  90 0E         		bcc	?10a		; 1,2,3 - ok
1191
 3665  FEA0E9  C9 09         		cmp	#MAXVIEC+1
1192
 3666  FEA0EB  90 03         		bcc	?10		; 4..MAXVIEC -> virtual serial bus ok
1193
 3667  FEA0ED  4C 8C A1      	?05:	jmp	SetErr05	; error: device not present
1194
 3668  FEA0F0  AA            	?10:	tax
1195
 3669  FEA0F1  20 AC 9E      		jsr	ieclsn
1196
 3670  FEA0F4  B0 F7         		bcs	?05
1197
 3671  FEA0F6  8A            		txa
1198
 3672  FEA0F7  85 9A         	?10a:	sta	dflto		; ok - set output device
1199
 3673  FEA0F9  18            		clc
1200
 3674  FEA0FA  60            		rts
1201
 3675  FEA0FB  4C 86 A1      	?11:	jmp	SetErr03	; file not open
1202
 3676  FEA0FE  4C 92 A1      	?12:	jmp	SetErr07	; error: not output file
1203
 3677
1204
 3678                        	; wrapper for close all opened files
1205
 3679  FEA101                	_clall:
1206
 3680  FEA101  20 10 A1      		jsr	_clrch
1207
 3681  FEA104  A6 98         	?02:	ldx	ldtnd
1208
 3682  FEA106  F0 07         		beq	?04		; no more files to close
1209
 3683  FEA108  B5 C3         		lda	latb,x		; logical file number
1210
 3684  FEA10A  20 26 A1      		jsr	_close		; close file
1211
 3685  FEA10D  80 F5         		bra	?02		; loop next file
1212
 3686  FEA10F  60            	?04:	rts
1213
 3687
1214
 3688                        	; wrapper for restore default i/o devices
1215
 3689  FEA110                	_clrch:
1216
 3690  FEA110  A2 03         		ldx	#$03		; default output device
1217
 3691  FEA112  E4 9A         		cpx	dflto
1218
 3692  FEA114  B0 03         		bcs	?10
1219
 3693  FEA116  20 D0 9E      		jsr	iecunlsn
1220
 3694  FEA119  E4 99         	?10:	cpx	dfltn
1221
 3695  FEA11B  B0 03         		bcs	?20
1222
 3696  FEA11D  20 1D 9F      		jsr	iecuntlk
1223
 3697  FEA120  86 9A         	?20:	stx	dflto		; default output device
1224
 3698  FEA122  64 99         		stz	dfltn		; default input device
1225
 3699  FEA124  18            		clc
1226
 3700  FEA125  60            		rts
1227
 3701
1228
 3702                        	; wrapper for close a logical file
1229
 3703                        	; before call this user must set A = logical file to be closed
1230
 3704  FEA126                	_close:
1231
 3705  FEA126  20 69 A1      		jsr	lfsrchx
1232
 3706  FEA129  D0 39         		bne	?12		; exit without error (no file found)
1233
 3707  FEA12B  20 73 A1      		jsr	lfget		; get parameters for logical file
1234
 3708  FEA12E  DA            		phx			; save index to logical file table
1235
 3709  FEA12F  A5 BA         		lda	facur		; device #
1236
 3710  FEA131  30 14         		bmi	?10		; illegal device - delete file
1237
 3711  FEA133  F0 12         		beq	?10		; no action - delete file
1238
 3712  FEA135  C9 03         		cmp	#3
1239
 3713  FEA137  F0 0E         		beq	?10		; no action - delete file
1240
 3714  FEA139  B0 05         		bcs	?02
1241
  Tue Jul 17 11:00:23 2018                                                                                               Page   21
1242
 
1243
 
1244
 
1245
 
1246
 3715  FEA13B  20 AF 9D      		jsr	serclose	; close on device 1 & 2
1247
 3716  FEA13E  80 07         		bra	?10		; delete file
1248
 3717  FEA140  C9 09         	?02:	cmp	#MAXVIEC+1
1249
 3718  FEA142  B0 03         		bcs	?10		; no action - delete file
1250
 3719  FEA144  20 81 9E      		jsr	iecclose	; close on devices 4..MAXVIEC
1251
 3720  FEA147  FA            	?10:	plx			; index of file to be deleted
1252
 3721  FEA148  C6 98         		dec	ldtnd		; update number of logical files
1253
 3722  FEA14A  E4 98         		cpx	ldtnd		; if index is for the last entry, done
1254
 3723  FEA14C  F0 16         		beq	?12		; otherwise move files on table
1255
 3724  FEA14E  9B            		txy			; Y = index to entry be removed
1256
 3725  FEA14F  A6 98         		ldx	ldtnd
1257
 3726  FEA151  B5 C3         		lda	latb,x
1258
 3727  FEA153  BB            		tyx
1259
 3728  FEA154  95 C3         		sta	latb,x
1260
 3729  FEA156  A6 98         		ldx	ldtnd
1261
 3730  FEA158  B5 CE         		lda	fatb,x
1262
 3731  FEA15A  BB            		tyx
1263
 3732  FEA15B  95 CE         		sta	fatb,x
1264
 3733  FEA15D  A6 98         		ldx	ldtnd
1265
 3734  FEA15F  B5 D9         		lda	satb,x
1266
 3735  FEA161  BB            		tyx
1267
 3736  FEA162  95 D9         		sta	satb,x
1268
 3737  FEA164  18            	?12:	clc
1269
 3738  FEA165  60            		rts
1270
 3739  FEA166
1271
 3740                        	; search logical file X in table 'latb'
1272
 3741  FEA166                	lfsrch:
1273
 3742  FEA166  64 90         		stz	kstat
1274
 3743  FEA168  8A            		txa			; file number
1275
 3744  FEA169                	lfsrchx:
1276
 3745  FEA169  A6 98         		ldx	ldtnd
1277
 3746  FEA16B  CA            	?01:	dex
1278
 3747  FEA16C  30 04         		bmi	?02
1279
 3748  FEA16E  D5 C3         		cmp	latb,x
1280
 3749  FEA170  D0 F9         		bne	?01
1281
 3750  FEA172  60            	?02:	rts
1282
 3751
1283
 3752                        	; get parameters of logical file
1284
 3753  FEA173                	lfget:
1285
 3754                        		;stx	lxcur
1286
 3755  FEA173  B5 C3         		lda	latb,x
1287
 3756  FEA175  85 B8         		sta	lacur
1288
 3757  FEA177  B5 D9         		lda	satb,x
1289
 3758  FEA179  85 B9         		sta	sacur
1290
 3759  FEA17B  B5 CE         		lda	fatb,x
1291
 3760  FEA17D  85 BA         		sta	facur
1292
 3761  FEA17F  60            		rts
1293
 3762
1294
 3763                        	;---------------------------------------------------------------------------
1295
 3764                        	; kernal error's
1296
 3765                        	;---------------------------------------------------------------------------
1297
 3766
1298
 3767                        	SetErr01:			; too many files
1299
 3768  FEA180  A9 01         		lda	#1
1300
 3769  FEA182  2C            		.DB	$2C
1301
 3770                        	SetErr02:			; file open
1302
 3771  FEA183  A9 02         		lda	#2
1303
  Tue Jul 17 11:00:23 2018                                                                                               Page   22
1304
 
1305
 
1306
 
1307
 
1308
 3772  FEA185  2C            		.DB	$2C
1309
 3773                        	SetErr03:			; file not open
1310
 3774  FEA186  A9 03         		lda	#3
1311
 3775  FEA188  2C            		.DB	$2C
1312
 3776                        	SetErr04:			; file not found
1313
 3777  FEA189  A9 04         		lda	#4
1314
 3778  FEA18B  2C            		.DB	$2C
1315
 3779                        	SetErr05:			; device not presnt
1316
 3780  FEA18C  A9 05         		lda	#5
1317
 3781  FEA18E  2C            		.DB	$2C
1318
 3782                        	SetErr06:			; not input file
1319
 3783  FEA18F  A9 06         		lda	#6
1320
 3784  FEA191  2C            		.DB	$2C
1321
 3785                        	SetErr07:			; not output file
1322
 3786  FEA192  A9 07         		lda	#7
1323
 3787  FEA194  2C            		.DB	$2C
1324
 3788                        	SetErr08:			; missing file name
1325
 3789  FEA195  A9 08         		lda	#8
1326
 3790  FEA197  2C            		.DB	$2C
1327
 3791                        	SetErr09:			; illegal device number
1328
 3792  FEA198  A9 09         		lda	#9
1329
 3793  FEA19A  2C            		.DB	$2C
1330
 3794                        	SetErr10:			; out of memory
1331
 3795  FEA19B  A9 10         		lda	#$10
1332
 3796  FEA19D                	SetErr:
1333
 3797                        		.EXTERN L0FAA
1334
 3798
1335
 3799  FEA19D  48            		pha
1336
 3800  FEA19E  20 CC FF      		jsr	FCLRCH		; restore default I/O
1337
 3801  FEA1A1  24 97         		bit	runf		; check if running pascal virtual machine
1338
 3802  FEA1A3  30 2B         		bmi	?20
1339
 3803  FEA1A5  70 29         		bvs	?20
1340
 3804  FEA1A7  A0 00         		ldy	#$00
1341
 3805  FEA1A9  24 9D         		bit	msgflg		; <6> -> print kernal msg
1342
 3806  FEA1AB  50 20         		bvc	?10		; no print
1343
 3807  FEA1AD  20 38 A2      		jsr	kprint		; print msg
1344
 3808  FEA1B0  A3 01         		lda	$01,s		; error code
1345
 3809  FEA1B2  C9 0A         		cmp	#$0A
1346
 3810  FEA1B4  90 12         		bcc	?08
1347
 3811  FEA1B6  A0 FF         		ldy	#$FF		; partial remainder
1348
 3812  FEA1B8  38            		sec
1349
 3813  FEA1B9  C8            	?02:	iny
1350
 3814  FEA1BA  E9 0A         		sbc	#$0A
1351
 3815  FEA1BC  B0 FB         		bcs	?02
1352
 3816  FEA1BE  69 0A         		adc	#$0A
1353
 3817  FEA1C0  EB            		xba
1354
 3818  FEA1C1  98            		tya
1355
 3819  FEA1C2  09 30         		ora	#$30		; print 0..9
1356
 3820  FEA1C4  20 D2 FF      		jsr	FCHROUT
1357
 3821  FEA1C7  EB            		xba
1358
 3822  FEA1C8  09 30         	?08:	ora	#$30		; print 0..9
1359
 3823  FEA1CA  20 D2 FF      		jsr	FCHROUT
1360
 3824  FEA1CD  68            	?10:	pla
1361
 3825  FEA1CE  38            		sec			; error
1362
 3826  FEA1CF  60            		rts
1363
 3827  FEA1D0
1364
 3828  FEA1D0  68            	?20:	pla
1365
  Tue Jul 17 11:00:23 2018                                                                                               Page   23
1366
 
1367
 
1368
 
1369
 
1370
 3829  FEA1D1  C9 2B         		cmp	#$2B
1371
 3830  FEA1D3  D0 04         		bne	?22
1372
 3831  FEA1D5  A9 00         		lda	#0
1373
 3832  FEA1D7  80 06         		bra	?24
1374
 3833  FEA1D9  C9 10         	?22:	cmp	#$10
1375
 3834  FEA1DB  D0 02         		bne	?24
1376
 3835  FEA1DD  A9 0A         		lda	#$0A
1377
 3836  FEA1DF  AA            	?24:	tax
1378
 3837  FEA1E0  BF EA A1 FE   		lda	>CVTTBL,x
1379
 3838                        		;sta	iecerr
1380
 3839  FEA1E4  AA            		tax
1381
 3840  FEA1E5  38            		sec
1382
 3841  FEA1E6  4C C0 31      		jmp	L0FAA
1383
 3842  FEA1E9  60            		rts
1384
 3843
1385
 3844  FEA1EA                	CVTTBL:
1386
 3845  FEA1EA  14 10 16 15 17 		.DB	$14, $10, $16, $15, $17, $18, $0D, $0E, $19, $1A, $01
1387
               18 0D 0E 19 1A
1388
               01
1389
 3846  FEA1F5
1390
 3847
1391
 3848  FEA1F5                	sysmsg:
1392
 3849  FEA1F5                	SYSMSGTBL:
1393
 3850  FEA1F5  0D 49 2F 4F 20 		.DC	$0D, 'I/O error '
1394
               65 72 72 6F 72
1395
               A0
1396
 3851
1397
 3852          00000B        	SYSMSG1		.EQU	($ - SYSMSGTBL)
1398
 3853
1399
 3854  FEA200  0D 73 65 61 72 		.DC	$0D, 'searching '
1400
               63 68 69 6E 67
1401
               A0
1402
 3855
1403
 3856          000016        	SYSMSG2		.EQU	($ - SYSMSGTBL)
1404
 3857
1405
 3858  FEA20B  0D 6C 6F 61 64 		.DC	$0D, 'loading'
1406
               69 6E E7
1407
 3859
1408
 3860          00001E        	SYSMSG3		.EQU	($ - SYSMSGTBL)
1409
 3861
1410
 3862  FEA213  0D 73 61 76 69 		.DC	$0D, 'saving '
1411
               6E 67 A0
1412
 3863
1413
 3864          000026        	SYSMSG4		.EQU	($ - SYSMSGTBL)
1414
 3865
1415
 3866  FEA21B  0D 76 65 72 69 		.DC	$0D, 'verifying'
1416
               66 79 69 6E E7
1417
 3867  FEA225
1418
 3868          000030        	SYSMSG5		.EQU	($ - SYSMSGTBL)
1419
 3869
1420
 3870  FEA225  0D 66 6F 75 6E 		.DC	$0D, 'found '
1421
               64 A0
1422
 3871
1423
 3872          000037        	SYSMSG6		.EQU	($ - SYSMSGTBL)
1424
 3873
1425
 3874  FEA22C  0D 6F 6B 8D   		.DB	$0D, 'ok', $8D
1426
 3875
1427
  Tue Jul 17 11:00:23 2018                                                                                               Page   24
1428
 
1429
 
1430
 
1431
 
1432
 3876          00003B        	SYSMSG7		.EQU	($ - SYSMSGTBL)
1433
 3877
1434
 3878  FEA230  66 6F 72 A0   		.DC	'for '
1435
 3879
1436
 3880  FEA234
1437
 3881  FEA234                	sysprint:
1438
 3882  FEA234  24 9D         		bit	msgflg		; <7> -> print msg
1439
 3883  FEA236  10 11         		bpl	nopr
1440
 3884  FEA238
1441
 3885  FEA238                	kprint:
1442
 3886  FEA238  8B            		phb
1443
 3887  FEA239  4B            		phk
1444
 3888  FEA23A  AB            		plb			; set data bank = program bank
1445
 3889  FEA23B  B9 F5 A1      	?02:	lda	sysmsg,y
1446
 3890  FEA23E  08            		php
1447
 3891  FEA23F  29 7F         		and	#$7F
1448
 3892  FEA241  20 D2 FF      		jsr	FCHROUT
1449
 3893  FEA244  C8            		iny
1450
 3894  FEA245  28            		plp
1451
 3895  FEA246  10 F3         		bpl	?02
1452
 3896  FEA248  AB            		plb
1453
 3897  FEA249  18            	nopr:	clc
1454
 3898  FEA24A  60            		rts
1455
 3899  FEA24B
1456
 3900                        	;---------------------------------------------------------------------------
1457
 3901                        	; kernal miscellaneous
1458
 3902                        	;---------------------------------------------------------------------------
1459
 3903  FEA24B
1460
 3904  FEA24B                	_setmsg:
1461
 3905  FEA24B  85 9D         		sta	msgflg
1462
 3906  FEA24D  60            		rts
1463
 3907
1464
 3908  FEA24E                	_memtop:
1465
 3909  FEA24E  90 05         		bcc	?02
1466
 3910  FEA250  A6 A9         		ldx	topmem
1467
 3911  FEA252  A4 AA         		ldy	topmem+1
1468
 3912  FEA254  60            		rts
1469
 3913  FEA255  86 A9         	?02:	stx	topmem
1470
 3914  FEA257  84 AA         		sty	topmem+1
1471
 3915  FEA259  60            		rts
1472
 3916
1473
 3917  FEA25A                	_membot:
1474
 3918  FEA25A  90 05         		bcc	?02
1475
 3919  FEA25C  A6 A7         		ldx	botmem
1476
 3920  FEA25E  A4 A8         		ldy	botmem+1
1477
 3921  FEA260  60            		rts
1478
 3922  FEA261  86 A7         	?02:	stx	botmem
1479
 3923  FEA263  84 A8         		sty	botmem+1
1480
 3924  FEA265  60            		rts
1481
 3925
1482
 3926  FEA266                	_scnkey:
1483
 3927  FEA266                		SCNKEYFLG
1484
 3928  FEA266  02 18         		cop	$18
1485
 3929  FEA268  05            		.DB	$05
1486
 3930                        		.MNLIST
1487
 3931  FEA269  85 92         		sta	keyfg
1488
 3932  FEA26B  86 95         		stx	keytg
1489
  Tue Jul 17 11:00:23 2018                                                                                               Page   25
1490
 
1491
 
1492
 
1493
 
1494
 3933  FEA26D  84 94         		sty	keysh
1495
 3934  FEA26F  60            		rts
1496
 3935  FEA270
1497
 3936  FEA270                	_readst:
1498
 3937  FEA270  A5 90         		lda	kstat
1499
 3938  FEA272  60            		rts
1500
 3939
1501
 3940  FEA273                	_setlfs:
1502
 3941  FEA273  85 B8         		sta	lacur
1503
 3942  FEA275  86 BA         		stx	facur
1504
 3943  FEA277  84 B9         		sty	sacur
1505
 3944  FEA279  60            		rts
1506
 3945  FEA27A
1507
 3946  FEA27A                	_setnam:
1508
 3947  FEA27A  85 B7         		sta	fnlen
1509
 3948  FEA27C  86 BB         		stx	fnadr
1510
 3949  FEA27E  84 BC         		sty	fnadr+1
1511
 3950  FEA280  60            		rts
1512
 3951
1513
 3952  FEA281                	_load:
1514
 3953  FEA281  60            		rts
1515
 3954  FEA282
1516
 3955  FEA282                	_save:
1517
 3956  FEA282  60            		rts
1518
 3957
1519
 3958                        	; set jiffy clock
1520
 3959                        	; C = 16 bit low, XY = 16 bit high
1521
 3960  FEA283                	_settim:
1522
 3961  FEA283  78            		sei
1523
 3962  FEA284  0B            		phd
1524
 3963  FEA285  F4 00 00      		pea	#0
1525
 3964  FEA288  2B            		pld
1526
 3965  FEA289  85 00         		sta	<JiffyClk
1527
 3966  FEA28B  EB            		xba
1528
 3967  FEA28C  85 01         		sta	<JiffyClk+1
1529
 3968  FEA28E  86 02         		stx	<JiffyClk+2
1530
 3969  FEA290  84 03         		sty	<JiffyClk+3
1531
 3970  FEA292  2B            		pld
1532
 3971  FEA293  58            		cli
1533
 3972  FEA294  60            		rts
1534
 3973
1535
 3974                        	; get jiffy clock
1536
 3975                        	; C = 16 bit low, XY = 16 bit high
1537
 3976  FEA295                	_rdtim:
1538
 3977  FEA295  78            		sei
1539
 3978  FEA296  0B            		phd
1540
 3979  FEA297  F4 00 00      		pea	#0
1541
 3980  FEA29A  2B            		pld
1542
 3981  FEA29B  A5 01         		lda	<JiffyClk+1
1543
 3982  FEA29D  EB            		xba
1544
 3983  FEA29E  A5 00         		lda	<JiffyClk
1545
 3984  FEA2A0  A6 02         		ldx	<JiffyClk+2
1546
 3985  FEA2A2  A4 03         		ldy	<JiffyClk+3
1547
 3986  FEA2A4  2B            		pld
1548
 3987  FEA2A5  58            		cli
1549
 3988  FEA2A6  60            		rts
1550
 3989  FEA2A7
1551
  Tue Jul 17 11:00:23 2018                                                                                               Page   26
1552
 
1553
 
1554
 
1555
 
1556
 3990  FEA2A7                	_chkstop:
1557
 3991  FEA2A7                		SCNKEYBRK
1558
 3992  FEA2A7  02 18         		cop	$18
1559
 3993  FEA2A9  07            		.DB	$07
1560
 3994                        		.MNLIST
1561
 3995  FEA2AA  C9 80         		cmp	#$80		; set ZF if = $80 (ctrl break detected)
1562
 3996  FEA2AC  D0 05         		bne	?02
1563
 3997  FEA2AE  08            		php
1564
 3998  FEA2AF  20 10 A1      		jsr	_clrch		; restore default devices
1565
 3999  FEA2B2  28            		plp
1566
 4000  FEA2B3  60            	?02:	rts
1567
 4001
1568
 4002  FEA2B4                	_scrorg:
1569
 4003  FEA2B4                		SCNGETORG
1570
 4004  FEA2B4  02 18         		cop	$18
1571
 4005  FEA2B6  04            		.DB	$04
1572
 4006                        		.MNLIST
1573
 4007  FEA2B7  60            		rts
1574
 4008
1575
 4009  FEA2B8                	_scrplot:
1576
 4010  FEA2B8  90 04         		bcc	?02		; set pos
1577
 4011  FEA2BA                		SCNGETPOS
1578
 4012  FEA2BA  02 18         		cop	$18
1579
 4013  FEA2BC  02            		.DB	$02
1580
 4014                        		.MNLIST
1581
 4015  FEA2BD  60            		rts
1582
 4016  FEA2BE                	?02:	SCNSETPOS
1583
 4017  FEA2BE  02 18         		cop	$18
1584
 4018  FEA2C0  03            		.DB	$03
1585
 4019                        		.MNLIST
1586
 4020  FEA2C1  60            		rts
1587
 4021  FEA2C2
1588
 4022  FEA2C2                	_iobase:
1589
 4023  FEA2C2  A2 00         		ldx	#$00
1590
 4024  FEA2C4  A0 FD         		ldy	#$FD
1591
 4025  FEA2C6  60            		rts
1592
 4026  FEA2C7
1593
 4027  FEA2C7                	_cinit:
1594
 4028  FEA2C7                		SCNINIT
1595
 4029  FEA2C7  02 18         		cop	$18
1596
 4030  FEA2C9  00            		.DB	$00
1597
 4031                        		.MNLIST
1598
 4032  FEA2CA  60            		rts
1599
 4033
1600
 4034                        	; cold start ram init (Y = $80 if basic, $00 if pascal)
1601
 4035  FEA2CB                	_ramtas:
1602
 4036  FEA2CB  AF 80 FF FE   		lda	>TXTBNK		; current data bank
1603
 4037  FEA2CF  48            		pha
1604
 4038  FEA2D0  AB            		plb			; set current data bank
1605
 4039  FEA2D1                		ACC16
1606
 4040  FEA2D1  C2 20         		rep	#PMFLAG
1607
 4041                        		.LONGA	on
1608
 4042                        		.MNLIST
1609
 4043  FEA2D3  AF 7E FF FE   		lda	>CBMDP		; set current direct page
1610
 4044  FEA2D7  5B            		tcd
1611
 4045  FEA2D8  A2 00         		ldx	#0		; clear page 0
1612
 4046  FEA2DA  74 00         	?02:	stz	<$00,x
1613
  Tue Jul 17 11:00:23 2018                                                                                               Page   27
1614
 
1615
 
1616
 
1617
 
1618
 4047                        		;stz	!cbmwork,x
1619
 4048  FEA2DC  E8            		inx
1620
 4049  FEA2DD  E8            		inx
1621
 4050  FEA2DE  D0 FA         		bne	?02
1622
 4051  FEA2E0  8B            		phb
1623
 4052  FEA2E1  FA            		plx
1624
 4053  FEA2E2  86 A1         		stx	tbnk		; +0: text bank
1625
 4054  FEA2E4  E8            		inx
1626
 4055  FEA2E5  86 A2         		stx	vbnk		; +1: var/pcode bank
1627
 4056  FEA2E7  E8            		inx
1628
 4057  FEA2E8  86 A5         		stx	xbnk		; +2: exchange bank
1629
 4058  FEA2EA  E8            		inx
1630
 4059  FEA2EB  86 A3         		stx	cbnk		; +3: compiler/tmp bank
1631
 4060  FEA2ED  E8            		inx
1632
 4061  FEA2EE  86 A4         		stx	jbnk		; +4: object code bank for compiler (3 bank)
1633
 4062  FEA2F0  E8            		inx
1634
 4063  FEA2F1  E8            		inx
1635
 4064  FEA2F2  E8            		inx
1636
 4065  FEA2F3  86 A6         		stx	dbnk		; +7: ram disk
1637
 4066  FEA2F5  84 96         		sty	basic		; setup basic flag
1638
 4067  FEA2F7  A6 A2         		ldx	vbnk		; clear working area in var/p-code bank
1639
 4068  FEA2F9  20 93 A3      		jsr	?30
1640
 4069  FEA2FC  A6 A5         		ldx	xbnk		; clear working area in exchange bank
1641
 4070  FEA2FE  20 93 A3      		jsr	?30
1642
 4071  FEA301  A6 A3         		ldx	cbnk		; clear working area in compiler/tmp bank
1643
 4072  FEA303  20 93 A3      		jsr	?30
1644
 4073  FEA306  A0 00         		ldy	#0		; set up bank 0
1645
 4074  FEA308  5A            		phy
1646
 4075  FEA309  AB            		plb
1647
 4076  FEA30A  AC 0C 00      		ldy	!Bnk0Flag	; bit 6 mean warm reset
1648
 4077  FEA30D  84 5E         		sty	tmpval+1	; high in 16 bits!
1649
 4078  FEA30F  AF 7A FF FE   		lda	>TOPVAR
1650
 4079  FEA313  85 B3         		sta	vartop		; setup top mem. basic var/pcode/ex bank
1651
 4080  FEA315  A6 A1         		ldx	tbnk		; set up current working bank
1652
 4081  FEA317  DA            		phx
1653
 4082  FEA318  AB            		plb
1654
 4083  FEA319  A0 00         		ldy	#$00
1655
 4084  FEA31B  24 5D         		bit	tmpval		; flag warm reset in tmpval + 1
1656
 4085  FEA31D  70 05         		bvs	?04		; was warm reset
1657
 4086  FEA31F  20 95 A3      		jsr	?32		; clear working area of text-bank
1658
 4087  FEA322  80 33         		bra	?14
1659
 4088  FEA324  AD FE FF      	?04:	lda	!XBVSGN		; check valid signature for text in x-bank
1660
 4089  FEA327  C9 55 AA      		cmp	#VALIDSGN
1661
 4090  FEA32A  D0 07         		bne	?06		; not valid
1662
 4091  FEA32C  A2 80         		ldx	#$80		; bit 7 -> flag valid source text in x-bank
1663
 4092  FEA32E  AD FC FF      		lda	!XTOP2		; set the end of text pointer
1664
 4093  FEA331  80 08         		bra	?08
1665
 4094  FEA333  9C FE FF      	?06:	stz	!XBVSGN		; clear signature
1666
 4095  FEA336  9C FC FF      		stz	!XTOP2
1667
 4096  FEA339  98            		tya			; A = 0
1668
 4097  FEA33A  BB            		tyx			; X = 0
1669
 4098  FEA33B  86 8F         	?08:	stx	vxflag		; set flag
1670
 4099  FEA33D  85 B5         		sta	xtop		; top of text end on x-bank
1671
 4100  FEA33F  BB            		tyx			; clear working area
1672
 4101  FEA340  9E 00 FF      	?12:	stz	!$FF00,x
1673
 4102  FEA343  E8            		inx
1674
 4103  FEA344  E8            		inx
1675
  Tue Jul 17 11:00:23 2018                                                                                               Page   28
1676
 
1677
 
1678
 
1679
 
1680
 4104  FEA345  E0 F8         		cpx	#$F8
1681
 4105  FEA347  90 F7         		bcc	?12
1682
 4106  FEA349  AD FA FF      		lda	!TXTVSGN
1683
 4107  FEA34C  C9 55 AA      		cmp	#VALIDSGN
1684
 4108  FEA34F  F0 06         		beq	?14		; possible valid source text in buffer
1685
 4109  FEA351  9C FA FF      		stz	!TXTVSGN
1686
 4110  FEA354  9C F8 FF      		stz	!TXTEND2
1687
 4111  FEA357  A9 01 01      	?14:	lda	#$0101
1688
 4112  FEA35A  8D 00 FF      		sta	!cbmwork	; used by editor
1689
 4113  FEA35D  A9 00 FF      		lda	#cbmwork	; set top mem
1690
 4114  FEA360  85 A9         		sta	topmem
1691
 4115  FEA362  64 76         		stz	longp
1692
 4116  FEA364  A6 A5         		ldx	xbnk
1693
 4117  FEA366  86 78         		stx	longp+2
1694
 4118  FEA368  98            		tya
1695
 4119  FEA369                		ACC08
1696
 4120  FEA369  E2 20         		sep	#PMFLAG
1697
 4121                        		.LONGA	off
1698
 4122                        		.MNLIST
1699
 4123  FEA36B  87 76         		sta	[longp]		; first byte always null
1700
 4124  FEA36D                		ACC16
1701
 4125  FEA36D  C2 20         		rep	#PMFLAG
1702
 4126                        		.LONGA	on
1703
 4127                        		.MNLIST
1704
 4128  FEA36F  AD F8 FF      		lda	!TXTEND2
1705
 4129  FEA372  85 5D         		sta	tmpval		; save end of text to recover
1706
 4130  FEA374  AD FA FF      		lda	!TXTVSGN
1707
 4131  FEA377  C9 55 AA      		cmp	#VALIDSGN
1708
 4132  FEA37A                		CPU08
1709
 4133  FEA37A  E2 30         		sep	#(PMFLAG.OR.PXFLAG)
1710
 4134                        		.LONGA	off
1711
 4135                        		.LONGI	off
1712
 4136                        		.MNLIST
1713
 4137  FEA37C  D0 04         		bne	?16
1714
 4138  FEA37E  A9 40         		lda	#$40		; bit 6 -> possible valid source text
1715
 4139  FEA380  04 8F         		tsb	vxflag
1716
 4140  FEA382  A2 03         	?16:	ldx	#3
1717
 4141  FEA384  86 9A         		stx	dflto		; default output device
1718
 4142  FEA386  A9 0A         		lda	#$0A
1719
 4143  FEA388  85 9F         		sta	wauto
1720
 4144  FEA38A  A9 80         		lda	#$80
1721
 4145  FEA38C  85 9E         		sta	autof
1722
 4146  FEA38E  A9 40         		lda	#$40
1723
 4147  FEA390  04 96         		tsb	basic		; editor/emulator mode flag
1724
 4148  FEA392  60            		rts
1725
 4149
1726
 4150  FEA393  DA            	?30:	phx			; clear working area bank = X
1727
 4151  FEA394  AB            		plb
1728
 4152  FEA395  A2 00         	?32:	ldx	#0		; clear working area in bank
1729
 4153  FEA397  9E 00 FF      	?34:	stz	!$FF00,x
1730
 4154  FEA39A  E8            		inx
1731
 4155  FEA39B  E8            		inx
1732
 4156  FEA39C  D0 F9         		bne	?34
1733
 4157  FEA39E  60            		rts
1734
 4158  FEA39F
1735
 4159  FEA39F                	_ikeybuf:
1736
 4160  FEA39F  8B            		phb			; insert string in keyboard input buffer
1737
  Tue Jul 17 11:00:23 2018                                                                                               Page   29
1738
 
1739
 
1740
 
1741
 
1742
 4161  FEA3A0  FA            		plx			; X = data bank, C = address
1743
 4162  FEA3A1                		SCNKEYBUF
1744
 4163  FEA3A1  02 18         		cop	$18
1745
 4164  FEA3A3  08            		.DB	$08
1746
 4165                        		.MNLIST
1747
 4166  FEA3A4  60            		rts
1748
 4167
1749
 4168                        	; cold start CBM emulator
1750
 4169                        	; In	- Y = $00 -> pascal mode
1751
 4170                        	;	  Y = $80 -> basic mode
1752
 4171  FEA3A5                	_cold:
1753
 4172  FEA3A5  08            		php			; save caller context
1754
 4173  FEA3A6  8B            		phb
1755
 4174  FEA3A7  0B            		phd			; status, data bank and direct page
1756
 4175  FEA3A8                		CPU08
1757
 4176  FEA3A8  E2 30         		sep	#(PMFLAG.OR.PXFLAG)
1758
 4177                        		.LONGA	off
1759
 4178                        		.LONGI	off
1760
 4179                        		.MNLIST
1761
 4180  FEA3AA  20 87 FF      		jsr	RAMTAS		; init memory
1762
 4181  FEA3AD                		ACC16
1763
 4182  FEA3AD  C2 20         		rep	#PMFLAG
1764
 4183                        		.LONGA	on
1765
 4184                        		.MNLIST
1766
 4185  FEA3AF  3B            		tsc
1767
 4186  FEA3B0  85 C0         		sta	curstk		; current operative stack
1768
 4187  FEA3B2                		ACC08
1769
 4188  FEA3B2  E2 20         		sep	#PMFLAG
1770
 4189                        		.LONGA	off
1771
 4190                        		.MNLIST
1772
 4191  FEA3B4  20 2C A4      		jsr	_basinit
1773
 4192  FEA3B7  20 81 FF      		jsr	CINIT
1774
 4193  FEA3BA  A5 8F         		lda	vxflag		; save recovery flag
1775
 4194  FEA3BC  85 5A         		sta	tmpb2
1776
 4195  FEA3BE  20 91 06      		jsr	cbm_new2	; this clear recovery flag
1777
 4196  FEA3C1  24 5A         		bit	tmpb2
1778
 4197  FEA3C3  50 4B         		bvc	?20
1779
 4198  FEA3C5                		ACC16CLC		; attempt to recover a source text
1780
 4199  FEA3C5  C2 21         		rep	#(PMFLAG.OR.PCFLAG)
1781
 4200                        		.LONGA	on
1782
 4201                        		.MNLIST
1783
 4202  FEA3C7  A5 AB         		lda	txtbeg		; attempt to relink
1784
 4203  FEA3C9  85 76         		sta	longp
1785
 4204  FEA3CB                		ACC08
1786
 4205  FEA3CB  E2 20         		sep	#PMFLAG
1787
 4206                        		.LONGA	off
1788
 4207                        		.MNLIST
1789
 4208  FEA3CD  A0 03         		ldy	#$03		; search end of line
1790
 4209  FEA3CF  C8            	?04:	iny
1791
 4210  FEA3D0  B1 76         		lda	(longp),y
1792
 4211  FEA3D2  D0 FB         		bne	?04
1793
 4212  FEA3D4  C8            		iny
1794
 4213  FEA3D5                		ACC16CLC
1795
 4214  FEA3D5  C2 21         		rep	#(PMFLAG.OR.PCFLAG)
1796
 4215                        		.LONGA	on
1797
 4216                        		.MNLIST
1798
 4217  FEA3D7  98            		tya
1799
  Tue Jul 17 11:00:23 2018                                                                                               Page   30
1800
 
1801
 
1802
 
1803
 
1804
 4218  FEA3D8  65 76         		adc	longp
1805
 4219  FEA3DA  85 5F         		sta	tlnptr		; possible first link
1806
 4220  FEA3DC  85 76         	?06:	sta	longp		; check all link
1807
 4221  FEA3DE  B2 76         		lda	(longp)
1808
 4222  FEA3E0  F0 15         		beq	?10		; end of text
1809
 4223  FEA3E2                		ACC08
1810
 4224  FEA3E2  E2 20         		sep	#PMFLAG
1811
 4225                        		.LONGA	off
1812
 4226                        		.MNLIST
1813
 4227  FEA3E4  A0 03         		ldy	#$03		; search end of line
1814
 4228  FEA3E6  C8            	?08:	iny
1815
 4229  FEA3E7  B1 76         		lda	(longp),y
1816
 4230  FEA3E9  D0 FB         		bne	?08
1817
 4231  FEA3EB  C8            		iny
1818
 4232  FEA3EC                		ACC16CLC
1819
 4233  FEA3EC  C2 21         		rep	#(PMFLAG.OR.PCFLAG)
1820
 4234                        		.LONGA	on
1821
 4235                        		.MNLIST
1822
 4236  FEA3EE  98            		tya
1823
 4237  FEA3EF  65 76         		adc	longp		; compare with stored link
1824
 4238  FEA3F1  D2 76         		cmp	(longp)
1825
 4239  FEA3F3  F0 E7         		beq	?06		; check next link
1826
 4240  FEA3F5  D0 17         		bne	?15		; mismatch: invalid source text
1827
 4241  FEA3F7  A5 76         	?10:	lda	longp
1828
 4242  FEA3F9  1A            		inc	a
1829
 4243  FEA3FA  1A            		inc	a
1830
 4244  FEA3FB  C5 5D         		cmp	tmpval		; compare with saved end of text
1831
 4245  FEA3FD  D0 0F         		bne	?15		; failed recovery
1832
 4246  FEA3FF  85 AD         		sta	txtend
1833
 4247  FEA401  8D F8 FF      		sta	!TXTEND2	; valid signature
1834
 4248  FEA404  A5 5F         		lda	tlnptr		; setup first link
1835
 4249  FEA406  92 AB         		sta	(txtbeg)
1836
 4250  FEA408  A9 55 AA      		lda	#VALIDSGN
1837
 4251  FEA40B  8D FA FF      		sta	!TXTVSGN
1838
 4252  FEA40E                	?15:	ACC08
1839
 4253  FEA40E  E2 20         		sep	#PMFLAG
1840
 4254                        		.LONGA	off
1841
 4255                        		.MNLIST
1842
 4256  FEA410  4C A4 01      	?20:	jmp	cbm_rdy
1843
 4257  FEA413
1844
 4258  FEA413                	_mon:
1845
 4259  FEA413  A9 FF         		lda	#$FF
1846
 4260  FEA415  22 00 00 FF   		jsl	MONITOR
1847
 4261  FEA419                		ACC16
1848
 4262  FEA419  C2 20         		rep	#PMFLAG
1849
 4263                        		.LONGA	on
1850
 4264                        		.MNLIST
1851
 4265  FEA41B  AF 7E FF FE   		lda	>CBMDP		; set current direct page
1852
 4266  FEA41F  5B            		tcd
1853
 4267  FEA420                		ACC08
1854
 4268  FEA420  E2 20         		sep	#PMFLAG
1855
 4269                        		.LONGA	off
1856
 4270                        		.MNLIST
1857
 4271  FEA422  A5 A1         		lda	tbnk
1858
 4272  FEA424  48            		pha
1859
 4273  FEA425  AB            		plb
1860
 4274  FEA426                	_warm:
1861
  Tue Jul 17 11:00:23 2018                                                                                               Page   31
1862
 
1863
 
1864
 
1865
 
1866
 4275  FEA426  20 CB 06      		jsr	cbm_res
1867
 4276  FEA429  4C A4 01      		jmp	cbm_rdy
1868
 4277  FEA42C
1869
 4278                        	; init basic memory
1870
 4279  FEA42C                	_basinit:
1871
 4280  FEA42C  38            		sec
1872
 4281  FEA42D  20 9C FF      		jsr	MEMBOT		; get bottom of memory
1873
 4282  FEA430  86 AB         		stx	txtbeg
1874
 4283  FEA432  84 AC         		sty	txtbeg+1
1875
 4284  FEA434  38            		sec
1876
 4285  FEA435  20 99 FF      		jsr	MEMTOP		; get top of memory
1877
 4286  FEA438  86 AF         		stx	txttop
1878
 4287  FEA43A  84 B0         		sty	txttop+1
1879
 4288  FEA43C  86 33         		stx	freetop
1880
 4289  FEA43E  84 34         		sty	freetop+1
1881
 4290  FEA440  24 96         		bit	basic
1882
 4291  FEA442  30 06         		bmi	?02
1883
 4292  FEA444  A9 80         		lda	#$80
1884
 4293  FEA446  85 9B         		sta	skpbk
1885
 4294  FEA448  85 9C         		sta	w2sf
1886
 4295  FEA44A  A2 1B         	?02: 	ldx	#$1B
1887
 4296  FEA44C  86 16         		stx	tmppt
1888
 4297  FEA44E  A9 00         		lda	#0
1889
 4298  FEA450  85 68         		sta	facov
1890
 4299  FEA452  85 53         		sta	prompt
1891
 4300  FEA454  92 AB         		sta	(txtbeg)
1892
 4301  FEA456  E6 AB         		inc	txtbeg
1893
 4302  FEA458  D0 02         		bne	?20
1894
 4303  FEA45A  E6 AC         		inc	txtbeg+1
1895
 4304  FEA45C  60            	?20:	rts
1896
 4305
1897
 4306                        		.CBMJMP
1898
 4307
1899
 4308                        		.LONGA off
1900
 4309                        		.LONGI off
1901
 4310
1902
 4311  FEFF00                		.ORG	$00
1903
 4312
1904
 4313                        	; $FF00 - cold start
1905
 4314  FEFF00  4C A5 A3      		jmp	_cold
1906
 4315                        	; $FF03 - warm start
1907
 4316  FEFF03  4C 26 A4      		jmp	_warm
1908
 4317
1909
 4318  FEFF30                		.ORG	$30
1910
 4319                        	; jump table for pascal compiler
1911
 4320  FEFF30
1912
 4321                        		.EXTERN L0836, L083C, L083F, L0842, L0845, L084B, L084E, L0851
1913
 4322                        		.EXTERN L0854, L0857
1914
 4323  FEFF30
1915
 4324                        	; $FF30 ($0836)
1916
 4325  FEFF30  4C E5 35      		jmp	L0836
1917
 4326                        	; $FF33 ($083C)
1918
 4327  FEFF33  4C 98 35      		jmp	L083C
1919
 4328                        	; $FF36 ($083F)
1920
 4329  FEFF36  4C 30 36      		jmp	L083F
1921
 4330                        	; $FF39 ($0842)
1922
 4331  FEFF39  4C EE 36      		jmp	L0842
1923
  Tue Jul 17 11:00:23 2018                                                                                               Page   32
1924
 
1925
 
1926
 
1927
 
1928
 4332                        	; $FF3C ($0845)
1929
 4333  FEFF3C  4C 16 37      		jmp	L0845
1930
 4334                        	; $FF3F ($084B)
1931
 4335  FEFF3F  4C EE 35      		jmp	L084B
1932
 4336                        	; $FF42 ($084E)
1933
 4337  FEFF42  4C F4 34      		jmp	L084E
1934
 4338                        	; $FF45 ($0851)
1935
 4339  FEFF45  4C 52 35      		jmp	L0851
1936
 4340                        	; $FF48 ($0854)
1937
 4341  FEFF48  4C 3B 37      		jmp	L0854
1938
 4342                        	; $FF4B ($0857)
1939
 4343  FEFF4B  4C 35 37      		jmp	L0857
1940
 4344
1941
 4345  FEFF4E
1942
 4346  FEFF7A                		.ORG	$7A
1943
 4347
1944
 4348  FEFF7A  00FF          	TOPVAR:		.DW	$FF00	; top of memory reserved to var/pcode
1945
 4349  FEFF7C  E0FF          	TOPMRD:		.DW	$FFE0	; top of memory reserved to ram disk
1946
 4350  FEFF7E  007F          	CBMDP:		.DW	$7F00	; direct page used by CBM emulator
1947
 4351  FEFF80  10            	TXTBNK:		.DB	$10	; bank that hold text buffer
1948
 4352  FEFF81
1949
 4353                        	; $FF81 - CINIT
1950
 4354  FEFF81  4C C7 A2      		jmp	_cinit
1951
 4355                        	; $FF84 - IOINIT (no op)
1952
 4356  FEFF84  EA            		nop
1953
 4357  FEFF85  18            		clc
1954
 4358  FEFF86  60            		rts
1955
 4359                        	; $FF87 - RAMTAS
1956
 4360  FEFF87  4C CB A2      		jmp	_ramtas
1957
 4361                        	; $FF8A - RESTOR (no op)
1958
 4362  FEFF8A  EA            		nop
1959
 4363  FEFF8B  18            		clc
1960
 4364  FEFF8C  60            		rts
1961
 4365                        	; $FF8D - VECTOR (no op)
1962
 4366  FEFF8D  EA            		nop
1963
 4367  FEFF8E  18            		clc
1964
 4368  FEFF8F  60            		rts
1965
 4369                        	; $FF90 - SETMSG
1966
 4370  FEFF90  4C 4B A2      		jmp	_setmsg
1967
 4371                        	; $FF93 - SECOND (no op)
1968
 4372  FEFF93  EA            		nop
1969
 4373  FEFF94  18            		clc
1970
 4374  FEFF95  60            		rts
1971
 4375                        	; $FF96 - TKSA (no op)
1972
 4376  FEFF96  EA            		nop
1973
 4377  FEFF97  18            		clc
1974
 4378  FEFF98  60            		rts
1975
 4379                        	; $FF99 - MEMTOP
1976
 4380  FEFF99  4C 4E A2      		jmp	_memtop
1977
 4381                        	; $FF9C - MEMBOT
1978
 4382  FEFF9C  4C 5A A2      		jmp	_membot
1979
 4383                        	; $FF9F - SCNKEY
1980
 4384  FEFF9F  4C 66 A2      		jmp	_scnkey
1981
 4385                        	; $FFA2 - SETTMO (no op)
1982
 4386  FEFFA2  EA            		nop
1983
 4387  FEFFA3  18            		clc
1984
 4388  FEFFA4  60            		rts
1985
  Tue Jul 17 11:00:23 2018                                                                                               Page   33
1986
 
1987
 
1988
 
1989
 
1990
 4389                        	; $FFA5 - ACPTR
1991
 4390  FEFFA5  4C 5D 9F      		jmp	iecin
1992
 4391                        	; $FFA8 - CIOUT
1993
 4392  FEFFA8  4C 2D 9F      		jmp	iecout
1994
 4393                        	; $FFAB - UNTLK (no op)
1995
 4394  FEFFAB  EA            		nop
1996
 4395  FEFFAC  18            		clc
1997
 4396  FEFFAD  60            		rts
1998
 4397                        	; $FFAE - UNLSN (no op)
1999
 4398  FEFFAE  EA            		nop
2000
 4399  FEFFAF  18            		clc
2001
 4400  FEFFB0  60            		rts
2002
 4401                        	; $FFB1 - LISTEN (no op)
2003
 4402  FEFFB1  EA            		nop
2004
 4403  FEFFB2  18            		clc
2005
 4404  FEFFB3  60            		rts
2006
 4405                        	; $FFB4 - TALK (no op)
2007
 4406  FEFFB4  EA            		nop
2008
 4407  FEFFB5  18            		clc
2009
 4408  FEFFB6  60            		rts
2010
 4409                        	; $FFB7 - READST
2011
 4410  FEFFB7  4C 70 A2      		jmp	_readst
2012
 4411                        	; $FFBA - SETLFS
2013
 4412  FEFFBA  4C 73 A2      		jmp	_setlfs
2014
 4413                        	; $FFBD - SETNAM
2015
 4414  FEFFBD  4C 7A A2      		jmp	_setnam
2016
 4415                        	; $FFC0 - FOPEN
2017
 4416  FEFFC0  4C 64 A0      		jmp	_open
2018
 4417                        	; $FFC3 - FCLOSE
2019
 4418  FEFFC3  4C 26 A1      		jmp	_close
2020
 4419                        	; $FFC6 - FSETIN
2021
 4420  FEFFC6  4C B1 A0      		jmp	_chkin
2022
 4421                        	; $FFC9 - FSETOUT
2023
 4422  FEFFC9  4C D9 A0      		jmp	_chkout
2024
 4423                        	; $FFCC - FCLRCH
2025
 4424  FEFFCC  4C 10 A1      		jmp	_clrch
2026
 4425                        	; $FFCF - FCHRIN
2027
 4426  FEFFCF  4C 42 A0      		jmp	_chrin
2028
 4427                        	; $FFD2 - FCHROUT
2029
 4428  FEFFD2  4C 18 A0      		jmp	_chrout
2030
 4429                        	; $FFD5 - FLOAD
2031
 4430  FEFFD5  4C 81 A2      		jmp	_load
2032
 4431                        	; $FFD8 - FSAVE
2033
 4432  FEFFD8  4C 82 A2      		jmp	_save
2034
 4433                        	; $FFDB - SETTIM
2035
 4434  FEFFDB  4C 83 A2      		jmp	_settim
2036
 4435                        	; $FFDE - RDTIM
2037
 4436  FEFFDE  4C 95 A2      		jmp	_rdtim
2038
 4437                        	; $FFE1 - CHKSTOP
2039
 4438  FEFFE1  4C A7 A2      		jmp	_chkstop
2040
 4439                        	; $FFE4 -  FGETIN
2041
 4440  FEFFE4  4C 36 A0      		jmp	_getin
2042
 4441                        	; $FFE7 - FCLALL
2043
 4442  FEFFE7  4C 01 A1      		jmp	_clall
2044
 4443                        	; $FFEA - UDTIM (no op)
2045
 4444  FEFFEA  EA            		nop
2046
 4445  FEFFEB  18            		clc
2047
  Tue Jul 17 11:00:23 2018                                                                                               Page   34
2048
 
2049
 
2050
 
2051
 
2052
 4446  FEFFEC  60            		rts
2053
 4447                        	; $FFED - SCRORG
2054
 4448  FEFFED  4C B4 A2      		jmp	_scrorg
2055
 4449                        	; $FFF0 - SCRPLOT
2056
 4450  FEFFF0  4C B8 A2      		jmp	_scrplot
2057
 4451                        	; $FFF3 - GETIOBASE
2058
 4452  FEFFF3  4C C2 A2      		jmp	_iobase
2059
 4453                        	; $FFF6 - IKEYBUF
2060
 4454  FEFFF6  4C 9F A3      		jmp	_ikeybuf
2061
 4455                        	; $FFF9 - GOMON
2062
 4456  FEFFF9  4C 13 A4      		jmp	_mon
2063
 
2064
 
2065
             Lines Assembled : 4328                  Errors : 0
2066
 
2067
 
2068