annotate level1/cmds/ngu.asm @ 821:b0b1886efbd0

added unknown option
author boisy
date Mon, 13 Jan 2003 21:47:07 +0000
parents 2de53dfabcc8
children 83e3677c8b1f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
820
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
1 ********************************************************************
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
2 * NGU - The "Next Great Utility"
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
3 *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
4 * $Id$
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
5 *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
6 * NGU is a template for writing utilities under OS-9/6809. It has
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
7 * robust option handling and is littered with comments to help you
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
8 * write your own utilities.
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
9 *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
10 * NGU uses a two-pass method for parsing the command line. On the
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
11 * first pass, dash options are processed and internal flags are set
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
12 * accordingly. As the options are processed, they are cleared to
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
13 * spaces so that they won't be present on the second pass.
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
14 *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
15 * For the second pass, NGU parses options that don't begin with -.
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
16 * Presumably these are filenames or other names that are to be
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
17 * processed.
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
18 *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
19 * Features:
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
20 * - Both options and files can be specified anywhere
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
21 * on the command line
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
22 * (i.e ngu -a test1 -b test2 -c=foo)
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
23 *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
24 * - Options can be combined behind one dash:
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
25 * (i.e ngu -ab test1 -c=foo test2 test3)
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
26 *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
27 * - Several useful assembly routines are provided for
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
28 * copying strings and determining string length.
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
29 *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
30 * Limitations:
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
31 * - Only single character options can be processed.
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
32 * Multi-character options (i.e. -delete) are not allowed.
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
33 *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
34 * - The current file counter is one byte, allowing a maximum
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
35 * of 255 files.
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
36 *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
37 * Ed. Comments Who YY/MM/DD
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
38 * ------------------------------------------------------------------
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
39 * 1 Put your development info here BGP 03/01/11
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
40
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
41 nam NGU
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
42 ttl The "Next Great Utility"
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
43
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
44 ifp1
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
45 use defsfile
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
46 use rbfdefs
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
47 endc
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
48
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
49 * Here are some tweakable options
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
50 DOHELP set 1 1 = include help info
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
51 STCKSIZE set 64 our stack size in bytes
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
52 COPTSIZ set 64 max size of C option's parameter
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
53
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
54 * Module header definitions
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
55 tylg set Prgrm+Objct
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
56 atrv set ReEnt+rev
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
57 rev set $01
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
58 edition set 1
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
59
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
60 mod eom,name,tylg,atrv,start,size
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
61
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
62
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
63 * Your utility's static storage vars go here
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
64 org 0
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
65 parmptr rmb 2 pointer to our command line params
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
66 bufptr rmb 2 pointer to user expandable buffer
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
67 bufsiz rmb 2 size of user expandable buffer
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
68 * What follows are utility specific options
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
69 gota rmb 1
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
70 gotb rmb 1
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
71 filecnt rmb 1
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
72 coptflg rmb 1 1 = this option has been processed once already
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
73 clrmark equ . everything before here gets cleared at start
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
74 copt rmb COPTSIZ buffer for what follows after -c=
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
75 * Next is a user adjustable buffer with # modifier on command line.
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
76 * Some utilities won't need this, some will.
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
77 * Currently set up to be larger for Level 2 than Level 1
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
78 * Note: this buffer must come just before the stack
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
79 IFGT Level-1
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
80 bigbuff rmb 8*1024 8K default buffer for Level 2
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
81 ELSE
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
82 bigbuff rmb 512 512 byte default buffer for Level 1
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
83 ENDC
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
84 * Finally the stack for any PSHS/PULS/BSR/LBSRs that we might do
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
85 stack rmb STCKSIZE
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
86 size equ .
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
87
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
88 * The utility name and edition goes here
821
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
89 name fcs /NGU/
820
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
90 fcb edition
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
91
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
92 * Place constant strings here
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
93 IFNE DOHELP
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
94 HlpMsg fcb C$LF
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
95 fcc /Use: NGU [<opts>] <path> [<path>] [<opts>]/
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
96 fcb C$LF
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
97 fcc / -a option 1/
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
98 fcb C$LF
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
99 fcc / -b option 2/
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
100 fcb C$LF
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
101 fcb C$CR
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
102 HlpMsgL equ *-HlpMsg
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
103 ENDC
821
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
104 UnkOpt fcc /unknown option: /
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
105 UnkOptL equ *-UnkOpt
820
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
106
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
107 * Here's how registers are set when this process is forked:
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
108 *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
109 * +-----------------+ <-- Y (highest address)
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
110 * ! Parameter !
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
111 * ! Area !
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
112 * +-----------------+ <-- X, SP
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
113 * ! Data Area !
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
114 * +-----------------+
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
115 * ! Direct Page !
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
116 * +-----------------+ <-- U, DP (lowest address)
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
117 *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
118 * D = parameter area size
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
119 * PC = module entry point abs. address
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
120 * CC = F=0, I=0, others undefined
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
121
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
122 * The start of the program is here
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
123 * Before any command line processing is done, we clear out
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
124 * our static memory from U to clrmark, then determine the
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
125 * size of our data area (minus stack)
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
126 start pshs u,x save registers for later
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
127 leax <clrmark,u point to end of area to zero out
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
128 IFNE H6309
821
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
129 subr u,x subtract U from X
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
130 tfr x,w and put X in W
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
131 clr ,-s put a zero on the stack
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
132 tfm s,u+ and use TFM to clear starting at U
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
133 leas 1,s clean up the stack
820
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
134 ELSE
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
135 pshs x save end pointer on stack
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
136 clrnxt clr ,u+ clear out
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
137 cmpu ,s done?
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
138 bne clrnxt branch if not
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
139 leas 2,s else clear stack
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
140 ENDC
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
141 puls x,u and restore our earlier saved registers
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
142 leay bigbuff,u point Y to copy buffer offset in U
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
143 stx <parmptr save parameter pointer
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
144 sty <bufptr save pointer to buffer
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
145 tfr s,d place top of stack in D
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
146 IFNE H6309
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
147 subr y,d
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
148 ELSE
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
149 pshs y save Y on stack
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
150 subd ,s++ get size of space between copybuf and X
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
151 ENDC
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
152 subd #STCKSIZE subtract out our stack
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
153 std <bufsiz size of our buffer
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
154
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
155 * At this point we have determined our buffer space and saved pointers
821
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
156 * for later use. Now we will parse the command line for options that
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
157 * begin with -
820
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
158 lbsr SkipSpcs move past any spaces on command line
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
159 cmpa #C$CR CR?
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
160 lbeq ShowHelp if so, no parameters... show help and exit
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
161 GetChar lda ,x+ get next character on cmd line
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
162 cmpa #C$CR CR?
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
163 lbeq DoNGU if so, do whatever this utility does
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
164 cmpa #'- is it an option?
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
165 beq GetDash if so, process it
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
166 inc <filecnt else must be a non-option argument (file)
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
167 lbsr SkipNSpc move past the argument
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
168 ChkDash lbsr SkipSpcs and any following spaces
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
169 bra GetChar start processing again
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
170 GetDash lda #C$SPAC get a space char
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
171 sta -1,x and wipe out the dash from the cmd line
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
172 GetDash2 ldd ,x+ load option char and char following
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
173 anda #$5F make uppercase
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
174 IsItA cmpa #'A is it this option?
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
175 bne IsItB branch if not
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
176 inc <gota
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
177 lbra FixCmdLn
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
178 IsItB cmpa #'B is it this option?
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
179 bne IsItC branch if not
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
180 inc <gotb
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
181 bra FixCmdLn
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
182 IsItC cmpa #'C is it this option?
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
183 bne BadOpt branch if not
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
184 tst <coptflg was this option already specified?
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
185 bne BadOpt show help if so
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
186 cmpb #'= 2nd char =?
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
187 bne BadOpt show help if not
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
188 inc <coptflg else tag this option as parsed
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
189 ldb #C$SPAC get space
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
190 stb -$01,x write over c
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
191 stb ,x+ and = sign, inc X to dest dir
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
192 * check for valid char after -c=
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
193 lda ,x
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
194 cmpa #C$SPAC
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
195 lbeq ShowHelp
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
196 cmpa #C$COMA
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
197 lbeq ShowHelp
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
198 cmpa #C$CR
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
199 lbeq ShowHelp
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
200 leay <copt,u point Y to parameber buffer
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
201 tfr y,d transfer Y to D
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
202 addd #COPTSIZ
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
203 pshs b,a save updated ptr value
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
204 ldb #C$SPAC get space
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
205 L0339 lda ,x get byte at X
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
206 stb ,x+ store space at X and inc
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
207 sta ,y+ save loaded byte at Y and inc
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
208 cmpy ,s are we at end?
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
209 beq L035D branch if so (buffer too small)
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
210 cmpa #C$SPAC else is char in A a space?
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
211 beq L0350 branch if so
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
212 cmpa #C$COMA coma?
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
213 beq L0350 branch if so
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
214 cmpa #C$CR cr?
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
215 bne L0339 get next byte if not
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
216 L0350 leax -1,x
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
217 sta ,x restore previous A
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
218 leas $02,s kill stack
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
219 lbra ChkDash
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
220 L035D leas $02,s
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
221 ldb #$BF else buffer size too small
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
222 orcc #Carry
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
223 lbra Exit
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
224 FixCmdLn lda #C$SPAC get space
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
225 sta -$01,x and wipe out option character
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
226 cmpb #'0
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
227 lblt ChkDash start dash option processing again
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
228 lbra GetDash possibly another option following?
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
229
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
230 * We branch here if we encounter an unknown option character
821
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
231 * A = bad option character
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
232 BadOpt leax UnkOpt,pcr
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
233 ldy #UnkOptL
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
234 ldb #C$CR
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
235 pshs d save bad option and CR on stack
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
236 lda #$02 stderr
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
237 os9 I$Write
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
238 leax ,s point X at option char on stack
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
239 os9 I$WritLn print option and CR
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
240 puls d clean up stack
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
241 lbra ShowHelp
820
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
242
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
243
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
244 * At this point options are processed.
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
245 * We load X with our parameter pointer and go down the command line
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
246 * looking at each file to process (options have been wiped out with
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
247 * spaces)
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
248 DoNGU tst <filecnt we should have at least one file on cmdline
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
249 lbeq ShowHelp if not, exit with error
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
250 ldx <parmptr get our parameter pointer off stack
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
251 lbsr SkipSpcs skip any leading spaces
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
252 bra ExitOk
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
253
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
254 ShowHelp equ *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
255 IFNE DOHELP
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
256 leax >HlpMsg,pcr point to help message
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
257 ldy #HlpMsgL get length
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
258 lda #$02 std error
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
259 os9 I$WritLn write it
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
260 ENDC
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
261 ExitOk clrb clear carry
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
262 Exit os9 F$Exit and exit
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
263
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
264 * This routine counts the number of non-whitespace characters
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
265 * starting at X
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
266 *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
267 * Entry:
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
268 * X = ptr to string (space, comma or CR terminated)
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
269 * Exit:
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
270 * D = length of string
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
271 * X = ptr to byte after string
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
272 StrLen pshs u
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
273 ldu #$0000
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
274 StrLenLp lda ,x+
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
275 cmpa #C$SPAC
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
276 beq StrLenEx
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
277 cmpa #C$COMA
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
278 beq StrLenEx
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
279 cmpa #C$CR
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
280 beq StrLenEx
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
281 leau 1,u
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
282 bra StrLenLp
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
283 StrLenEx tfr u,d
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
284 puls u,pc
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
285
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
286 * This routine copies a string of text from X to Y until
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
287 * a whitespace character or CR is encountered
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
288 *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
289 * Entry:
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
290 * X = ptr to src string
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
291 * Y = ptr to dest string
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
292 * Exit:
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
293 * D = number of bytes copied
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
294 * X = ptr to byte after original string
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
295 * Y = ptr to byte after copied string
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
296 StrCpy pshs u
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
297 ldu #$0000
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
298 CopyFnLp lda ,x+
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
299 cmpa #C$SPAC
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
300 beq CopyFnEx
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
301 cmpa #C$COMA
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
302 beq CopyFnEx
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
303 cmpa #C$CR
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
304 beq CopyFnEx
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
305 sta ,y+
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
306 leau 1,u
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
307 bra CopyFnLp
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
308 CopyFnEx tfr u,d
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
309 puls u,pc
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
310
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
311 * This routine skip over spaces and commas
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
312 *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
313 * Entry:
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
314 * X = ptr to data to parse
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
315 * Exit:
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
316 * X = ptr to first non-whitespace char
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
317 * A = non-whitespace char
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
318 SkipSpcs lda ,x+
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
319 cmpa #C$SPAC
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
320 beq SkipSpcs
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
321 cmpa #C$COMA
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
322 beq SkipSpcs
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
323 leax -1,x
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
324 rts
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
325
821
b0b1886efbd0 added unknown option
boisy
parents: 820
diff changeset
326 * This routine skips over everything but spaces, commas and CRs
820
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
327 *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
328 * Entry:
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
329 * X = ptr to data to parse
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
330 * Exit:
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
331 * X = ptr to first whitespace char
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
332 * A = whitespace char
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
333 SkipNSpc lda ,x+
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
334 cmpa #C$SPAC
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
335 beq EatOut
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
336 cmpa #C$COMA
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
337 beq EatOut
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
338 cmpa #C$CR
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
339 bne SkipNSpc
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
340 EatOut leax -1,x
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
341 rts
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
342
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
343 emod
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
344 eom equ *
2de53dfabcc8 Added for future development
boisy
parents:
diff changeset
345 end