Mercurial > hg > Members > kono > nitros9-code
annotate level1/cmds/copy.asm @ 921:617c1b90e623
Added DOHELP conditionals, set all to zero to eliminate help from commands
author | boisy |
---|---|
date | Sun, 19 Jan 2003 14:04:37 +0000 |
parents | c6e6cf68e03e |
children | c04528763543 |
rev | line source |
---|---|
0 | 1 ******************************************************************** |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
2 * Copy - File copy utility |
0 | 3 * |
4 * $Id$ | |
5 * | |
6 * Ed. Comments Who YY/MM/DD | |
7 * ------------------------------------------------------------------ | |
802 | 8 * 9 From Tandy OS-9 Level One VR 02.00.00 |
9 * 10 Reworked RML | |
10 * 11 Added useful options, made more robust BGP 03/01/11 | |
0 | 11 |
12 nam Copy | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
13 ttl File copy utility |
0 | 14 |
802 | 15 ifp1 |
15 | 16 use defsfile |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
17 use rbfdefs |
802 | 18 endc |
15 | 19 |
921
617c1b90e623
Added DOHELP conditionals, set all to zero to eliminate help from commands
boisy
parents:
846
diff
changeset
|
20 DOHELP set 0 |
802 | 21 |
22 tylg set Prgrm+Objct | |
0 | 23 atrv set ReEnt+rev |
24 rev set $01 | |
802 | 25 edition set 11 |
15 | 26 |
0 | 27 mod eom,name,tylg,atrv,start,size |
15 | 28 |
802 | 29 STCKSIZE equ 64 our stack size |
30 DDIRBSIZ equ 64 destination directory buffer size | |
31 | |
32 org 0 | |
33 rdbufptr rmb 2 | |
34 parmptr rmb 2 | |
35 srcpath rmb 1 | |
36 dstpath rmb 1 | |
37 devtyp rmb 1 | |
38 bufsiz rmb 2 | |
39 srcflsiz rmb 4 | |
40 abortflg rmb 1 | |
41 quiet rmb 1 | |
42 single rmb 1 | |
43 rewrite rmb 1 | |
44 filecnt rmb 1 | |
45 srccnt rmb 1 | |
46 srcmode rmb 1 | |
47 wopt rmb 1 | |
48 srcfname rmb 2 | |
49 dstfptr rmb 2 | |
50 wfileptr rmb 2 | |
51 wfilelen rmb 2 | |
52 lstfopen rmb 2 pointer to name of last file attempted open | |
53 lstfopln rmb 2 length of last file atteppted open | |
54 srcattr rmb 1 | |
55 fdbufcpy rmb 16 | |
56 optbuf rmb 32 | |
57 wdest rmb DDIRBSIZ portion after '-w=' | |
58 rmb DDIRBSIZ additional space | |
59 * Note: copy buffer must come just before the stack | |
60 IFGT Level-1 | |
61 copybuff rmb 8*1024 8K default buffer for Level 2 | |
62 ELSE | |
63 copybuff rmb 512 512 byte default buffer for Level 1 | |
64 ENDC | |
65 stack rmb STCKSIZE | |
0 | 66 size equ . |
200
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
188
diff
changeset
|
67 |
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
188
diff
changeset
|
68 name fcs /Copy/ |
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
188
diff
changeset
|
69 fcb edition |
15 | 70 |
802 | 71 SrcPmpt fcc /Ready SOURCE, hit C to continue: / |
72 SrcPmptL equ *-SrcPmpt | |
73 DstPmpt fcc /Ready DESTINATION, hit C to continue: / | |
74 DstPmptL equ *-DstPmpt | |
75 CrRtn fcb C$CR | |
76 IFNE DOHELP | |
77 HlpMsg fcb C$LF | |
78 fcc /Use: Copy [<opts>] <srcpath> [<dstpath>] [<opts>]/ | |
79 fcb C$LF | |
841 | 80 fcc / -a = abort on error/ |
802 | 81 fcb C$LF |
841 | 82 fcc / -p = don't print files copied (use with -w)/ |
802 | 83 fcb C$LF |
841 | 84 fcc / -r = rewrite destination/ |
802 | 85 fcb C$LF |
841 | 86 fcc / -s = single drive copy/ |
802 | 87 fcb C$LF |
846 | 88 fcc / -w=<dir> = copy to <dir>/ |
802 | 89 fcb C$LF |
841 | 90 fcc / -x = copy from exec dir/ |
802 | 91 fcb C$CR |
92 HlpMsgL equ *-HlpMsg | |
93 ENDC | |
94 PLIncmp fcc /copy: destination must be complete pathlist/ | |
95 fcb C$CR | |
96 TooMany fcc /copy: must specify output directory if more than 2 files/ | |
97 fcb C$CR | |
98 Copying fcc /copying / | |
99 CopyingL equ *-Copying | |
100 CopyTo fcc / to / | |
101 CopyToL equ *-CopyTo | |
102 Cont fcc !Continue (y/n) ?! | |
103 ContL equ *-Cont | |
104 CantCpy fcc /copy: can't open / | |
105 CantCpyL equ *-CantCpy | |
106 SpcDsh fcc / - / | |
107 SpcDshL equ *-SpcDsh | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
108 |
802 | 109 * +-----------------+ <-- Y (highest address) |
110 * ! ! | |
111 * ! Parameter ! | |
112 * ! Area ! | |
113 * ! ! | |
114 * +-----------------+ <-- X, SP | |
115 * ! ! | |
116 * ! ! | |
117 * ! Data Area ! | |
118 * ! ! | |
119 * ! ! | |
120 * +-----------------+ | |
121 * ! Direct Page ! | |
122 * +-----------------+ <-- U, DP (lowest address) | |
123 * | |
124 * D = parameter area size | |
125 * PC = module entry point abs. address | |
126 * CC = F=0, I=0, others undefined | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
127 |
802 | 128 start pshs u,x |
129 leax <wdest,u | |
130 pshs x | |
131 clrnxt clr ,u+ | |
132 cmpu ,s | |
133 bne clrnxt | |
134 leas 2,s | |
135 puls x,u | |
136 leay copybuff,u point Y to copy buffer offset in U | |
137 stx <parmptr save parameter pointer | |
138 sty <rdbufptr save pointer to buffer | |
139 tfr s,d place top of stack in D | |
140 pshs y save Y on stack | |
141 subd ,s++ get size of space between copybuf and X | |
142 subd #STCKSIZE subtract out our stack | |
143 std <bufsiz size of our buffer | |
144 lbsr SkipSpcs move past any spaces on command line | |
145 cmpa #C$CR CR? | |
146 lbeq ShowHelp if so, show help | |
147 GetNChr lda ,x+ | |
148 cmpa #C$CR CR? | |
149 lbeq CpyFiles branch if so | |
150 cmpa #'- option? | |
151 beq GetDash | |
152 inc <filecnt must be a file | |
153 lbsr SkipNSpc else go past non-spaces | |
154 ChkDash lbsr SkipSpcs and any following spaces | |
155 bra GetNChr and check for Cr | |
156 GetDash lda #C$SPAC | |
157 sta -1,x | |
158 GetDash2 ldd ,x+ load option char and char following | |
159 anda #$5F | |
160 cmpa #'S single drive copy? | |
161 bne IsItA branch if not | |
162 inc <single | |
163 lbra FixCmdLn | |
164 IsItA cmpa #'A abort option? | |
165 bne IsItP branch if not | |
166 inc <abortflg | |
167 bra FixCmdLn | |
168 IsItP cmpa #'P supress output? | |
169 bne IsItX branch if not | |
170 inc <quiet | |
171 bra FixCmdLn | |
172 IsItX cmpa #'X execution dir? | |
173 bne IsItW branch if not | |
174 lda #EXEC. else get EXEC. | |
175 sta <srcmode and save as source mode | |
176 bra FixCmdLn | |
177 IsItW cmpa #'W directory specification? | |
178 bne IsItR branch if not | |
179 tst <wopt already specified? | |
180 bne BadOpt show help if so | |
181 cmpb #'= 2nd char =? | |
182 bne BadOpt show help if not | |
183 inc <wopt else tag wopt as specified | |
184 ldb #C$SPAC get space | |
185 stb -$01,x write over w | |
186 stb ,x+ and = sign, inc X to dest dir | |
187 * check for valid char after -w= | |
188 lda ,x | |
189 cmpa #C$SPAC | |
190 lbeq ShowHelp | |
191 cmpa #C$COMA | |
192 lbeq ShowHelp | |
193 cmpa #C$CR | |
194 lbeq ShowHelp | |
195 leay <wdest,u point Y to parameber buffer | |
196 sty <dstfptr save pointer to destination file | |
197 tfr y,d transfer Y to D | |
198 addd #DDIRBSIZ add size | |
199 pshs b,a save updated ptr value | |
200 ldb #C$SPAC get space | |
201 L0339 lda ,x get byte at X | |
202 stb ,x+ store space at X and inc | |
203 sta ,y+ save loaded byte at Y and inc | |
204 cmpy ,s are we at end? | |
205 beq L035D branch if so (buffer too small) | |
206 cmpa #C$SPAC else is char in A a space? | |
207 beq L0350 branch if so | |
208 cmpa #C$COMA coma? | |
209 beq L0350 branch if so | |
210 cmpa #C$CR cr? | |
211 bne L0339 get next byte if not | |
212 L0350 leax -1,x | |
213 sta ,x restore previous A | |
214 lda #PDELIM get pathlist delimiter | |
215 sta -$01,y save slash at end (for building path later) | |
216 sty <wfileptr save pointer for -w pathlist file copying | |
217 leas $02,s kill stack | |
218 lbra ChkDash | |
219 L035D leas $02,s | |
220 ldb #$BF else buffer size too small | |
221 orcc #Carry | |
222 lbra Exit | |
223 IsItR cmpa #'R rewrite? | |
224 bne BadOpt branch if not | |
225 inc <rewrite | |
226 FixCmdLn lda #C$SPAC get space | |
227 sta -$01,x and wipe out option character | |
228 cmpb #'0 | |
229 lblt ChkDash start dash option processing again | |
230 lbra GetDash possibly another option following? | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
231 |
802 | 232 BadOpt puls x |
233 lbra ShowHelp | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
234 |
802 | 235 CopyToW ldx <srcfname get ptr to next file to process |
236 * In case the source file name has a / in it (i.e. /dd/x/y/fname), | |
237 * we go past the file and then back up to either the first / we | |
238 * encounter, or a space (be sure we don't go past parmptr) | |
239 lda ,x | |
240 cmpa #C$CR carriage return? | |
241 lbeq ExitOk yep, no more files | |
242 lbsr SkipNSpc skip over filename | |
243 * X points to first char after file name (space, comma or CR) | |
244 L038B cmpx <parmptr are we at start of command line? | |
245 beq PlugIt2 if so, we can't go further back | |
246 lda ,-x get byte | |
247 cmpa #PDELIM path delimiter? | |
248 beq PlugIt branch if so | |
249 cmpa #C$SPAC space? | |
250 beq PlugIt branch if so | |
251 cmpa #C$COMA comma? | |
252 beq PlugIt branch if so | |
253 bra L038B else get next char | |
254 PlugIt leax 1,x go forward 1 | |
255 PlugIt2 ldy <wfileptr get address past xxxx/ (specified by -w=) | |
823 | 256 lbsr StrCpy copy filename |
802 | 257 std <wfilelen save file length |
258 lda #C$CR get CR | |
259 sta ,y and terminate | |
260 * ldx <wopt | |
261 * stx <wfileptr | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
262 rts |
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
263 |
802 | 264 * At this point options are processed, so we need to start copying files |
265 CpyFiles tst <filecnt we should have at least one file on cmdline | |
266 lbeq ShowHelp if not, exit with error | |
267 ldx <parmptr get our parameter pointer off stack | |
268 lbsr SkipSpcs skip any leading spaces | |
269 tst <wopt -w specified? | |
270 beq L03C5 branch if not | |
271 stx <srcfname else save start of parameter pointer as next file | |
272 clr <single no single option with -w | |
273 L03BE bsr CopyToW copy file at <srcfname to -w buffer | |
274 bra OpenSrc | |
275 * This code handles single file copy (i.e. copy file1 file2) | |
276 * or a single disk copy (i.e. copy -s abc) | |
277 L03C5 lbsr GetSDFl else get source/destination files | |
278 bcc L03D4 branch if we got both ok | |
279 tst <single is this a single drive copy? | |
280 lbne PListErr if not, user didn't specify enough files | |
281 lbcs Exit if error, exit | |
282 * test for right number of files | |
283 L03D4 lda <filecnt get total file count | |
284 cmpa #2 should be no more than two files | |
285 ble OpenSrc | |
286 leax TooMany,pcr | |
287 lbsr WrLine | |
288 lbra ExitOk | |
289 OpenSrc ldx <srcfname get file to open | |
290 pshs x | |
291 lbsr StrLen get length | |
292 std <lstfopln save length | |
293 puls x | |
294 lda #READ. read mode | |
295 ora <srcmode or in any additional modes (i.e. EXEC.) | |
296 stx <lstfopen save pointer to last file open var | |
297 os9 I$Open open source file | |
298 bcc L03FA branch if open ok | |
299 cmpx <srcfname did open go past pathlist? | |
300 bne OpenFail branch if so | |
301 lbsr SkipNSpc else skip over failed filename | |
302 lbsr SkipSpcs and any trailing spaces | |
303 OpenFail stx <srcfname save updated pathlist pointer (points to next file on cmd line) | |
304 lbra ShutDown | |
305 L03FA sta <srcpath save source path | |
306 pshs a save path | |
307 lbsr SkipSpcs destroy any leading spaces | |
308 stx <srcfname and save pointer to next source filename | |
309 lbsr StrLen get length | |
310 std <lstfopln save length | |
311 puls a get path off stack | |
312 leax <fdbufcpy,u point to FD buffer | |
313 ldy #FD.SEG number of bytes | |
314 ldb #SS.FD | |
315 os9 I$GetStt get file's file descriptor | |
316 bcs L041B branch if error | |
317 tst <single single drive copy? | |
318 beq L041B branch if not | |
319 lda [<dstfptr,u] get first char of destination filename | |
320 ldb #E$BPNam prepare for possible error | |
321 cmpa #PDELIM path has leading slash? | |
322 lbne PListErr if not, show error | |
323 L041B lda <srcpath get source path | |
324 leax <optbuf,u point to options buffer | |
325 clrb was: ldb #SS.Opt | |
326 os9 I$GetStt get path options | |
327 lbcs ShutDown branch if error | |
328 lda ,x get device type | |
329 sta <devtyp save | |
330 ldb #$0F | |
331 cmpa #DT.RBF rbf device? | |
332 bne L0449 branch if not | |
333 pshs u,x save regs | |
334 lda <srcpath get source path | |
335 ldb #SS.Size | |
336 os9 I$GetStt get size | |
337 lbcs ShutDown | |
338 stx <srcflsiz save file size | |
339 stu <srcflsiz+2 | |
340 puls u,x restore regs | |
341 ldb <PD.ATT-PD.OPT,x get source file's attributes | |
342 L0449 stb <srcattr save | |
343 lda #$01 | |
344 lbsr SwapDsk check for single disk copy and prompt if necessary | |
345 L0450 ldx <dstfptr point to destination file | |
346 pshs x | |
347 lbsr StrLen get length | |
348 std <lstfopln save length | |
349 puls x | |
350 lda #WRITE. write mode | |
351 ldb <srcattr get source attributes | |
352 stx <lstfopen | |
353 os9 I$Create create file | |
354 bcc L048B branch if create ok | |
355 tst <rewrite rewrite flag set? | |
356 lbeq ShutDown branch if no | |
357 cmpb #E$CEF file already exists? | |
358 lbne ShutDown branch if any other error | |
359 L047A os9 I$Delete delete file first | |
360 lbcs ShutDown branch if error | |
361 bra L0450 else try opening again | |
362 L048B sta <dstpath save destination path | |
363 tst <wopt w option specified? | |
364 beq GetOpts branch iff not | |
365 tst <quiet p option specified? | |
366 bne GetOpts branch if so | |
367 pshs a else save dest path on stack | |
368 leax >Copying,pcr else print 'Copying...' | |
369 ldy #CopyingL | |
370 lbsr WritSOut write it to stdout | |
371 ldx <wfileptr get pointer to file being copied | |
372 ldy <wfilelen get file name length | |
373 lbsr WritSOut print file name | |
374 leax >CopyTo,pcr print ' to ' | |
375 ldy #CopyToL | |
376 lbsr WritSOut write it to stdout | |
377 ldx <dstfptr get pointer to file being copied | |
378 lbsr WrLine print file with CR | |
379 puls a restore dest path | |
380 GetOpts leax <optbuf,u point to option buffer | |
381 clrb was: ldb #SS.Opt | |
382 os9 I$GetStt get options | |
383 lbcs ShutDown branch if error | |
384 ldb ,x get device type | |
385 cmpb #DT.RBF rbf? | |
386 bne CopyLoop if not rbf device, don't get file size or fd seg | |
387 L04B4 lda <devtyp get device type | |
388 cmpa #DT.RBF rbf? | |
389 bne CopyLoop branch if not | |
390 pshs u save our statics ptr | |
391 lda <dstpath else get dest path | |
392 ldb #SS.Size and setstat option | |
393 ldx <srcflsiz get file size of source | |
394 ldu <srcflsiz+2 | |
395 os9 I$SetStt and set dest file to same size | |
396 lbcs ShutDown branch if error | |
397 puls u restore U | |
398 lda <dstpath get dest path | |
399 leax <fdbufcpy,u point to file desc. buffer | |
400 ldy #FD.SEG get size | |
401 ldb #SS.FD | |
402 os9 I$SetStt write src fd seg to dest file | |
403 * Copy loop is here | |
404 CopyLoop ldx <rdbufptr get ptr to read buffer | |
405 clra A = 0 = source prompt if needed | |
406 lbsr SwapDsk check for single disk copy and prompt if so | |
407 lda <srcpath get source path | |
408 ldy <bufsiz get buffer size | |
409 os9 I$Read read it! | |
410 bcs L0558 branch if error | |
411 lda #$01 A = 1 = dest prompt | |
412 lbsr SwapDsk check for single disk copy and prompt if so | |
413 lda <dstpath get dest path | |
414 os9 I$Write write it out! | |
415 lbcs ShutDown branch if error | |
416 lda <srcpath get source path | |
417 ldb #SS.EOF | |
418 os9 I$GetStt are we at end of file? | |
419 bcc CopyLoop branch if not | |
420 cmpb #E$EOF end of file error? | |
421 beq L0561 branch if so | |
422 L0558 cmpb #E$EOF end of file rror? | |
423 bne ShutDown branch if not | |
424 lda #$01 prompt destination flag | |
425 lbsr SwapDsk check for single drive copy and prompt if necessary | |
426 L0561 lda <dstpath get destination path | |
427 os9 I$Close close that file | |
428 bcs ShutDown branch if error | |
429 clr <dstpath else clear dest path | |
430 lda <srcpath get source path | |
431 os9 I$Close close it | |
432 bcs ShutDown branch if error | |
433 clr <srcpath clear src path | |
434 tst <wopt -w specified | |
435 lbeq ExitOk branch if not | |
436 lbra L03BE | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
437 |
802 | 438 * Entry: X = ptr to data to write, Y = length |
439 WritSOut lda #$01 standard out | |
440 os9 I$Write write it | |
0 | 441 rts |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
442 |
802 | 443 PListErr leax >PLIncmp,pcr |
444 bsr WrLine | |
445 bra ExitOk | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
446 |
802 | 447 ShutDown pshs b |
448 lda <srcpath get source path | |
449 beq L05AA branch if none | |
450 os9 I$Close close it | |
451 L05AA lda <dstpath get dest path | |
452 beq L05B1 branch if none | |
453 os9 I$Close close it | |
454 L05B1 clr <srcpath clear source path | |
455 clr <dstpath and destination | |
456 leax >CantCpy,pcr else show can't copy error | |
457 ldy #CantCpyL | |
458 bsr WritSOut write out | |
459 ldx <lstfopen show filename that failed | |
460 ldy <lstfopln get length | |
461 bsr WritSOut | |
462 leax >SpcDsh,pcr | |
463 ldy #SpcDshL | |
464 bsr WritSOut write out | |
465 puls b | |
466 PrintErr os9 F$PErr print error | |
467 tst <wopt -w used? | |
468 beq ExitOk branch if not | |
469 tst <abortflg abort flag set? | |
470 bne ExitOk branch if so | |
471 AskAgain leax >Cont,pcr point to continue prompt | |
472 ldy #ContL get length | |
473 bsr WritSOut write | |
474 clra ADDED +BGP+ | |
475 ldx <rdbufptr get pointer at readbuf | |
476 ldy #$0002 2 bytes | |
477 os9 I$ReadLn read form stdin | |
478 lda ,x get byte at X | |
479 anda #$5F | |
480 cmpa #'Y user wants to continue? | |
481 lbeq L03BE branch if so | |
482 cmpa #'N no? | |
483 beq ExitOk branch if so | |
484 bra AskAgain else ask again | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
485 |
802 | 486 ShowHelp equ * |
487 IFNE DOHELP | |
488 leax >HlpMsg,pcr point to help message | |
489 ldy #HlpMsgL get length | |
490 lda #$02 std error | |
491 os9 I$WritLn write it | |
492 ENDC | |
493 ExitOk clrb clear carry | |
494 Exit os9 F$Exit and exit | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
495 |
802 | 496 * Write line passed in X |
497 WrLine ldy #$00A0 | |
498 WrNBytes lda #$01 | |
499 os9 I$WritLn | |
500 rts | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
501 |
802 | 502 * Prompt User for Source or Destination Disk |
503 SwapDsk tst <single single disk copy? | |
504 beq NoSwap branch if not | |
505 pshs y,x | |
506 L0626 pshs a | |
507 tsta | |
508 bne L0635 | |
509 leax >SrcPmpt,pcr point to source prompt | |
510 ldy #SrcPmptL get size | |
511 bra L063D write it and get input | |
512 L0635 leax >DstPmpt,pcr point to dest prompt | |
513 ldy #DstPmptL get size | |
514 L063D bsr WrNBytes write it | |
515 leax ,-s point to stack for temp buffer | |
516 ldy #$0001 one byte | |
517 clra from std in | |
518 os9 I$Read read byte from user | |
519 lda ,s+ get char | |
520 eora #'C | |
521 anda #$DF | |
522 beq L0657 branch if C | |
523 bsr L065E | |
524 puls a | |
525 bne L0626 | |
526 L0657 bsr L065E | |
527 puls a | |
528 puls y,x | |
529 NoSwap rts | |
530 L065E pshs y,x,a | |
531 lda #$01 | |
532 leax >CrRtn,pcr | |
533 ldy #80 | |
534 os9 I$WritLn | |
535 puls pc,y,x,a | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
536 |
802 | 537 * StrLen |
538 * | |
539 * Entry: | |
540 * X = ptr to string (space, comma or CR terminated) | |
541 * Exit: | |
542 * D = length of string | |
543 * X = ptr to byte after string | |
544 StrLen pshs u | |
545 ldu #$0000 | |
546 StrLenLp lda ,x+ | |
547 cmpa #C$SPAC | |
548 beq StrLenEx | |
549 cmpa #C$COMA | |
550 beq StrLenEx | |
551 cmpa #C$CR | |
552 beq StrLenEx | |
553 leau 1,u | |
554 bra StrLenLp | |
555 StrLenEx tfr u,d | |
556 puls u,pc | |
557 | |
558 * StrCpy | |
559 * | |
560 * Entry: | |
561 * X = ptr to src string | |
562 * Y = ptr to dest string | |
563 * Exit: | |
564 * D = number of bytes copied | |
565 * X = ptr to byte after original string | |
566 * X = ptr to byte after copied string | |
567 StrCpy pshs u | |
568 ldu #$0000 | |
569 CopyFnLp lda ,x+ | |
570 cmpa #C$SPAC | |
571 beq CopyFnEx | |
572 cmpa #C$COMA | |
573 beq CopyFnEx | |
574 cmpa #C$CR | |
575 beq CopyFnEx | |
576 sta ,y+ | |
577 leau 1,u | |
578 bra CopyFnLp | |
579 CopyFnEx tfr u,d | |
580 puls u,pc | |
581 | |
582 * Skip over spaces and commas | |
583 * | |
584 * Entry: | |
585 * X = ptr to string | |
586 * Exit: | |
587 * X = ptr to first non-whitespace char | |
588 * A = non-whitespace char | |
589 SkipSpcs lda ,x+ | |
590 cmpa #C$SPAC | |
591 beq SkipSpcs | |
592 cmpa #C$COMA | |
593 beq SkipSpcs | |
594 leax -1,x | |
595 rts | |
15 | 596 |
802 | 597 * Skip over non-spaces and non-commas |
598 * | |
599 * Entry: | |
600 * X = ptr to string | |
601 * Exit: | |
602 * X = ptr to first non-whitespace char | |
603 * A = non-whitespace char | |
604 SkipNSpc lda ,x+ | |
605 cmpa #C$SPAC | |
606 beq EatOut | |
607 cmpa #C$COMA | |
608 beq EatOut | |
609 cmpa #C$CR | |
610 bne SkipNSpc | |
611 EatOut leax -1,x | |
612 rts | |
613 | |
614 * Get source file in <srcfname and destination file in <dstfptr | |
615 GetSDFl leay <srcfname,u point X to next file pointer | |
616 bsr SrchFile skip white spaces, look for name on cmd line | |
617 bcs L067D branch if end | |
618 inc <srccnt else increment souce count | |
619 leay <dstfptr,u point Y to destination file | |
620 bsr SkipSpcs destroy any leading spaces | |
621 bsr SrchFile skip white spaces, look for name on cmd line | |
622 L067D rts | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
623 |
802 | 624 * Starting at X, parse for a filename, skipping leading white spaces |
625 SrchFile lda ,x | |
626 cmpa #C$CR CR? | |
627 beq L06A2 branch if so | |
628 stx ,y else store X at Y | |
629 SkipFile bsr SkipNSpc skip non-spaces | |
630 ParseOk clrb clear B | |
631 rts return | |
632 L06A2 tst <srccnt any file specified? | |
633 bne L06AA branch if so | |
634 BadPName ldb #E$BPNam else no source was specified | |
635 coma | |
636 rts | |
637 | |
638 L06AA ldx <srcfname get pointer | |
639 L06AC lda ,x+ get char | |
640 cmpa #C$SPAC space? | |
641 beq L06C4 branch if so | |
642 cmpa #C$COMA comma? | |
643 beq L06C4 branch if so | |
644 cmpa #C$CR carriage return? | |
645 beq L06C4 branch if so | |
646 cmpa #PDELIM pathlist delimiter? | |
647 bne L06AC branch if not | |
648 clr <srccnt else clear file count | |
649 stx ,y and store | |
650 bra L06AC continue parsing | |
651 L06C4 tst <srccnt file count 0? | |
652 beq L06D2 branch if so | |
653 tst <srcmode source mode? (exec or data dir) | |
654 beq BadPName branch if data | |
655 ldx <srcfname else get pointer | |
656 stx ,y save | |
657 bra ParseOk branch | |
658 L06D2 lda -$02,x | |
659 cmpa #PDELIM | |
660 beq BadPName | |
661 bra ParseOk | |
662 | |
663 emod | |
0 | 664 eom equ * |
15 | 665 end |