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