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