Subversion Repositories MB01 Project

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 - 1
  Tue Jul 17 11:00:21 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\FA\getopt.asm
13
                       Output Filename : obj\FA\getopt.obj
14
                       Listing Has Been Relocated
15
 
16
 
17
 2603                        	.LIST		on
18
 2604
19
 2605  F8FFB1                		.INCLUDE inc\dirp00.inc
20
 2606                        	;----------------------------------------------------------
21
 2607                        	; DIRP00.ASM
22
 2608                        	; PROGETTO: B1601
23
 2609                        	;
24
 2610                        	; Variabili in Direct Page $00
25
 2611                        	;----------------------------------------------------------
26
 2612
27
 2613                        	; sezione COMMON -- questo permette di includere il file in piu' file
28
 2614
29
 2615                        	.LIST on
30
 2616
31
 2617                        	DIRP00:	.SECTION page0, ref_only, common	;Direct-Page 00
32
 2618
33
 2619  000000                		.ABSOLUTE		;; inizia sempre da $00
34
 2620  000000                		.ORG		0x00
35
 2621  000000
36
 2622  000000  0000          	JiffyClk	.DW			; contatore 10ms 32 bit
37
 2623  000002  0000          			.DW
38
 2624  000004                	SysTmr		.DS	SYSTMRCNT	; system timer 0 (10ms)
39
 2625  000008                	SysTMF		.DS	SYSTMRCNT	; flag timer (80 -> start)
40
 2626  00000C  00            	Bnk0Flag	.DB			; <7>: flag test RAM banco 0 ok
41
 2627                        						; <6>: flag warm reset
42
 2628  00000D  00            	RTCFlag		.DB
43
 2629
44
 2630  00000E                	diskstat	.DS	2	; flag device on ata bus #0 & #1
45
 2631                        					; <7>: device ready
46
 2632                        					; <6>: compact flash device (C.F.)
47
 2633                        					; <5>: device identification ok
48
 2634                        					; <4>: MBR loaded
49
 2635                        					; <3>: valid signature in MBR
50
 2636                        					; <2>: first partition found&active
51
 2637                        					; <1>:
52
 2638                        					; <0>: valid partition flag
53
 2639
54
 2640                        					; <7>: device ready
55
 2641                        					; <6>: USB device
56
 2642                        					; <5>: compact flash device (C.F.)
57
 2643                        					; <4>: device identification ok
58
 2644                        					; <3>: MBR loaded
59
 2645                        					; <2>: first partition found&active
60
 2646                        					; <1>: always 1
61
 2647                        					; <0>: valid partition flag
62
 2648  000010
63
  Tue Jul 17 11:00:21 2018                                                                                               Page    2
64
 
65
 
66
 
67
 
68
 2649
69
 2650          00000E        	atadev		.EQU	diskstat
70
 2651
71
 2652  000010                	usbdev		.DS	2	; flag flash disk on usb bus #0
72
 2653                        					; <7>: device plugged and ready
73
 2654                        					; <6>: always 1
74
 2655                        					; <5>: device identification ok
75
 2656                        					; <4>: MBR loaded
76
 2657                        					; <3>: valid signature in MBR
77
 2658                        					; <2>: first partition found&active
78
 2659                        					; <1>:
79
 2660                        					; <0>: valid partition flag
80
 2661
81
 2662  000012                	diskmax		.DS	16	; disk max. sector's
82
 2663          000012        	atasec		.EQU	diskmax
83
 2664          00001A        	usbsec		.EQU	diskmax+8
84
 2665
85
 2666
86
 2667  000022                	atambr		.DS	8	; data for first partition found in mbr
87
 2668                        					; first 3 bytes for start sector of partition
88
 2669                        					; last byte for partition type
89
 2670  00002A                	usbmbr		.DS	8
90
 2671
91
 2672  000032                	ataprt		.DS	8	; total sec's of first partition
92
 2673  00003A                	usbprt		.DS	8	; total sec's of first partition
93
 2674
94
 2675
95
 2676  000042  00            	usb0ch		.DB	; usb0 (ch375/ch376) flag
96
 2677                        				; <7>: module on
97
 2678                        				; <6>: ch376 flag
98
 2679                        				; <5:0>: chip version
99
 2680
100
 2681  000043  00            	usb0st		.DB	; usb0 status
101
 2682                        				; <7>: usb0 host mode ok
102
 2683                        				; <6>: flash disk attached flag
103
 2684                        				; <5>: usb device attached
104
 2685
105
 2686  000044  00            	fdcdrv		.DB		; phisycal drive status (drive #0)
106
 2687                        					; <7>: disk format established in bit 0&1
107
 2688                        					; <6>: double step seek done
108
 2689                        					; <5>: trust format bit's (set after ok r/w)
109
 2690                        					; <4>: write protect bit (if disk in drive)
110
 2691                        					; <3>: don't care
111
 2692                        					; <2>: don't care
112
 2693                        					; <1>: HD disk if set else DD disk
113
 2694                        					; <0>: CBM format if set else IBM format
114
 2695
115
 2696  000045  00            	vdrive		.DB		; virtual drive status (ram disk, drive #1)
116
 2697                        					; <7>: disk format established in bit 0&1
117
 2698                        					; <6>: change disk simulation (after format)
118
 2699                        					; <5>: don't care
119
 2700                        					; <4>: write protect bit (under sw control)
120
 2701                        					; <3>: don't care
121
 2702                        					; <2>: don't care
122
 2703                        					; <1>: HD disk if set else DD disk
123
 2704                        					; <0>: CBM format if set else IBM format
124
 2705
125
  Tue Jul 17 11:00:21 2018                                                                                               Page    3
126
 
127
 
128
 
129
 
130
 2706  000046  00            	fdcctl		.DB		; fdc controller status
131
 2707                        					; <7>: drive is attached
132
 2708                        					; <6>: drive need recalibration (restore)
133
 2709                        					; <5>: FDC controller ok
134
 2710                        					; <4>: motor on
135
 2711                        					; <3>: dma is active
136
 2712                        					; <2>: dma chip ok (post routine)
137
 2713                        					; <1>: clock rate (1=HD,0=DD)
138
 2714                        					; <0>: disk ready
139
 2715
140
 2716  000047  00            	fdctrk		.DB		; fd: current seek track
141
 2717  000048  00            	fdcerr		.DB		; fd: last error code
142
 2718  000049  00            	ataerr		.DB		; ata: last error code
143
 2719  00004A  00            	ataxer		.DB		; ata: last extended error code
144
 2720
145
 2721  00004B  00            	CtrlBrk		.DB		; flag CTRL+BREAK (NMI)
146
 2722
147
 2723  00004C  0000          	MemTop		.DW		; top memoria RAM
148
 2724  00004E  00            			.DB		; banco top mem
149
 2725
150
 2726  00004F  00            	DflTxtIn	.DB		; device di default text input
151
 2727  000050  00            	DflTxtOut	.DB		; device di default text output
152
 2728
153
 2729  000051                	COPPtr		LP		; long pointer for COP decoding
154
 2730  000054  00            	COPIdx		.DB		; COP signature/index
155
 2731
156
 2732  000055  00            	BiosEnt		.DB		; flag accesso a bios setup
157
 2733
158
 2734                        	; variabili utilizzate da ACIA
159
 2735  000056                	spwrk		.DS	$30
160
 2736
161
 2737                        	; bios mem
162
 2738  000086  0000          	nsize		.DW	; dimensione blocco da allocare
163
 2739                        	;bsize		.DW	; dimensione vera blocco free
164
 2740  000088  0000          	splitsz		.DW	; dimensione blocco splittato
165
 2741  00008A  0000          	bfree		.DW	; puntatore blocco free
166
 2742  00008C  0000          	hdrptr		.DW	; puntatore header heap
167
 2743
168
 2744  00008E  0000          	pbrklv		.DW	; current break level of current process
169
 2745  000090  0000          	pbrkmin		.DW	; minimum breal level of current process
170
 2746  000092  0000          	pbrkmax		.DW	; maximum breal level of current process
171
 2747  000094
172
 2748                        	; bios temp. work area
173
 2749  000094                	bwrktmp		.DS	$28
174
 2750
175
 2751  0000BC  00            	coptmp		.DB	; temp. used while cop
176
 2752
177
 2753  0000BD  00            	tstser		.DB	; check ser/usb test board post
178
 2754                        				; <7>: VIA2 ok
179
 2755                        				; <6>: PICRAM ok
180
 2756                        				; <1>: UART 16C550 ok
181
 2757                        				; <0>: R65C51 ok
182
 2758
183
 2759
184
 2760                        	;crc16		.DW
185
 2761
186
 2762  0000BD                		.RELATIVE
187
  Tue Jul 17 11:00:21 2018                                                                                               Page    4
188
 
189
 
190
 
191
 
192
 2763
193
 2764                        		.ENDS
194
 2765
195
 2766          [01]          	.IFDEF		_ACIA_INC_
196
 2767                        		.INCLUDE INC\SP.INC
197
 2768          [00]          	.ENDIF
198
 2769
199
 2773                        	.LIST on
200
 2774
201
 2775                        	; page 0 local var's (declared in bios temp. work area)
202
 2776                        	_P0BTMP:	.SECTION page0, ref_only, offset bwrktmp	; DP Tmp. BIOS
203
 2777
204
 2778  000094                	cmdlin		LP		; long pointer to command line
205
 2779  000097                	optstr		LP		; long pointer to options mask
206
 2780  00009A  0000 0000     	dwres		.LWORD		; result
207
 2781  00009E  00            	slen		.DB		; string length
208
 2782  00009F  00            	squot		.DB		; flag quotation marks
209
 2783  0000A0  00            	cmdy		.DB		; index
210
 2784  0000A1  00            	chopt		.DB		; option char
211
 2785  0000A2  00            	prsfg		.DB		; parsing flag
212
 2786  0000A3  00            	opttyp		.DB		; option type
213
 2787  0000A4                	intarg		.DS	4	; integer argument
214
 2788  0000A8                	tmpp		LP
215
 2789  0000AB  00            	argsgn		.DB
216
 2790
217
 2791                        		.ENDS
218
 2792
219
 2793                        	;---------------------------------------------------------------------------
220
 2794                        	; code segment -- bank $FA
221
 2795                        	;---------------------------------------------------------------------------
222
 2796
223
 2797                        		.CODEFA
224
 2798                        		.EXTERN _lstrtoint
225
 2799
226
 2800                        		.LONGA	off
227
 2801                        		.LONGI	off
228
 2802
229
 2803                        	; getopt
230
 2804                        	;
231
 2805                        	; parse a command line and return option&argument
232
 2806                        	; command line is parsed basis on option string, a mask that specify option ch
233
 2807                        	; and argument type. Any option start with '-' character, followed by a single
234
 2808                        	; character; if option requires an argument, this argument follow (without
235
 2809                        	; blanks) the character option. String option can be quoted (with quotation
236
 2810                        	; marks, this need when argument contains blanks).
237
 2811                        	; Option string have this simple skeleton:
238
 2812                        	;
239
 2813                        	;	xtxtxtxt....
240
 2814                        	;
241
 2815                        	; where x is a single option character and t is the argument type
242
 2816                        	; recognized argument types:
243
 2817                        	;	t=	blank, mean option does not requires argument
244
 2818                        	;		':', '$': mean option requires a string argument
245
 2819                        	;			  type '$' return an up case string
246
 2820                        	;		'!', '^': mean option requires a single char argument
247
 2821                        	; 			  type '^' return an up case char
248
 2822                        	;		'%'	: byte argument required
249
  Tue Jul 17 11:00:21 2018                                                                                               Page    5
250
 
251
 
252
 
253
 
254
 2823                        	;		'#'	: integer 16 bit argument required
255
 2824                        	;		'*'	: integer 24 bit argument required (ptr type)
256
 2825                        	;		'&'	: integer 32 bit argument required
257
 2826                        	;
258
 2827                        	; option string example: 'r s:t^'
259
 2828                        	; option '-r' without argument
260
 2829                        	; option '-s' requires a string
261
 2830                        	; option '-t' requires a single character, returned in up case
262
 2831                        	; an example of valid command line for above mask:
263
 2832                        	;	xxxxx  -szzzzz -r -tC  yyyyy
264
 2833                        	; string 'yyyyy' is an argument without option
265
 2834                        	;
266
 2835                        	; function return
267
 2836                        	; getopt does not clean stack frame when exit and parameter's will be modified
268
 2837                        	; sCmd change at any call and hold the residual command line string
269
 2838                        	; sRes change at any call and hold the argument (long pointer to string,
270
 2839                        	; a single character, a numeric argument)
271
 2840                        	; Y return the option type associated with the current parsed option
272
 2841                        	; A return: 0 if reached the end of command line, the current parsed option,
273
 2842                        	; or a negative value if return an argument without option: in this last case
274
 2843                        	; sRes return a string.
275
 2844                        	;
276
 2845                        	; calling getopt will be in a loop until A=0 or until error; the caller should
277
 2846                        	; clean stack when finish to parse command line
278
 2847                        	;
279
 2848                        	; param's:
280
 2849                        	;
281
 2850                        	;		sFlag	= <7>: show error message
282
 2851                        	;			  <6>: accept decimal numeric arguments
283
 2852                        	;			  <5>: wanted signed int arg. (only if bit 6 is set)
284
 2853                        	;			  <0>: called from monitor
285
 2854                        	;		sCmd	= long pointer to command line
286
 2855                        	;		sOpt	= long pointer to option's string
287
 2856                        	;		sRes	= 32 bit result
288
 2857                        	;
289
 2858                        	; exit:
290
 2859                        	;		sCmd	= residual command line string
291
 2860                        	;		sRes	= argument (depend on type)
292
 2861                        	;		A	= option character currently parsed
293
 2862                        	;			  or =0 when end of string,
294
 2863                        	;			  or negative when parsed argument without option
295
 2864                        	;		Y	= option type associated with option
296
 2865                        	;
297
 2866                        	; if any error, function return CF=1, otherwise CF=0
298
 2867                        	;
299
 2868                        	; param's stack offset
300
 2869          000006        	sRes	.SET	6
301
 2870          00000A        	sOpt	.SET	10
302
 2871          00000D        	sCmd	.SET	13
303
 2872          000010        	sFlag	.SET	16
304
 2873
305
 2874                        	;----------------------
306
 2875  FA0009                	_getopt:
307
 2876                        		.PUBLIC _getopt
308
 2877                        	;----------------------
309
 2878  FA0009  0B            		phd
310
 2879  FA000A  F4 00 00      		pea	#0
311
  Tue Jul 17 11:00:21 2018                                                                                               Page    6
312
 
313
 
314
 
315
 
316
 2880  FA000D  2B            		pld
317
 2881  FA000E                		ACC16			; move param's in local var's
318
 2882  FA000E  C2 20         		rep	#PMFLAG
319
 2883                        		.LONGA	on
320
 2884                        		.MNLIST
321
 2885  FA0010  A3 0A         		lda	sOpt,s
322
 2886  FA0012  85 97         		sta	optstr
323
 2887  FA0014  A3 0D         		lda	sCmd,s
324
 2888  FA0016  85 94         		sta	cmdlin
325
 2889  FA0018  64 A4         		stz	intarg
326
 2890  FA001A  64 A6         		stz	intarg+2
327
 2891  FA001C                		ACC08
328
 2892  FA001C  E2 20         		sep	#PMFLAG
329
 2893                        		.LONGA	off
330
 2894                        		.MNLIST
331
 2895  FA001E  A3 0C         		lda	sOpt+2,s
332
 2896  FA0020  85 99         		sta	optstr+2
333
 2897  FA0022  A3 0F         		lda	sCmd+2,s
334
 2898  FA0024  85 96         		sta	cmdlin+2
335
 2899  FA0026  A3 10         		lda	sFlag,s
336
 2900  FA0028  85 A2         		sta	prsfg
337
 2901  FA002A  A0 00         		ldy	#0
338
 2902  FA002C  84 A3         		sty	opttyp
339
 2903  FA002E  84 AB         		sty	argsgn
340
 2904  FA0030  20 A5 00      		jsr	?104		; get next char
341
 2905  FA0033  F0 6C         		beq	?94		; return A=0
342
 2906  FA0035  C9 2D         		cmp	#'-'		; option?
343
 2907  FA0037  F0 0B         		beq	?05		; yes
344
 2908  FA0039  20 AE 00      		jsr	?110		; find end of argument
345
 2909  FA003C  B0 64         		bcs	?95		; error
346
 2910  FA003E  A9 80         		lda	#$80		; no option argument
347
 2911  FA0040  85 A1         		sta	chopt
348
 2912  FA0042  80 45         		bra	?90
349
 2913  FA0044  20 59 01      	?05:	jsr	?130		; check option
350
 2914  FA0047  B0 59         		bcs	?95		; error
351
 2915  FA0049  20 C4 01      		jsr	?140		; test option argument
352
 2916  FA004C  B0 54         		bcs	?95		; error
353
 2917  FA004E  A6 A3         		ldx	opttyp
354
 2918  FA0050  E0 20         		cpx	#' '		; option without argument?
355
 2919  FA0052  F0 35         		beq	?90		; yes...so exit
356
 2920  FA0054  E0 3A         		cpx	#':'		; option requires a simple string argument?
357
 2921  FA0056  F0 31         		beq	?90		; yes...so exit
358
 2922  FA0058  E0 24         		cpx	#'$'		; option requires up case string argument?
359
 2923  FA005A  F0 08         		beq	?10		; yes
360
 2924  FA005C  E0 21         		cpx	#'!'		; option requires a single char argument?
361
 2925  FA005E  F0 1D         		beq	?30		; yes
362
 2926  FA0060  E0 5E         		cpx	#'^'		; option requires a single up case char arg.?
363
 2927  FA0062  D0 20         		bne	?40		; no
364
 2928  FA0064  A0 00         	?10:	ldy	#0
365
 2929  FA0066  B7 9A         	?15:	lda	[dwres],y	; up case string
366
 2930  FA0068  F0 0F         		beq	?25		; end of string
367
 2931  FA006A  C9 61         		cmp	#'a'
368
 2932  FA006C  90 08         		bcc	?20
369
 2933  FA006E  C9 7B         		cmp	#'z'+1
370
 2934  FA0070  B0 04         		bcs	?20
371
 2935  FA0072  29 DF         		and	#$DF
372
 2936  FA0074  97 9A         		sta	[dwres],y
373
  Tue Jul 17 11:00:21 2018                                                                                               Page    7
374
 
375
 
376
 
377
 
378
 2937  FA0076  C8            	?20:	iny
379
 2938  FA0077  80 ED         		bra	?15
380
 2939  FA0079  E0 24         	?25:	cpx	#'$'		; if requires string exit
381
 2940  FA007B  F0 0C         		beq	?90
382
 2941  FA007D  20 52 02      	?30:	jsr	?150		; check single char argument
383
 2942  FA0080  B0 20         		bcs	?95		; error
384
 2943  FA0082  80 05         		bra	?90
385
 2944  FA0084  20 AD 02      	?40:	jsr	?160		; others option type
386
 2945  FA0087  B0 19         		bcs	?95
387
 2946  FA0089                	?90:	ACC16			; return result to the caller...
388
 2947  FA0089  C2 20         		rep	#PMFLAG
389
 2948                        		.LONGA	on
390
 2949                        		.MNLIST
391
 2950  FA008B  A5 94         		lda	cmdlin		; ...and residual command line string
392
 2951  FA008D  83 0D         		sta	sCmd,s
393
 2952  FA008F  A5 9A         		lda	dwres
394
 2953  FA0091  83 06         		sta	sRes,s
395
 2954  FA0093  A5 9C         		lda	dwres+2
396
 2955  FA0095  83 08         		sta	sRes+2,s
397
 2956  FA0097                		ACC08
398
 2957  FA0097  E2 20         		sep	#PMFLAG
399
 2958                        		.LONGA	off
400
 2959                        		.MNLIST
401
 2960  FA0099  A5 96         		lda	cmdlin+2
402
 2961  FA009B  83 0F         		sta	sCmd+2,s
403
 2962  FA009D  A4 A3         		ldy	opttyp		; return Y=option type
404
 2963  FA009F  A5 A1         		lda	chopt		; return A=option char
405
 2964  FA00A1  18            	?94:	clc			; no error
406
 2965  FA00A2  2B            	?95:	pld
407
 2966  FA00A3  6B            		rtl
408
 2967
409
 2968  FA00A4  C8            	?100:	iny			; get char from command line
410
 2969  FA00A5  B7 94         	?104:	lda	[cmdlin],y
411
 2970  FA00A7  F0 04         		beq	?106
412
 2971  FA00A9  C9 20         		cmp	#' '
413
 2972  FA00AB  F0 F7         		beq	?100
414
 2973  FA00AD  60            	?106:	rts
415
 2974
416
 2975  FA00AE  A2 20         	?110:	ldx	#' '
417
 2976  FA00B0  86 9F         		stx	squot		; normal end of string char
418
 2977  FA00B2  64 9E         		stz	slen		; size of argument
419
 2978  FA00B4  C9 22         		cmp	#'"'		; search end of string
420
 2979  FA00B6  D0 03         		bne	?112		; not quoted
421
 2980  FA00B8  85 9F         		sta	squot		; quoted string
422
 2981  FA00BA  C8            		iny
423
 2982  FA00BB  84 A0         	?112:	sty	cmdy		; save index
424
 2983  FA00BD  B7 94         	?114:	lda	[cmdlin],y
425
 2984  FA00BF  D0 08         		bne	?115
426
 2985  FA00C1  A6 9F         		ldx	squot
427
 2986  FA00C3  E0 22         		cpx	#'"'
428
 2987  FA00C5  F0 37         		beq	?122		; missing final quote
429
 2988  FA00C7  80 0E         		bra	?117
430
 2989  FA00C9  C5 9F         	?115:	cmp	squot		; first blank/quote is end of string
431
 2990  FA00CB  F0 05         		beq	?116
432
 2991  FA00CD  E6 9E         		inc	slen
433
 2992  FA00CF  C8            		iny
434
 2993  FA00D0  80 EB         		bra	?114
435
  Tue Jul 17 11:00:21 2018                                                                                               Page    8
436
 
437
 
438
 
439
 
440
 2994  FA00D2  A9 00         	?116:	lda	#0		; put string terminator
441
 2995  FA00D4  97 94         		sta	[cmdlin],y
442
 2996  FA00D6  C8            		iny			; next token in command line
443
 2997  FA00D7  A6 9E         	?117:	ldx	slen		; check string length
444
 2998  FA00D9  F0 53         		beq	?126		; error
445
 2999  FA00DB  A6 A0         		ldx	cmdy
446
 3000  FA00DD                		ACC16CLC
447
 3001  FA00DD  C2 21         		rep	#(PMFLAG.OR.PCFLAG)
448
 3002                        		.LONGA	on
449
 3003                        		.MNLIST
450
 3004  FA00DF  8A            		txa
451
 3005  FA00E0  65 94         		adc	cmdlin
452
 3006  FA00E2  85 9A         		sta	dwres		; pointer to argument
453
 3007  FA00E4                		ACC08
454
 3008  FA00E4  E2 20         		sep	#PMFLAG
455
 3009                        		.LONGA	off
456
 3010                        		.MNLIST
457
 3011  FA00E6  A5 96         		lda	cmdlin+2
458
 3012  FA00E8  90 01         		bcc	?118
459
 3013  FA00EA  1A            		inc	a
460
 3014  FA00EB  85 9C         	?118:	sta	dwres+2
461
 3015  FA00ED  64 9D         		stz	dwres+3
462
 3016  FA00EF                	?119:	ACC16CLC
463
 3017  FA00EF  C2 21         		rep	#(PMFLAG.OR.PCFLAG)
464
 3018                        		.LONGA	on
465
 3019                        		.MNLIST
466
 3020  FA00F1  98            		tya
467
 3021  FA00F2  65 94         		adc	cmdlin
468
 3022  FA00F4  85 94         		sta	cmdlin		; bump command line ptr
469
 3023  FA00F6                		ACC08
470
 3024  FA00F6  E2 20         		sep	#PMFLAG
471
 3025                        		.LONGA	off
472
 3026                        		.MNLIST
473
 3027  FA00F8  90 03         		bcc	?120
474
 3028  FA00FA  E6 96         		inc	cmdlin+2
475
 3029  FA00FC  18            		clc
476
 3030  FA00FD  60            	?120:	rts
477
 3031  FA00FE  A5 A2         	?122:	lda	prsfg		; test bit 7
478
 3032  FA0100  10 2A         		bpl	?124		; no show error message
479
 3033  FA0102  20 50 01      		jsr	?128
480
 3034  FA0105                		SCNPRINT
481
 3035  FA0105  02 01         		cop	$01
482
 3036                        		.MNLIST
483
 3037  FA0107  6D 69 73 73 69 		.DB	'missig quotation marks in argument.', 13, 0
484
               67 20 71 75 6F
485
               74 61 74 69 6F
486
               6E 20 6D 61 72
487
               6B 73 20 69 6E
488
               20 61 72 67 75
489
               6D 65 6E 74 2E
490
               0D 00
491
 3038  FA012C  38            	?124:	sec			; error flag
492
 3039  FA012D  60            		rts
493
 3040  FA012E  A5 A2         	?126:	lda	prsfg
494
 3041  FA0130  10 FA         		bpl	?124
495
 3042  FA0132  20 50 01      		jsr	?128
496
 3043  FA0135                		SCNPRINT
497
  Tue Jul 17 11:00:21 2018                                                                                               Page    9
498
 
499
 
500
 
501
 
502
 3044  FA0135  02 01         		cop	$01
503
 3045                        		.MNLIST
504
 3046  FA0137  61 72 67 75 6D 		.DB	'argument zero length.', 13, 0
505
               65 6E 74 20 7A
506
               65 72 6F 20 6C
507
               65 6E 67 74 68
508
               2E 0D 00
509
 3047  FA014E  38            	?127:	sec
510
 3048  FA014F  60            		rts
511
 3049  FA0150  4A            	?128:	lsr	a
512
 3050  FA0151  90 05         		bcc	?129
513
 3051  FA0153                		SCNPRINT
514
 3052  FA0153  02 01         		cop	$01
515
 3053                        		.MNLIST
516
 3054  FA0155  3A 3A 00      		.DB	'::', 0
517
 3055  FA0158  60            	?129:	rts
518
 3056
519
 3057  FA0159  C8            	?130:	iny			; check option
520
 3058  FA015A  B7 94         		lda	[cmdlin],y
521
 3059  FA015C  F0 1E         		beq	?135		; missing option
522
 3060  FA015E  C9 20         		cmp	#' '
523
 3061  FA0160  F0 1A         		beq	?135		; missing option
524
 3062  FA0162  BB            		tyx
525
 3063  FA0163  85 A1         		sta	chopt		; store option char
526
 3064  FA0165  A0 00         		ldy	#0		; scan option string
527
 3065  FA0167  B7 97         	?132:	lda	[optstr],y
528
 3066  FA0169  F0 2D         		beq	?136		; option not found
529
 3067  FA016B  C5 A1         		cmp	chopt
530
 3068  FA016D  F0 04         		beq	?134		; found
531
 3069  FA016F  C8            		iny
532
 3070  FA0170  C8            		iny
533
 3071  FA0171  80 F4         		bra	?132
534
 3072  FA0173  C8            	?134:	iny
535
 3073  FA0174  B7 97         		lda	[optstr],y	; get option type
536
 3074  FA0176  85 A3         		sta	opttyp
537
 3075  FA0178  9B            		txy
538
 3076  FA0179  C8            		iny
539
 3077  FA017A  18            		clc
540
 3078  FA017B  60            		rts
541
 3079  FA017C
542
 3080  FA017C  A5 A2         	?135:	lda	prsfg
543
 3081  FA017E  10 CE         		bpl	?127
544
 3082  FA0180  20 50 01      		jsr	?128
545
 3083  FA0183                		SCNPRINT
546
 3084  FA0183  02 01         		cop	$01
547
 3085                        		.MNLIST
548
 3086  FA0185  6D 69 73 73 69 		.DB	'missing option.', 13, 0
549
               6E 67 20 6F 70
550
               74 69 6F 6E 2E
551
               0D 00
552
 3087  FA0196  38            		sec
553
 3088  FA0197  60            		rts
554
 3089
555
 3090  FA0198  A5 A2         	?136:	lda	prsfg
556
 3091  FA019A  10 B2         		bpl	?127
557
 3092  FA019C  20 50 01      		jsr	?128
558
 3093  FA019F  A5 A1         		lda	chopt
559
  Tue Jul 17 11:00:21 2018                                                                                               Page   10
560
 
561
 
562
 
563
 
564
 3094  FA01A1  48            		pha
565
 3095  FA01A2  4B            		phk
566
 3096  FA01A3  F4 AD 01      		pea	#!?138
567
 3097  FA01A6  A9 05         		lda	#5
568
 3098  FA01A8  48            		pha
569
 3099  FA01A9                		BPRINTF
570
 3100  FA01A9  02 11         		cop	$11
571
 3101                        		.MNLIST
572
 3102  FA01AB  38            		sec
573
 3103  FA01AC  60            		rts
574
 3104
575
 3105  FA01AD  69 6C 6C 65 67 	?138:	.DB	'illegal option ''-%c''.', 13, 0
576
               61 6C 20 6F 70
577
               74 69 6F 6E 20
578
               27 2D 25 63 27
579
               2E 0D 00
580
 3106
581
 3107  FA01C4  A6 A3         	?140:	ldx	opttyp		; option type
582
 3108  FA01C6  B7 94         		lda	[cmdlin],y	; get char after option
583
 3109  FA01C8  F0 0B         		beq	?142		; no argument
584
 3110  FA01CA  C9 20         		cmp	#' '
585
 3111  FA01CC  F0 07         		beq	?142		; no argument
586
 3112  FA01CE  E0 20         		cpx	#' '		; option requires an argument?
587
 3113  FA01D0  F0 0A         		beq	?144		; no...so error
588
 3114  FA01D2  4C AE 00      		jmp	?110		; get argument
589
 3115  FA01D5  E0 20         	?142:	cpx	#' '		; option requires an argument?
590
 3116  FA01D7  D0 45         		bne	?148		; yes...so error
591
 3117  FA01D9  4C EF 00      		jmp	?119		; bump command line ptr
592
 3118  FA01DC
593
 3119  FA01DC  A5 A2         	?144:	lda	prsfg
594
 3120  FA01DE  10 0F         		bpl	?145
595
 3121  FA01E0  20 50 01      		jsr	?128
596
 3122  FA01E3  A5 A1         		lda	chopt
597
 3123  FA01E5  48            		pha
598
 3124  FA01E6  4B            		phk
599
 3125  FA01E7  F4 F1 01      		pea	#!?146
600
 3126  FA01EA  A9 05         	?144a:	lda	#5
601
 3127  FA01EC  48            		pha
602
 3128  FA01ED                		BPRINTF
603
 3129  FA01ED  02 11         		cop	$11
604
 3130                        		.MNLIST
605
 3131  FA01EF  38            	?145:	sec
606
 3132  FA01F0  60            		rts
607
 3133
608
 3134  FA01F1  6F 70 74 69 6F 	?146:	.DB	'option ''-%c'' does not requires an argument.', 13, 0
609
               6E 20 27 2D 25
610
               63 27 20 64 6F
611
               65 73 20 6E 6F
612
               74 20 72 65 71
613
               75 69 72 65 73
614
               20 61 6E 20 61
615
               72 67 75 6D 65
616
               6E 74 2E 0D 00
617
 3135
618
 3136  FA021E  A5 A2         	?148:	lda	prsfg
619
 3137  FA0220  10 CD         		bpl	?145
620
 3138  FA0222  20 50 01      		jsr	?128
621
  Tue Jul 17 11:00:21 2018                                                                                               Page   11
622
 
623
 
624
 
625
 
626
 3139  FA0225  A5 A1         		lda	chopt
627
 3140  FA0227  48            		pha
628
 3141  FA0228  4B            		phk
629
 3142  FA0229  F4 2E 02      		pea	#!?149
630
 3143  FA022C  80 BC         		bra	?144a
631
 3144
632
 3145  FA022E  6F 70 74 69 6F 	?149:	.DB	'option ''-%c'' requires an argument.', 13, 0
633
               6E 20 27 2D 25
634
               63 27 20 72 65
635
               71 75 69 72 65
636
               73 20 61 6E 20
637
               61 72 67 75 6D
638
               65 6E 74 2E 0D
639
               00
640
 3146
641
 3147  FA0252  A5 9E         	?150:	lda	slen		; check single char argument
642
 3148  FA0254  C9 01         		cmp	#1
643
 3149  FA0256  D0 0C         		bne	?152
644
 3150  FA0258  A7 9A         		lda	[dwres]
645
 3151  FA025A  85 9A         		sta	dwres
646
 3152  FA025C  64 9B         		stz	dwres+1
647
 3153  FA025E  64 9C         		stz	dwres+2
648
 3154  FA0260  64 9D         		stz	dwres+3
649
 3155  FA0262  18            		clc
650
 3156  FA0263  60            		rts
651
 3157  FA0264  A5 A2         	?152:	lda	prsfg
652
 3158  FA0266  10 0F         		bpl	?154
653
 3159  FA0268  20 50 01      		jsr	?128
654
 3160  FA026B  A5 A1         		lda	chopt
655
 3161  FA026D  48            		pha
656
 3162  FA026E  4B            		phk
657
 3163  FA026F  F4 79 02      		pea	#!?156
658
 3164  FA0272  A9 05         		lda	#5
659
 3165  FA0274  48            		pha
660
 3166  FA0275                		BPRINTF
661
 3167  FA0275  02 11         		cop	$11
662
 3168                        		.MNLIST
663
 3169  FA0277  38            	?154:	sec
664
 3170  FA0278  60            		rts
665
 3171
666
 3172  FA0279  6F 70 74 69 6F 	?156:	.DB	'option ''-%c'' requires a single character argument.', 13, 0
667
               6E 20 27 2D 25
668
               63 27 20 72 65
669
               71 75 69 72 65
670
               73 20 61 20 73
671
               69 6E 67 6C 65
672
               20 63 68 61 72
673
               61 63 74 65 72
674
               20 61 72 67 75
675
               6D 65 6E 74 2E
676
               0D 00
677
 3173
678
 3174  FA02AD  A2 03         	?160:	ldx	#3		; check others option's type
679
 3175  FA02AF  BF F3 03 FA   	?162:	lda	>?200,x
680
 3176  FA02B3  C5 A3         		cmp	opttyp
681
 3177  FA02B5  F0 46         		beq	?166
682
 3178  FA02B7  CA            		dex
683
  Tue Jul 17 11:00:21 2018                                                                                               Page   12
684
 
685
 
686
 
687
 
688
 3179  FA02B8  10 F5         		bpl	?162
689
 3180  FA02BA  A5 A2         		lda	prsfg
690
 3181  FA02BC  10 12         		bpl	?164
691
 3182  FA02BE  20 50 01      		jsr	?128
692
 3183  FA02C1  A5 A3         		lda	opttyp
693
 3184  FA02C3  48            		pha
694
 3185  FA02C4  A5 A1         		lda	chopt
695
 3186  FA02C6  48            		pha
696
 3187  FA02C7  4B            		phk
697
 3188  FA02C8  F4 D2 02      		pea	#!?165
698
 3189  FA02CB  A9 06         		lda	#6
699
 3190  FA02CD  48            		pha
700
 3191  FA02CE                		BPRINTF
701
 3192  FA02CE  02 11         		cop	$11
702
 3193                        		.MNLIST
703
 3194  FA02D0  38            	?164:	sec
704
 3195  FA02D1  60            		rts
705
 3196
706
 3197  FA02D2  6F 70 74 69 6F 	?165:	.DB	'option ''-%c'': invalid argument type ''%c''.', 13, 0
707
               6E 20 27 2D 25
708
               63 27 3A 20 69
709
               6E 76 61 6C 69
710
               64 20 61 72 67
711
               75 6D 65 6E 74
712
               20 74 79 70 65
713
               20 27 25 63 27
714
               2E 0D 00
715
 3198
716
 3199  FA02FD  E8            	?166:	inx			; wanted integer size
717
 3200  FA02FE  A5 A2         		lda	prsfg
718
 3201  FA0300  A8            		tay
719
 3202  FA0301  29 40         		and	#$40		; mask autodetect flag
720
 3203  FA0303  F0 07         		beq	?166a		; hex string only
721
 3204  FA0305  85 A8         		sta	tmpp
722
 3205  FA0307  98            		tya
723
 3206  FA0308  0A            		asl	a
724
 3207  FA0309  0A            		asl	a		; wanted signed flag
725
 3208  FA030A  05 A8         		ora	tmpp
726
 3209  FA030C  A4 9C         	?166a:	ldy	dwres+2		; string ptr
727
 3210  FA030E  5A            		phy
728
 3211  FA030F  D4 9A         		pei	(dwres)
729
 3212  FA0311  DA            		phx			; integer size
730
 3213  FA0312  48            		pha			; flag
731
 3214  FA0313  F4 00 00      		pea	#0		; pointer to result
732
 3215  FA0316  A9 A4         		lda	#intarg
733
 3216  FA0318  48            		pha
734
 3217  FA0319  22 BB 27 F8   		jsl	_lstrtoint
735
 3218  FA031D  B0 1A         		bcs	?168
736
 3219  FA031F  70 31         		bvs	?180
737
 3220  FA0321                		ACC16
738
 3221  FA0321  C2 20         		rep	#PMFLAG
739
 3222                        		.LONGA	on
740
 3223                        		.MNLIST
741
 3224  FA0323  85 A8         		sta	tmpp
742
 3225  FA0325  86 AA         		stx	tmpp+2
743
 3226  FA0327  84 AB         		sty	argsgn
744
 3227  FA0329  A5 A4         		lda	intarg
745
  Tue Jul 17 11:00:21 2018                                                                                               Page   13
746
 
747
 
748
 
749
 
750
 3228  FA032B  85 9A         		sta	dwres
751
 3229  FA032D  A5 A6         		lda	intarg+2
752
 3230  FA032F  85 9C         		sta	dwres+2
753
 3231  FA0331                		ACC08
754
 3232  FA0331  E2 20         		sep	#PMFLAG
755
 3233                        		.LONGA	off
756
 3234                        		.MNLIST
757
 3235  FA0333  A7 A8         		lda	[tmpp]		; check residual string
758
 3236  FA0335  D0 01         		bne	?167		; should be null
759
 3237  FA0337  60            		rts
760
 3238  FA0338  B8            	?167:	clv			; invalid numeric string
761
 3239  FA0339  A5 A2         	?168:	lda	prsfg
762
 3240  FA033B  10 28         		bpl	?184
763
 3241  FA033D  08            		php
764
 3242  FA033E  20 50 01      		jsr	?128
765
 3243  FA0341  28            		plp
766
 3244  FA0342  A5 A1         		lda	chopt
767
 3245  FA0344  48            		pha
768
 3246  FA0345  4B            		phk
769
 3247  FA0346  70 05         		bvs	?170
770
 3248  FA0348  F4 67 03      		pea	#!?190
771
 3249  FA034B  80 13         		bra	?182
772
 3250  FA034D  F4 97 03      	?170:	pea	#!?192
773
 3251  FA0350  80 0E         		bra	?182
774
 3252  FA0352  A5 A2         	?180:	lda	prsfg
775
 3253  FA0354  10 0F         		bpl	?184
776
 3254  FA0356  20 50 01      		jsr	?128
777
 3255  FA0359  A5 A1         		lda	chopt
778
 3256  FA035B  48            		pha
779
 3257  FA035C  4B            		phk
780
 3258  FA035D  F4 C1 03      		pea	#!?194
781
 3259  FA0360  A9 05         	?182:	lda	#5
782
 3260  FA0362  48            		pha
783
 3261  FA0363                		BPRINTF
784
 3262  FA0363  02 11         		cop	$11
785
 3263                        		.MNLIST
786
 3264  FA0365  38            	?184:	sec
787
 3265  FA0366  60            		rts
788
 3266
789
 3267  FA0367  6F 70 74 69 6F 	?190:	.DB	'option ''-%c'': invalid numeric string argument.', 13, 0
790
               6E 20 27 2D 25
791
               63 27 3A 20 69
792
               6E 76 61 6C 69
793
               64 20 6E 75 6D
794
               65 72 69 63 20
795
               73 74 72 69 6E
796
               67 20 61 72 67
797
               75 6D 65 6E 74
798
               2E 0D 00
799
 3268  FA0397  6F 70 74 69 6F 	?192:	.DB	'option ''-%c'': numeric argument overflow.', 13, 0
800
               6E 20 27 2D 25
801
               63 27 3A 20 6E
802
               75 6D 65 72 69
803
               63 20 61 72 67
804
               75 6D 65 6E 74
805
               20 6F 76 65 72
806
               66 6C 6F 77 2E
807
  Tue Jul 17 11:00:21 2018                                                                                               Page   14
808
 
809
 
810
 
811
 
812
               0D 00
813
 3269  FA03C1  6F 70 74 69 6F 	?194:	.DB	'option ''-%c'': signed/unsigned mismatch argument.', 13, 0
814
               6E 20 27 2D 25
815
               63 27 3A 20 73
816
               69 67 6E 65 64
817
               2F 75 6E 73 69
818
               67 6E 65 64 20
819
               6D 69 73 6D 61
820
               74 63 68 20 61
821
               72 67 75 6D 65
822
               6E 74 2E 0D 00
823
 3270
824
 3271  FA03F3  25 23 2A 26   	?200:	.DB	'%#*&'
825
 
826
 
827
             Lines Assembled : 3213                  Errors : 0
828
 
829
 
830