comparison level1/cmds/ngu.asm @ 902:bffd011cbef3

Made more changes
author boisy
date Sat, 18 Jan 2003 14:53:34 +0000
parents 053078ef1289
children c04528763543
comparison
equal deleted inserted replaced
901:8786f4894882 902:bffd011cbef3
10 * NGU uses a two-pass method for parsing the command line. On the 10 * NGU uses a two-pass method for parsing the command line. On the
11 * first pass, dash options are processed and internal flags are set 11 * first pass, dash options are processed and internal flags are set
12 * accordingly. As the options are processed, they are cleared to 12 * accordingly. As the options are processed, they are cleared to
13 * spaces so that they won't be present on the second pass. 13 * spaces so that they won't be present on the second pass.
14 * 14 *
15 * For the second pass, NGU parses options that don't begin with -. 15 * e.g.
16 * Presumably these are filenames or other names that are to be 16 * 1st pass: ngu -x foo1 -y foo2 -t=bar1 -ab
17 * 2nd pass: ngu foo1 foo2
18 *
19 * For the second pass, NGU parses the remaining arguments, which don't
20 * begin with -. Presumably these are filenames or other names that are to be
17 * processed. 21 * processed.
18 * 22 *
19 * Features: 23 * Features:
20 * - Written for 6809 and 6309 processors in fast, compact 24 * - Written for 6809 and 6309 processors in fast, compact
21 * assembly language. 25 * assembly language.
22 * 26 *
23 * - Both options and files can be specified anywhere 27 * - Both options and files can be specified anywhere
24 * on the command line 28 * on the command line
25 * (i.e ngu -a test1 -b test2 -c=foo) 29 * (i.e ngu -a test1 -b test2 -c=foo)
26 * 30 *
27 * - Options can be combined behind one dash: 31 * - Multiple options can be combined behind one dash:
28 * (i.e ngu -ab test1 -c=foo test2 test3) 32 * (i.e ngu -ab test1 -c=foo test2 test3)
29 * 33 *
30 * - Several useful assembly routines are provided for 34 * - Several useful assembly routines are provided for
31 * copying strings and determining string length. 35 * copying strings and determining string length.
32 * 36 *
33 * Limitations: 37 * Limitations:
34 * - Only single character option names can be processed. 38 * - Only single character option names can be processed.
35 * Multi-character option names (i.e. -delete) are not allowed. 39 * Multi-character option names (i.e. -delete) aren't supported.
36 * 40 *
37 * - The current file counter is one byte, allowing a maximum 41 * - The current file counter is one byte, counting a maximum
38 * of 255 files. 42 * of 255 files.
39 * 43 *
40 * Ed. Comments Who YY/MM/DD 44 * Ed. Comments Who YY/MM/DD
41 * ------------------------------------------------------------------ 45 * ------------------------------------------------------------------
42 * 1 Put your development info here BGP 03/01/11 46 * 1 Put your development info here BGP 03/01/11
62 66
63 mod eom,name,tylg,atrv,start,size 67 mod eom,name,tylg,atrv,start,size
64 68
65 * Your utility's static storage vars go here 69 * Your utility's static storage vars go here
66 org 0 70 org 0
71 * These vars are used by the base template and shouldn't be removed
67 parmptr rmb 2 pointer to our command line params 72 parmptr rmb 2 pointer to our command line params
68 bufptr rmb 2 pointer to user expandable buffer 73 bufptr rmb 2 pointer to user expandable buffer
69 bufsiz rmb 2 size of user expandable buffer 74 bufsiz rmb 2 size of user expandable buffer
70 * What follows are utility specific options 75 filecnt rmb 1
76 * These vars are used for this example, it will probably change for you
71 gota rmb 1 77 gota rmb 1
72 gotb rmb 1 78 gotb rmb 1
73 filecnt rmb 1
74 coptflg rmb 1 1 = this option has been processed once already 79 coptflg rmb 1 1 = this option has been processed once already
75 cleartop equ . everything up to here gets cleared at start 80 cleartop equ . everything up to here gets cleared at start
76 copt rmb COPTSIZ buffer for what follows after -c= 81 copt rmb COPTSIZ buffer for what follows after -c=
77 * Next is a user adjustable buffer with # modifier on command line. 82 * Next is a user adjustable buffer with # modifier on command line.
78 * Some utilities won't need this, some will. 83 * Some utilities won't need this flexibility, some will.
79 * Currently set up to be larger for Level 2 than Level 1 84 * Currently set up to be larger for Level 2 than Level 1
80 * Note: this buffer must come just before the stack 85 * Note: this buffer must come just before the stack
81 IFGT Level-1 86 IFGT Level-1
82 bigbuff rmb 8*1024 8K default buffer for Level 2 87 bigbuff rmb 8*1024 8K default buffer for Level 2
83 ELSE 88 ELSE
161 * begin with a dash. 166 * begin with a dash.
162 * Note that X will NOT point to a space, but to either a CR (if no 167 * Note that X will NOT point to a space, but to either a CR (if no
163 * parameters were passed) or the first non-space character of the 168 * parameters were passed) or the first non-space character of the
164 * parameter. 169 * parameter.
165 * Here we merely grab the byte at X into A and test for end of line, 170 * Here we merely grab the byte at X into A and test for end of line,
166 * exiting if so. Utilities that don't require non-option arguments 171 * exiting if so. Utilities that don't require arguments should
167 * should comment out the following three lines. 172 * comment out the following three lines.
168 lda ,x get first char 173 lda ,x get first char
169 cmpa #C$CR CR? 174 cmpa #C$CR CR?
170 lbeq ShowHelp if so, no parameters... show help and exit 175 lbeq ShowHelp if so, no parameters... show help and exit
171 GetChar lda ,x+ get next character on cmd line 176 GetChar lda ,x+ get next character on cmd line
172 cmpa #C$CR CR? 177 cmpa #C$CR CR?
201 stb ,x+ and = sign, inc X to dest dir 206 stb ,x+ and = sign, inc X to dest dir
202 * check for valid char after -c= 207 * check for valid char after -c=
203 lda ,x 208 lda ,x
204 cmpa #C$SPAC 209 cmpa #C$SPAC
205 lbeq ShowHelp 210 lbeq ShowHelp
206 cmpa #C$COMA
207 lbeq ShowHelp
208 cmpa #C$CR 211 cmpa #C$CR
209 lbeq ShowHelp 212 lbeq ShowHelp
210 leay <copt,u point Y to parameber buffer 213 leay <copt,u point Y to parameber buffer
211 tfr y,d transfer Y to D 214 tfr y,d transfer Y to D
212 addd #COPTSIZ 215 addd #COPTSIZ
216 stb ,x+ store space at X and inc 219 stb ,x+ store space at X and inc
217 sta ,y+ save loaded byte at Y and inc 220 sta ,y+ save loaded byte at Y and inc
218 cmpy ,s are we at end? 221 cmpy ,s are we at end?
219 beq L035D branch if so (buffer too small) 222 beq L035D branch if so (buffer too small)
220 cmpa #C$SPAC else is char in A a space? 223 cmpa #C$SPAC else is char in A a space?
221 beq L0350 branch if so
222 cmpa #C$COMA coma?
223 beq L0350 branch if so 224 beq L0350 branch if so
224 cmpa #C$CR cr? 225 cmpa #C$CR cr?
225 bne L0339 get next byte if not 226 bne L0339 get next byte if not
226 L0350 leax -1,x 227 L0350 leax -1,x
227 sta ,x restore previous A 228 sta ,x restore previous A
308 StrLen pshs a 309 StrLen pshs a
309 ldy #$0000 310 ldy #$0000
310 StrLenLp lda ,x+ 311 StrLenLp lda ,x+
311 cmpa #C$SPAC 312 cmpa #C$SPAC
312 beq StrLenEx 313 beq StrLenEx
313 cmpa #C$COMA
314 beq StrLenEx
315 cmpa #C$CR 314 cmpa #C$CR
316 beq StrLenEx 315 beq StrLenEx
317 leay 1,y 316 leay 1,y
318 bra StrLenLp 317 bra StrLenLp
319 StrLenEx puls a,pc 318 StrLenEx puls a,pc
331 StrCpy pshs u 330 StrCpy pshs u
332 ldu #$0000 331 ldu #$0000
333 CopyFnLp lda ,x+ 332 CopyFnLp lda ,x+
334 cmpa #C$SPAC 333 cmpa #C$SPAC
335 beq CopyFnEx 334 beq CopyFnEx
336 cmpa #C$COMA
337 beq CopyFnEx
338 cmpa #C$CR 335 cmpa #C$CR
339 beq CopyFnEx 336 beq CopyFnEx
340 sta ,y+ 337 sta ,y+
341 leau 1,u 338 leau 1,u
342 bra CopyFnLp 339 bra CopyFnLp
351 * X = ptr to first non-whitespace char 348 * X = ptr to first non-whitespace char
352 * A = non-whitespace char 349 * A = non-whitespace char
353 SkipSpcs lda ,x+ 350 SkipSpcs lda ,x+
354 cmpa #C$SPAC 351 cmpa #C$SPAC
355 beq SkipSpcs 352 beq SkipSpcs
356 cmpa #C$COMA
357 beq SkipSpcs
358 leax -1,x 353 leax -1,x
359 rts 354 rts
360 355
361 * This routine skips over everything but spaces, commas and CRs 356 * This routine skips over everything but spaces, commas and CRs
362 * 357 *
366 * X = ptr to first whitespace char 361 * X = ptr to first whitespace char
367 * A = whitespace char 362 * A = whitespace char
368 SkipNSpc lda ,x+ 363 SkipNSpc lda ,x+
369 cmpa #C$SPAC 364 cmpa #C$SPAC
370 beq EatOut 365 beq EatOut
371 cmpa #C$COMA
372 beq EatOut
373 cmpa #C$CR 366 cmpa #C$CR
374 bne SkipNSpc 367 bne SkipNSpc
375 EatOut leax -1,x 368 EatOut leax -1,x
376 rts 369 rts
377 370