Mercurial > hg > Members > kono > nitros9-code
annotate level1/cmds/dsave.asm @ 953:c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
author | boisy |
---|---|
date | Fri, 24 Jan 2003 21:43:13 +0000 |
parents | 062d7f4e63b7 |
children | 9a075092f6ce |
rev | line source |
---|---|
0 | 1 ******************************************************************** |
951 | 2 * dsave - Multi-file copy utility |
0 | 3 * |
4 * $Id$ | |
5 * | |
951 | 6 * Syntax: dsave [<opts>] <destpath> |
7 * Opts : | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
8 * -b = include bootfile (doesn't work) |
951 | 9 * -e = execute files |
10 * -i = indent dir levels | |
11 * -l = only one dir level | |
12 * -m = omit makdirs | |
13 * -r = force rewrite on copy | |
14 * -s = alter copy mem size | |
15 * -v = verify copied files | |
16 * | |
0 | 17 * Ed. Comments Who YY/MM/DD |
18 * ------------------------------------------------------------------ | |
951 | 19 * 1 Put your development info here BGP 03/01/11 |
0 | 20 |
21 nam dsave | |
951 | 22 ttl Multi-file copy utility |
0 | 23 |
24 ifp1 | |
951 | 25 use defsfile |
26 use rbfdefs | |
0 | 27 endc |
200
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
113
diff
changeset
|
28 |
951 | 29 * Here are some tweakable options |
30 DOHELP set 0 1 = include help info | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
31 INDENTSZ set 2 number of spaces to indent when -i is used |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
32 STACKSZ set 1024 estimated stack size in bytes |
951 | 33 PARMSZ set 256 estimated parameter size in bytes |
34 | |
35 * Module header definitions | |
0 | 36 tylg set Prgrm+Objct |
37 atrv set ReEnt+rev | |
38 rev set $01 | |
951 | 39 edition set 1 |
200
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
113
diff
changeset
|
40 |
0 | 41 mod eom,name,tylg,atrv,start,size |
200
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
113
diff
changeset
|
42 |
951 | 43 * Your utility's static storage vars go here |
924 | 44 org 0 |
951 | 45 * These vars are used by the base template and shouldn't be removed |
46 parmptr rmb 2 pointer to our command line params | |
47 bufptr rmb 2 pointer to user expandable buffer | |
48 bufsiz rmb 2 size of user expandable buffer | |
49 * These vars are used for this example, it will probably change for you | |
50 dirlevel rmb 1 current directory level | |
51 doexec rmb 1 execute flag | |
52 errcode rmb 1 error code storage | |
53 plistcnt rmb 1 command line pathlist count | |
54 doboot rmb 1 | |
55 indent rmb 1 | |
56 onelevel rmb 1 | |
57 nomakdir rmb 1 | |
58 rewrite rmb 1 | |
59 cpymemsz rmb 1 | |
60 doverify rmb 1 | |
61 dstpath rmb 2 pointer to second (optional) pathlist on cmd line | |
62 lineptr rmb 2 | |
63 sopt rmb 1 | |
64 * vars for pwd integrated code | |
65 fildes rmb 1 | |
66 srcptr rmb 2 | |
67 dotdotfd rmb 3 LSN of .. | |
68 dotfd rmb 3 LSN of . | |
69 ddcopy rmb 3 | |
70 dentry rmb DIR.SZ*2 | |
71 srcpath rmb 128 | |
72 buffend rmb 1 | |
73 pathext rmb 256 extended part of source pathlist | |
74 devname rmb 32 | |
75 cleartop equ . everything up to here gets cleared at start | |
76 direntbf rmb DIR.SZ | |
77 * Next is a user adjustable buffer with # modifier on command line. | |
78 * Some utilities won't need this flexibility, some will. | |
79 * Currently set up to be larger for Level 2 than Level 1 | |
80 * Note: this buffer must come just before the stack | |
81 linebuff rmb 256 | |
82 IFGT Level-1 | |
83 bigbuff rmb 8*1024 8K default buffer for Level 2 | |
84 ELSE | |
85 bigbuff rmb 512 512 byte default buffer for Level 1 | |
86 ENDC | |
87 * Finally the stack for any PSHS/PULS/BSR/LBSRs that we might do | |
88 rmb STACKSZ+PARMSZ | |
0 | 89 size equ . |
200
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
113
diff
changeset
|
90 |
951 | 91 * The utility name and edition goes here |
92 name fcs /dsave/ | |
93 fcb edition | |
94 | |
95 * Place constant strings here | |
96 IFNE DOHELP | |
97 HlpMsg fcb C$LF | |
98 fcb C$CR | |
99 HlpMsgL equ *-HlpMsg | |
100 ENDC | |
101 | |
102 UnkOpt fcc /unknown option: / | |
103 UnkOptL equ *-UnkOpt | |
104 | |
105 ShlEko fcc "t" | |
106 fcb C$CR | |
107 | |
108 Chd fcc "chd" | |
109 fcb C$CR | |
110 | |
111 MakDir fcc "makdir" | |
112 fcb C$CR | |
113 | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
114 Cmp fcc "cmp" |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
115 fcb C$CR |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
116 |
951 | 117 TMode fcc "tmode" |
118 fcb C$CR | |
119 TPause fcc ".1 pause" | |
120 fcb C$CR | |
121 TNoPause fcc ".1 -pause" | |
122 fcb C$CR | |
123 | |
124 Load fcc "load" | |
125 fcb C$CR | |
126 | |
127 Unlink fcc "unlink" | |
128 fcb C$CR | |
129 | |
130 Copy fcc "copy" | |
131 fcb C$CR | |
132 | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
133 OS9Boot fcc "OS9BOOT " |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
134 |
951 | 135 DotDot fcc "." |
136 Dot fcc "." | |
137 fcb C$CR | |
138 | |
139 * Here's how registers are set when this process is forked: | |
140 * | |
141 * +-----------------+ <-- Y (highest address) | |
142 * ! Parameter ! | |
143 * ! Area ! | |
144 * +-----------------+ <-- X, SP | |
145 * ! Data Area ! | |
146 * +-----------------+ | |
147 * ! Direct Page ! | |
148 * +-----------------+ <-- U, DP (lowest address) | |
149 * | |
150 * D = parameter area size | |
151 * PC = module entry point abs. address | |
152 * CC = F=0, I=0, others undefined | |
153 | |
154 * The start of the program is here. | |
155 * Before any command line processing is done, we clear out | |
156 * our static memory from U to cleartop, then determine the | |
157 * size of our data area (minus the stack). | |
158 start pshs u,x save registers for later | |
159 leax cleartop,u point to end of area to zero out | |
160 IFNE H6309 | |
161 subr u,x subtract U from X | |
162 tfr x,w and put X in W | |
163 clr ,-s put a zero on the stack | |
164 tfm s,u+ and use TFM to clear starting at U | |
165 leas 1,s clean up the stack | |
166 ELSE | |
167 pshs x save end pointer on stack | |
168 clrnxt clr ,u+ clear out | |
169 cmpu ,s done? | |
170 bne clrnxt branch if not | |
171 leas 2,s else clear stack | |
172 ENDC | |
173 puls x,u and restore our earlier saved registers | |
174 leay bigbuff,u point Y to copy buffer offset in U | |
175 stx <parmptr save parameter pointer | |
176 sty <bufptr save pointer to buffer | |
177 tfr s,d place top of stack in D | |
178 IFNE H6309 | |
179 subr y,d | |
180 ELSE | |
181 pshs y save Y on stack | |
182 subd ,s++ get size of space between copybuf and X | |
183 ENDC | |
184 subd #STACKSZ+PARMSZ subtract out our stack/param size | |
185 std <bufsiz size of our buffer | |
186 | |
187 * At this point we have determined our buffer space and saved pointers | |
188 * for later use. Now we will parse the command line for options that | |
189 * begin with a dash. | |
190 * Note that X will NOT point to a space, but to either a CR (if no | |
191 * parameters were passed) or the first non-space character of the | |
192 * parameter. | |
193 * Here we merely grab the byte at X into A and test for end of line, | |
194 * exiting if so. Utilities that don't require arguments should | |
195 * comment out the following three lines. | |
196 lda ,x get first char | |
197 cmpa #C$CR CR? | |
198 lbeq ShowHelp if so, no parameters... show help and exit | |
199 GetChar lda ,x+ get next character on cmd line | |
200 cmpa #C$CR CR? | |
201 lbeq DoDSave if so, do whatever this utility does | |
202 cmpa #'- is it an option? | |
203 beq GetDash if so, process it | |
204 inc <plistcnt else must be a non-option argument (file) | |
205 lbsr SkipNSpc move past the argument | |
206 ChkDash lbsr SkipSpcs and any following spaces | |
207 bra GetChar start processing again | |
208 GetDash lda #C$SPAC get a space char | |
209 sta -1,x and wipe out the dash from the cmd line | |
210 GetDash2 ldd ,x+ load option char and char following | |
211 ora #$20 make lowercase | |
212 IsItB cmpa #'b is it this option? | |
213 bne IsItE branch if not | |
214 sta <doboot | |
215 bra FixCmdLn | |
216 IsItE cmpa #'e is it this option? | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
217 bne IsItI branch if not |
951 | 218 sta <doexec |
219 bra FixCmdLn | |
220 IsItI cmpa #'i is it this option? | |
221 bne IsItL branch if not | |
222 sta <indent | |
223 bra FixCmdLn | |
224 IsItL cmpa #'l is it this option? | |
225 bne IsItM branch if not | |
226 sta <onelevel | |
227 bra FixCmdLn | |
228 IsItM cmpa #'m is it this option? | |
229 bne IsItR branch if not | |
230 sta <nomakdir | |
231 bra FixCmdLn | |
232 IsItR cmpa #'r is it this option? | |
233 bne IsItS branch if not | |
234 sta <rewrite | |
235 bra FixCmdLn | |
236 IsItS cmpa #'s is it this option? | |
237 bne IsItV branch if not | |
238 * add code to parse memsize | |
239 pshs x | |
240 lbsr ASC2Byte | |
241 stb <sopt | |
242 lda #C$SPAC | |
243 SpcNext sta ,-x erase everything after -s | |
244 cmpx ,s | |
245 bne SpcNext | |
246 puls x | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
247 clrb |
951 | 248 bra FixCmdLn |
249 IsItV cmpa #'v is it this option? | |
250 bne BadOpt branch if not | |
251 sta <doverify | |
252 FixCmdLn lda #C$SPAC get space | |
253 sta -$01,x and wipe out option character | |
254 cmpb #'0 | |
255 lblt ChkDash start dash option processing again | |
256 lbra GetDash possibly another option following? | |
257 | |
258 * We branch here if we encounter an unknown option character | |
259 * A = bad option character | |
260 BadOpt leax UnkOpt,pcr | |
261 ldy #UnkOptL | |
262 ldb #C$CR | |
263 pshs d save bad option and CR on stack | |
264 lda #$02 stderr | |
265 os9 I$Write | |
266 leax ,s point X at option char on stack | |
267 os9 I$WritLn print option and CR | |
268 puls d clean up stack | |
269 lbra ShowHelp | |
270 | |
271 * At this point options are processed. | |
272 * We load X with our parameter pointer and go down the command line | |
273 * looking at each file to process (options have been wiped out with | |
274 * spaces) | |
275 * | |
276 * Note, the following two instructions may not be needed, depending on | |
277 * if your utility requires a non-option on the command line. | |
278 DoDSave dec <plistcnt we should have only one path on cmdline | |
279 lbne ShowHelp if not, exit with error | |
280 ldx <parmptr get our parameter pointer off stack | |
281 lbsr SkipSpcs skip any leading spaces | |
282 stx <dstpath save dest path | |
283 lbsr SkipNSpc | |
284 lda #C$CR | |
285 sta ,x+ | |
286 | |
287 * Here we have src and possibly destination pathlist. Now we can | |
288 * start processing the dsave | |
289 leax linebuff,u | |
290 stx <lineptr reset line buffer pointer | |
291 | |
292 * Get entire pathlist to working directory | |
293 lbsr pwd | |
294 | |
295 * Do dsave "pre" commands | |
296 lbsr DoEcho | |
297 ldx <dstpath point to source path | |
298 lbsr DoChd chd to it | |
299 lbsr DoPauseOff | |
300 lbsr DoLoadCopy | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
301 tst <doverify |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
302 beq PreRecurse |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
303 lbsr DoLoadCmp |
951 | 304 |
305 * Steps in processing files: | |
306 * 0. Open path to '.' | |
307 * 1. Read next directory entry | |
308 * 2. if directory encountered: | |
309 * a. chd entry | |
310 * b. bsr step 0 | |
311 * c. chd .. | |
312 * 3. if eof, goto step 6 | |
313 * 4. copy file to dest | |
314 * 5. goto 1 | |
315 * 6. Close path to source dir | |
316 | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
317 PreRecurse |
951 | 318 leay buffend,u |
319 bsr CopyDir | |
320 | |
321 * Do dsave "post" commands | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
322 tst <doverify |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
323 beq PostRecurse |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
324 lbsr DoUnlinkCmp |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
325 PostRecurse |
951 | 326 lbsr DoUnlinkCopy |
327 lbsr DoPauseOn | |
328 | |
329 lbra ExitOk | |
330 | |
331 CopyDir ldx <srcptr | |
332 lda #DIR.+READ. permissions as DIR. | |
333 os9 I$Open open directory | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
334 lbcs CopyRts branch if error |
951 | 335 ldb #PDELIM |
336 stb ,y+ | |
337 pshs y | |
338 pshs a save path to . | |
339 pshs x,u save regs | |
340 ldx #$0000 | |
341 ldu #DIR.SZ*2 seek past two dir entries | |
342 os9 I$Seek skip over . and .. entries of this dir | |
343 puls x,u get saved regs | |
344 bcs Copy2Ex branch if error | |
345 FileLoop lda ,s get path to . on stack | |
346 ldy #DIR.SZ get size of directory entry | |
347 leax direntbf,u point to directory entry buffer | |
348 os9 I$Read read directory entry | |
349 bcs Copy2Ex branch if error | |
350 tst ,x first byte at x... is it zero? | |
351 beq FileLoop yep, empty dir entry | |
352 ldy 1,s get Y on stack | |
353 lbsr StrCpy | |
354 lda #C$CR | |
355 sta ,y | |
356 ldx <srcptr | |
357 lda #DIR.+READ. open as directory | |
358 os9 I$Open open it | |
359 bcs ItsAFile if error, it's not a dir | |
360 os9 I$Close close it | |
361 * Here, we know that the file we just opened and closed was a directory | |
362 ItsADir | |
363 tst <onelevel do we ignore dirs? | |
364 bne FileLoop branch if so | |
365 pshs y | |
366 ldx 3,s | |
367 lbsr DoMakDir makdir it | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
368 bcc ItsADir2 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
369 os9 F$PErr |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
370 ItsADir2 ldx 3,s |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
371 lbsr DoChd |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
372 bcs FileLoop if error, ignore dir |
951 | 373 inc <dirlevel |
374 puls y | |
375 bsr CopyDir | |
376 leax DotDot,pcr | |
377 lbsr DoChd | |
378 dec <dirlevel | |
379 bra FileLoop | |
380 | |
381 * Here, we know that the file we just opened and closed was NOT a directory | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
382 ItsAFile tst <doboot test for allowance of os9boot |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
383 bne ItsAFile2 branch if so |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
384 ldx 1,s |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
385 lbsr BootCmp compare against os9boot |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
386 beq FileLoop if a match, don't copy |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
387 ItsAFile2 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
388 ldx 1,s |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
389 lbsr BuildCopy |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
390 tst <doverify verify on? |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
391 beq FileLoop branch if not |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
392 ldx 1,s |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
393 lbsr BuildCmp |
951 | 394 bra FileLoop |
395 Copy2Ex puls a get path to . | |
396 os9 I$Close close path | |
397 CopyEx leas 2,s | |
398 CopyRts rts | |
399 | |
400 ShowHelp equ * | |
401 IFNE DOHELP | |
402 leax >HlpMsg,pcr point to help message | |
403 ldy #HlpMsgL get length | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
404 lda #INDENTSZ std error |
951 | 405 os9 I$WritLn write it |
406 ENDC | |
407 ExitOk clrb clear carry | |
408 Exit os9 F$Exit and exit | |
409 | |
410 * This routine counts the number of non-whitespace characters | |
411 * starting at X | |
412 * | |
413 * Entry: | |
414 * X = ptr to string (space, comma or CR terminated) | |
415 * Exit: | |
416 * Y = length of string | |
417 * X = ptr to byte after string | |
418 StrLen pshs a | |
419 ldy #$0000 | |
420 StrLenLp lda ,x+ | |
421 cmpa #C$SPAC | |
422 beq StrLenEx | |
423 cmpa #C$CR | |
424 beq StrLenEx | |
425 leay 1,y | |
426 bra StrLenLp | |
427 StrLenEx puls a,pc | |
428 | |
429 * This routine copies a string of text from X to Y until | |
430 * a CR or hi bit char is encountered | |
431 * | |
432 * Entry: | |
433 * X = ptr to src string | |
434 * Y = ptr to dest string | |
435 * Exit: | |
436 * D = number of bytes copied | |
437 * X = ptr to char past src string | |
438 * Y = ptr to char past dest string | |
439 StrCpy pshs u | |
440 ldu #$0000 | |
441 CopyFnLp lda ,x+ | |
442 tfr a,b | |
443 anda #$7F | |
444 cmpa #C$CR | |
445 ble CopyFnEx | |
446 sta ,y+ | |
447 leau 1,u | |
448 tstb | |
449 bpl CopyFnLp | |
450 * clr ,y+ add null byte at end | |
451 CopyFnEx tfr u,d | |
452 puls u,pc | |
453 | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
454 * Compare two filenames to see if they match |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
455 * X = filename to compare against OS9boot |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
456 BootCmp pshs y,x |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
457 lbsr StrLen get length of passed filename |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
458 puls x get pointer to passed filename |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
459 cmpy #7 compare stlren of X against OS9Boot |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
460 bne FileCmpEx if not the same length, they aren't equal |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
461 * Here we know the filenames are the same length |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
462 ldb #6 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
463 FIleCmp2 leay OS9Boot,pcr |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
464 lda b,x |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
465 bsr MakeUp |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
466 cmpa b,y |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
467 bne FileCmpEx |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
468 decb |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
469 bpl FileCmp2 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
470 clrb clear carry |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
471 puls y,pc |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
472 FileCmpEx orcc #Carry |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
473 puls y,pc |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
474 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
475 MakeUp cmpa #'a |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
476 blt MakeUpEx |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
477 cmpa #'z |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
478 bgt MakeUpEx |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
479 anda #$DF make uppercase |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
480 MakeUpEx rts |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
481 |
951 | 482 StrHCpy pshs u |
483 ldu #$0000 | |
484 HCpyFnLp lda ,x+ | |
485 beq HCpyFnEx | |
486 tfr a,b | |
487 anda #$7F strip out possible hi bit | |
488 sta ,y+ | |
489 leau 1,u | |
490 tstb test copy of byte in B | |
491 bpl HCpyFnLp if hi bit not set, keep going | |
492 * clr ,y+ add null byte at end | |
493 HCpyFnEx tfr u,d | |
494 puls u,pc | |
495 | |
496 * This routine skip over spaces | |
497 * | |
498 * Entry: | |
499 * X = ptr to data to parse | |
500 * Exit: | |
501 * X = ptr to first non-whitespace char | |
502 * A = non-whitespace char | |
503 SkipSpcs lda ,x+ | |
504 cmpa #C$SPAC | |
505 beq SkipSpcs | |
506 leax -1,x | |
507 rts | |
508 | |
509 * This routine skips over everything but spaces, commas and CRs | |
510 * | |
511 * Entry: | |
512 * X = ptr to data to parse | |
513 * Exit: | |
514 * X = ptr to first whitespace char | |
515 * A = whitespace char | |
516 SkipNSpc lda ,x+ | |
517 cmpa #C$SPAC | |
518 beq EatOut | |
519 cmpa #C$CR | |
520 bne SkipNSpc | |
521 EatOut leax -1,x | |
522 rts | |
523 | |
524 | |
525 * Entry: X = directory to make | |
526 DoMakDir | |
527 tst <nomakdir do we do the makdir? | |
528 bne Ret branch if not | |
529 pshs x | |
530 leax MakDir,pcr | |
531 bsr CopyCmd | |
532 ldx ,s | |
533 bsr CopyParm | |
534 bsr WriteIt | |
535 puls x | |
536 tst <doexec are we executing? | |
537 beq Ret if not, just return | |
538 lda #DIR.+PREAD.+PEXEC.+EXEC.+UPDAT. | |
539 os9 I$MakDir | |
540 rts | |
541 | |
542 * Entry: X = path to chd to | |
543 DoChd | |
544 pshs x | |
545 leax Chd,pcr | |
546 bsr CopyCmd | |
547 ldx ,s | |
548 bsr CopyParm | |
549 bsr WriteIt | |
550 puls x | |
551 tst <doexec are we executing? | |
552 beq Ret if not, just return | |
553 lda #DIR.+READ. | |
554 os9 I$ChgDir | |
555 bcc Ret | |
556 os9 F$PErr | |
557 Ret rts | |
558 | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
559 WriteIt ldy #1024 |
951 | 560 lda #1 |
561 os9 I$WritLn | |
562 Rts rts | |
563 | |
564 DoEcho tst <doexec are we executing? | |
565 bne Rts if so, ignore this shell command | |
566 leax ShlEko,pcr else point to shell echo command | |
567 bra WriteIt | |
568 | |
569 * Copy command into linebuff and put space after it | |
570 * Entry: X = pointer to command to copy to linebuff | |
571 CopyCmd leay linebuff,u and point Y to line buffer | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
572 * Do level indention if specified |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
573 tst <indent |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
574 beq CopyCmd3 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
575 lda <dirlevel |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
576 beq CopyCmd3 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
577 ldb #$02 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
578 mul |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
579 lda #C$SPAC |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
580 CopyCmd2 sta ,y+ |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
581 decb |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
582 bne CopyCmd2 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
583 CopyCmd3 lbsr StrCpy copy command |
951 | 584 lda #C$SPAC get space |
585 sta ,y+ and store it after command in buff | |
586 rts | |
587 | |
588 DoPauseOn | |
589 leax TMode,pcr | |
590 bsr CopyCmd | |
591 leax TPause,pcr get pause command | |
592 bsr CopyParm | |
593 bsr WriteIt | |
594 bra ExecCmd | |
595 | |
596 * Copy parameters into linebuff and put CR after it, then write it out to stdout | |
597 CopyParm lbsr StrCpy copy it | |
598 lda #C$CR | |
599 sta ,y+ and store CR after command in buff | |
600 leax linebuff,u | |
601 CPRts rts | |
602 | |
603 * Entry: X = command to execute, with parameters | |
604 ExecCmd tst <doexec | |
605 beq CPRts | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
606 lbsr SkipSpcs skip any leading spaces at X |
951 | 607 tfr x,y transfer command ptr to Y temporarily |
608 lbsr SkipNSpc skip command | |
609 clr ,x+ clear white space char and move X | |
610 pshs u save our statics | |
611 tfr x,u move paramter pointer to Y | |
612 tfr y,x move command ptr from Y back to X | |
613 ldy #256 | |
614 clra | |
615 os9 F$Fork | |
616 os9 F$Wait | |
617 bcc ExecRTS | |
618 os9 F$PErr | |
619 ExecRTS puls u,pc | |
620 | |
621 DoPauseOff | |
622 leax TMode,pcr | |
623 bsr CopyCmd | |
624 leax TNoPause,pcr | |
625 bsr CopyParm | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
626 lbsr WriteIt |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
627 bra ExecCmd |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
628 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
629 DoLoadCmp |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
630 leax Load,pcr point to load command |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
631 bsr CopyCmd copy it to buffer |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
632 leax Cmp,pcr point to copy command |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
633 bsr CopyParm copy it to buffer |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
634 lbsr WriteIt |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
635 bra ExecCmd |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
636 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
637 DoUnlinkCmp |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
638 leax Unlink,pcr |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
639 lbsr CopyCmd |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
640 leax Cmp,pcr |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
641 bsr CopyParm |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
642 lbsr WriteIt |
951 | 643 bra ExecCmd |
644 | |
645 DoLoadCopy | |
646 leax Load,pcr point to load command | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
647 lbsr CopyCmd copy it to buffer |
951 | 648 leax Copy,pcr point to copy command |
649 bsr CopyParm copy it to buffer | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
650 lbsr WriteIt |
951 | 651 bra ExecCmd |
652 | |
653 DoUnlinkCopy | |
654 leax Unlink,pcr | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
655 lbsr CopyCmd |
951 | 656 leax Copy,pcr |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
657 lbsr CopyParm |
951 | 658 lbsr WriteIt |
659 bra ExecCmd | |
660 | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
661 BuildCmp pshs x |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
662 leax Cmp,pcr |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
663 lbsr CopyCmd |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
664 bra BuildCopy3 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
665 |
951 | 666 BuildCopy |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
667 pshs x |
951 | 668 leax Copy,pcr |
669 lbsr CopyCmd | |
670 tst <rewrite | |
671 beq BuildCopy2 | |
672 ldd #$2D72 -r | |
673 std ,y++ | |
674 lda #C$SPAC | |
675 sta ,y+ | |
676 BuildCopy2 | |
677 ldb <sopt -s option specified? | |
678 beq BuildCopy3 | |
679 lda #'# | |
680 sta ,y+ | |
681 lbsr Byte2ASC | |
682 ldd #$4B20 K'space' | |
683 std ,y++ | |
684 BuildCopy3 | |
685 ldx <srcptr get source path from statics | |
686 lbsr StrCpy copy to buffer | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
687 lda #C$SPAC get space |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
688 sta ,y+ and store it after command in buff |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
689 puls x |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
690 lbsr StrCpy |
951 | 691 lda #C$CR get space |
692 sta ,y+ and store it after command in buff | |
693 leax linebuff,u | |
694 lbsr WriteIt | |
695 lbsr ExecCmd | |
696 rts | |
697 | |
698 * Code to get current working directory | |
699 pwd leax >buffend,u point X to buffer | |
700 * lda #PDELIM get path delimiter | |
701 * sta ,x store at start of buffer | |
702 stx <srcptr store buffer pointer | |
703 leax >dot,pcr point to '.' | |
704 bsr open open directory | |
705 sta <fildes save path | |
706 lbsr rdtwo read '.' and '..' entries | |
707 ldd <dotdotfd get 24 bit LSN of .. | |
708 std <ddcopy | |
709 lda <dotdotfd+2 | |
710 sta <ddcopy+2 and save copy | |
711 L0052 bsr AtRoot are we at root? | |
712 beq L0079 branch if so | |
713 leax >dotdot,pcr else point to '..' | |
714 bsr chdir change directory | |
715 lda <fildes get path to previous dir | |
716 os9 I$Close close it | |
717 lbcs Exit branch if error | |
718 leax >dot,pcr point X to new current dir | |
719 bsr open open it | |
720 bsr rdtwo read . and .. entires of this dir | |
721 bsr FindMtch search for match | |
722 bsr L00E2 | |
723 ldd <dotdotfd | |
724 std <ddcopy | |
725 lda <dotdotfd+2 | |
726 sta <ddcopy+2 | |
727 bra L0052 | |
728 L0079 lbsr GetDevNm get device name | |
729 lda <fildes get path | |
730 os9 I$Close close | |
731 rts | |
732 | |
733 chdir lda #DIR.+READ. | |
734 os9 I$ChgDir | |
735 rts | |
736 | |
737 open lda #DIR.+READ. | |
738 os9 I$Open | |
739 rts | |
740 | |
741 * Read directory entry | |
742 read32 lda <fildes | |
743 leax dentry,u | |
744 ldy #DIR.SZ | |
745 os9 I$Read | |
746 rts | |
747 | |
748 FindMtch lda <fildes get path to current dir | |
749 bsr read32 read entry | |
750 lbcs pwdrts branch if error | |
751 leax dentry,u point to entry buffer | |
752 leax <DIR.FD,x point X to FD LSN | |
753 leay ddcopy,u point Y to copy of LSN | |
754 bsr attop compare the two | |
755 bne FindMtch keep reading until we find match | |
756 rts | |
757 | |
758 * Compare 3 bytes at X and Y | |
759 attop ldd ,x++ | |
760 cmpd ,y++ | |
761 bne L00C5 | |
762 lda ,x | |
763 cmpa ,y | |
764 L00C5 rts | |
765 | |
766 AtRoot leax dotdotfd,u point X at .. entry | |
767 leay dotfd,u point Y at . entry | |
768 bsr attop check if we're at the top | |
769 pwdrts rts | |
770 | |
771 rdtwo bsr read32 * read "." from directory | |
772 ldd <dentry+DIR.FD | |
773 std <dotfd | |
774 lda <dentry+DIR.FD+2 | |
775 sta <dotfd+2 | |
776 bsr read32 * read ".." from directory | |
777 ldd <dentry+DIR.FD | |
778 std <dotdotfd | |
779 lda <dentry+DIR.FD+2 | |
780 sta <dotdotfd+2 | |
781 rts | |
782 | |
783 * Get name from directory entry | |
784 L00E2 leax dentry,u | |
785 prsnam os9 F$PrsNam | |
786 lbcs pwdrts | |
787 ldx <srcptr | |
788 L00EB lda ,-y | |
789 anda #$7F mask hi bit | |
790 sta ,-x save | |
791 decb | |
792 bne L00EB | |
793 lda #PDELIM | |
794 sta ,-x | |
795 stx <srcptr | |
796 rts | |
797 | |
798 GetDevNm lda <fildes | |
799 ldb #SS.DevNm | |
800 leax >devname,u | |
801 os9 I$GetStt | |
802 bsr prsnam | |
803 rts | |
804 | |
805 | |
806 * Entry: X = ptr to ASCII number | |
807 * Exit: B = byte value of ASCII number | |
808 ASC2Byte clrb clear B | |
809 ASC2BLp lda ,x+ get byte from X | |
810 cmpa #'0 | |
811 blt ASC2BEx | |
812 suba #'0 make 8 bit integer | |
813 cmpa #$09 compare against 9 | |
814 bhi ASC2BEx branch if greater | |
815 pshs a else save A | |
816 lda #10 multiply by 10 | |
817 mul do it | |
818 addb ,s+ add on stack | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
819 bcc ASC2BLp if overflow clear, do it again |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
820 ASC2BEx |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
821 * leax -1,x load byte |
951 | 822 rts return |
823 | |
824 * Entry: Y = address to store number | |
825 * B = number to convert | |
826 Byte2ASC lda #$2F start A out just below $30 (0) | |
827 Hundreds inca inc it | |
828 subb #100 subtract 100 | |
829 bcc Hundreds if result >= 0, continue | |
830 cmpa #'0 zero? | |
831 beq Tens if so, don't add to buffer | |
832 sta ,y+ else save at U and inc. | |
833 Tens lda #$3A start A out just above $39 (9) | |
834 TensLoop deca dec it | |
835 addb #10 add 10 | |
836 bcc TensLoop if carry clear, continue | |
837 sta ,y+ save 10's digit | |
838 addb #'0 | |
839 stb ,y+ and 1's digit | |
840 rts | |
841 | |
0 | 842 emod |
843 eom equ * | |
951 | 844 end |