Mercurial > hg > Members > kono > nitros9-code
annotate level1/cmds/dsave.asm @ 2050:d63587190d9b
For porting
author | boisy |
---|---|
date | Sun, 23 Apr 2006 19:13:38 +0000 |
parents | 91fb0d6e789f |
children |
rev | line source |
---|---|
0 | 1 ******************************************************************** |
951 | 2 * dsave - Multi-file copy utility |
0 | 3 * |
4 * $Id$ | |
5 * | |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
962
diff
changeset
|
6 * Edt/Rev YYYY/MM/DD Modified by |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
962
diff
changeset
|
7 * Comment |
0 | 8 * ------------------------------------------------------------------ |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
962
diff
changeset
|
9 * 1 2003/01/11 Boisy G. Pitre |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
962
diff
changeset
|
10 * Rewrote in assembly language. |
1449
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
11 * |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
12 * 1r1 2003/12/11 Boisy G. Pitre |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
13 * Fixed -b option so that it prepends device name in front of os9boot |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
14 * filename. Also fixed -b= option to work as well. |
1930 | 15 * |
16 * 2r0 2005/11/26 Boisy G. Pitre | |
17 * Added -t and -n options, ala OS-9/68K. | |
0 | 18 |
19 nam dsave | |
951 | 20 ttl Multi-file copy utility |
0 | 21 |
22 ifp1 | |
951 | 23 use defsfile |
0 | 24 endc |
200
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
113
diff
changeset
|
25 |
951 | 26 * Here are some tweakable options |
27 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
|
28 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
|
29 STACKSZ set 1024 estimated stack size in bytes |
951 | 30 PARMSZ set 256 estimated parameter size in bytes |
31 | |
32 * Module header definitions | |
0 | 33 tylg set Prgrm+Objct |
34 atrv set ReEnt+rev | |
1930 | 35 rev set $00 |
36 edition set 2 | |
200
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
113
diff
changeset
|
37 |
0 | 38 mod eom,name,tylg,atrv,start,size |
200
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
113
diff
changeset
|
39 |
951 | 40 * Your utility's static storage vars go here |
924 | 41 org 0 |
951 | 42 * These vars are used by the base template and shouldn't be removed |
43 parmptr rmb 2 pointer to our command line params | |
44 bufptr rmb 2 pointer to user expandable buffer | |
45 bufsiz rmb 2 size of user expandable buffer | |
46 * 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
|
47 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
|
48 *doexec rmb 1 execute flag |
951 | 49 errcode rmb 1 error code storage |
50 plistcnt rmb 1 command line pathlist count | |
51 doboot rmb 1 | |
52 indent rmb 1 | |
53 onelevel rmb 1 | |
54 nomakdir rmb 1 | |
1930 | 55 noload rmb 1 don't load copy/cmp |
56 notmode rmb 1 | |
951 | 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 | |
1678
40322608e006
tmode is now made from xmode, dsave modified to handle new tmode parameter
boisy
parents:
1531
diff
changeset
|
120 TPause fcc ".1 pau=1" |
951 | 121 fcb C$CR |
1678
40322608e006
tmode is now made from xmode, dsave modified to handle new tmode parameter
boisy
parents:
1531
diff
changeset
|
122 TNoPause fcc ".1 pau=0" |
951 | 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 | |
1449
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
219 pshs x save for later |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
220 cmpb #'= = follows? |
955 | 221 beq DoEqual |
222 * -b alone, copy default bootfile name to bbuff | |
1449
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
223 * first, get device name |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
224 lda #DIR.+READ. |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
225 leax dot,pcr |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
226 os9 I$Open |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
227 lbcs Exit |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
228 leax >bbuff,u |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
229 ldb #PDELIM |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
230 stb ,x+ |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
231 ldb #SS.DevNm |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
232 os9 I$GetStt |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
233 lbcs Exit |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
234 os9 I$Close |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
235 os9 F$PrsNam |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
236 lbcs Exit |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
237 lda -1,y |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
238 anda #$7F wipe out hi bit |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
239 sta -1,y |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
240 lda #PDELIM |
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
241 sta ,y+ |
955 | 242 leax OS9Boot,pcr |
243 lbsr StrCpy | |
244 lda #C$CR | |
245 sta ,y | |
246 bra IsItBEx | |
1449
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
247 DoEqual leax 1,x move X past '=' |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
248 leay bbuff,u point to buffer |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
249 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
|
250 lda #C$CR |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
251 sta ,y |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
252 lda #C$SPAC |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
253 IsItBLp sta ,-x |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
254 cmpx ,s |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
255 bne IsItBLp |
1449
9859ddd89ff8
Fixed bugs in -b option of dsave, modified ChangeLogs
boisy
parents:
1325
diff
changeset
|
256 clrb so FixCmdLn will not look for more opts |
955 | 257 IsItBEx puls x |
951 | 258 bra FixCmdLn |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
259 IsItE equ * |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
260 * cmpa #'e is it this option? |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
261 * bne IsItI branch if not |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
262 * sta <doexec |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
263 * bra FixCmdLn |
951 | 264 IsItI cmpa #'i is it this option? |
265 bne IsItL branch if not | |
266 sta <indent | |
267 bra FixCmdLn | |
268 IsItL cmpa #'l is it this option? | |
269 bne IsItM branch if not | |
270 sta <onelevel | |
271 bra FixCmdLn | |
272 IsItM cmpa #'m is it this option? | |
273 bne IsItR branch if not | |
274 sta <nomakdir | |
275 bra FixCmdLn | |
276 IsItR cmpa #'r is it this option? | |
1930 | 277 bne IsItT branch if not |
278 sta <rewrite | |
279 bra FixCmdLn | |
280 IsItT cmpa #'t is it this option? | |
281 bne IsItN branch if not | |
282 sta <notmode | |
283 bra FixCmdLn | |
284 IsItN cmpa #'n is it this option? | |
951 | 285 bne IsItS branch if not |
1930 | 286 sta <noload |
951 | 287 bra FixCmdLn |
288 IsItS cmpa #'s is it this option? | |
289 bne IsItV branch if not | |
290 * add code to parse memsize | |
291 pshs x | |
292 lbsr ASC2Byte | |
293 stb <sopt | |
294 lda #C$SPAC | |
295 SpcNext sta ,-x erase everything after -s | |
296 cmpx ,s | |
297 bne SpcNext | |
298 puls x | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
299 clrb |
951 | 300 bra FixCmdLn |
301 IsItV cmpa #'v is it this option? | |
302 bne BadOpt branch if not | |
303 sta <doverify | |
304 FixCmdLn lda #C$SPAC get space | |
305 sta -$01,x and wipe out option character | |
306 cmpb #'0 | |
307 lblt ChkDash start dash option processing again | |
308 lbra GetDash possibly another option following? | |
309 | |
310 * We branch here if we encounter an unknown option character | |
311 * A = bad option character | |
312 BadOpt leax UnkOpt,pcr | |
313 ldy #UnkOptL | |
314 ldb #C$CR | |
315 pshs d save bad option and CR on stack | |
316 lda #$02 stderr | |
317 os9 I$Write | |
318 leax ,s point X at option char on stack | |
319 os9 I$WritLn print option and CR | |
320 puls d clean up stack | |
321 lbra ShowHelp | |
322 | |
323 * At this point options are processed. | |
324 * We load X with our parameter pointer and go down the command line | |
325 * looking at each file to process (options have been wiped out with | |
326 * spaces) | |
327 * | |
328 * Note, the following two instructions may not be needed, depending on | |
329 * if your utility requires a non-option on the command line. | |
330 DoDSave dec <plistcnt we should have only one path on cmdline | |
331 lbne ShowHelp if not, exit with error | |
332 ldx <parmptr get our parameter pointer off stack | |
333 lbsr SkipSpcs skip any leading spaces | |
334 stx <dstpath save dest path | |
335 lbsr SkipNSpc | |
336 lda #C$CR | |
337 sta ,x+ | |
338 | |
339 * Here we have src and possibly destination pathlist. Now we can | |
340 * start processing the dsave | |
341 leax linebuff,u | |
342 stx <lineptr reset line buffer pointer | |
343 | |
344 * Get entire pathlist to working directory | |
345 lbsr pwd | |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
346 * Open source device as raw and obtain 24 bit LSN to bootfile |
955 | 347 * ldd #$400D @ + CR |
348 * pshs d save on stack | |
349 * leax ,s point X to stack | |
350 * lda #READ. read mode | |
351 * os9 I$Open open | |
352 * puls x clean stack | |
353 * lbcs Exit branch if error | |
354 * pshs a save path | |
355 * ldx #0000 | |
356 * tfr u,y | |
357 * ldu #DD.BT | |
358 * os9 I$Seek seek to DD.BT in LSN0 | |
359 * tfr y,u | |
360 * lbcs Exit | |
361 * leax ddbt,u point to buffer | |
362 * ldy #3 read 3 bytes at DD.BT | |
363 * os9 I$Read | |
364 * lbcs Exit exit of error | |
365 * puls a get path on stack | |
366 * os9 I$Close and close it | |
951 | 367 |
368 * Do dsave "pre" commands | |
369 lbsr DoEcho | |
370 ldx <dstpath point to source path | |
371 lbsr DoChd chd to it | |
372 lbsr DoPauseOff | |
373 lbsr DoLoadCopy | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
374 tst <doverify |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
375 beq PreRecurse |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
376 lbsr DoLoadCmp |
951 | 377 |
378 * Steps in processing files: | |
379 * 0. Open path to '.' | |
380 * 1. Read next directory entry | |
381 * 2. if directory encountered: | |
382 * a. chd entry | |
383 * b. bsr step 0 | |
384 * c. chd .. | |
385 * 3. if eof, goto step 6 | |
386 * 4. copy file to dest | |
387 * 5. goto 1 | |
388 * 6. Close path to source dir | |
389 | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
390 PreRecurse |
951 | 391 leay buffend,u |
392 bsr CopyDir | |
393 | |
394 * Do dsave "post" commands | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
395 tst <doverify |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
396 beq PostRecurse |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
397 lbsr DoUnlinkCmp |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
398 PostRecurse |
951 | 399 lbsr DoUnlinkCopy |
400 lbsr DoPauseOn | |
401 | |
402 lbra ExitOk | |
403 | |
404 CopyDir ldx <srcptr | |
405 lda #DIR.+READ. permissions as DIR. | |
406 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
|
407 lbcs CopyRts branch if error |
951 | 408 ldb #PDELIM |
409 stb ,y+ | |
410 pshs y | |
411 pshs a save path to . | |
412 pshs x,u save regs | |
413 ldx #$0000 | |
414 ldu #DIR.SZ*2 seek past two dir entries | |
415 os9 I$Seek skip over . and .. entries of this dir | |
416 puls x,u get saved regs | |
417 bcs Copy2Ex branch if error | |
418 FileLoop lda ,s get path to . on stack | |
419 ldy #DIR.SZ get size of directory entry | |
420 leax direntbf,u point to directory entry buffer | |
421 os9 I$Read read directory entry | |
422 bcs Copy2Ex branch if error | |
423 tst ,x first byte at x... is it zero? | |
424 beq FileLoop yep, empty dir entry | |
425 ldy 1,s get Y on stack | |
426 lbsr StrCpy | |
427 lda #C$CR | |
428 sta ,y | |
429 ldx <srcptr | |
430 lda #DIR.+READ. open as directory | |
431 os9 I$Open open it | |
432 bcs ItsAFile if error, it's not a dir | |
433 os9 I$Close close it | |
434 * Here, we know that the file we just opened and closed was a directory | |
435 ItsADir | |
436 tst <onelevel do we ignore dirs? | |
437 bne FileLoop branch if so | |
438 pshs y | |
439 ldx 3,s | |
440 lbsr DoMakDir makdir it | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
441 bcc ItsADir2 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
442 os9 F$PErr |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
443 ItsADir2 ldx 3,s |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
444 lbsr DoChd |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
445 bcs FileLoop if error, ignore dir |
951 | 446 inc <dirlevel |
447 puls y | |
448 bsr CopyDir | |
449 leax DotDot,pcr | |
450 lbsr DoChd | |
451 dec <dirlevel | |
452 bra FileLoop | |
453 | |
454 * 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
|
455 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
|
456 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
|
457 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
|
458 lbsr BootCmp is it os9boot? |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
459 bcs ItsAFile2 no, copy away! |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
460 tst <doboot -b option specified? |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
461 beq FileLoop nope, ignore bootfile |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
462 |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
463 * 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
|
464 * We must os9gen the sucker |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
465 lbsr BuildOS9Gen |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
466 bra FileLoop |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
467 |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
468 ItsAFile2 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
469 ldx 1,s |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
470 lbsr BuildCopy |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
471 tst <doverify verify on? |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
472 beq FileLoop branch if not |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
473 ldx 1,s |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
474 lbsr BuildCmp |
951 | 475 bra FileLoop |
476 Copy2Ex puls a get path to . | |
477 os9 I$Close close path | |
478 CopyEx leas 2,s | |
479 CopyRts rts | |
480 | |
481 ShowHelp equ * | |
482 IFNE DOHELP | |
483 leax >HlpMsg,pcr point to help message | |
484 ldy #HlpMsgL get length | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
485 lda #INDENTSZ std error |
951 | 486 os9 I$WritLn write it |
487 ENDC | |
488 ExitOk clrb clear carry | |
489 Exit os9 F$Exit and exit | |
490 | |
491 * This routine counts the number of non-whitespace characters | |
492 * starting at X | |
493 * | |
494 * Entry: | |
495 * X = ptr to string (space, comma or CR terminated) | |
496 * Exit: | |
497 * Y = length of string | |
498 * X = ptr to byte after string | |
499 StrLen pshs a | |
500 ldy #$0000 | |
501 StrLenLp lda ,x+ | |
502 cmpa #C$SPAC | |
503 beq StrLenEx | |
504 cmpa #C$CR | |
505 beq StrLenEx | |
506 leay 1,y | |
507 bra StrLenLp | |
508 StrLenEx puls a,pc | |
509 | |
510 * This routine copies a string of text from X to Y until | |
511 * a CR or hi bit char is encountered | |
512 * | |
513 * Entry: | |
514 * X = ptr to src string | |
515 * Y = ptr to dest string | |
516 * Exit: | |
517 * D = number of bytes copied | |
518 * X = ptr to char past src string | |
519 * Y = ptr to char past dest string | |
520 StrCpy pshs u | |
521 ldu #$0000 | |
522 CopyFnLp lda ,x+ | |
523 tfr a,b | |
524 anda #$7F | |
525 cmpa #C$CR | |
526 ble CopyFnEx | |
527 sta ,y+ | |
528 leau 1,u | |
529 tstb | |
530 bpl CopyFnLp | |
531 CopyFnEx tfr u,d | |
532 puls u,pc | |
533 | |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
534 * 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
|
535 ParmCpy pshs u |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
536 ldu #$0000 |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
537 ParmFnLp lda ,x+ |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
538 tfr a,b |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
539 anda #$7F |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
540 cmpa #C$SPAC |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
541 ble ParmFnEx |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
542 sta ,y+ |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
543 leau 1,u |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
544 tstb |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
545 bpl ParmFnLp |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
546 ParmFnEx tfr u,d |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
547 puls u,pc |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
548 |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
549 * 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
|
550 * 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
|
551 BootCmp pshs y,x |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
552 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
|
553 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
|
554 tfr y,d |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
555 leay OS9Boot,pcr |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
556 os9 F$CmpNam |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
557 puls y,pc |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
558 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
559 MakeUp cmpa #'a |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
560 blt MakeUpEx |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
561 cmpa #'z |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
562 bgt MakeUpEx |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
563 anda #$DF make uppercase |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
564 MakeUpEx rts |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
565 |
951 | 566 StrHCpy pshs u |
567 ldu #$0000 | |
568 HCpyFnLp lda ,x+ | |
569 beq HCpyFnEx | |
570 tfr a,b | |
571 anda #$7F strip out possible hi bit | |
572 sta ,y+ | |
573 leau 1,u | |
574 tstb test copy of byte in B | |
575 bpl HCpyFnLp if hi bit not set, keep going | |
576 * clr ,y+ add null byte at end | |
577 HCpyFnEx tfr u,d | |
578 puls u,pc | |
579 | |
580 * This routine skip over spaces | |
581 * | |
582 * Entry: | |
583 * X = ptr to data to parse | |
584 * Exit: | |
585 * X = ptr to first non-whitespace char | |
586 * A = non-whitespace char | |
587 SkipSpcs lda ,x+ | |
588 cmpa #C$SPAC | |
589 beq SkipSpcs | |
590 leax -1,x | |
591 rts | |
592 | |
593 * This routine skips over everything but spaces, commas and CRs | |
594 * | |
595 * Entry: | |
596 * X = ptr to data to parse | |
597 * Exit: | |
598 * X = ptr to first whitespace char | |
599 * A = whitespace char | |
600 SkipNSpc lda ,x+ | |
601 cmpa #C$SPAC | |
602 beq EatOut | |
603 cmpa #C$CR | |
604 bne SkipNSpc | |
605 EatOut leax -1,x | |
606 rts | |
607 | |
608 | |
609 * Entry: X = directory to make | |
610 DoMakDir | |
611 tst <nomakdir do we do the makdir? | |
612 bne Ret branch if not | |
613 pshs x | |
614 leax MakDir,pcr | |
615 bsr CopyCmd | |
616 ldx ,s | |
617 bsr CopyParm | |
618 bsr WriteIt | |
619 puls x | |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
620 * tst <doexec are we executing? |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
621 * beq Ret if not, just return |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
622 * lda #DIR.+PREAD.+PEXEC.+EXEC.+UPDAT. |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
623 * os9 I$MakDir |
951 | 624 rts |
625 | |
626 * Entry: X = path to chd to | |
627 DoChd | |
628 pshs x | |
629 leax Chd,pcr | |
630 bsr CopyCmd | |
631 ldx ,s | |
632 bsr CopyParm | |
633 bsr WriteIt | |
634 puls x | |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
635 * tst <doexec are we executing? |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
636 * beq Ret if not, just return |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
637 * lda #DIR.+READ. |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
638 * os9 I$ChgDir |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
639 * bcc Ret |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
640 * os9 F$PErr |
951 | 641 Ret rts |
642 | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
643 WriteIt ldy #1024 |
951 | 644 lda #1 |
645 os9 I$WritLn | |
646 Rts rts | |
647 | |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
648 DoEcho equ * |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
649 * tst <doexec are we executing? |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
650 * bne Rts if so, ignore this shell command |
951 | 651 leax ShlEko,pcr else point to shell echo command |
652 bra WriteIt | |
653 | |
654 * Copy command into linebuff and put space after it | |
655 * Entry: X = pointer to command to copy to linebuff | |
656 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
|
657 * Do level indention if specified |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
658 tst <indent |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
659 beq CopyCmd3 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
660 lda <dirlevel |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
661 beq CopyCmd3 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
662 ldb #$02 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
663 mul |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
664 lda #C$SPAC |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
665 CopyCmd2 sta ,y+ |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
666 decb |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
667 bne CopyCmd2 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
668 CopyCmd3 lbsr StrCpy copy command |
951 | 669 lda #C$SPAC get space |
670 sta ,y+ and store it after command in buff | |
671 rts | |
672 | |
673 DoPauseOn | |
1930 | 674 tst <notmode do we do the tmode? |
675 bne CPRts | |
951 | 676 leax TMode,pcr |
677 bsr CopyCmd | |
678 leax TPause,pcr get pause command | |
679 bsr CopyParm | |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
680 bra WriteIt |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
681 * bra ExecCmd |
951 | 682 |
683 * Copy parameters into linebuff and put CR after it, then write it out to stdout | |
684 CopyParm lbsr StrCpy copy it | |
685 lda #C$CR | |
686 sta ,y+ and store CR after command in buff | |
687 leax linebuff,u | |
688 CPRts rts | |
689 | |
690 * 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
|
691 *ExecCmd tst <doexec |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
692 * beq CPRts |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
693 * 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
|
694 * 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
|
695 * lbsr SkipNSpc skip command |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
696 * 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
|
697 * pshs u save our statics |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
698 * 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
|
699 * 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
|
700 * ldy #256 |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
701 * clra |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
702 * os9 F$Fork |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
703 * os9 F$Wait |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
704 * bcc ExecRTS |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
705 * os9 F$PErr |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
706 *ExecRTS puls u,pc |
951 | 707 |
708 DoPauseOff | |
1930 | 709 tst <notmode do we do the tmode? |
710 bne CPRts | |
951 | 711 leax TMode,pcr |
712 bsr CopyCmd | |
713 leax TNoPause,pcr | |
714 bsr CopyParm | |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
715 lbra WriteIt |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
716 * bra ExecCmd |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
717 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
718 DoLoadCmp |
1930 | 719 tst <noload do we load the utility? |
720 bne CPRts | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
721 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
|
722 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
|
723 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
|
724 bsr CopyParm copy it to buffer |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
725 lbra WriteIt |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
726 * bra ExecCmd |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
727 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
728 DoUnlinkCmp |
1930 | 729 tst <noload do we load the utility? |
730 bne CPRts | |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
731 leax Unlink,pcr |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
732 lbsr CopyCmd |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
733 leax Cmp,pcr |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
734 bsr CopyParm |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
735 lbra WriteIt |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
736 * bra ExecCmd |
951 | 737 |
738 DoLoadCopy | |
1930 | 739 tst <noload do we load the utility? |
740 bne CPRts | |
951 | 741 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
|
742 lbsr CopyCmd copy it to buffer |
951 | 743 leax Copy,pcr point to copy command |
744 bsr CopyParm copy it to buffer | |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
745 lbra WriteIt |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
746 * bra ExecCmd |
951 | 747 |
748 DoUnlinkCopy | |
1930 | 749 tst <noload do we load the utility? |
750 bne CPRts | |
951 | 751 leax Unlink,pcr |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
752 lbsr CopyCmd |
951 | 753 leax Copy,pcr |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
754 lbsr CopyParm |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
755 lbra WriteIt |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
756 * bra ExecCmd |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
757 |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
758 BuildOS9Gen |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
759 pshs x |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
760 leax OS9Gen,pcr |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
761 lbsr CopyCmd |
955 | 762 ldx <dstpath |
763 lbsr StrCpy copy to buffer | |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
764 * write file name, then CR |
955 | 765 lda #C$CR get space |
766 sta ,y+ and store it after command in buff | |
767 leax linebuff,u | |
768 lbsr WriteIt | |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
769 leax bbuff,u |
951 | 770 lbsr WriteIt |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
771 leax CR,pc |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
772 lbsr WriteIt |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
773 puls x,pc |
951 | 774 |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
775 BuildCmp pshs x |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
776 leax Cmp,pcr |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
777 lbsr CopyCmd |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
778 bra BuildCopy3 |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
779 |
951 | 780 BuildCopy |
953
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
781 pshs x |
951 | 782 leax Copy,pcr |
783 lbsr CopyCmd | |
962 | 784 ldb <sopt -s option specified? |
951 | 785 beq BuildCopy2 |
786 lda #'# | |
787 sta ,y+ | |
788 lbsr Byte2ASC | |
789 ldd #$4B20 K'space' | |
790 std ,y++ | |
962 | 791 BuildCopy2 |
792 tst <rewrite | |
793 beq BuildCopy3 | |
794 ldd #$2D72 -r | |
795 std ,y++ | |
796 lda #C$SPAC | |
797 sta ,y+ | |
951 | 798 BuildCopy3 |
799 ldx <srcptr get source path from statics | |
800 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
|
801 lda #C$SPAC get space |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
802 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
|
803 puls x |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
804 lbsr StrCpy |
951 | 805 lda #C$CR get space |
806 sta ,y+ and store it after command in buff | |
807 leax linebuff,u | |
954
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
808 lbra WriteIt |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
809 * lbsr ExecCmd |
9a075092f6ce
-b now working closer to original dsave, but BuildOS9Gen routine still
boisy
parents:
953
diff
changeset
|
810 * rts |
951 | 811 |
812 * Code to get current working directory | |
813 pwd leax >buffend,u point X to buffer | |
814 * lda #PDELIM get path delimiter | |
815 * sta ,x store at start of buffer | |
816 stx <srcptr store buffer pointer | |
817 leax >dot,pcr point to '.' | |
818 bsr open open directory | |
819 sta <fildes save path | |
820 lbsr rdtwo read '.' and '..' entries | |
821 ldd <dotdotfd get 24 bit LSN of .. | |
822 std <ddcopy | |
823 lda <dotdotfd+2 | |
824 sta <ddcopy+2 and save copy | |
825 L0052 bsr AtRoot are we at root? | |
826 beq L0079 branch if so | |
827 leax >dotdot,pcr else point to '..' | |
828 bsr chdir change directory | |
829 lda <fildes get path to previous dir | |
830 os9 I$Close close it | |
831 lbcs Exit branch if error | |
832 leax >dot,pcr point X to new current dir | |
833 bsr open open it | |
834 bsr rdtwo read . and .. entires of this dir | |
835 bsr FindMtch search for match | |
836 bsr L00E2 | |
837 ldd <dotdotfd | |
838 std <ddcopy | |
839 lda <dotdotfd+2 | |
840 sta <ddcopy+2 | |
841 bra L0052 | |
842 L0079 lbsr GetDevNm get device name | |
843 lda <fildes get path | |
844 os9 I$Close close | |
845 rts | |
846 | |
847 chdir lda #DIR.+READ. | |
848 os9 I$ChgDir | |
849 rts | |
850 | |
851 open lda #DIR.+READ. | |
852 os9 I$Open | |
853 rts | |
854 | |
855 * Read directory entry | |
856 read32 lda <fildes | |
857 leax dentry,u | |
858 ldy #DIR.SZ | |
859 os9 I$Read | |
860 rts | |
861 | |
862 FindMtch lda <fildes get path to current dir | |
863 bsr read32 read entry | |
864 lbcs pwdrts branch if error | |
865 leax dentry,u point to entry buffer | |
866 leax <DIR.FD,x point X to FD LSN | |
867 leay ddcopy,u point Y to copy of LSN | |
868 bsr attop compare the two | |
869 bne FindMtch keep reading until we find match | |
870 rts | |
871 | |
872 * Compare 3 bytes at X and Y | |
873 attop ldd ,x++ | |
874 cmpd ,y++ | |
875 bne L00C5 | |
876 lda ,x | |
877 cmpa ,y | |
878 L00C5 rts | |
879 | |
880 AtRoot leax dotdotfd,u point X at .. entry | |
881 leay dotfd,u point Y at . entry | |
882 bsr attop check if we're at the top | |
883 pwdrts rts | |
884 | |
885 rdtwo bsr read32 * read "." from directory | |
886 ldd <dentry+DIR.FD | |
887 std <dotfd | |
888 lda <dentry+DIR.FD+2 | |
889 sta <dotfd+2 | |
890 bsr read32 * read ".." from directory | |
891 ldd <dentry+DIR.FD | |
892 std <dotdotfd | |
893 lda <dentry+DIR.FD+2 | |
894 sta <dotdotfd+2 | |
895 rts | |
896 | |
897 * Get name from directory entry | |
898 L00E2 leax dentry,u | |
899 prsnam os9 F$PrsNam | |
900 lbcs pwdrts | |
901 ldx <srcptr | |
902 L00EB lda ,-y | |
903 anda #$7F mask hi bit | |
904 sta ,-x save | |
905 decb | |
906 bne L00EB | |
907 lda #PDELIM | |
908 sta ,-x | |
909 stx <srcptr | |
910 rts | |
911 | |
912 GetDevNm lda <fildes | |
913 ldb #SS.DevNm | |
914 leax >devname,u | |
915 os9 I$GetStt | |
916 bsr prsnam | |
917 rts | |
918 | |
919 | |
920 * Entry: X = ptr to ASCII number | |
921 * Exit: B = byte value of ASCII number | |
922 ASC2Byte clrb clear B | |
923 ASC2BLp lda ,x+ get byte from X | |
924 cmpa #'0 | |
925 blt ASC2BEx | |
926 suba #'0 make 8 bit integer | |
927 cmpa #$09 compare against 9 | |
928 bhi ASC2BEx branch if greater | |
929 pshs a else save A | |
930 lda #10 multiply by 10 | |
931 mul do it | |
932 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
|
933 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
|
934 ASC2BEx |
c8489e2f382d
Virtually 100% working EXCEPT for -b option. also need to support -b=xxx
boisy
parents:
951
diff
changeset
|
935 * leax -1,x load byte |
951 | 936 rts return |
937 | |
938 * Entry: Y = address to store number | |
939 * B = number to convert | |
940 Byte2ASC lda #$2F start A out just below $30 (0) | |
941 Hundreds inca inc it | |
942 subb #100 subtract 100 | |
943 bcc Hundreds if result >= 0, continue | |
944 cmpa #'0 zero? | |
945 beq Tens if so, don't add to buffer | |
946 sta ,y+ else save at U and inc. | |
947 Tens lda #$3A start A out just above $39 (9) | |
948 TensLoop deca dec it | |
949 addb #10 add 10 | |
950 bcc TensLoop if carry clear, continue | |
951 sta ,y+ save 10's digit | |
952 addb #'0 | |
953 stb ,y+ and 1's digit | |
954 rts | |
955 | |
0 | 956 emod |
957 eom equ * | |
951 | 958 end |