Mercurial > hg > Members > kono > nitros9-code
annotate level1/cmds/shellplus.asm @ 2870:91d0226c431a
sierra/goldrush: Use same tOC for dw and dw_becker
author | Tormod Volden <debian.tormod@gmail.com> |
---|---|
date | Sun, 24 Nov 2013 11:44:34 +0100 (2013-11-24) |
parents | bfb8eefc19e1 |
children | 5c6b71612ce4 |
rev | line source |
---|---|
714 | 1 ******************************************************************** |
1505 | 2 * Shellplus - Enhanced shell for NitrOS-9 |
714 | 3 * |
4 * Modified by L. Curtis Boyle from original 2.2 disassembly | |
5 * | |
6 * $Id$ | |
7 * | |
1255 | 8 * Edt/Rev YYYY/MM/DD Modified by |
9 * Comment | |
714 | 10 * ------------------------------------------------------------------ |
1255 | 11 * 21 ????/??/?? |
12 * Original Tandy/Microware version. | |
13 * | |
14 * 22/2 ????/??/?? | |
15 * History and numerous features added. | |
2358
79c544b33a09
Made to honor S$Peer signal (sent when peer disconnects)
boisy
parents:
1505
diff
changeset
|
16 * |
79c544b33a09
Made to honor S$Peer signal (sent when peer disconnects)
boisy
parents:
1505
diff
changeset
|
17 * 23 2010/01/19 Boisy G. Pitre |
2372 | 18 * Added code to honor S$HUP signal and exit when received to support |
2358
79c544b33a09
Made to honor S$Peer signal (sent when peer disconnects)
boisy
parents:
1505
diff
changeset
|
19 * networking. |
714 | 20 |
21 nam Shell | |
1505 | 22 ttl Enhanced shell for NitrOS-9 |
714 | 23 |
24 * Disassembled 93/04/15 14:58:18 by Disasm v1.6 (C) 1988 by RML | |
25 * Signals: Signals 2 & 3 are assigned new keys to handle forward/backward | |
26 * command history. Signal $B (11) is the signal sent out on a key being ready | |
27 * for normal command processing | |
28 | |
29 ifp1 | |
30 use defsfile | |
31 endc | |
32 | |
33 tylg set Prgrm+Objct | |
34 atrv set ReEnt+rev | |
2358
79c544b33a09
Made to honor S$Peer signal (sent when peer disconnects)
boisy
parents:
1505
diff
changeset
|
35 rev set $00 |
79c544b33a09
Made to honor S$Peer signal (sent when peer disconnects)
boisy
parents:
1505
diff
changeset
|
36 edition set 23 |
79c544b33a09
Made to honor S$Peer signal (sent when peer disconnects)
boisy
parents:
1505
diff
changeset
|
37 |
714 | 38 mod eom,name,tylg,atrv,start,size |
39 | |
40 u0000 rmb 1 Path # for standard input | |
41 u0001 rmb 1 Path # for standard output | |
42 u0002 rmb 1 Path # for standard error | |
43 u0003 rmb 1 # of 256 byte pages of data mem for frked module | |
44 u0004 rmb 2 Temp ptr (current parse ptr, mem module ptr,etc) | |
45 u0006 rmb 2 Size of current group | |
46 u0008 rmb 2 Pointer to start of current group (past '(') | |
47 u000A rmb 2 | |
48 u000C rmb 1 Current char. being processed in command parser | |
49 u000D rmb 1 # of command groups [ '()' groupings ] | |
50 u000E rmb 1 unprocessed signal # (0=none waiting) | |
51 u000F rmb 1 ??? Flag of some sort | |
52 u0010 rmb 2 ??? (ptr to some module name) | |
53 u0012 rmb 1 Current working DIR path # | |
54 u0013 rmb 1 Flag to kill parent process (1=Kill parent) | |
55 u0014 rmb 1 Flag: If set, a result must not be 0 ??? | |
56 u0015 rmb 1 | |
57 u0016 rmb 1 | |
58 u0017 rmb 1 | |
59 u0018 rmb 1 Immortal shell (0=NO) | |
60 * A clearing routine only does u0000 to u0018 | |
61 u0019 rmb 1 | |
62 u001A rmb 2 | |
63 u001C rmb 1 Shell logging on flag (0=OFF) | |
64 u001D rmb 1 Shell prompting (0=ON) | |
65 u001E rmb 1 Echo input (0=OFF) | |
66 u001F rmb 1 Variable expansion (0=ON) | |
67 u0020 rmb 1 Kill shell on error (0=OFF) | |
68 u0021 rmb 1 Process # to set priority on | |
69 u0022 rmb 1 Priority to set (0=don't change) (ours or fork) | |
70 u0023 rmb 2 | |
71 u0025 rmb 2 End of data mem ptr (top of stack) | |
72 u0027 rmb 1 | |
73 u0028 rmb 1 | |
74 u0029 rmb 1 | |
75 u002A rmb 2 | |
76 u002C rmb 2 | |
77 u002E rmb 1 | |
78 u002F rmb 1 | |
79 u0030 rmb 1 | |
80 u0031 rmb 1 | |
81 u0032 rmb 2 | |
82 u0034 rmb 3 | |
83 u0037 rmb 1 Flag: 0=Data dir .PWD invalid, 1=valid | |
84 u0038 rmb 1 Flag: 0=Exec dir .PXD invalid, 1=valid | |
85 u0039 rmb 1 | |
86 u003A rmb 1 | |
87 u003B rmb 2 | |
88 u003D rmb 1 | |
89 u003E rmb 2 | |
90 u0040 rmb 2 Ptr to start of filename (vs. pathname) ('/') | |
91 * Shell prompt flag | |
92 u0042 rmb 1 Current working dir path already done flag | |
93 u0043 rmb 1 | |
94 u0044 rmb 1 | |
95 u0045 rmb 1 ??? <>0 means looking for GOTO label? | |
96 u0046 rmb 1 Flag: 1=GOTO label found? | |
97 u0047 rmb 1 Error code from ReadLn or signal | |
98 u0048 rmb 2 Ptr to 1st char after redirection symbols | |
99 u004A rmb 2 Ptr to text message | |
100 u004C rmb 2 Size of text message | |
101 u004E rmb 1 | |
102 u004F rmb 1 0=no pathname in parm line, else IS pathname | |
103 u0050 rmb 2 | |
104 u0052 rmb 2 Current expanded buffer size (max=2048) | |
105 u0054 rmb 2 Ptr to current char in wildcard filename we are | |
106 * checking | |
107 u0056 rmb 2 Ptr to current pos in expanded buffer | |
108 u0058 rmb 2 Pointer to end of GOTO label name | |
109 u005A rmb 2 User ID # from F$ID call | |
110 u005C rmb 1 | |
111 u005D rmb 1 | |
112 u005E rmb 1 Device type: 0=SCF (keyboard),1=RBF (Scriptfile) | |
113 u005F rmb 1 | |
114 u0060 rmb 1 Data module linked flag: 1= Yes | |
115 u0061 rmb 2 Ptr to data module name | |
116 u0063 rmb 2 Ptr to intercept routines data mem | |
117 u0065 rmb 2 Execution address of linked module | |
118 u0067 rmb 2 Start address of module | |
119 u0069 rmb 2 | |
120 u006B rmb 1 Flag: 0=No module to unlink, <>0 module to unlink | |
121 u006C rmb 1 | |
122 u006D rmb 1 Start of device name buffer (start with '/') | |
123 u006E rmb 71 Actual device name | |
124 u00B5 rmb 20 Start of another device name buffer ('/') | |
125 u00C9 rmb 13 | |
126 u00D6 rmb 13 Standard module header info (M$ID-M$Mem) | |
127 u00E3 rmb 5 Module name string (reserves 64 chars) | |
128 u00E8 rmb 3 | |
129 u00EB rmb 4 | |
130 u00EF rmb 10 Temp buffer (many uses) | |
131 u00F9 rmb 6 | |
132 u00FF rmb 37 Place to point SP when CHAINing | |
133 u0124 rmb 81 Temporary buffer (used for several things) | |
134 u0175 rmb 119 Part of temp buffer for ReadLn (200 chars total) | |
135 u01EC rmb 2 Least sig. 2 digits of process # (ASCII format) | |
136 u01EE rmb 1 | |
137 u01EF rmb 2 Holding area for 2 digit ASCII conversions | |
138 * Shell prompt parsing flags | |
139 u01F1 rmb 1 Process ID # already done flag | |
140 u01F2 rmb 1 Standard output device name already done flag | |
141 u01F3 rmb 1 Quoting on flag in shell prompt string parsing | |
142 u01F4 rmb 1 Date already done flag | |
143 u01F5 rmb 1 Time already done flag | |
144 u01F6 rmb 1 Date OR time already done flag | |
145 u01F7 rmb 2 Size of expanded shell prompt | |
146 u01F9 rmb 25 Current shell prompt string | |
147 u0212 rmb 1 Lead in Line feed for expanded shell prompt | |
148 u0213 rmb 199 Expanded shell prompt | |
149 u02DA rmb 6 Date/time packet | |
150 u02E0 rmb 8 Date string | |
151 u02E8 rmb 1 Space separating date & time (for shell init) | |
152 u02E9 rmb 9 Time string (and CR) | |
153 u02F2 rmb 131 | |
154 u0375 rmb 131 | |
155 u03F8 rmb 29 | |
156 u0415 rmb 2 | |
157 u0417 rmb 1 | |
158 u0418 rmb 400 Intercept routines memory area (not used) | |
159 u05A8 rmb 810 Shell variables (user?) | |
160 u08D2 rmb 810 Shell variables (shell sub?) | |
161 u0BFC rmb 80 | |
162 u0C4C rmb 81 Copy of GOTO label name | |
163 u0C9D rmb 32 DIR Entry buffer | |
164 u0CBD rmb 32 Shell logging filename (append mode '+') | |
165 u0CDD rmb 400 PATH=Buffer (each entry CR terminated) | |
166 u0E6D rmb 2048 Fully expanded filenames buffer (for wildcards) | |
167 * Actually,this next block appears to be generic buffers for various functions | |
168 u166D rmb 80 Process descriptor copies go here (512 bytes) | |
169 u16BD rmb 1 | |
170 u16BE rmb 80 | |
171 u170E rmb 238 | |
172 u17FC rmb 10 | |
173 u1806 rmb 2 ??? Ptr to end of shell history buffers | |
174 u1808 rmb 2 Ptr to where next history entry will go | |
175 u180A rmb 2 Ptr to start of shell history buffers | |
176 u180C rmb 1 # of lines in history buffer (1-(u180C)) | |
177 u180D rmb 1 Current line # in history buffer | |
178 u180E rmb 1 Original keyboard terminate char | |
179 u180F rmb 1 Original keyboard interrupt char | |
180 u1810 rmb 1 | |
181 u1811 rmb 1 Original end of line NUL count | |
182 u1812 rmb 1 Flag to indicate if we have to restore PD.OPT | |
183 u1813 rmb 2 | |
184 u1815 rmb 808 Shell history copies start here | |
185 u1B3D rmb 963 Local stack space, etc. | |
186 size equ . | |
187 name equ * | |
188 L000D fcs /Shell/ | |
2358
79c544b33a09
Made to honor S$Peer signal (sent when peer disconnects)
boisy
parents:
1505
diff
changeset
|
189 fcb edition |
714 | 190 L0013 fcb Prgrm+PCode |
191 fcs 'PascalS' | |
192 fcb Sbrtn+CblCode | |
193 fcs 'RunC' | |
194 fcb Sbrtn+ICode | |
195 L0021 fcs 'RunB' | |
196 fcb $00,$00,$00,$00,$00,$00,$00,$00,$00 | |
197 L002E fcb C$LF | |
198 fcc 'Shell+ v2.2a ' | |
199 L003C fcb $00 | |
200 L003D fcc '{@|#}$: ' | |
201 L0055 fcc '+++START+++' | |
202 fcb C$CR | |
203 L0061 fcc '+++END+++' | |
204 fcb C$CR | |
205 * Intercept routine | |
206 L006B stb <u000E Save signal code & return | |
2372 | 207 * +++ BGP added for Hang Up |
208 * +++ Note we are exiting even if shell is immortal! | |
209 cmpb #S$HUP | |
2358
79c544b33a09
Made to honor S$Peer signal (sent when peer disconnects)
boisy
parents:
1505
diff
changeset
|
210 lbeq exit |
2360 | 211 * +++ |
714 | 212 rti |
213 | |
214 start leas -5,s Make 5 byte buffer on stack | |
215 pshs y,x,d Save Top/bottom of param area, and size of area | |
216 leax >u1815,u Pointer to start of history buffer area | |
217 stx >u1808,u Save ptr to where next history entry goes | |
218 stx >u180A,u Save ptr to start of history buffers | |
219 leax >$0328,x Setup up another pointer (end of history area?) | |
220 stx >u1806,u Save it | |
221 clr >u1812,u Clear flag that we have to restore PD.OPT | |
222 clr >u180D,u Current line # of history buffer=0 | |
223 clr >u180C,u # lines in history buffer=0 | |
224 ldx 2,s Get back top of data area ptr | |
225 ldb #$FF 255 bytes to clear | |
226 lbsr L0412 Go clear direct page | |
227 sts <u0025 Save current stack ptr | |
228 stu <u0027 Save Data mem ptr (0) | |
229 leax >u0418,u Point to intercept routines memory area | |
230 stx <u0063 Save a copy of it | |
231 leax <L006B,pc Point to intercept routine | |
232 os9 F$Icpt Setup the intercept routine | |
233 lbsr L16A6 Get user #, and make 2 digit ASCII ver. @ 1EC | |
234 lbsr L1674 Make shell logging pathname @ CBD | |
235 leax <L003D,pc Point to default shell prompt string | |
236 lbsr L0A14 Go create shell prompt string & prompt itself | |
237 leax >u05A8,u Point to start of shell variables | |
238 ldd #C$CR*256+20 Carriage return (blank entries) & all 20 of them | |
239 L009C sta ,x Mark shell variable as blank | |
240 leax <81,x Point to next entry (81 bytes/entry) | |
241 decb Do until all 20 are done (user & shell sub) | |
242 bne L009C | |
243 sta >u0CDD,u Init 1st 2 entries of PATH= buffer to CR's | |
244 sta >u0CDD+1,u | |
245 puls x,d Get parameter ptr & parameter size | |
246 std <u0006 Save size of parameter area | |
247 beq L00BF If no parameters, skip ahead | |
248 lbsr L041B Pre-Parse parameters passed to this shell | |
249 lbcs L01FA Error, go handle it | |
250 tst <u000C Any char being processed in parser? | |
251 lbne L01F9 Yes, skip ahead | |
252 L00BF lbsr L0225 Release any keyboard/mouse signals & get PD.OPT | |
253 inc <u006C ??? Set flag | |
254 lds ,s++ Since parameters parsed, point SP to top of mem | |
255 sts <u0025 Save end of data mem ptr (top of stack) | |
256 stu <u0027 Save start of data mem ptr | |
257 L00CC leax >L002E,pc Point to Shellplus v2.2 message | |
258 tst <u001D Shell prompting turned on? | |
259 bne L00EA No, skip ahead | |
260 ldy #$000E Length of message | |
261 lda #$01 Standard out | |
262 os9 I$Write Write it | |
263 lbcs L0200 If error writing, terminate Shellplus | |
264 bsr L00FB Go create date & time strings | |
265 lbsr L021B Write out date & time | |
266 lbcs L0200 If error writing, terminate Shellplus | |
267 L00EA clra | |
268 sta <u005C | |
269 leax >L0055,pc Point to '+++START+++' for shell logging | |
270 lbsr L07E7 Go deal with logging if necessary | |
271 tst <u001D Shell prompting turn on? | |
272 bne L0120 No, skip ahead | |
273 bra L010D Yes, do something else first | |
274 | |
275 L00FB clr >u01F6,u Clear date or time done flag | |
276 lbsr L0B3B Create current date & time strings | |
277 lda #C$SPAC Put in a space to separate date & time | |
278 sta >u02E8,u | |
279 leax >u02E0,u Point to start of date buffer | |
280 rts | |
281 | |
282 * Shell just booted goes here | |
283 L010D lbsr L09F7 Update expanded shell prompt if needed | |
284 leax >u0212,u Point to expanded shell prompt | |
285 ldy >u01F7,u Get size of expanded shell prompt | |
286 L0119 tst <u001D Shell prompting on? | |
287 bne L0120 No, continue on | |
288 lbsr L021F Print shell prompt to standard error | |
289 * Shell already booted goes here | |
290 L0120 clra | |
291 leax >u0124,u Point to an input line of some sort | |
292 tst <u006B Any module linked? | |
293 beq L015B No, continue on | |
294 ldy <u0065 Yes, get Execution address of linked module | |
295 cmpy <u0069 ??? | |
296 lbhs L01F0 | |
297 ldb #200 LDW #200/PSHS X/TFM Y+,X+ | |
298 pshs x Copy temporary buffer to [<u0065] | |
299 L0137 lda ,y+ | |
300 sta ,x+ | |
301 decb | |
302 beq L014E Whole buffer copied, skip ahead | |
303 cmpy <u0069 But don't go past here | |
304 bhs L0147 | |
305 cmpa #C$CR Also, stop on carriage return | |
306 bne L0137 | |
307 L0147 sty <u0065 Save new start address | |
308 puls x Restore ptr to u0124 | |
309 bra L01B9 Skip ahead | |
310 | |
311 L014E lda ,y+ | |
312 cmpy <u0069 | |
313 bhs L0147 | |
314 cmpa #C$CR | |
315 bne L014E | |
316 bra L0147 | |
317 | |
318 L015B tst <u005E We reading from script file? | |
319 bne L017F Yes, skip ahead | |
320 ldd #SS.Relea Std input path/release keyboard+mouse signals | |
321 os9 I$SetStt Release any keyboard signals | |
322 lbsr L18DB Go modify signals 2&3 to use up/down arrows, | |
323 * set up to re-enable Kybd signals | |
324 L016A clr <u000E Clear out last signal received | |
325 os9 I$SetStt Re-set up SS.SSig | |
326 * NOTE: This BRA L0177 is required for type-ahead to work | |
327 bra L0177 Go check for history-related signals | |
328 | |
329 * DOESN'T SEEM TO GET BACK TO HERE WHEN ABORT BUG APPEARS | |
330 L0171 ldx #$0000 Sleep until signal is received | |
331 os9 F$Sleep | |
332 L0177 lbra L191C Go check for history signals (PD.QUT & PD.INT) | |
333 * Signal received is not PD.QUT or PD.INT goes here | |
334 L017B cmpb #$0B Key pressed signal? | |
335 bne L0171 No, ignore signal & go to sleep again | |
336 * Keyboard input received signal goes here | |
337 L017F leax >u0124,u Point to temp buffer to hold line | |
338 clra Std Input | |
339 ldy #200 Maximum 200 char. input | |
340 lbra L193E Go read the rest of line as ReadLn | |
341 | |
342 * Comes here after line or signal received & processed | |
343 * NOTE: IF LINE RECEIVED, PD.QUT & PD.INT ARE BACK TO NORMAL VALUES | |
344 L018B bcc L01B9 If no errors, skip ahead | |
345 cmpb #E$EOF <ESC> key in ReadLn? | |
346 beq L01F0 Yes, skip ahead | |
347 | |
348 L0191 lds <u0025 Get top of stack ptr | |
349 ldu <u0027 Get back ptr to DP | |
350 stb <u0047 Save error code | |
351 tst <u0046 GOTO label active? | |
352 bne L01A4 Yes, go print error message | |
353 tst <u0018 Is this shell immortal? | |
354 bne L01A4 Yes, go print error message | |
355 tst <u0020 Kill shell on error? | |
356 bne L01FA Yes, go do that | |
357 | |
358 L01A4 os9 F$PErr Print the error message | |
359 tst <u0046 GOTO label active? | |
360 lbeq L010D No, go print shell prompt/process next line | |
361 clr <u0046 Clear GOTO label flag | |
362 leax >u0C4C,u Point to copy of GOTO label name | |
363 lbsr L0FD0 Go process GOTO line | |
364 lbra L010D Go print shell prompt/process next line | |
365 | |
366 * No error received on line | |
367 L01B9 cmpy #$0001 Just 1 char read (just a CR)? | |
368 bhi L01CE No, go parse parameters | |
369 lbsr L09F7 Go update date/time & expanded shell prompt | |
370 leax >u0213,u Point to expanded shell prompt | |
371 ldy >u01F7,u Get size of expanded shell prompt | |
372 lbra L0119 Go print shell prompt & get next line from user | |
373 | |
374 * No errors-got input line, and there is something in it | |
375 L01CE lbsr L041B Go parse parameters? | |
376 pshs cc Save flags | |
377 tst <u0045 | |
378 bne L01D9 | |
379 clr <u0047 Clear error/signal code from ReadLn | |
380 L01D9 puls cc Restore flags | |
381 lbcc L010D If no error from parse, do prompts & read again | |
382 tstb If a 0 error, do prompts & read again | |
383 lbeq L010D | |
384 tst <u0045 ??? Do we care about errors? | |
385 bne L0191 No, go handle error | |
386 stb <u0047 Save error/signal code | |
387 bra L0191 Go handle error | |
388 | |
389 L01EC fcc 'eof' | |
390 fcb $0d | |
391 | |
392 * <ESC> received | |
393 L01F0 tst <u001D Shell prompting on? | |
394 L01F2 bne L01F9 No, skip printing 'eof' to screen | |
395 leax <L01EC,pc Point to 'eof' string | |
396 bsr L021B Write it out to std error | |
397 L01F9 clrb No error flag | |
398 * Possible shell error - Process | |
399 L01FA lda <u0018 Is this shell immortal? | |
400 lbne L0BDA Yes, go close or dupe paths | |
401 * Shell not immortal, exit routine in here | |
402 L0200 pshs u,b,cc Preserve regs | |
403 tst <u006B Shellsub module to unlink? | |
404 beq L020B No, skip ahead | |
405 ldu <u0067 Yes, get ptr to module | |
406 os9 F$UnLink Unlink it | |
407 L020B puls u,b,cc Restore U, error # & flags | |
408 * EX with no module name (or non-existant one) go here | |
409 L020D pshs b,cc Save error # & flags | |
410 leax >L0061,pc Point to '+++END+++' string | |
411 lbsr L07E7 Close log file if one is open, restore ID # | |
412 puls b,cc Restore error # & flags | |
2358
79c544b33a09
Made to honor S$Peer signal (sent when peer disconnects)
boisy
parents:
1505
diff
changeset
|
413 exit os9 F$Exit Terminate shellplus |
714 | 414 |
415 L021B ldy #80 Write up to 80 chars or CR | |
416 L021F lda #$02 Std error path | |
417 os9 I$WritLn Write message out & return | |
418 rts | |
419 | |
420 L0225 pshs y,x,d Preserve regs | |
421 ldd #SS.Relea Std In & Release keyboard & mouse signals | |
422 os9 I$SetStt | |
423 bcc L0233 No error, continue | |
424 lda #$01 Couldn't release keyboard/mouse signals flag | |
425 bra L0241 | |
426 | |
427 L0233 leax >u0124,u Point to buffer for current path options | |
428 clra | |
429 clrb CHANGE TO CLRB | |
430 os9 I$GetStt Get std input path options | |
431 lda >u0124,u Get Device type (0 (SCF) usually) | |
432 | |
433 L0241 sta <u005E Save device type (1=SS.Relea failed) | |
434 puls pc,y,x,d Restore regs & return | |
435 | |
436 * R= command (redirect specific paths) | |
437 L0245 lda ,x Get char from input line | |
438 cmpa #'< Is it input path? | |
439 beq L0251 Yes, skip ahead | |
440 cmpa #'> Is it an output/error path? | |
441 lbne L0BCF No, print 'WHAT?' | |
442 L0251 pshs x Preserve ptr to 1st redirection symbol | |
443 leay >L03CF,pc Point to modifier symbol table | |
444 lbsr L092A Go to command line parser | |
445 lbcs L0BCF Error, print 'WHAT?' | |
446 ldd ,y Get table offset | |
447 jsr d,y Call appropriate subroutine | |
448 stx <u0048 Save ptr to source after redirection symbols | |
449 puls x Restore ptr to redirection symbols | |
450 lbcs L0B96 If error in subroutine, close paths & return | |
451 | |
452 L026A lda ,x+ Get 1st char again | |
453 cmpa #'< Input path? | |
454 beq L026A Yes, skip to next | |
455 cmpa #'> Output or Error path? | |
456 beq L026A Yes, skip to next | |
457 cmpa #'- Overwrite old file? | |
458 beq L026A Yes, skip to next | |
459 cmpa #'+ Append to old file? | |
460 beq L026A Yes, skip to next | |
461 leax -1,x Point to non-redirect char | |
462 bsr L02A3 Make name buffer, release signals,parse modifiers | |
463 clrb Start path # 0 | |
464 L0281 pshs b Save on stack | |
465 lda b,u Get special path # | |
466 beq L028A None, skip ahead | |
467 os9 I$Close Close the path | |
468 L028A puls b Get path # back | |
469 clr b,u Clear out entry | |
470 incb Next path # | |
471 cmpb #$03 Done the 3 standard paths yet? | |
472 blo L0281 No, keep doing until all done | |
473 ldx <u0048 Get ptr to redirected dev/file name & return | |
474 rts | |
475 * Z= command (immortal shell setting, but kill parent process) | |
476 L0296 inc <u0013 Flag we want to kill parent | |
477 * I= command (immortal shell setting) | |
478 L0298 lbsr L0CD2 | |
479 lbcs L0B96 | |
480 bsr L02A3 | |
481 bra L02D4 | |
482 | |
483 * Create device name buffer @ u006D, Write NUL to std out, parse special | |
484 * chars: # @ @+hibit $ ( ), Release any keyboard/mouse signals | |
485 L02A3 pshs x Prsrve ptr to file/dev name we're redirecting to | |
486 ldb #SS.DevNm Get device name call code | |
487 leax <u006D,u Point to buffer for path names | |
488 lda #'/ Preload '/' for device names | |
489 sta ,x+ | |
490 clra Standard input path | |
491 os9 I$GetStt Get the current device name | |
492 puls x Get back ptr to file/dev name for redirection | |
493 lbcs L0B96 Error on GetStt, shut down paths & exit | |
494 ldy #$0001 One char to write | |
495 pshs x Prsrve ptr to file/dev name we're redirecting to | |
496 leax >L003C,pc Point to a NUL | |
497 lda #1 Std out | |
498 os9 I$Write Write the NUL out | |
499 puls x Restore Devname ptr | |
500 lbcs L0B96 Error on Write, shut down paths & exit | |
501 lbsr L0A04 Do normal parsing - includes #,@,$e0,$,(,) | |
502 lbsr L0225 Release signals | |
503 rts | |
504 | |
505 L02D4 inc <u0018 Set 'immortal shell' flag | |
506 inc <u0019 ??? (flag used by L0B96 routine) | |
507 lbsr L0B96 | |
508 clr <u0019 | |
509 tst <u0013 Do we want to kill the parent process? | |
510 beq L02FC | |
1505 | 511 IFEQ Level-1 |
512 ldx <D.Proc | |
513 ELSE | |
714 | 514 os9 F$ID Get our process ID # into A |
515 pshs x Preserve X | |
516 leax >u166D,u Point to process descriptor buffer | |
517 os9 F$GPrDsc Get our process descriptor | |
1505 | 518 ENDC |
714 | 519 lda P$PID,x Get our parents process # |
1505 | 520 IFGT Level-1 |
714 | 521 puls x Restore X |
1505 | 522 ENDC |
714 | 523 beq L02A3 If parent's process # is 0 (system), skip back |
524 clrb S$Kill signal code | |
525 os9 F$Send Send it to parent | |
526 lbcs L0191 If error sending signal, go to error routine | |
527 L02FC clrb No error | |
528 stb <u0013 Clear 'kill parent' flag | |
529 rts | |
530 | |
531 * Command list | |
532 L0300 fdb L0B87-L0300 $0887 | |
533 fcs '*' | |
534 L0303 fdb L12D1-L0303 $0fce | |
535 fcs 'W' | |
536 L0306 fdb L09BD-L0306 $06b7 | |
537 fcs 'CHD' | |
538 L030B fdb L09B5-L030B $06aa | |
539 fcs 'CHX' | |
540 L0310 fdb L09BD-L0310 $06ad | |
541 fcs 'CD' | |
542 L0314 fdb L09B5-L0314 $06a1 | |
543 fcs 'CX' | |
544 L0318 fdb L0987-L0318 $066f | |
545 fcs 'EX' | |
546 L031C fdb L16DD-L031C $13c1 | |
547 fcs 'KILL' | |
548 L0322 fdb L09EF-L0322 $06cd | |
549 fcs 'X' | |
550 L0325 fdb L09F3-L0325 $06ce | |
551 fcs '-X' | |
552 L0329 fdb L0A14-L0329 $06eb | |
553 fcs 'P=' | |
554 L032D fdb L09D7-L032D $06aa | |
555 fcs 'P' | |
556 L0330 fdb L09DA-L0330 $06aa | |
557 fcs '-P' | |
558 L0334 fdb L09DF-L0334 $06ab | |
559 fcs 'T' | |
560 L0337 fdb L09E3-L0337 $06ac | |
561 fcs '-T' | |
562 L033B fdb L170D-L033B $13d2 | |
563 fcs 'SETPR' | |
564 L0342 fdb L0298-L0342 $ff56 | |
565 fcs 'I=' | |
566 L0346 fdb L0245-L0346 $feff | |
567 fcs 'R=' | |
568 L034A fdb L0296-L034A $ff4c | |
569 fcs 'Z=' | |
570 L034E fdb L0927-L034E $05d9 | |
571 fcs ';' | |
572 L0351 fdb L176B-L0351 $141a | |
573 fcs '.PWD' | |
574 L0357 fdb L177D-L0357 $1426 | |
575 fcs '.PXD' | |
576 L035D fdb L1029-L035D $0ccc | |
577 fcs 'M=' | |
578 L0361 fdb L105A-L0361 $0cf9 | |
579 fcs 'VAR.' | |
580 L0367 fdb L09E7-L0367 $0680 | |
581 fcs 'V' | |
582 L036A fdb L09EA-L036A $0680 | |
583 fcs '-V' | |
584 L036E fdb L1209-L036E $0e9b | |
585 fcs 'PATH=' | |
586 L0375 fdb L11CF-L0375 $0e5a | |
587 fcs 'PAUSE' | |
588 L037C fdb L1126-L037C $0daa | |
589 fcs 'INC.' | |
590 L0382 fdb L1131-L0382 $0daf | |
591 fcs 'DEC.' | |
592 L0388 fdb L0D62-L0388 $09da | |
593 fcs 'IF' | |
594 L038C fdb L0E0B-L038C $0a7f | |
595 fcs 'THEN' | |
596 L0392 fdb L0F8C-L0392 $0bfa | |
597 fcs 'ELSE' | |
598 L0398 fdb L0E0B-L0398 $0a73 | |
599 fcs 'FI' | |
600 L039C fdb L0E0B-L039C $0a6f | |
601 fcs 'ENDIF' | |
602 L03A3 fdb L0F3F-L03A3 $0b9c | |
603 fcs 'CLRIF' | |
604 L03AA fdb L0FD0-L03AA $0c26 | |
605 L03AC fcs 'GOTO' | |
606 L03B0 fdb L0F93-L03B0 $0be3 | |
607 fcs 'ONERR' | |
608 L03B7 fdb L09CF-L03B7 $0618 | |
609 fcs 'L' | |
610 L03BA fdb L09D3-L03BA $0619 | |
611 fcs '-L' | |
612 L03BE fdb L0969-L03BE $05ab | |
613 fcs 'S.T.A.R.T.U.P' | |
614 fdb $0000 | |
615 L03CF fdb L1634-L03CF $1265 | |
616 fcs '!' | |
617 L03D2 fdb L1634-L03D2 $1262 | |
618 fcs '|' | |
619 L03D5 fdb L12A0-L03D5 $0ecb | |
620 fcs ';' | |
621 L03D8 fdb L12C3-L03D8 $0eeb | |
622 fcs '&' | |
623 L03DB fdb L1299-L03DB $0ebe | |
624 fcb $8d CR | |
625 L03DE fdb L0CCE-L03DE $08f0 | |
626 fcs '<>>>' | |
627 L03E4 fdb L0CE5-L03E4 $0901 | |
628 fcs '<>>' | |
629 L03E9 fdb L0CD7-L03E9 $08ee | |
630 fcs '<>' | |
631 L03ED fdb L0CF3-L03ED $0906 | |
632 fcs '>>>' | |
633 L03F2 fdb L0C01-L03F2 $080f | |
634 fcs '>>' | |
635 L03F6 fdb L0BFA-L03F6 $0804 | |
636 fcs '<' | |
637 L03F9 fdb L0C08-L03F9 $080f | |
638 fcs '>' | |
639 L03FC fdb L1277-L03FC $0e7b | |
640 fcs '#' | |
641 L03FF fdb L1265-L03FF $0e66 | |
642 fcs '^' | |
643 fdb $0000 End of table marker | |
644 | |
645 L0404 fcb $0d | |
646 fcc '()' | |
647 fcb $ff | |
648 L0408 fcb $0d | |
649 fcc '!#&;<>^|' | |
650 fcb $ff | |
651 | |
652 * Subroutine: Clears B bytes of memory to NUL's starting @ U | |
653 L0412 pshs u Clear memory | |
654 L0414 clr ,u+ | |
655 decb | |
656 L0417 bne L0414 | |
657 L0419 puls pc,u | |
658 | |
659 * Pre-Parse parameters passed to this shell. Will copy from parm area to | |
660 * buffer area at u0166D, checking for raw mode access allowability if needed | |
661 * Will also | |
662 * Entry: X=ptr to parm area | |
663 L041B ldb #$18 # of bytes to clear in DP | |
664 L041D bsr L0412 Go clear from <u0000 to <u0018 (immortal off) | |
665 tst <u006C ??? (If shell is initing, it's 0) | |
666 lbeq L04CE Shell just initializing, skip ahead | |
667 leay >u17FC,u Point to end of buffer marker | |
668 pshs y Save ptr on stack | |
669 leay >u166D,u Point to buffer for process descriptor | |
670 L042F bsr L0486 Copy next char (check for '@', possibly eat) | |
671 cmpa #C$CR CR? | |
672 beq L04A8 Yes, force CR into ,y & process line from start | |
673 cmpy ,s At end of buffer? | |
674 beq L04A8 Yes, force CR, process line from start | |
675 tst <u001F Variable expansion on? | |
676 bne L042F No, check next char | |
677 cmpa #'% Is it a '%' (shell variable)? | |
678 bne L042F No, do next character | |
679 leay -1,y Back up destination ptr to where '%' is | |
680 pshs x Save current position in parms | |
681 lda ,x Get 1st char of shell variable nam | |
682 cmpa #'* Shell variable for last error code received? | |
683 beq L049D Yes,replace shell var with contents of shell var | |
684 leax >u05A8,u Point to user shell variable contents table | |
685 cmpa #'% 2nd '%'= shellsub variable | |
686 bne L0460 No, just user, go process | |
687 puls x Get back parm ptr | |
688 leax 1,x Skip over 2nd '%' | |
689 lda ,x Get shellsub variable # | |
690 pshs x Save parm ptr | |
691 leax >u08D2,u Point to shellsub variable contents table | |
692 * Entry: A=ASCII 0-9 for either shell or shellsub variable # | |
693 L0460 cmpa #'9 ASCII numeric? | |
694 bhi L0470 No, skip ahead | |
695 cmpa #'0 | |
696 blo L0470 | |
697 suba #$30 Yes, bump down to binary equivalent | |
698 ldb #81 Point to proper variable entry within var table | |
699 mul | |
700 leax d,x | |
701 incb ??? Used in TSTB below | |
702 L0470 bsr L0486 Copy char from var table to pre-parse buffer | |
703 cmpy 2,s Hit end of pre-parse buffer? | |
704 beq L04A6 Yes, force CR at end of it, do full parse | |
705 cmpa #C$CR End of variable? | |
706 bne L0470 No, keep copying characters | |
707 leay -1,y Knock ptr back one (to where CR is) | |
708 puls x Get current parm ptr back | |
709 tstb ??? flag to skip a byte in parm or not | |
710 beq L042F Don't skip | |
711 L0482 leax 1,x Skip to next byte in parm line | |
712 bra L042F Continue pre-parse | |
713 | |
714 * Copy char from parm area to command line buffer - if '@', eat if user is | |
715 * not super-user (#0) | |
716 * Entry: X=ptr to current pos. in original parm buffer | |
717 * Y=ptr to current pos. in new, pre-parsed buffer | |
718 L0486 lda ,x+ Get char from parms | |
719 cmpa #'@ Raw mode request? | |
720 bne L049A Skip ahead if not (SHOULD BE BNE) | |
721 L048C pshs y,a Preserve regs | |
722 os9 F$ID Get user ID # | |
723 cmpy #$0000 Is it 0 (superuser)? (should be leay ,y) | |
724 puls y,a Restore regs | |
725 beq L049A Yes, allow char thru | |
726 rts Otherwise eat it | |
727 | |
728 L049A sta ,y+ Save char & return | |
729 rts | |
730 | |
731 * Shell variable '%* (for last error code) requested | |
732 * Put contents of shell var. into pre-parsed command line buffer | |
733 L049D puls x Get back parm ptr | |
734 lbsr L168A Put error code into preparse buffer | |
735 leay 3,y Skip over error code space we just added | |
736 bra L0482 Skip over shell varname, continue preparse | |
737 | |
738 L04A6 leas 2,s Eat stack | |
739 L04A8 lda #C$CR Force CR as last char in buffer | |
740 sta ,y | |
741 puls y | |
742 leax >u166D,u Point to start of pre-parse buffer again | |
743 L04B2 bra L04CE Start real parse | |
744 | |
745 L04B4 fcb C$LF | |
746 fcc 'Expanded line too long' | |
747 fcb C$CR | |
748 L04CC fcc '.' | |
749 L04CD fcb C$CR | |
750 | |
751 * Parse command line buffer - already pre-parsed (user 0 RAW mode checks & | |
752 * shell/shellsub variable expansion is already done) | |
753 * Entry: X=Ptr to pre-parsed command line buffer | |
754 L04CE lda ,x Get 1st char from parameter area | |
755 cmpa #'* Is it a comment? | |
756 beq L04DE Yes, skip ahead | |
757 cmpa #': Is it a wildcard on/off? | |
758 bne L04DA No, skip ahead | |
759 leax 1,x Bump ptr past it | |
760 L04DA cmpa #': Is it a wildcard off? | |
761 * FOLLOWING LINE: BEQ means wildcarding default off, BNE = on | |
762 beq L04F0 No, go process wildcarding | |
763 * No wildcard processing | |
764 L04DE leay >u0E6D,u Point Y to expanded buffer | |
765 lbsr L1320 Copy param area to buffer area until 1st CR | |
766 leax >u0E6D,u Point X to expanded (wildcard) buffer | |
767 ldy #$0800 Max. size of expanded buffer (2048 bytes) | |
768 lbra L079B Process line without wildcards | |
769 | |
770 * Wild carding processor | |
771 * Entry: X=ptr to current position in pre-parsed parm line | |
772 * 1st, set up error msg for if buffer gets full | |
773 L04F0 leay >L04B4,pc Point to 'Expanded line too long' | |
774 sty <u004A Save it | |
775 ldy #$0018 Get size of text | |
776 sty <u004C Save it too | |
777 leay >L04CD,pc Point to CR | |
778 sty <u0048 Save ptr | |
779 sts <u0050 Save stack ptr | |
780 leay >u0E6D,u Point to fully expanded buffer (2k max) | |
781 sty <u0056 Save it | |
782 clra | |
783 clrb | |
784 sta <u0012 No current working DIR path | |
785 sta <u004F Flag no pathname in parm area | |
786 std <u0052 Expanded buffer size=0 bytes | |
787 bra L0520 Enter main loop for wildcards | |
788 | |
789 L051D lbsr L06FB Special shell chars handling | |
790 L0520 lbsr L0746 Check for special chars (wildcard or shell) | |
791 bcc L051D Special shell char process | |
792 * Wildcard char found | |
793 pshs x Save current pre-parsed parm ptr | |
794 bsr L0549 Check from that point for '/' or special char | |
795 ldx ,s Get previous parm ptr back | |
796 bcc L0557 No '/' found, open current dir '.' | |
797 * Found '/' (part of path) - keep looking for last '/' for filename (not | |
798 * pathname) portion | |
799 L052D bsr L0549 Check for special char or '/' again | |
800 bcc L0535 No '/', skip ahead | |
801 stx <u0040 Save latest ptr to '/' in parm line found so far | |
802 bra L052D See if any more sub-paths | |
803 | |
804 * Found one or more '/' path dividers in current parm line. | |
805 * Entry: <u0040 - contains the last '/' found | |
806 L0535 inc <u004F Flag that their IS a pathname from parm line | |
807 L0538 ldx <u0040 Get last level of path ptr | |
808 puls y Get original parm ptr | |
809 sty <u0040 Save it | |
810 pshs x Save filename ptr on stack | |
811 lda #C$SPAC Save space over '/' after pathname | |
812 sta -1,x (before filename) | |
813 tfr y,x Move original parm ptr to X | |
814 bra L055E Open dir path | |
815 | |
816 * Parse from current position in pre-parsed parm line until shell special | |
817 * char, or '/' found (path) | |
818 * Entry: X=ptr to current pos in pre-parsed parm line | |
819 * Exit: Carry clear if special shell char found | |
820 * Carry set if '/' found | |
821 * X=ptr to found char+1 | |
822 L0549 clrb | |
823 lda ,x+ Get next char | |
824 lbsr L05D3 See if shell special char | |
825 beq L0556 Yes, return | |
826 cmpa #'/ No, is it a slash (path start)? | |
827 bne L0549 No, Keep checking for / or special char | |
828 comb | |
829 L0556 rts | |
830 | |
831 * No '/' found in parm line at all | |
832 L0557 clr <u004F Flag no pathname from parm line | |
833 leax >L04CC,pc Point to '.' | |
834 * Entry: X=ptr to pathname to directory | |
835 * 0-1,s = Ptr to filename spec we are looking for in this directory | |
836 L055E lda #DIR.+READ. Open directory in READ mode | |
837 os9 I$Open | |
838 lbcs L0776 Error, skip ahead | |
839 sta <u0012 Save current DIR path | |
840 puls x Get back ptr to filename (not pathname) | |
841 lbsr L0746 Check for special shell char or wildcard | |
842 lbcc L06E3 Special shell char found, ?????? | |
843 L0572 lda ,x+ Get next char from filename | |
844 cmpa #C$CR End of user specified filename (CR)? | |
845 lbeq L0789 Yes, close DIR and proceed | |
846 cmpa #', Comma? | |
847 beq L0572 Yes, skip it | |
848 cmpa #C$SPAC Space? | |
849 beq L0572 Yes, skip it | |
850 leax -1,x Other char, point to it. | |
851 stx <u0054 Save ptr to it | |
852 lda <u0012 Get DIR path # | |
853 pshs u Preserve u | |
854 ldx #$0000 Skip '.' and '..' dir entries | |
855 ldu #$0040 | |
856 os9 I$Seek | |
857 lbcs L0776 Error, skip ahead | |
858 puls u Restore u | |
859 L0599 leax >u0C9D,u Point to dir entry buffer | |
860 pshs x Save ptr | |
861 lda <u0012 Get Current dir path # | |
862 ldy #$0020 Read 1 file entry | |
863 os9 I$Read | |
864 lbcs L06BD Error, skip ahead | |
865 puls y Restore pointer to dir filename buffer | |
866 lda ,y Get 1st char of entry | |
867 tsta Is it a deleted file? | |
868 beq L0599 Yes, skip it | |
869 ldx <u0054 Get ptr to current char in expanded filename bfr | |
870 bsr L05EF Check wildcard spec against this filename | |
871 bcs L0599 No match, skip to next file in DIR | |
872 tst <u004F Was a pathname specified? | |
873 beq L05CA No, skip ahead | |
874 ldx <u0040 Yes,get ptr to end of pathname/start of filename | |
875 lbsr L06FB Check for wildcard stuff there | |
876 ldx <u0056 Get current pos in expanded buffer | |
877 lda #'/ Save '/' there (to separate path & filename) | |
878 sta -1,x | |
879 L05CA leax >u0C9D,u Point to start of matched DIR entry filename | |
880 lbsr L06FB Copy filename over, handling quoted chars, etc. | |
881 bra L0599 On to next DIR entry | |
882 | |
883 * Check if shell 'special' char. (except wildcards & shell var) | |
884 * non-wildcard char in current byte of pre-parsed parm buffer | |
885 * Entry: X=ptr to next char in parms buffer | |
886 * A=current char in parms buffer | |
887 * Exit: BEQ if shell special char found, BNE if just regular char | |
888 * A=char we were checking | |
889 L05D3 pshs x Save parms buffer ptr | |
890 cmpa #'( Group start char? | |
891 beq L05ED Yes, skip ahead | |
892 cmpa #') Group end char? | |
893 beq L05ED Yes, skip ahead | |
894 cmpa #C$SPAC Space? | |
895 beq L05ED Yes, skip ahead | |
896 cmpa #', Comma? | |
897 beq L05ED Yes, skip ahead | |
898 leax >L0408,pc Table of other special chars | |
899 L05E9 cmpa ,x+ Found match or end of table? | |
900 bhi L05E9 No, keep checking (or fall through if not found) | |
901 L05ED puls pc,x Exit with BEQ/BNE flag set | |
902 | |
903 * IF wildcards were detected in preparsing, filename compares happen here | |
904 * Entry: X=ptr to current char in user's pre-parse parm line | |
905 * Y=ptr to start of current DIR entry filename | |
906 * Exit: Carry set if no match | |
907 * Carry clear if match | |
908 L05EF ldd ,x+ Get 2 chars (NOTE: PTR UP BY ONLY 1!) | |
909 L05F1 cmpa #'* 1st char a * (multi-char wildcard)? | |
910 beq L064C Yes, go handle it | |
911 cmpa #'? Question mark (single char wildcard)? | |
912 beq L0638 Yes, go handle it | |
913 cmpa #'[ Start of ranged wildcard? | |
914 lbeq L068B Yes, go handle it | |
915 bsr L05D3 Not wildcard, check for special shell chars | |
916 beq L062B It is a special shell char, skip ahead | |
917 bsr L0631 Just regular char, force uppercase | |
918 pshs a Save char | |
919 bsr L062D Force uppercase on DIR filename char | |
920 eora ,s+ Same char as last parm char? | |
921 bne L062B No, exit with carry set | |
922 L060D lda ,y+ Re-get char from DIR filename | |
923 bpl L05EF Not on last char yet, check next char from parm | |
924 ldd ,x At end of DIR filename, grab 2 chars from parm | |
925 bsr L05D3 Check 1st char against special shell chars | |
926 beq L0621 Found one, skip ahead | |
927 cmpa #'* Multi-char wildcard char? | |
928 bne L062B No, no match, exit with carry set | |
929 tfr b,a 1st char from parm is '*', check 2nd char for | |
930 bsr L05D3 special shell chars | |
931 bne L062B None found, no match, exit with carry set | |
932 L0621 lda -1,y Special char, get last char from DIR filename | |
933 L0623 anda #$7F Strip 'end of filename' bit flag | |
934 ldb #C$SPAC Space char | |
935 std -1,y Save 'fixed' last char & space | |
936 clrb Flag match | |
937 rts | |
938 | |
939 L062B comb Flag no match | |
940 rts | |
941 | |
942 * Force char to uppercase | |
943 L062D lda ,y Get char | |
944 anda #$7F Strip hi-bit | |
945 L0631 cmpa #'A Need to force uppercase? | |
946 blo L0637 No, exit | |
947 anda #$DF Yes, force to uppercase | |
948 L0637 rts | |
949 | |
950 * '?' single char wildcard found | |
951 L0638 cmpb #'* Is next char a multi-char wildcard? | |
952 beq L060D Yes, process as if just '*' | |
953 cmpb #', 2nd char '-' or greater? | |
954 bhi L060D Yes, process normally | |
955 lda ,y+ Get next char from DIR filename | |
956 bpl L062B Not end of filename, Flag no match | |
957 bra L0623 Save hibit stripped char & space, flag match | |
958 | |
959 L0646 lda ,y+ Get next char from DIR filename | |
960 bpl L0646 Hunt for end of DIR filename | |
961 bra L0623 Found it, fix hibit and add space to DIR entry | |
962 | |
963 * '*' multi-char wildcard found | |
964 L064C lda ,x+ Get next char after '*' from parm buffer | |
965 bsr L05D3 Check for shell special char | |
966 beq L0646 Found one, check if end of DIR filename | |
967 cmpa #'? Single char wildcard next? | |
968 beq L067F Yes, Process | |
969 cmpa #'[ Start of Ranged wildcard next? | |
970 beq L067F Yes, process | |
971 bsr L0631 Force char to uppercase | |
972 pshs a Save it | |
973 L065E bsr L062D Get next char from DIR filename, force uppercase | |
974 eora ,s+ Same char? | |
975 beq L066E Yes, possible resync after '*' | |
976 L0664 leas -1,s Make room on stack | |
977 lda ,y+ Re-get un-modified char from DIR filename | |
978 bpl L065E Not end of filename, try next char | |
979 leas 1,s Found end of filename, eat temp stack | |
980 bra L062B Flag no match | |
981 * Above loop @ L0664/L065E uses sneaky stack stuff | |
982 | |
983 * Found possible resync char match after '*' | |
984 L066E leas -1,s Make room on stack | |
985 pshs y,x Preserve both DIR & parm ptrs | |
986 bsr L060D Attempt normal matching using this resync | |
987 puls y,x Restore ptrs | |
988 leas 1,s Eat temp stack | |
989 bcs L0664 No, resync did not work, look for next resync | |
990 rts worked, exit with carry clear | |
991 | |
992 L067B lda ,y+ Get next char in DIR | |
993 bmi L062B Last char, flag no match | |
994 * '?' found after '*' in parm buffer | |
995 L067F pshs y,x Preserve both DIR and parm buffer ptrs | |
996 ldd -1,x Get previous & current parm chars | |
997 lbsr L05F1 Do normal sub-parsing from here | |
998 puls y,x Restore ptrs | |
999 bcs L067B No match, go to next char in DIR and attemp resync | |
1000 rts Matched, exit with match | |
1001 | |
1002 * Ranged wildcard here | |
1003 * Entry: X=ptr to 1st char in parm buffer AFTER '[' | |
1004 L068B ldd ,x+ Get 1st 2 chars of range sub-string from parm bfr | |
1005 bsr L0631 Force uppercase on 1st char | |
1006 exg b,a Force uppercase on 2nd char | |
1007 bsr L0631 | |
1008 exg b,a | |
1009 cmpa #'] Is 1st char a close range check char? | |
1010 beq L062B Yes, flag no match for '[]' | |
1011 cmpa #'- Range separator char? | |
1012 beq L06A7 Yes, need to get end of range | |
1013 * Special case for [x] - acts as if just normal char (no range or wildcard) | |
1014 sta <u00EF No, save start of range char | |
1015 bsr L062D Get char from DIR filename, force uppercase | |
1016 eora <u00EF Match only range char? | |
1017 beq L06B4 Yes, skip to next char now | |
1018 * Special case for [xyz] - one of these chars must match | |
1019 bra L068B No, see if more single chars to try matching | |
1020 | |
1021 * Actual range - need to get end of range char | |
1022 * Entry: B=high char of range | |
1023 * <u00EF - current char (within range) we are checking against | |
1024 L06A7 inc <u00EF Bump up start char's ascii value | |
1025 cmpb <u00EF Hit end of range yet? | |
1026 beq L068B Yes, try next char | |
1027 lbsr L062D Force char in A to uppercase | |
1028 eora <u00EF equal to current range check char? | |
1029 bne L06A7 No, try next char in range | |
1030 L06B4 ldd ,x+ Get next 2 chars from pathname | |
1031 cmpa #'] End of range? | |
1032 bne L06B4 No, check next char | |
1033 lbra L060D End of range specifier, process normally | |
1034 | |
1035 * Error reading from current DIR | |
1036 L06BD cmpb #E$EOF End of file error? | |
1037 lbne L0776 No, fatal error, leave | |
1038 ldx <u0054 Get ptr to current char in wildcard filename | |
1039 lda -1,x Get last char processed | |
1040 bsr L0714 Add it to new expanded buffer | |
1041 L06C9 lda ,x+ Get next char, inc ptr | |
1042 stx <u0054 Save updated pointer | |
1043 cmpa #C$CR CR? | |
1044 lbeq L0789 Yes, append CR to expanded buffer, we are done | |
1045 lbsr L05D3 See if special shell char | |
1046 bne L06C9 Just regular char, go to next one | |
1047 pshs x Save current ptr to wildcard filename | |
1048 ldx <u0056 Get current ptr in expanded buffer | |
1049 sta -1,x Save that char overtop last char written | |
1050 puls x Get wildcard ptr back | |
1051 bra L06EA Close dir path, go back into loop | |
1052 | |
1053 * If special shell char found right after OPEN of DIR path | |
1054 * Entry: X=ptr to filename (not pathname) - but with special char | |
1055 L06E3 bsr L06FB Process special shell char copying | |
1056 bsr L072F Close DIR path | |
1057 lbra L051D More processing | |
1058 | |
1059 L06EA bsr L072F Close DIR path | |
1060 lbra L0520 Go back to main wildcard processing loop | |
1061 | |
1062 * This chunk (6EF-6F9) is for copying '\x' when x is NOT a wildcard char | |
1063 L06EF lda ,x+ Get quoted char | |
1064 bsr L0739 Check if it is [, * or ? | |
1065 beq L06F9 Yes, add that char to expanded buffer by itself | |
1066 leax -2,x No, bump ptr back to '\' | |
1067 lda ,x+ Get '\' char | |
1068 L06F9 bsr L0714 Append that to output buffer | |
1069 * Special shell chars found goes here | |
1070 * This part copies filename from [,x] to expanded buffer, handling quoted | |
1071 * wildcard chars, and ending on CR or special shell char | |
1072 L06FB lda ,x+ Get char | |
1073 cmpa #'\ Backslash (for quoted char)? | |
1074 beq L06EF Yes, go get quoted char | |
1075 cmpa #C$CR Is it the end of the filename? | |
1076 beq L0789 Yes, append CR to expanded line, we are done | |
1077 bsr L073D Is it '?' or '*' | |
1078 beq L0714 Yes, add that char to expanded buffer | |
1079 lbsr L05D3 Check if shell special char | |
1080 beq L0714 Yes, add to expanded buffer, return from there | |
1081 bsr L0714 No, add to expanded buffer, stay in this loop | |
1082 bra L06FB | |
1083 | |
1084 * Add char to expanded line buffer | |
1085 * Entry: A=char to append to expanded line buffer | |
1086 * <u0056=Current position in expanded line buffer | |
1087 * <u0052=Current size of expanded line buffer | |
1088 * Exit: <u0056 & <u0052 updated | |
1089 L0714 pshs x,a Preserve regs | |
1090 ldx <u0056 Get current pos in expanded buffer | |
1091 sta ,x+ Save char | |
1092 stx <u0056 Save updated expanded buffer ptr | |
1093 ldd <u0052 Get expanded buffer size | |
1094 addd #$0001 Increase by 1 | |
1095 cmpd #2048 Is it full yet? | |
1096 bhi L0773 Yes, exit with expanded line too long error | |
1097 std <u0052 No, save new size | |
1098 puls pc,x,a Restore regs & return | |
1099 | |
1100 * Close DIR path | |
1101 L072F lda <u0012 Get DIR path # | |
1102 beq L0738 If none, exit | |
1103 os9 I$Close Close the path | |
1104 clr <u0012 Clear DIR path # to none | |
1105 L0738 rts | |
1106 | |
1107 * Wildcard checks | |
1108 * Entry: A=char to check | |
1109 * Exit: BEQ if any of the 3 wildcard chars, or BNE if not | |
1110 L0739 cmpa #'[ Range wildcard? | |
1111 beq L0745 | |
1112 L073D cmpa #'? Single char wildcard? | |
1113 beq L0745 | |
1114 cmpa #'* Multi-char wildcard? | |
1115 beq L0745 | |
1116 L0745 rts | |
1117 | |
1118 * Parse for next wildcard or special shell char in pre-parsed parm line | |
1119 * Entry: X=current pos in pre-parse parm line | |
1120 * Exit: X=Same as entry | |
1121 * IF WILDCARD CHAR FOUND: | |
1122 * B=# chars to next wildcard/special char | |
1123 * A=special char found | |
1124 * Carry bit set | |
1125 * IF SPECIAL SHELL CHAR FOUND | |
1126 * B=0 | |
1127 * Carry bit clear | |
1128 * A=special char found: CR ( ) , space ! # & ; < > ^ | | |
1129 L0746 pshs x Save current parm ptr | |
1130 bra L0752 Parse for wildcard or special shell chars | |
1131 | |
1132 L074A lda ,x+ Get char from parms | |
1133 bsr L0739 Do wildcard char check | |
1134 beq L0752 If wildcard char, skip over it & continue | |
1135 leax -1,x not wildcard char, bump back to char after \ | |
1136 L0752 lda ,x+ Get char from parms | |
1137 cmpa #'\ Wildcard quote char (do not expand next)? | |
1138 beq L074A Yes, handle it | |
1139 lbsr L05D3 No, check for other special shell chars | |
1140 beq L0770 Found one, skip ahead | |
1141 bsr L0739 Check for wildcard char | |
1142 bne L0752 None, skip to next char | |
1143 * One of the 3 wildcard chars found, process | |
1144 pshs a Save char | |
1145 tfr x,d Move parm ptr to D | |
1146 subd 1,s Calc distance since last wildcard/special char | |
1147 subd #$0001 -1 | |
1148 puls a B=distance between wild/special chars | |
1149 orcc #Carry Set Carry Flag | |
1150 puls pc,x Exit with original parm ptr in X | |
1151 | |
1152 * Exit with B=0, Carry clear and A=special char found (which ends current | |
1153 * 'chunk' being checked... can included CR) | |
1154 L0770 clrb Clear carry, exit | |
1155 puls pc,x | |
1156 | |
1157 * Expanded buffer full error | |
1158 L0773 comb | |
1159 ldb #E$BufSiz | |
1160 L0776 pshs b,cc Preserve error code | |
1161 bsr L072F Close DIR path (if we had one) | |
1162 ldx <u004A Print text message (usually error msg) | |
1163 ldy <u004C | |
1164 lda #$02 | |
1165 os9 I$WritLn | |
1166 puls b,cc | |
1167 lbra L0191 Exit with error | |
1168 | |
1169 L0789 lda #C$CR Append CR to expanded filenames buffer | |
1170 bsr L0714 | |
1171 ldy <u0052 Get expanded buffer size | |
1172 leax >u0E6D,u Point to start of expanded buffer | |
1173 bsr L072F Close DIR path | |
1174 lds <u0050 Get back original stack ptr | |
1175 * At this point, expanded buffer is complete and ready to go (either through | |
1176 * wildcard routine, or by simply copying the original parm buffer from user) | |
1177 | |
1178 * Main entry point for non-wildcard filename search/match | |
1179 * Entry: X=Ptr to start of expanded buffer | |
1180 L079B tst <u001E Echo required? | |
1181 beq L07A2 No, skip ahead | |
1182 lbsr L021F Print out user entered parm line to std err | |
1183 L07A2 tst <u0043 2=FALSE,0=TRUE, 1=??? (check current IF status, | |
1184 beq L07B0 if any. If TRUE flag set, skip ahead) | |
1185 lbsr L0F69 Do checks for IF type statements | |
1186 tsta Find match? | |
1187 lbpl L0F1D Yes, process IF type statement | |
1188 L07AE clrb No error & return | |
1189 rts | |
1190 | |
1191 * If current IF type statement has result TRUE | |
1192 L07B0 tst <u0045 ??? (Are we looking for a label for GOTO?) | |
1193 beq L07E3 No, skip ahead | |
1194 lda ,x+ Get char from buffer | |
1195 cmpa #'* Comment line? | |
1196 bne L07AE No, exit without error | |
1197 lbsr L091F Yes, get ptr to first non-space char into X | |
1198 leay >u0124,u Point to temp buffer | |
1199 lbsr L100B Copy label from X to Y | |
1200 lda ,x Get 1st char of label | |
1201 cmpa #'\ '*\'? (Which means cancel impending GOTO) | |
1202 beq L07DB Yes, cancel GOTO | |
1203 leax >u0BFC,u No, point to 80 byte buffer (GOTO label holder?) | |
1204 clra default char to check against=NUL | |
1205 L07CF cmpa #C$CR End of label? | |
1206 beq L07DB Yes, cancel GOTO search | |
1207 lda ,x+ Get next char from buffer | |
1208 cmpa ,y+ Is it the label we are looking for? | |
1209 beq L07CF Keep checking till done | |
1210 bra L07AE No match, clear carry & return | |
1211 | |
1212 * Cancelling GOTO search | |
1213 L07DB clr <u0045 Flag we are NOT looking for label for GOTO | |
1214 clrb | |
1215 leas 2,s Eat stack | |
1216 lbra L010D Reprint shell prompt, process from scratch | |
1217 | |
1218 L07E3 bsr L07E7 | |
1219 bra L083A | |
1220 | |
1221 L07E7 pshs x | |
1222 tst <u006C | |
1223 beq L0832 | |
1224 tst <u005C | |
1225 bne L07F5 | |
1226 tst <u001C | |
1227 beq L0832 | |
1228 L07F5 lda ,x | |
1229 cmpa #'* | |
1230 beq L0832 | |
1505 | 1231 IFGT Level-1 |
714 | 1232 ldy #$0000 Force temporarily to super-user |
1233 os9 F$SUser | |
1505 | 1234 ENDC |
714 | 1235 leax >u0CBD,u |
1236 ldd #$0203 | |
1237 lbsr L0C79 | |
1238 bcs L0832 | |
1239 lbsr L00FB | |
1240 lda #$20 | |
1241 sta <$11,x | |
1242 ldy #$0012 | |
1243 lda <u0012 | |
1244 os9 I$Write | |
1245 bcs L082D | |
1246 ldx ,s | |
1247 ldy #$0800 | |
1248 lda <u0012 | |
1249 os9 I$WritLn | |
1250 L082D lda <u0012 | |
1251 os9 I$Close | |
1505 | 1252 L0832 |
1253 IFGT Level-1 | |
1254 ldy <u005A Get original user # back | |
714 | 1255 os9 F$SUser Change user # to original |
1505 | 1256 ENDC |
714 | 1257 puls pc,x |
1258 | |
1259 * Parse input line | |
1260 * Entry : X=Ptr to current char in line buffer | |
1261 L083A clra | |
1262 sta <u0022 Flag we don't change priority for forked process | |
1263 sta <u0003 Clear out # pages of data mem for forked process | |
1264 sta <u000E Clear out signal code | |
1265 leay >L0300,pc Point to main command list | |
1266 lbsr L08D1 Parse keywords from list | |
1267 bcs L08A0 Keyword found but generated error, done line | |
1268 cmpa #C$CR Is 1st non-keyword char a carriage return? | |
1269 beq L08A0 Yes, done line | |
1270 sta <u000C Save non-keyword char | |
1271 cmpa #'( Is it a 'start command group' char? | |
1272 bne L087B No, try next | |
1273 leay >L000D,pc Point to 'Shell' | |
1274 sty <u0004 Save pointer to program to fork? | |
1275 leax 1,x Bump ptr past '(' | |
1276 stx <u0008 Save updated ptr | |
1277 L0860 inc <u000D Bump up # of command groups | |
1278 L0862 leay >L0404,pc Point to command group symbols to parse | |
1279 lbsr L08E9 Hunt down EOL, or '(' or ')' (skip quoted text) | |
1280 cmpa #'( Another group start? | |
1281 beq L0860 Yes, bump up # of command groups & continue | |
1282 cmpa #') Group end? | |
1283 bne L0898 No, skip ahead (to print WHAT?) | |
1284 dec <u000D Bump down # of command groups | |
1285 bne L0862 Still more groups, continue parsing for them | |
1286 lda #C$CR Append CR at end of command line | |
1287 sta -1,x | |
1288 bra L087F Check for modifiers | |
1289 | |
1290 L087B bsr L08A3 Check for valid path, do '<>', '#', '^' if needed | |
1291 bcs L08A0 No valid path found, skip ahead | |
1292 * Found valid pathname | |
1293 L087F leay >L0408,pc Point to modifiers table | |
1294 bsr L08E9 Go parse for them | |
1295 tfr x,d Move ')' ptr to D for SUB | |
1296 subd <u0008 Calculate size from 1st '(' to ')' | |
1297 std <u0006 Save size of group (could also be pathname-modifier) | |
1298 leax -1,x | |
1299 leay >L03CF,pc Point to modifier branch table | |
1300 bsr L08D1 Go execute modifier routine | |
1301 bcs L08A0 If error in modifier routine, exit | |
1302 ldy <u0004 Get ptr to first char we started at | |
1303 L0898 lbne L0BCF Not proper, print 'WHAT?' | |
1304 cmpa #C$CR Last char a carriage return? | |
1305 bne L083A No, start parsing again at current position | |
1306 L08A0 lbra L0B96 Done processing line, continue | |
1307 | |
1308 * Entry: X=Ptr to text to check for valid device name (including '.' & '..') | |
1309 * Exit: Carry set if not a valid device name | |
1310 * Carry clear if there was | |
1311 * <u0004 = Ptr to first char where we started at | |
1312 * <u0008 = Ptr to end of redirection/mem size/priority setting chars (if found) | |
1313 L08A3 stx <u0004 Save ptr to current char in input line | |
1314 bsr L08B6 Check for valid device name | |
1315 bcs L08B5 None found, return | |
1316 * Found valid device name | |
1317 L08A9 bsr L08B6 Eat rest of valid pathlist | |
1318 bcc L08A9 Keep going until we are done pathlist | |
1319 leay >L03DE,pc Point to Command list starting at '<>>>' | |
1320 bsr L08D1 Call any redirection, mem size or priority routines | |
1321 stx <u0008 Save ptr to where we are now (end of current set) | |
1322 L08B5 rts | |
1323 | |
1324 L08B6 os9 F$PrsNam Valid OS9 device name? | |
1325 bcc L08C7 Yes, point X to it & return | |
1326 lda ,x+ Not valid, get first char | |
1327 cmpa #'. Is it a period? | |
1328 bne L08CB No, bad path name | |
1329 cmpa ,x+ Is it a double period? | |
1330 beq L08C9 Yes, leave src ptr pointing to name after '..' | |
1331 leay -1,x If single, bump ptr to name after '.' | |
1332 L08C7 leax ,y Point X to pathname in source | |
1333 L08C9 clra No error & return | |
1334 rts | |
1335 | |
1336 L08CB comb Error flag | |
1337 leax -1,x Bump source ptr back | |
1338 ldb #E$BPNam Bad Path Name error & return | |
1339 rts | |
1340 * Entry: Y=ptr to command list (L0300) | |
1341 L08D1 bsr L0907 Go find 1st non-space char | |
1342 pshs y Save command list ptr | |
1343 bsr L092A Parse for keyword or special char | |
1344 bcs L08E2 If no keyword found, skip ahead | |
1345 ldd ,y Keyword found, get offset | |
1346 jsr d,y Go execute routine for command found | |
1347 puls y Restore command list ptr | |
1348 bcc L08D1 No error, continue parsing for keywords | |
1349 rts Subroutine had error, return with it | |
1350 L08E2 clra No error | |
1351 lda ,x Get character (not in command list) | |
1352 puls pc,y Restore command list ptr & return | |
1353 | |
1354 * Start searching at beginning of current command list | |
1355 * For looking for single character modifiers | |
1356 L08E7 puls y | |
1357 L08E9 pshs y Preserve command list ptr | |
1358 lda ,x+ Get next char from command line | |
1359 L08ED tst ,y Check current char in command list | |
1360 bmi L08E7 If done list, start over at beginning | |
1361 cmpa #'" Is it quotes? | |
1362 bne L0901 No, skip ahead | |
1363 L08F5 lda ,x+ Get next char from command line | |
1364 cmpa #C$CR EOL? | |
1365 beq L0905 Yes, exit with A being CR | |
1366 cmpa #'" Is it another set of quotes? | |
1367 bne L08F5 No, keep looking for it (or EOL) | |
1368 lda ,x+ Get char after 2nd quotes | |
1369 L0901 cmpa ,y+ Is it the current command char we are checking? | |
1370 bne L08ED No, try next | |
1371 L0905 puls pc,y Yes, exit with A containing it | |
1372 | |
1373 * Entry: Y=ptr to command list | |
1374 L0907 pshs x Preserve X | |
1375 lda ,x+ Get char from line entered by user | |
1376 cmpa #C$SPAC Is it a space? | |
1377 beq L091D Yes, skip ahead | |
1378 cmpa #', Is it a comma? | |
1379 beq L091D Yes, skip ahead | |
1380 leax >L0408,pc Point to single character modifiers | |
1381 L0917 cmpa ,x+ Found a match? | |
1382 bhi L0917 No, try next until list is done | |
1383 puls pc,x Found it, restore X to point to it & return | |
1384 | |
1385 L091D leas 2,s Eat X off the stack | |
1386 L091F lda #C$SPAC Get space character | |
1387 L0921 cmpa ,x+ Keep searching until non-space char is found | |
1388 beq L0921 | |
1389 leax -1,x Point to 1st non-space char | |
1390 * ; (1st pass) comes here | |
1391 L0927 andcc #^Carry No carry & return | |
1392 rts | |
1393 * Command line parser | |
1394 L092A pshs y,x Preserve command table ptr & input line ptr | |
1395 leay 2,y Skip first offset | |
1396 L092E ldx ,s Get input line ptr | |
1397 L0930 lda ,x+ Get char from input line | |
1398 lbsr L0F0C Convert char to uppercase if lowercases | |
1399 eora ,y+ Check for a match | |
1400 lsla | |
1401 bne L0951 No match, skip to next keyword in table | |
1402 bcc L0930 Keep checking until end of keyword (high bit set) | |
1403 lda -$01,y Get command table char again | |
1404 cmpa #'|+$80 '|' (with high bit set)? | |
1405 beq L094E Yes, exit with carry clear | |
1406 cmpa #'^+$80 '^' (with high bit set)? | |
1407 beq L094E Yes, exit with carry clear | |
1408 cmpa #'A+$80 Any of the other special modifiers with high bit? | |
1409 blo L094E Yes, exit with carry clear | |
1410 bsr L0907 Eat spaces until first non-space char | |
1411 bcs L0951 If special char (!|#,etc.), skip ahead | |
1412 L094E clra | |
1413 puls pc,y,d | |
1414 | |
1415 L0951 leay -1,y Bump search ptr back | |
1416 L0953 lda ,y+ Get char again | |
1417 bpl L0953 Keep getting them until end of keyword | |
1418 sty 2,s Save ptr to next offset on stack | |
1419 ldd ,y++ Get offset | |
1420 bne L092E If not at end of table, keep searching | |
1421 comb End of table, command not found error | |
1422 puls pc,y,x | |
1423 | |
1424 L0961 fcc 'startup' | |
1425 fcb C$CR | |
1426 | |
1427 * Create child shell to run 'startup' file | |
1428 L0969 pshs u,y,x Preserve regs | |
1429 leax L000D,pc Point to 'shell' (module name) | |
1430 leau L0961,pc Point to 'startup' (parameter for 'shell') | |
1431 ldy #$0008 Size of 'startup<CR>' | |
1505 | 1432 IFGT Level-1 |
714 | 1433 ldd #$111F Program+Objct / 7.5K data area |
1505 | 1434 ELSE |
1435 ldd #$1102 Program+Objct / 512 byte data area | |
1436 ENDC | |
714 | 1437 os9 F$Fork Fork a shell to run the startup file |
1438 bcs L0983 Couldn't fork, exit | |
1439 os9 F$Wait Wait until 'startup' is done | |
1440 L0983 puls u,y,x Restore regs | |
1441 clrb No error & return | |
1442 rts | |
1443 | |
1444 * EX command | |
1445 L0987 lbsr L08A3 Go check for valid device name (module) | |
1446 bcs L09AB If none, exit | |
1447 clra Std in path | |
1448 bsr L09B0 Go close it | |
1449 bsr L09AF Go close Std out | |
1450 bsr L09AF Go close Std Err | |
1451 lbsr L0B87 Go find the end of the input line | |
1452 leax 1,x Bump ptr to 1 past CR | |
1453 tfr x,d Move ptr to D | |
1454 subd <u0008 Calculate size of current command group | |
1455 std <u0006 Save it | |
1456 lbsr L130A Point to module to chain&get its parm size, etc. | |
1457 leas >u00FF,u Point stack to end of DP | |
1458 os9 F$Chain Chain to the new program | |
1459 lbra L01FA Couldn't, go here | |
1460 L09AB clrb No error | |
1461 lbra L020D Close logging file (if any) and exit ShellPlus | |
1462 | |
1463 L09AF inca Inc path # | |
1464 L09B0 pshs a Save path # | |
1465 lbra L0BBC close path if it is open | |
1466 * CHX & CX commands | |
1467 L09B5 clr <u0038 | |
1468 lda #DIR.+EXEC. | |
1469 os9 I$ChgDir | |
1470 rts | |
1471 * CHD & CD commands | |
1472 L09BD lda #DIR.+READ. (bug fix, originally opened in UPDATE) | |
1473 os9 I$ChgDir Change the directory | |
1474 bcs L09CE Error, exit with it | |
1475 clr <u0037 Flag .pwd entry as invalid | |
1476 tst <u0042 WAS ,U | |
1477 beq L09CE | |
1478 bsr L0A04 Go update shell expanded prompt if needed | |
1479 L09CE rts | |
1480 * L command - Logging ON | |
1481 L09CF lda #$01 | |
1482 bra L09D4 | |
1483 * -L command - Logging OFF | |
1484 L09D3 clra | |
1485 L09D4 sta <u001C | |
1486 rts | |
1487 * P command - Prompting ON | |
1488 L09D7 clra | |
1489 bra L09DC | |
1490 * -P command - Prompting OFF | |
1491 L09DA lda #$01 | |
1492 L09DC sta <u001D | |
1493 rts | |
1494 * T command - Echo input ON | |
1495 L09DF lda #$01 | |
1496 bra L09E4 | |
1497 * -T command - Echo input OFF | |
1498 L09E3 clra | |
1499 L09E4 sta <u001E | |
1500 rts | |
1501 * V command - Turn variable expansion ON | |
1502 L09E7 clra | |
1503 bra L09EC | |
1504 * -V command - Turn variable expansion OFF | |
1505 L09EA lda #$01 | |
1506 L09EC sta <u001F | |
1507 rts | |
1508 * X command - Kill Shell when error occurs ON | |
1509 L09EF lda #$01 | |
1510 bra L09F4 | |
1511 * -X command - Kill Shell when error occurs OFF | |
1512 L09F3 clra | |
1513 L09F4 sta <u0020 | |
1514 rts | |
1515 | |
1516 L09F7 tst >u01F4,u Date already done? | |
1517 bne L0A04 Yes, skip ahead | |
1518 tst >u01F5,u Time already done? | |
1519 bne L0A04 Yes, skip ahead | |
1520 rts If neither, we don't need to change prompt? | |
1521 L0A04 pshs y,x Preserve regs | |
1522 bra L0A64 Go update shell expanded prompt if needed | |
1523 | |
1524 * Make shell prompt string the default one | |
1525 L0A08 puls y Restore Y | |
1526 pshs x Preserve X | |
1527 leax >L003D,pc Point to default prompt string | |
1528 bsr L0A14 Put that into working shell prompt string | |
1529 puls pc,x Restore X & return | |
1530 | |
1531 * P= (prompt set) command | |
1532 * Make shell prompt string (default or user-specified) | |
1533 * Entry: X=ptr to source of new shell prompt string | |
1534 L0A14 pshs y Preserve Y | |
1535 leay >u01F9,u Point to working prompt text buffer | |
1536 ldd #C$LF*256+22 Line feed & max count for prompt string+1 | |
1537 sta ,y+ Save LF as first char | |
1538 bsr L0A25 Go copy prompt string (& parse quotes) | |
1539 bra L0A5E Go see if we need to override with default | |
1540 | |
1541 L0A25 clr >u01F3,u Clear quotes in progress flag | |
1542 L0A29 lda ,x+ Get char from default shell prompt | |
1543 cmpa #'" Is it a quotes? | |
1544 bne L0A3F No, skip ahead | |
1545 leax 1,x Yes, bump ptr up 2 past quotes | |
1546 tst >u01F3,u We processing quotes already? | |
1547 bne L0A59 Yes, we are done then | |
1548 inc >u01F3,u Set processing quotes flag | |
1549 leax -1,x Set ptr back to char just after quotes | |
1550 bra L0A29 Check next char | |
1551 | |
1552 L0A3F cmpa #C$CR Carriage return? | |
1553 beq L0A59 Yes, we are done then | |
1554 cmpa #C$SPAC Space? | |
1555 beq L0A4B Yes, skip ahead | |
1556 cmpa #'; Semi-colon? | |
1557 bne L0A51 No, skip ahead | |
1558 * Semi-colon or space found | |
1559 L0A4B tst >u01F3,u We quoting at the moment? | |
1560 beq L0A59 No, we are done | |
1561 L0A51 tstb Char count down to 0? | |
1562 beq L0A29 Yes, continue parsing (but eating them) | |
1563 decb Dec max char counter | |
1564 sta ,y+ Save literal char into current copy | |
1565 bra L0A29 continue parsing | |
1566 | |
1567 L0A59 clr ,y Append NUL to indicate end of string | |
1568 leax -1,x Bump source ptr back to last char & return | |
1569 rts | |
1570 | |
1571 L0A5E cmpb #22 Did the user do a no-length prompt? | |
1572 beq L0A08 Yes, go override with default prompt | |
1573 pshs x Preserve ptr to last char of source prompt | |
1574 | |
1575 * Create expanded shell prompt from shell prompt string | |
1576 L0A64 leay >u01F9,u Point to shell prompt string | |
1577 leax >u0212,u Point to expanded prompt buffer | |
1578 pshs x Preserve it a moment | |
1579 clr >u01F2,u Output device name done already = OFF | |
1580 clr >u01F1,u Process ID # done already = OFF | |
1581 clr >u01F4,u Date done already = OFF | |
1582 clr >u01F5,u Time done already = OFF | |
1583 clr >u01F6,u Date OR time already done once = OFF | |
1584 clr >u0042,u Current working dir name done already = OFF | |
1585 L0A86 lda ,y+ Get char from shell prompt string | |
1586 lbeq L0B29 If end of string, exit | |
1587 cmpa #'# Process ID # wanted? | |
1588 bne L0AA2 No, try next | |
1589 * Process ID # | |
1590 tst >u01F1,u Done it already? | |
1591 bne L0A86 Yes, skip doing it again | |
1592 inc >u01F1,u No, flag it as being done now | |
1593 ldd >u01EC,u Get process # (01-99) | |
1594 std ,x++ Save in expanded prompt buffer | |
1595 bra L0A86 Continue parsing | |
1596 L0AA2 cmpa #'@ Standard output path device name wanted? | |
1597 beq L0AAA Yes, go do it | |
1598 cmpa #$E0 High bit version? | |
1599 bne L0AC7 No, try next | |
1600 * Standard output path device name | |
1601 L0AAA tst >u01F2,u Done it already? | |
1602 bne L0A86 Yes, skip doing it again | |
1603 ldd #$01*256+SS.DevNm Standard out/get device name | |
1604 os9 I$GetStt Get the device name | |
1605 bcs L0A86 Error, skip doing device name | |
1606 inc >u01F2,u Flag it as being done now | |
1607 L0ABD lda ,x+ Get char from device name | |
1608 bpl L0ABD Keep looking until last char (high bit set) | |
1609 anda #$7F Mask out high bit | |
1610 sta -1,x Save the normal char | |
1611 bra L0A86 Continue parsing | |
1612 L0AC7 cmpa #'$ Current working directory wanted? | |
1613 bne L0AF2 No, check next | |
1614 * Current working directory | |
1615 tst <u0042 Done it already? (WAS ,U) | |
1616 bne L0A86 Yes, skip doing it again | |
1617 inc <u0042 Flag it as being done now (WAS ,U) | |
1618 lda #$01 | |
1619 sta <u003D | |
1620 lbsr L176D Go figure out current working directory | |
1621 tstb | |
1622 bne L0AF2 | |
1623 pshs y Save prompt string ptr | |
1624 ldy <u002A Get pointer to current working directory | |
1625 * Copy string: Y=source string ptr, X=prompt buffer ptr | |
1626 L0AE4 lda ,y+ Get char | |
1627 sta ,x+ Save as part of shell prompt text | |
1628 cmpa #C$CR Was it the end? | |
1629 bne L0AE4 No, keep copying | |
1630 leax -1,x Bump ptr back CR | |
1631 puls y Restore source string ptr | |
1632 bra L0A86 Continue parsing | |
1633 | |
1634 L0AF2 cmpa #'( Current Date wanted? | |
1635 bne L0B0A No, check next | |
1636 * Current date | |
1637 tst >u01F4,u Done it already? | |
1638 bne L0A86 Yes, skip doing it again | |
1639 inc >u01F4,u Flag as being done now | |
1640 bsr L0B3B Go get date & time | |
1641 pshs y Save shell prompt string ptr | |
1642 leay >u02E0,u Point to date text | |
1643 bra L0AE4 Copy into expanded prompt | |
1644 L0B0A cmpa #') Current Time wanted? | |
1645 bne L0B24 No, just store the raw ASCII char | |
1646 * Current time | |
1647 tst >u01F5,u Done Time already? | |
1648 lbne L0A86 Yes, skip doing it again | |
1649 inc >u01F5,u Flag as being done now | |
1650 bsr L0B3B Go get date & time | |
1651 pshs y Save shell prompt string ptr | |
1652 leay >u02E9,u Point to time text | |
1653 bra L0AE4 Copy into expanded prompt | |
1654 | |
1655 L0B24 sta ,x+ Save raw character | |
1656 lbra L0A86 Continue parsing | |
1657 | |
1658 L0B29 sta ,x Save NUL to mark end of prompt | |
1659 tfr x,d Move End of prompt ptr to D for subtract | |
1660 subd ,s++ Subtract start of prompt ptr | |
1661 std >u01F7,u Save size of expanded shell prompt | |
1662 puls pc,y,x Restore regs & return | |
1663 | |
1664 * Separator table for date & time strings | |
1665 L0B35 fcc '//' | |
1666 fcb $0d | |
1667 fcc '::' | |
1668 fcb $0d | |
1669 | |
1670 * Get current date (2E0-2E8) & time (2E9-2EF) | |
1671 L0B3B pshs y,x Preserve shell prompt string & shell prompt ptrs | |
1672 tst >u01F6,u Have we already been here before? | |
1673 bne L0B75 Yes, both date & time strings already done | |
1674 inc >u01F6,u Flag we have been here now | |
1675 leax >u02DA,u Point to date/time packet buffer | |
1676 os9 F$Time Get the date/time packet | |
1677 leay >u02E0,u Point to where date string goes | |
1678 clrb Offset into separator table to first '/' | |
1679 L0B54 lda ,x+ Get byte from time packet | |
1680 bsr L0B77 Convert to ASCII | |
1681 pshs b Preserve offset into separator table | |
1682 ldd >u01EF,u Get ASCII version of byte | |
1683 std ,y++ Save into date/string buffers | |
1684 puls b Restore offset into separator table | |
1685 pshs y Preserve date/string buffer ptr | |
1686 leay >L0B35,pc Point to separator's table | |
1687 lda b,y Get current separator | |
1688 puls y Restore date/string buffer ptr | |
1689 sta ,y+ Save separator into date/string buffer | |
1690 incb Point to next separator | |
1691 cmpb #6 On last one? | |
1692 bne L0B54 No, continue converting | |
1693 L0B75 puls pc,y,x Restore prompt & buffer ptrs & return | |
1694 | |
1695 L0B77 pshs y,x,d Preserve regs | |
1696 leay >L0B80,pc Point to routine to copy ASCII digits | |
1697 lbra L16B9 Go convert byte to ASCII equivalent | |
1698 | |
1699 L0B80 ldd $04,s Copy 2 digit ASCII # to 1EF | |
1700 std >u01EF,u | |
1701 rts | |
1702 | |
1703 * Searches for CR in string pointed to by X | |
1704 * '*' Comment lines come here | |
1705 L0B87 lda #C$CR We want to find the CR | |
1706 L0B89 cmpa ,x+ Found it yet? | |
1707 bne L0B89 No, keep looking | |
1708 cmpa ,-x Set up flags & return | |
1709 rts | |
1710 | |
1711 L0B90 pshs d,cc Preserve regs | |
1712 lda #$01 Only do std in & out (not error) | |
1713 bra L0B9A | |
1714 | |
1715 * Any errors from any of the L0300 subroutines go here | |
1716 * If child process had error/status code it goes here (u005D cleared,B=Status | |
1717 * code) | |
1718 L0B96 pshs d,cc Preserve error code, flags & A | |
1719 lda #$02 # of paths to do | |
1720 L0B9A sta <u001A Save it | |
1721 clra Start at path 0 | |
1722 L0B9D bsr L0BA8 Go close (possibly dupe) paths | |
1723 inca Next path # | |
1724 cmpa <u001A Done up to last one yet? | |
1725 bls L0B9D No, do next one | |
1726 * POSSIBLY COULD BE PULS PC,D,CC | |
1727 ror ,s+ Eat CC but shift Carry bit into Carry | |
1728 puls pc,d Restore error code & A & return | |
1729 | |
1730 L0BA8 pshs a Save path # | |
1731 tst <u0019 | |
1732 bmi L0BC4 If high bit set, close path | |
1733 bne L0BBC If 0<u0019<128, get changed path # & close | |
1734 tst a,u Check 'real' path # from DP | |
1735 beq L0BC7 If 0, return | |
1736 os9 I$Close Otherwise, close current path # | |
1737 lda a,u Get 'real' path # | |
1738 os9 I$Dup Dupe it | |
1739 | |
1740 * Close path # on stack, if it is open | |
1741 L0BBC ldb ,s Get path # from stack | |
1742 lda b,u Get real path # from DP | |
1743 beq L0BC7 If none, exit | |
1744 clr b,u Clear out path # | |
1745 L0BC4 os9 I$Close Close the path | |
1746 L0BC7 puls pc,a Exit | |
1747 | |
1748 L0BC9 fcc 'WHAT?' | |
1749 fcb C$CR | |
1750 | |
1751 L0BCF bsr L0B96 Close 3 std paths (possibly dupe) | |
1752 leax <L0BC9,pc Point to 'WHAT?' | |
1753 lbsr L021B Write it out std err | |
1754 clrb | |
1755 coma | |
1756 rts | |
1757 | |
1758 L0BDA inc <u0019 ??? | |
1759 bsr L0B96 Do path closings (possibly dupings) | |
1760 lda #$FF Set flag to just close raw paths | |
1761 sta <u0019 | |
1762 bsr L0B90 Go close std in & std err | |
1763 leax <u006D,u Point to device name buffer | |
1764 lbsr L0CDB | |
1765 lbcs L0200 | |
1766 lda #$02 | |
1767 bsr L0BA8 | |
1768 lbsr L0CFF | |
1769 clr <u0019 | |
1770 lbra L00CC | |
1771 * < processing | |
1772 L0BFA ldd #$0001 | |
1773 orb <u000F | |
1774 bra L0C1A | |
1775 * >> processing | |
1776 L0C01 ldd #$020D | |
1777 stb -$02,x | |
1778 bra L0C0A | |
1779 * > processing | |
1780 L0C08 lda #$01 | |
1781 L0C0A ldb #$02 | |
1782 bra L0C1A | |
1783 * if from z= or i=, A=0, B=3 | |
1784 L0C0E tst a,u Test duped path? | |
1785 bne L0BCF There is one, print 'WHAT' & close paths & return | |
1786 pshs d Save path # & B | |
1787 tst <u0019 | |
1788 bmi L0C34 | |
1789 bra L0C24 | |
1790 | |
1791 L0C1A tst a,u | |
1792 bne L0BCF | |
1793 pshs d | |
1794 ldb #C$CR | |
1795 stb -$01,x | |
1796 | |
1797 L0C24 os9 I$Dup Create duplicate of the standard path | |
1798 lbcs L0CBE Couldn't create dupe, | |
1799 ldb ,s | |
1800 sta b,u | |
1801 lda ,s | |
1802 os9 I$Close | |
1803 | |
1804 L0C34 lda 1,s Get B | |
1805 bmi L0C40 | |
1806 ldb ,s | |
1807 lbsr L0D05 | |
1808 tsta | |
1809 bpl L0C47 | |
1810 L0C40 anda #$0F | |
1811 os9 I$Dup | |
1812 bra L0CBE | |
1813 L0C47 ldb #$0B | |
1814 bita #$02 | |
1815 bne L0C7B | |
1816 pshs a | |
1817 ldd ,x | |
1818 andb #$5F | |
1819 cmpd #$2F57 Is it '/W' | |
1820 puls a | |
1821 bne L0C74 | |
1822 ora #$02 | |
1823 os9 I$Open | |
1824 bcs L0CBE | |
1825 pshs x | |
1826 leax >L003C,pc | |
1827 ldy #$0001 | |
1828 clra | |
1829 os9 I$Write | |
1830 puls x | |
1831 bra L0CBE | |
1832 L0C74 os9 I$Open | |
1833 bra L0CBE | |
1834 L0C79 pshs d | |
1835 L0C7B stb <u004E | |
1836 ldb ,x | |
1837 cmpb #$2B | |
1838 bne L0C96 | |
1839 leax $01,x | |
1840 os9 I$Open | |
1841 bcs L0CB1 | |
1842 pshs u,x | |
1843 ldb #SS.Size | |
1844 os9 I$GetStt | |
1845 os9 I$Seek | |
1846 bra L0CA8 | |
1847 L0C96 cmpb #'- | |
1848 bne L0CB9 | |
1849 leax 1,x | |
1850 os9 I$Open | |
1851 bcs L0CB1 Error opening | |
1852 pshs u,x | |
1853 ldx #$0000 | |
1854 tfr x,u | |
1855 L0CA8 ldb #SS.Size Init size of file to 0 bytes | |
1856 os9 I$SetStt | |
1857 puls u,x | |
1858 bra L0CBE | |
1859 L0CB1 cmpb #E$PNNF Error 216 (path name not found)? | |
1860 beq L0CB9 Yes, create the file | |
1861 orcc #Carry Otherwise, set error flag | |
1862 bra L0CBE | |
1863 L0CB9 ldb <u004E Get file attributes | |
1864 os9 I$Create | |
1865 | |
1866 L0CBE sta <u0012 Save path # (or one we tried to duplicate?) | |
1867 stb 1,s Save possible error code? | |
1868 lda #$00 DO NOT CHANGE-NEED TO PRESERVE CARRY | |
1869 sta <u000F | |
1870 puls pc,d Restore regs & return | |
1871 L0CC8 ldd #$0003 Std in & ??? | |
1872 lbra L0C0E | |
1873 * <>>> processing | |
1874 L0CCE lda #C$CR | |
1875 sta -$04,x | |
1876 * i= & z= both come here right off the bat | |
1877 L0CD2 bsr L0CDB | |
1878 bcc L0CFF | |
1879 L0CD6 rts | |
1880 * <> processing | |
1881 L0CD7 lda #C$CR | |
1882 sta -$02,x | |
1883 | |
1884 L0CDB bsr L0CC8 | |
1885 bcs L0CD6 | |
1886 ldd #$0180 | |
1887 lbra L0C0E | |
1888 * <>> processing | |
1889 L0CE5 lda #C$CR | |
1890 sta -$03,x | |
1891 bsr L0CC8 | |
1892 bcs L0CD6 | |
1893 ldd #$0280 | |
1894 lbra L0C0E | |
1895 * >>> processing | |
1896 L0CF3 lda #C$CR | |
1897 sta -$03,x | |
1898 ldd #$0102 | |
1899 lbsr L0C0E | |
1900 bcs L0CD6 | |
1901 L0CFF ldd #$0281 | |
1902 lbra L0C0E | |
1903 L0D05 pshs x,d | |
1904 ldd ,x++ | |
1905 cmpd #$2F30 | |
1906 bcs L0D2F | |
1907 cmpd #$2F32 | |
1908 bhi L0D2F | |
1909 pshs x,d | |
1910 lbsr L0907 | |
1911 puls x,d | |
1912 bcs L0D2F | |
1913 andb #$03 | |
1914 cmpb 1,s | |
1915 bne L0D31 | |
1916 ldb b,u | |
1917 L0D26 orb #$80 | |
1918 stb ,s | |
1919 puls d | |
1920 leas 2,s | |
1921 rts | |
1922 L0D2F puls pc,x,d | |
1923 | |
1924 L0D31 tst $01,s | |
1925 bne L0D26 | |
1926 pshs x | |
1927 tfr b,a | |
1928 leax >u00B5,u Point to buffer for device name | |
1929 ldb #'/ Put a slash in it | |
1930 stb ,x+ | |
1931 ldb #SS.DevNm Get the device name | |
1932 os9 I$GetStt | |
1933 bcs L0D4F Error, skip ahead | |
1934 leax -1,x Reset ptr to include '/' | |
1935 lda #UPDAT. | |
1936 os9 I$Open | |
1937 L0D4F puls x Restore ptr to beginning (including '/') | |
1938 leas 6,s Eat stack | |
1939 lbra L0CBE | |
1940 | |
1941 L0D56 fcc 'TRUE ' | |
1942 L0D5B fcb $0d | |
1943 L0D5C fcc 'FALSE' | |
1944 fcb $0d | |
1945 | |
1946 L0D62 lda ,x+ | |
1947 cmpa #'[ | |
1948 bne L0D6B | |
1949 lbsr L0E15 | |
1950 L0D6B cmpa #'- | |
1951 lbne L0E3E | |
1952 ldb ,x+ | |
1953 lbsr L0E15 | |
1954 leax -$01,x | |
1955 tfr b,a | |
1956 lbsr L0F0C Convert char to uppercase if lower | |
1957 cmpa #'Y | |
1958 bne L0DBB | |
1959 L0D81 pshs x Preserve X | |
1960 leax >u0124,u Point to buffer | |
1961 ldy #$0001 Read 1 byte from error path??? | |
1962 lda #$02 | |
1963 os9 I$Read | |
1964 lbcs L0F17 | |
1965 lda ,x Get the character read | |
1966 puls x | |
1967 lbsr L0F0C Convert char to uppercase if lower | |
1968 cmpa #'Y Unless char is Y or N, re-read it | |
1969 beq L0DA3 | |
1970 cmpa #'N | |
1971 bne L0D81 | |
1972 L0DA3 pshs a Preserve char on stack | |
1973 leax >L0D5B,pc Point to a Carriage return | |
1974 lda #$02 Print it to std out | |
1975 ldy #$0001 | |
1976 os9 I$WritLn | |
1977 puls a Restore char | |
1978 clrb | |
1979 cmpa #'Y | |
1980 beq L0DF8 Print 'true' if it is a Y | |
1981 bra L0DEE Print 'false' if it is a N | |
1982 | |
1983 L0DBB clrb | |
1984 cmpa #'F | |
1985 beq L0DE0 | |
1986 cmpa #'E | |
1987 bne L0DC8 | |
1988 orb #%00000100 | |
1989 bra L0DE0 | |
1990 | |
1991 L0DC8 cmpa #'R | |
1992 bne L0DD0 | |
1993 orb #%00000001 | |
1994 bra L0DE0 | |
1995 | |
1996 L0DD0 cmpa #'W | |
1997 bne L0DD8 | |
1998 orb #%00000010 | |
1999 bra L0DE0 | |
2000 | |
2001 L0DD8 cmpa #'D | |
2002 lbne L0F17 | |
2003 orb #%10000000 | |
2004 L0DE0 tfr b,a | |
2005 os9 I$Open | |
2006 bcs L0DEE | |
2007 os9 I$Close | |
2008 bra L0DF8 | |
2009 | |
2010 L0DEE lda #$02 | |
2011 sta <u0043 | |
2012 leax >L0D5C,pc Point to 'FALSE' | |
2013 bra L0DFE | |
2014 | |
2015 L0DF8 clr <u0043 | |
2016 leax >L0D56,pc Point to 'TRUE' | |
2017 L0DFE tst <u001E Command echo on? | |
2018 beq L0E0B No, skip ahead | |
2019 ldy #$0006 Print result of IF to std error | |
2020 lda #$02 | |
2021 os9 I$WritLn | |
2022 L0E0B leax >u0124,u | |
2023 lda #C$CR | |
2024 sta ,x | |
2025 clrb | |
2026 rts | |
2027 | |
2028 L0E15 lda ,x+ | |
2029 cmpa #C$SPAC | |
2030 beq L0E15 | |
2031 rts | |
2032 | |
2033 L0E1C cmpa #$3D | |
2034 bne L0E26 | |
2035 lda <u005F | |
2036 ora #$01 | |
2037 bra L0E38 | |
2038 | |
2039 L0E26 cmpa #'< | |
2040 bne L0E30 | |
2041 lda <u005F | |
2042 ora #$02 | |
2043 bra L0E38 | |
2044 | |
2045 L0E30 cmpa #'> | |
2046 bne L0E3C | |
2047 * X command - Kill Shell when error occurs ON | |
2048 lda <u005F | |
2049 ora #$04 | |
2050 L0E38 sta <u005F | |
2051 clra | |
2052 rts | |
2053 | |
2054 L0E3C coma | |
2055 rts | |
2056 | |
2057 L0E3E cmpa #'+ | |
2058 bne L0E46 | |
2059 inc <u0015 | |
2060 bra L0E48 | |
2061 | |
2062 L0E46 leax -1,x | |
2063 L0E48 clr <u005F | |
2064 pshs u | |
2065 leau >u0124,u | |
2066 ldb #180 Clear out 180 bytes @ u0124 | |
2067 lbsr L0412 | |
2068 puls u | |
2069 leay >u0124,u | |
2070 ldb #81 | |
2071 L0E5D lda ,x+ Copy buffer up to CR or 81 chars | |
2072 lbsr L0F0C Convert char to uppercase if lower | |
2073 sta ,y+ | |
2074 cmpa #C$CR | |
2075 lbeq L0F17 | |
2076 bsr L0E1C | |
2077 bcc L0E74 | |
2078 decb | |
2079 bne L0E5D | |
2080 lbra L0F17 | |
2081 | |
2082 L0E74 negb | |
2083 addb #81 | |
2084 stb <u0016 | |
2085 clra | |
2086 sta -$01,y | |
2087 lda ,x | |
2088 bsr L0E1C | |
2089 bcs L0E84 | |
2090 leax $01,x | |
2091 L0E84 leay >u0175,u | |
2092 ldb #81 | |
2093 L0E8A lda ,x+ | |
2094 bsr L0F0C Convert char to uppercase if lower | |
2095 sta ,y+ | |
2096 cmpa #C$CR | |
2097 beq L0E99 | |
2098 decb | |
2099 bne L0E8A | |
2100 bra L0F17 | |
2101 | |
2102 L0E99 negb | |
2103 addb #$51 | |
2104 stb <u0017 | |
2105 clra | |
2106 sta -$01,y | |
2107 tst <u0015 | |
2108 beq L0EE0 | |
2109 leax >u166D,u | |
2110 ldd #$30b4 Store 180 ASCII 0's into buffer | |
2111 L0EAD sta ,x+ | |
2112 decb | |
2113 bne L0EAD | |
2114 leax >u0124,u | |
2115 ldb <u0016 | |
2116 leax b,x | |
2117 leay >u16BD,u | |
2118 bsr L0ED8 | |
2119 leax >u0175,u | |
2120 ldb <u0017 | |
2121 leax b,x | |
2122 leay >u170E,u | |
2123 bsr L0ED8 | |
2124 leax >u166D,u | |
2125 leay >u16BE,u | |
2126 bra L0EE8 | |
2127 | |
2128 L0ED8 lda ,-x | |
2129 sta ,-y | |
2130 decb | |
2131 bne L0ED8 | |
2132 rts | |
2133 | |
2134 L0EE0 leax >u0124,u | |
2135 leay >u0175,u | |
2136 L0EE8 ldb #80 | |
2137 L0EEA lda ,x+ | |
2138 cmpa ,y+ | |
2139 blo L0EFB | |
2140 bhi L0F01 | |
2141 decb | |
2142 bne L0EEA | |
2143 lda <u005F | |
2144 bita #$01 | |
2145 bra L0F05 | |
2146 | |
2147 L0EFB lda <u005F | |
2148 bita #$02 | |
2149 bra L0F05 | |
2150 | |
2151 L0F01 lda <u005F | |
2152 bita #$04 | |
2153 L0F05 lbne L0DF8 | |
2154 lbra L0DEE | |
2155 | |
2156 * Convert char to uppercase if it is a letter | |
2157 L0F0C cmpa #'a Lower case letter? | |
2158 blo L0F16 No, return | |
2159 cmpa #'z Check high range | |
2160 bhi L0F16 No, return | |
2161 suba #$20 Yes, convert to uppercase | |
2162 L0F16 rts | |
2163 | |
2164 L0F17 comb | |
2165 ldb #$01 | |
2166 lbra L0191 | |
2167 | |
2168 L0F1D cmpa #$03 | |
2169 beq L0F3F | |
2170 cmpa #$02 | |
2171 bne L0F2B | |
2172 dec <u0044 | |
2173 blt L0F3F | |
2174 bra L0F43 | |
2175 | |
2176 L0F2B cmpa #$01 | |
2177 bne L0F3B | |
2178 lda <u0043 | |
2179 cmpa #$02 | |
2180 bne L0F43 | |
2181 tst <u0044 | |
2182 beq L0F3F | |
2183 bra L0F43 | |
2184 | |
2185 L0F3B inc <u0044 | |
2186 bra L0F43 | |
2187 | |
2188 L0F3F clr <u0043 | |
2189 clr <u0044 | |
2190 L0F43 clrb | |
2191 rts | |
2192 | |
2193 * Table: 7 bytes/entry: | |
2194 * 1st 5 bytes is name, high bit set & NUL padded | |
2195 * Byte 6 is # bytes actually used | |
2196 L0F45 fcs 'IF' | |
2197 fcb 0,0,0,2,0 | |
2198 fcs 'ELSE' | |
2199 fcb 0,4,1 | |
2200 fcs 'ENDIF' | |
2201 fcb 5,2 | |
2202 fcs 'FI' | |
2203 fcb 0,0,0,2,2 | |
2204 fcs 'CLRIF' | |
2205 fcb 5,3 | |
2206 fcb $ff | |
2207 | |
2208 L0F69 leay <L0F45,pc Point to conditionals table | |
2209 L0F6D ldb 5,y Get actual length of string we are checking | |
2210 os9 F$CmpNam Compare with string pointed to by X | |
2211 bcs L0F80 If they don't match, skip ahead | |
2212 lda 6,y Get conditional token(?) number | |
2213 ldb b,x Get char past end of matching string | |
2214 cmpb #C$CR Is it a CR? | |
2215 beq L0F8B Yes, return | |
2216 cmpb #C$SPAC Is it a space? | |
2217 beq L0F8B Yes, return | |
2218 L0F80 leay 7,y Point to next command in table | |
2219 lda ,y Get 1st char from this entry | |
2220 cmpa #$FF End of table marker? | |
2221 beq L0F8B Yes, return | |
2222 * NOTE: THIS INCA SEEMS TO BE USELESS, AS F$CMPNAM DOESN'T USE A | |
2223 inca No, ??? | |
2224 bra L0F6D Process this one | |
2225 | |
2226 L0F8C lda #$01 | |
2227 sta <u0043 | |
2228 lbra L0E0B | |
2229 | |
2230 L0F93 lbsr L0907 Go find 1st non-space char or single char modifier | |
2231 bne L0F9B | |
2232 clr <u0046 | |
2233 L0F8B rts | |
2234 | |
2235 L0F9B leay >L03AC,pc Point to 'GOTO' | |
2236 ldb #4 4 chars to compare | |
2237 os9 F$CmpNam Does it match? | |
2238 lbcs L0BCF No, print 'WHAT?' | |
2239 leax 4,x Yes, skip X past 'GOTO' | |
2240 lbsr L091F Go find 1st non-space char past 'GOTO' | |
2241 leay >u0C4C,u Point to some sort of buffer | |
2242 lda ,x Get char from GOTO label | |
2243 cmpa #'+ Is label after current pos. in script file? | |
2244 bne L0FBB No, skip ahead | |
2245 sta ,y+ Save '+' in buffer | |
2246 leax 1,x Bump up source ptr past '+' | |
2247 L0FBB bsr L100B Go copy label name into buffer | |
2248 inc <u0046 Set flag that a GOTO was found | |
2249 L0FBF lda ,x+ Get 1st char from user's label again | |
2250 leay >L0408,pc Point to single char modifiers table | |
2251 L0FC5 cmpa ,y+ Illegal modifier char in label name? | |
2252 bhi L0FC5 Not yet, check other modifiers | |
2253 blo L0FBF This char ok, check rest of label name | |
2254 leax -1,x Point to last char (terminator) of label name | |
2255 stx <u0058 Save it & return | |
2256 rts | |
2257 | |
2258 L0FD0 lda ,x | |
2259 cmpa #'+ | |
2260 bne L0FDA | |
2261 leax 1,x | |
2262 bra L0FFB | |
2263 L0FDA tst <u006B | |
2264 beq L0FEA | |
2265 ldy <u0067 | |
2266 ldd $09,y | |
2267 leay d,y | |
2268 sty <u0065 | |
2269 bra L0FFB | |
2270 L0FEA pshs u,x | |
2271 clra | |
2272 ldx #$0000 Seek to beginning | |
2273 tfr x,u | |
2274 os9 I$Seek | |
2275 puls u,x | |
2276 lbcs L0191 | |
2277 L0FFB lbsr L091F | |
2278 leay >u0BFC,u | |
2279 bsr L100B | |
2280 lda #C$CR | |
2281 sta ,x | |
2282 inc <u0045 | |
2283 rts | |
2284 | |
2285 * Copy label from X to buffer @ Y, terminate at 1st illegal char with CR | |
2286 * Exit: X=ptr to start of label name from user's buffer | |
2287 * Y=ptr to start of buffer entry copy of label name | |
2288 L100B pshs y,x Preserve buffer & source ptrs | |
2289 ldb #79 (78 bytes to check) | |
2290 L100F decb Dec # chars left to check | |
2291 beq L1022 If done max, skip ahead | |
2292 lda ,x+ Get char for label | |
2293 sta ,y+ Save in buffer | |
2294 cmpa #'A Is it a letter or higher? | |
2295 bhs L100F Yes, continue copying | |
2296 cmpa #'0 Is it lower than a #? | |
2297 blo L1022 Yes, not allowed, force end of label name | |
2298 cmpa #'9 Is it a #? | |
2299 bls L100F Yes, that is fine | |
2300 L1022 lda #C$CR All others illegal, force CR in buffer copy | |
2301 sta -1,y Save it | |
2302 clrb No error | |
2303 puls pc,y,x Restore regs & return | |
2304 | |
2305 * M= command (???) | |
2306 L1029 ldb #C$CR | |
2307 stb -$01,x | |
2308 tst <u006B | |
2309 bne L1057 | |
2310 tst <u006C | |
2311 bne L1057 | |
2312 lda #Data Data module type | |
2313 pshs u,y,x | |
2314 os9 F$Link | |
2315 bcs L1055 | |
2316 stu <u0067 Save start address of module | |
2317 sty <u0065 Save execution address of module | |
2318 ldd 2,u | |
2319 addd <u0067 | |
2320 subd #$0003 | |
2321 std <u0069 | |
2322 inc <u006B | |
2323 puls u,y,x | |
2324 leax -$01,x | |
2325 lbra L0907 | |
2326 | |
2327 L1055 puls u,y,x | |
2328 L1057 lbra L0BCF | |
2329 | |
2330 * VAR. command | |
2331 L105A leay >u05A8,u | |
2332 lda ,x+ | |
2333 cmpa #'? | |
2334 beq L10C9 | |
2335 cmpa #'= | |
2336 beq L1096 | |
2337 cmpa #C$SPAC | |
2338 beq L1085 | |
2339 cmpa #'; | |
2340 beq L1085 | |
2341 cmpa #'9 | |
2342 bhi L1085 | |
2343 cmpa #'0 | |
2344 bcs L1085 | |
2345 suba #$30 | |
2346 ldb #$51 Multiply by 81 (size of each VAR entry) | |
2347 mul | |
2348 leay d,y | |
2349 lda ,x+ | |
2350 cmpa #'= | |
2351 beq L1096 | |
2352 L1085 leax -$01,x | |
2353 pshs x | |
2354 tfr y,x | |
2355 ldy #$0051 | |
2356 lda #$02 | |
2357 os9 I$ReadLn | |
2358 puls pc,x | |
2359 | |
2360 L1096 ldb #80 | |
2361 lbsr L0A25 | |
2362 lda #C$CR | |
2363 sta ,y | |
2364 rts | |
2365 | |
2366 L10A0 fcb C$LF | |
2367 fcc 'User Variables :' | |
2368 fcb C$CR | |
2369 | |
2370 L10B2 fcb C$LF | |
2371 fcc 'Shell Sub Variables :' | |
2372 fcb C$CR | |
2373 | |
2374 L10C9 pshs x | |
2375 clrb | |
2376 leax >L10A0,pc | |
2377 bsr L10DF | |
2378 leay >u08D2,u | |
2379 clrb | |
2380 leax >L10B2,pc | |
2381 bsr L10DF | |
2382 puls pc,x | |
2383 | |
2384 L10DF pshs y,b | |
2385 lbsr L021B | |
2386 puls y,b | |
2387 L10E6 pshs y,b | |
2388 lda #$51 | |
2389 mul | |
2390 leay d,y | |
2391 leax >u0124,u | |
2392 ldd #'V*256+'A | |
2393 std ,x++ | |
2394 ldd #'R*256+'. | |
2395 std ,x++ | |
2396 lda ,s | |
2397 L10FD adda #$30 | |
2398 ldb #'= | |
2399 std ,x++ | |
2400 L1103 lda ,y+ | |
2401 sta ,x+ | |
2402 cmpa #C$CR | |
2403 bne L1103 | |
2404 leax >u0124,u | |
2405 ldy #$0057 | |
2406 lda #$01 | |
2407 os9 I$WritLn | |
2408 puls y,b | |
2409 bcs L1122 | |
2410 incb | |
2411 cmpb #C$LF | |
2412 bcs L10E6 | |
2413 rts | |
2414 | |
2415 L1122 puls y | |
2416 puls pc,x | |
2417 | |
2418 * INC. command (increment shell variable by 1) | |
2419 L1126 bsr L1144 | |
2420 lbcs L0191 | |
2421 addd #$0001 | |
2422 bra L113A | |
2423 | |
2424 * DEC. command (decrement shell variable by 1) | |
2425 L1131 bsr L1144 | |
2426 lbcs L0191 | |
2427 subd #$0001 | |
2428 L113A bsr L11A7 | |
2429 lda #C$CR | |
2430 sta $05,y | |
2431 ldx <u0048 | |
2432 clrb | |
2433 rts | |
2434 | |
2435 L1144 inc <u0014 | |
2436 leay >u05A8,u | |
2437 lda ,x+ | |
2438 stx <u0048 | |
2439 cmpa #'0 | |
2440 bcs L1161 | |
2441 cmpa #'9 | |
2442 bhi L1161 | |
2443 suba #$30 | |
2444 ldb #81 | |
2445 mul | |
2446 leay d,y | |
2447 tfr y,x | |
2448 bra L1166 | |
2449 | |
2450 L1161 leas 2,s | |
2451 lbra L0BCF | |
2452 | |
2453 L1166 pshs y | |
2454 leas -$05,s | |
2455 tfr s,y | |
2456 clr $03,y | |
2457 clr $04,y | |
2458 L1170 clr $02,y | |
2459 lda ,x+ | |
2460 suba #$30 | |
2461 cmpa #$09 | |
2462 bhi L1195 | |
2463 pshs a | |
2464 lda #10 | |
2465 ldb $03,y | |
2466 mul | |
2467 std ,y | |
2468 lda $04,y | |
2469 ldb #10 | |
2470 mul | |
2471 addd $01,y | |
2472 std $01,y | |
2473 clra | |
2474 puls b | |
2475 addd $01,y | |
2476 std $03,y | |
2477 bra L1170 | |
2478 | |
2479 L1195 ldd 3,y | |
2480 leas 5,s | |
2481 puls pc,y | |
2482 | |
2483 * 2 byte ASCII conversion table | |
2484 L119B fdb 10000 | |
2485 fdb 1000 | |
2486 fdb 100 | |
2487 fdb 10 | |
2488 fdb 1 | |
2489 fdb 0 | |
2490 | |
2491 L11A7 pshs y,x,d | |
2492 pshs b | |
2493 leax >L119B,pc | |
2494 L11AF pshs d | |
2495 ldb #'/ | |
2496 stb 2,s | |
2497 puls d | |
2498 L11B7 inc ,s | |
2499 subd ,x | |
2500 bcc L11B7 | |
2501 addd ,x++ | |
2502 pshs d | |
2503 ldb $02,s | |
2504 stb ,y+ | |
2505 lda $01,x | |
2506 puls d | |
2507 bne L11AF | |
2508 puls b | |
2509 puls pc,y,x,d | |
2510 | |
2511 * PAUSE command - may display text message, and then waits for key press or | |
2512 * mouse button | |
2513 L11CF ldy #394 Write up to 394 chars of pause string | |
2514 lda #$02 To standard error | |
2515 os9 I$WritLn | |
2516 lbcs L0191 | |
2517 tfr y,d Tfr # chars written to D | |
2518 leax d,x Point X to next char after ones written | |
2519 leax -1,x Point to last char written | |
2520 pshs x Save ptr | |
2521 ldd #$02*256+SS.SSig Std Err/Send signal when key pressed | |
2522 ldx #$000A Signal $A is the one to send | |
2523 os9 I$SetStt | |
2524 lbcs L0191 Error, use main shell error handler | |
1505 | 2525 IFGT Level-1 |
714 | 2526 ldb #SS.MsSig Send signal on mouse button press |
2527 os9 I$SetStt | |
2528 lbcs L0191 | |
1505 | 2529 ENDC |
714 | 2530 ldx #$0000 Go to sleep until one of the 2 is received |
2531 os9 F$Sleep | |
2532 ldb #SS.Relea Signal gotten, release all signals | |
2533 os9 I$SetStt | |
2534 clrb No error & return | |
2535 puls pc,x | |
2536 | |
2537 * Parse PATH=, add paths to PATH buffer list | |
2538 L1209 pshs x Preserve ptr to string after 'PATH=' | |
2539 lda ,x Get 1st char | |
2540 cmpa #'? User requesting current paths? | |
2541 beq L1245 Yes, go do that | |
2542 pshs u Preserve U | |
2543 leau >u0CDD,u Point to PATH= buffer | |
2544 L1217 lda ,x+ Get char from user-requested path | |
2545 cmpa #C$SPAC Space? | |
2546 beq L1217 Yes, eat spaces until 1st real char found | |
2547 sta ,u+ No, save char | |
2548 L121F leay >L0408,pc Point to command modifier list | |
2549 L1223 cmpa ,y+ Match char? | |
2550 bhi L1223 No, our char is higher, check next modifier | |
2551 beq L1237 Found match, skip ahead | |
2552 lda ,x+ No modifier found, get next char | |
2553 sta ,u+ Save in PATH buffer | |
2554 cmpa #C$SPAC Was it a space? | |
2555 bne L121F No, check this char vs. modifier list | |
2556 lda #C$CR Yes, change to CR | |
2557 sta -1,u Save CR instead (terminate 1 path entry) | |
2558 bra L1217 Do whole list | |
2559 | |
2560 * NOTE: ANY modifier (not just CR, but ! # & ; < > ^ |) stops PATH=parsing | |
2561 L1237 leax -1,x Bump ptr back to last char from user | |
2562 stx 2,s Save ptr on stack over original X | |
2563 lda #C$CR Get CR | |
2564 sta -1,u Save CR as current path end | |
2565 sta ,u And 1 extra for parse routines | |
2566 puls u Get U back | |
2567 puls pc,x Restore new X & return | |
2568 | |
2569 L1245 leax >u0CDD,u Point to start of PATH=buffer | |
2570 L1249 ldy #400 Write up to 400 chars to standard out | |
2571 lda #$01 | |
2572 os9 I$WritLn Print text of one path | |
2573 lbcs L0191 Error, go process shell error | |
2574 tfr y,d Tfr # bytes written to D | |
2575 leax d,x Offset X to end of what was printed | |
2576 lda ,x Get char from there | |
2577 cmpa #C$CR CR (end of path list)? | |
2578 bne L1249 No, go write next path out | |
2579 puls x Restore ptr to next set of PATH= | |
2580 leax 1,x Bump ptr up by 1 & return | |
2581 rts | |
2582 | |
2583 * ^ (set priority on the fly) command | |
2584 L1265 ldb #C$CR Plop a CR onto the end | |
2585 stb -$01,x | |
2586 ldb <u0022 Any priority already set? | |
2587 lbne L0BCF Yes, print 'WHAT?' | |
2588 lbsr L16EB Go calculate binary priority into B | |
2589 stb <u0022 Save priority to fork module with | |
2590 lbra L0907 Continue processing for modifiers | |
2591 | |
2592 * # (set data memory size) command | |
2593 L1277 ldb #C$CR | |
2594 stb -1,x | |
2595 ldb <u0003 Already have a data mem size set? | |
2596 lbne L0BCF Yes, print 'WHAT?' | |
2597 lbsr L16EB | |
2598 eora #'K | |
2599 anda #$DF Force uppercase | |
2600 bne L1294 No 'K', just save # of 256 byte pages | |
2601 leax 1,x | |
2602 lda #4 Multiply # of K by 4 to get # pages | |
2603 mul | |
2604 tsta | |
2605 lbne L0BCF Ended up too big, print 'WHAT?' | |
2606 L1294 stb <u0003 Save data mem size to use | |
2607 lbra L0907 Continue processing command line | |
2608 | |
2609 * Carriage return processing | |
2610 L1299 leax -1,x | |
2611 lbsr L145D | |
2612 bra L12A3 | |
2613 | |
2614 * ; (separator) command (also called by others) | |
2615 L12A0 lbsr L1459 | |
2616 L12A3 bcs L12BA | |
2617 lbsr L0B96 Go do the path stuff | |
2618 tst <u005D Is there a module that is unlinking? | |
2619 bne L12AE Yes | |
2620 bsr L12D2 Go wait for child process to die (A=process #) | |
2621 | |
2622 L12AE bcs L12BA If child exited with status/signal code,skip | |
2623 lbsr L0907 Go parse for modifiers | |
2624 cmpa #C$CR Was the next non-space/comma char a CR? | |
2625 bne L12B9 No, skip ahead | |
2626 leas 4,s Yes, eat stack | |
2627 L12B9 clrb No error | |
2628 | |
2629 * Child process had a signal/status code | |
2630 L12BA pshs cc Preserve error status | |
2631 clr <u005D ??? | |
2632 puls cc Restore carry | |
2633 lbra L0B96 ??? Go close some paths & return? | |
2634 | |
2635 * & (background operation) command | |
2636 L12C3 lbsr L1459 | |
2637 bcs L12BA | |
2638 bsr L12BA | |
2639 ldb #$26 | |
2640 lbsr L16B3 | |
2641 bra L12AE | |
2642 | |
2643 * W command - Wait for a child to die | |
2644 L12D1 clra Clear process ID # | |
2645 * Entered here if commands are separated with ';' (or '()' groups) | |
2646 L12D2 pshs a Save ID # of process? | |
2647 L12D4 os9 F$Wait Wait for child to die or until signal received | |
2648 tst <u000E Signal received (which would be in SHELL)? | |
2649 beq L12EC No, child was exited (or got signal), go process | |
2650 * Shell was interrupted by signal while Waiting | |
2651 ldb <u000E Get signal that we received | |
2652 cmpb #S$Abort Was it a PD.QUT (<CTRL>-<E>) (quit 'W'aiting?) | |
2653 bne L1304 No, skip ahead | |
2654 lda ,s Get process # | |
2655 beq L1304 None, exit | |
2656 os9 F$Send Send the signal to the child as well | |
2657 clr ,s Clear process # | |
2658 bra L12D4 Go Wait again (until child dies) | |
2659 | |
2660 * Child F$Exited or was aborted - eat should go here | |
2661 * Entry: A=ID # of deceased child | |
2662 * B=Exit (error) code from child | |
2663 L12EC lbcs L1308 If F$Wait exited with error, return with it | |
2664 cmpa ,s Same process # as one we were waiting for? | |
2665 beq L1304 Yes, exit | |
2666 tst ,s No, was there a specific process # we wanted? | |
2667 beq L12F9 No, skip ahead | |
2668 * Child died, but not the one we were waiting for | |
2669 tstb Was there an error status? | |
2670 beq L12D4 No, ignore dead child and wait for one we wanted | |
2671 * Child died with error on exit | |
2672 L12F9 pshs b Preserve child's exit status code | |
2673 bsr L12BA ??? Go close & re-dupe paths? | |
2674 ldb #'- Get a '-' (for a '-003' process finished msg) | |
2675 lbsr L16B3 Print that out | |
2676 puls b Get back exit status code | |
2677 | |
2678 L1304 tstb is there an Error/signal code? | |
2679 beq L1308 No, exit | |
2680 cmpb #S$Intrpt Yes, is it a keyboard interrupt signal? | |
2681 beq eatchar Yes, eat the key | |
2682 cmpb #S$Abort Keyboard abort signal? | |
2683 bne errexit No, exit with unknown error/signal code | |
2684 | |
2685 * At this point, child died from signal 2 or 3 (CTRL-C or CTRL-E). The corres- | |
2686 * ponding key is also sitting in this devices PD.BUF as the 1st char. We musts | |
2687 * 1) Disable keyboard signal & eat the key from the buffer | |
2688 * 2) Exit from here with Carry set & signal (2 or 3) in B | |
2689 eatchar pshs b,x,y Preserve signal code & regs used | |
2690 ldd #SS.Ready Std in, check for data ready on device | |
2691 os9 I$GetStt Check it | |
2692 bcs NotSCF No chars waiting on device, exit with signal | |
2693 lda <u0018 Is the shell immortal? | |
2694 beq NotSCF No, don't try to eat the char | |
2695 eat clra Standard in path | |
2696 leas -PD.OPT,s Make 32 byte buffer for OPT's | |
2697 leax ,s Point X to it | |
2698 clrb SS.Opt call | |
2699 os9 I$GetStt Get current path options | |
2700 lda ,x Get device type | |
2701 beq Eatkey SCF (not script file) so go eat key | |
2702 NoChar leas PD.OPT,s Eat temp buffer | |
2703 bra NotSCF Exit with signal code (script file got signal) | |
2704 | |
2705 * Have to eat key: Shut echo off 1st | |
2706 Eatkey clr 4,x PD.EKO flag off | |
2707 os9 I$SetStt Shut echo off | |
2708 ldd #SS.Relea Std In, Release keyboard/mouse signals | |
2709 os9 I$SetStt Shut signals off so we don't get stuck | |
2710 leax ,-s Make 1 byte buffer on stack | |
2711 ldy #1 1 byte to read | |
2712 os9 I$Read Eat the char | |
2713 leas 1,s eat buffer | |
2714 ldd #SS.SSig Std In, send signal on key ready | |
2715 ldx #$B Signal to send | |
2716 os9 I$SetStt Turn keyboard signal on again | |
2717 leax ,s Point to temp buffer again | |
2718 inc 4,x PD.EKO flag on | |
2719 clra Std In | |
2720 clrb Set Options | |
2721 os9 I$SetStt Turn echo back on | |
2722 leas PD.OPT,s Deallocate temp buffer | |
2723 ldb u180D,u Get current history line # | |
2724 cmpb #1 First one? | |
2725 bhi Previous No, B=previous one | |
2726 ldb u180C,u Was on first, so get last | |
2727 incb Adjust for dec | |
2728 Previous decb Point to previous one | |
2729 lbsr L19D3 Go get ptr to history | |
2730 lda ,y Get 1st char from previous line in history | |
2731 sta ,x Save char there | |
2732 ldd #SS.Fill Fill keyboard buffer call to Std In | |
2733 ldy #$8001 1 char long, don't append CR | |
2734 os9 I$SetStt Stick that key into the keyboard buffer | |
2735 NotSCF puls b,x,y Restore regs (and exit status byte in B) | |
2736 errexit coma Yes, set carry & exit | |
2737 L1308 puls pc,a | |
2738 | |
1505 | 2739 * Level 2: If data area <4.25K, force up to 7.5K |
714 | 2740 * Exit: A=Type/language |
2741 * X=Current source line parsing ptr (module name to chain) | |
2742 * Y=Size of parameter area | |
2743 * U=Ptr to parameter area | |
2744 * B=Size of data area | |
2745 L130A lda #Prgrm+Objct Module type/language | |
2746 ldb <u0003 Get # pages of data mem needed for forked module | |
1505 | 2747 IFGT Level-1 |
714 | 2748 cmpb #$11 Is it at least 17? |
2749 bhs L1316 Yes, skip ahead | |
2750 ldb #$1F Otherwise, force to 7.5K minimum | |
2751 stb <u0003 Save it | |
1505 | 2752 ENDC |
714 | 2753 L1316 andcc #^Carry Clear carry |
2754 ldx <u0004 Get mem module ptr | |
2755 ldy <u0006 Get size of current command group | |
2756 ldu <u0008 Get ptr to start of current command group | |
2757 rts | |
2758 | |
2759 * Copy string from X to Y until CR is hit | |
2760 L1320 lda ,x+ Get char | |
2761 sta ,y+ Save it | |
2762 cmpa #C$CR Carriage return? | |
2763 bne L1320 No, keep copying | |
2764 rts Done, return | |
2765 | |
2766 * Attempt load in module to execute (it's not in memory) | |
2767 * Entry: X=Ptr to module name | |
2768 L1329 lda #EXEC. 1st, attempt to get it from current Exec DIR | |
2769 os9 I$Open Attempt to open it | |
2770 bcc L1362 Found it, continue | |
2771 * Possible search thru PATH= settings | |
2772 inc <u000F ??? Set flag to indicate using PATH= | |
2773 leax >u0CDD,u Point to start of PATH= list | |
2774 L1336 clrb | |
2775 lda ,x Get 1st char from next PATH= line | |
2776 cmpa #C$CR End of list? | |
2777 lbeq L1564 Yes, ??? | |
2778 leay >u0124,u No, point to temp buffer | |
2779 bsr L1320 Copy path to temp buffer until CR | |
2780 pshs x Preserve ptr to next possible path | |
2781 lda #'/ Add slash since we want file from this path | |
2782 sta -1,y Save at end of path in temp buffer | |
2783 ldx <u0004 Get ptr to module/script name we are looking for | |
2784 bsr L1320 Copy it into temp buffer up to CR | |
2785 leax >u0124,u Point to start of full path list | |
2786 lda #READ. Attempt to open file | |
2787 os9 I$Open | |
2788 puls x Restore ptr to next possible path | |
2789 bcs L1336 Didn't find file there, try next path | |
2790 leax >u0124,u Point to full pathlist again | |
2791 stx <u0004 Replace ptr to module with full pathlist ptr | |
2792 L1362 leax >u00D6,u Point to buffer to hold beginning of file | |
2793 ldy #77 77 bytes to read | |
2794 os9 I$Read Read it in | |
2795 bcc L1373 No error, skip ahead | |
2796 cmpb #E$EOF Just EOF error? | |
2797 bne L13CE No, something more serious, skip ahead | |
2798 L1373 tst <u000F | |
2799 bne L137B | |
2800 ldb #$04 | |
2801 stb <u000F | |
2802 L137B pshs a Save path # a sec | |
2803 ldd M$ID,x Get possible module header bytes | |
2804 cmpd #M$ID12 Legit module header? | |
2805 puls a Restore path # | |
2806 beq L1396 OS9 module, skip ahead | |
2807 * Not module...possible shell script? | |
2808 os9 I$Close Not OS9 module, close file | |
2809 clrb | |
2810 dec <u000F Dec flag | |
2811 lbeq L1564 If 0, skip ahead | |
2812 inc <u000F If not, inc & skip ahead | |
2813 lbra L1564 | |
2814 | |
2815 * Seems to be OS9 module | |
2816 L1396 clr <u000F Clear flag | |
2817 ldy M$Name,x Get offset to module name | |
2818 leax >u00E3,u Point X to offset $E in module | |
2819 cmpy #$000D Does the name start at offset $D? | |
2820 beq L13C0 Yes, skip ahead | |
2821 pshs u Preserve U | |
2822 tfr y,u Move name offset to U | |
2823 ldx #$0000 MSW of file pos=0 | |
2824 os9 I$Seek Go seek to that spot in file | |
2825 puls u Restore U | |
2826 bcs L13CE Error seeking, go handle | |
2827 ldy #64 Go read up to 64 char filename | |
2828 leax >u00E3,u Point to spot to hold filename | |
2829 os9 I$Read Read it in | |
2830 bcs L13CE Error reading, go handle | |
2831 L13C0 pshs a Save path # | |
2832 os9 F$PrsNam Parse module name | |
2833 puls a Restore path # | |
2834 bcs L13CE | |
2835 cmpb #$40 | |
2836 bhi L1422 | |
2837 clrb | |
2838 L13CE pshs b,cc Preserve error status | |
2839 os9 I$Close Close file | |
2840 puls b,cc Restore error status | |
2841 lbcs L162B If error, exit with it (S/B L162C) | |
2842 leax >u00D6,u Point to buffer holding 77 bytes of file | |
2843 lda $06,x | |
2844 ldy $0B,x | |
2845 cmpa #$40 | |
2846 bne L1407 | |
2847 bsr L13EF | |
2848 lbcs L162B | |
2849 lbra L14AF | |
2850 L13EF leax >u00E3,u | |
1505 | 2851 IFGT Level-1 |
2852 os9 F$NMLink | |
2853 ELSE | |
2854 pshs u | |
2855 os9 F$Link | |
2856 puls u | |
2857 ENDC | |
714 | 2858 bcc L1400 |
2859 ldx <u0004 | |
1505 | 2860 IFGT Level-1 |
2861 os9 F$NMLoad | |
2862 ELSE | |
2863 pshs u | |
2864 os9 F$Load | |
2865 puls u | |
2866 ENDC | |
714 | 2867 bcc L1400 |
2868 rts | |
2869 L1400 leax >u00E3,u | |
2870 stx <u0004 | |
2871 rts | |
2872 L1407 cmpa #$51 | |
2873 bne L1413 | |
2874 bsr L13EF | |
2875 lbcs L162B | |
2876 bra L1427 | |
2877 L1413 cmpa #$11 | |
2878 lbne L14D7 | |
2879 leax >u00E3,u | |
2880 stx <u0010 | |
2881 lbra L15D7 | |
2882 L1422 lbsr L08CB | |
2883 bra L13CE | |
2884 | |
2885 * Call a shellsub module | |
2886 L1427 clra Type/language byte to wildcard:any will match | |
2887 ldx <u0004 Get ptr to module name | |
2888 pshs u Preserve U | |
2889 os9 F$Link Attempt to link it in | |
2890 puls u Restore U | |
2891 lbcs L162B If we couldn't link, Exit with error | |
2892 ldx <u0004 Get ptr to module name again | |
1505 | 2893 IFGT Level-1 |
714 | 2894 os9 F$UnLoad Unlink it |
1505 | 2895 ELSE |
2896 pshs a,b,x,y,u | |
2897 os9 F$Link | |
2898 os9 F$Unlink | |
2899 os9 F$Unlink | |
2900 puls a,b,x,y,u | |
2901 ENDC | |
714 | 2902 lbcs L162B If we couldn't unlink exit with error |
2903 ldx <u0008 Get ptr to current group (param ptr for shellsub) | |
2904 ldd <u0006 Get size of param area for shellsub | |
2905 leau >u08D2,u Point to shellsub variable area | |
2906 jsr ,y Execute shellsub module | |
2907 pshs b,a,cc Preserve error status & A | |
2908 clra | |
2909 clrb | |
2910 std <u0010 ? (originally pointing to E3 if type $11 module) | |
2911 ldx <u0004 Get shellsub module ptr | |
1505 | 2912 IFGT Level-1 |
714 | 2913 os9 F$UnLoad Unlink it |
1505 | 2914 ELSE |
2915 pshs a,b,x,y,u | |
2916 os9 F$Link | |
2917 os9 F$Unlink | |
2918 os9 F$Unlink | |
2919 puls a,b,x,y,u | |
2920 ENDC | |
714 | 2921 std <u0004 Clear shellsub module ptr |
2922 inc <u005D Set flag that we should wait for module to exit? | |
2923 puls pc,u,y,x,d,cc restore regs & return | |
2924 | |
2925 L1459 lda #C$CR | |
2926 sta -1,x | |
2927 L145D clr <u0060 | |
2928 pshs u,y,x | |
2929 ldx <u0004 Get ptr to name | |
2930 ldd ,x Get 2 chars of name | |
2931 andb #$5F Force 2nd one to uppercase | |
2932 cmpd #$2F57 Is it a /W? | |
2933 bne L1473 No, check for shellsub | |
2934 comb Yes, exit with bad mode error | |
2935 ldb #E$BMode | |
2936 lbra L162B | |
2937 | |
2938 L1473 clra Wildcard NMLink | |
1505 | 2939 IFGT Level-1 |
714 | 2940 os9 F$NMLink Link to module |
1505 | 2941 ELSE |
2942 pshs u | |
2943 os9 F$Link Link to module | |
2944 puls u | |
2945 ENDC | |
714 | 2946 lbcs L1329 Error, do something |
2947 cmpa #ShellSub+Objct ShellSub module? | |
2948 beq L1427 Yes, go set up for it | |
2949 ldx <u0004 Get ptr to name back | |
1505 | 2950 IFGT Level-1 |
714 | 2951 os9 F$UnLoad Drop the link count back down |
1505 | 2952 ELSE |
2953 pshs a,b,x,y,u | |
2954 os9 F$Link | |
2955 os9 F$Unlink | |
2956 os9 F$Unlink | |
2957 puls a,b,x,y,u | |
2958 ENDC | |
714 | 2959 pshs y Save data area size |
2960 ldx <u0004 Get ptr to module name again | |
2961 leay >L000D,pc Point to 'Shell' | |
2962 ldb #$05 Size of 'Shell' | |
2963 os9 F$CmpNam Is the module requested Shell? | |
2964 puls y Restore data area size | |
2965 bcs L14A3 Not shell, skip ahead | |
2966 ldb 5,x Get char right after 'shell' | |
2967 cmpb #C$CR Is 'shell' the only thing on the line? | |
2968 lbeq L158D Yes, skip ahead | |
2969 cmpb #C$SPAC Is it a space? | |
2970 lbeq L158D Yes, skip ahead | |
2971 * Not Shell or Shellsub module | |
2972 L14A3 cmpa #Prgrm+Objct ML program? | |
2973 lbeq L15D7 Yes, skip ahead | |
2974 cmpa #Data Is it a data module? | |
2975 bne L14D7 No, skip ahead | |
2976 inc <u0060 Set flag - data module | |
2977 L14AF inc <u0060 Bump it up | |
2978 ldx <u0004 Get ptr to module name | |
2979 os9 F$PrsNam Parse the name | |
2980 ldy <u0063 Get ptr to Intercept routines data mem ($418) | |
2981 leay $0A,y Bump up to $422 | |
2982 sty <u0008 Save ptr to start of current group | |
2983 sty <u0061 ??? Ptr to data modules name? | |
2984 ldx #60 Max size of group | |
2985 stx <u0006 Save it | |
2986 ldx <u0004 Get ptr to module name | |
2987 L14C8 lda ,x+ Copy it to buffer @ $422 | |
2988 sta ,y+ | |
2989 decb | |
2990 bne L14C8 | |
2991 lda #C$CR Append a CR to it | |
2992 sta ,y+ | |
2993 clrb | |
2994 lbra L1564 | |
2995 * Not 6809 object code or data module either | |
2996 L14D7 sty <u000A Save data area size | |
2997 leax >L0013,pc Point to alternate languages table | |
2998 L14DE tst ,x Is this entry active? | |
2999 lbeq L1629 No, exit with non-existing module error | |
3000 cmpa ,x+ Same module type as we want? | |
3001 beq L14EE Yes, skip ahead | |
3002 L14E8 tst ,x+ No, eat module name | |
3003 bpl L14E8 | |
3004 bra L14DE Try next module | |
3005 * Found run-time language match | |
3006 L14EE ldd <u0008 Get ptr to start of current command group | |
3007 subd <u0004 Calculate size of whole group | |
3008 addd <u0006 Don't include size of current group | |
3009 std <u0006 Save remainder size | |
3010 ldd <u0004 Get ptr to start of sub-module | |
3011 std <u0008 Save it | |
3012 pshs y,x Preserve data area size & primary module ptr | |
3013 leax >L0021,pc Point to 'RUNB' | |
3014 cmpx ,s Is that the run-time module we want? | |
3015 bne L1546 No, skip ahead | |
3016 * RUNB needed - have to () & quote/commas between params | |
3017 ldx <u0008 Yes, get sub-module ptr? | |
3018 leay >u0418,u Point to before sub-module | |
3019 bsr L154B Copy buffer up to next param (or end of line) | |
3020 beq L1535 If it was end of line, add CR & continue | |
3021 ldd ,x Get 2 param chars | |
3022 cmpd #$2822 Is it '("' (RUNB variables ahead?) | |
3023 beq L1546 Yes, skip ahead (we won't have to add them) | |
3024 lda #C$SPAC No, add ' ("' | |
3025 sta ,y+ | |
3026 ldd #$2822 | |
3027 std ,y++ | |
3028 L151F bsr L154B Copy buffer up to next param (or end of line) | |
3029 beq L152E If end of line, add '")' (close params) | |
3030 ldd #$222C Add '","' (Basic09 param separators | |
3031 std ,y++ | |
3032 lda #$22 2nd quote of above | |
3033 sta ,y+ | |
3034 bra L151F Keep doing for all parameters | |
3035 | |
3036 L152E ldd #$2229 Add '")' to end parameter list | |
3037 std ,y++ | |
3038 lda #C$CR Add CR | |
3039 L1535 sta ,y+ | |
3040 tfr y,d Move end of param ptr to D | |
3041 leay >u0418,u Point to start of param | |
3042 sty <u0008 Save as start ptr | |
3043 subd <u0008 Calculate param size | |
3044 std <u0006 Save it | |
3045 L1546 puls y,x Restore data area size & primary module ptr | |
3046 lbra L15D5 | |
3047 | |
3048 * Copy from X to Y until either a CR or a space char is hit | |
3049 * If it finds a space, it will eat them until the next non-space char is found | |
3050 L154B lda ,x+ Get char | |
3051 cmpa #C$SPAC Is it a space? | |
3052 * Was L155B | |
3053 beq L1559 yes, skip ahead | |
3054 cmpa #C$CR Is it the end of the line? | |
3055 beq L155F Yes, bump ptr back to CR & exit | |
3056 sta ,y+ Save the char | |
3057 bra L154B Keep doing it | |
3058 | |
3059 L1559 lda ,x+ Get char | |
3060 L155B cmpa #C$SPAC Is it another space? | |
3061 beq L1559 Yes, keep eating spaces | |
3062 L155F leax -$01,x Bump ptr back to either non-space or CR | |
3063 cmpa #C$CR Is it a CR? & return | |
3064 rts | |
3065 | |
3066 * THIS CMPB / LBEQ SEEMS TO BE USELESS, AS B IS ALWAYS CLEAR COMING INTO THIS | |
3067 * ROUTINE | |
3068 L1564 cmpb #E$BMode | |
3069 lbeq L162B | |
3070 ldx <u0006 Get size of current group | |
3071 leax 5,x Bump it up by 5??? | |
3072 stx <u0006 Save new size | |
3073 tst <u0060 Data module linked? | |
3074 bne L1592 Yes, skip ahead | |
3075 ldx <u0004 Get module name ptr | |
3076 ldu 4,s | |
3077 lbsr L0BFA Set up paths | |
3078 lbcs L162B If error, exit with it | |
3079 bra L1592 Start up shell with '-P X PATH=(current)' | |
3080 | |
3081 * L1581 is for sub-shells (?), L1586 for normal shells | |
3082 L1581 fcc '-P X ' Prompting off/exit on error | |
3083 L1586 fcc 'PATH= ' For inheriting parent shell's paths | |
3084 fcb C$CR | |
3085 | |
3086 L158D leax <L1586,pc Point to 'path=' | |
3087 bra L1595 Skip ahead | |
3088 | |
3089 L1592 leax <L1581,pc Point to '-p x ' | |
3090 L1595 leay >u166D,u Point to about-to-be merged buffer | |
3091 lbsr L1320 Copy up until CR | |
3092 leay -1,y Point to CR | |
3093 leax >u0CDD,u Point to copy of current path= | |
3094 * Copy all paths to buffer, changing <CR> separated ones with Spaces | |
3095 L15A2 lda ,x Get char | |
3096 cmpa #C$CR CR? | |
3097 beq L15B1 Yes, don't copy this buffer | |
3098 lbsr L1320 Copy up until CR | |
3099 lda #C$SPAC Replace CR with Space | |
3100 sta -1,y | |
3101 bra L15A2 Continue copying CR marked blocks until done | |
3102 L15B1 lda #'; Replace final CR with ; (command separator) | |
3103 sta -1,y | |
3104 tst <u0060 | |
3105 beq L15BE | |
3106 ldd #'M*256+'= If flag set, append 'M=' | |
3107 std ,y++ | |
3108 L15BE ldx <u0008 Get ptr to start of current group | |
3109 lbsr L1320 Copy up until CR | |
3110 leax >u166D,u Point to merged buffer again | |
3111 stx <u0008 Make it the new current group start | |
3112 tfr y,d Move end buffer ptr to D | |
3113 pshs x Push merged buffer ptr for SUBD | |
3114 subd ,s++ Calculate size of merged buffer | |
3115 std <u0006 Save merged buffer size | |
3116 leax >L000D,pc Point to 'shell' | |
3117 | |
3118 L15D5 stx <u0004 Save ptr to module name to fork | |
3119 L15D7 ldx <u0004 Get ptr to module name to fork | |
3120 lda #Prgrm+Objct | |
1505 | 3121 IFGT Level-1 |
714 | 3122 os9 F$NMLink Get memory requirement stuff from it |
1505 | 3123 ELSE |
3124 pshs u | |
3125 os9 F$Link Get memory requirement stuff from it | |
3126 tfr u,y | |
3127 puls u | |
3128 ENDC | |
714 | 3129 bcc L15E5 Got it, continue |
1505 | 3130 IFGT Level-1 |
714 | 3131 os9 F$NMLoad Couldn't get, try loading it |
1505 | 3132 ELSE |
3133 pshs u | |
3134 os9 F$Load Couldn't get, try loading it | |
3135 tfr u,y | |
3136 puls u | |
3137 ENDC | |
714 | 3138 bcs L162B Still couldn't get, can't fork |
1505 | 3139 L15E5 |
3140 IFEQ Level-1 | |
3141 ldy M$Mem,y | |
3142 ENDC | |
3143 tst <u0003 Memory size specified? | |
714 | 3144 bne L15F2 Yes, skip ahead |
3145 tfr y,d No, tfr modules mem size to D | |
3146 addd <u000A ??? Add to something | |
3147 addd #$00FF Round up to nearest page | |
3148 sta <u0003 Save # of pages need for data mem | |
3149 L15F2 clr ,-s Clear byte on stack to store original priority | |
3150 ldb <u0022 Get priority we want to set new program at | |
3151 beq DnePrior 0=Use inherited priority, skip ahead | |
1505 | 3152 IFEQ Level-1 |
3153 ldx <D.Proc | |
3154 ELSE | |
714 | 3155 leax >u166D,u Point to place to hold Process descriptor |
3156 os9 F$ID Get our process # | |
3157 os9 F$GPrDsc Get our process descriptor | |
1505 | 3158 ENDC |
714 | 3159 ldb P$Prior,x Get our priority |
3160 stb ,s Save it | |
3161 ldb <u0022 Get priority for new process | |
3162 os9 F$SPrior Set our priority so child will inherit it | |
3163 DnePrior lbsr L130A Go setup Fork entry registers | |
3164 os9 F$Fork Create the new process | |
3165 pshs d,cc Preserve error (if any) & new process # | |
3166 ldb 3,s Get original priority back | |
3167 beq L1609 Priority didn't change, ignore it | |
3168 os9 F$ID Get our process # into A | |
3169 os9 F$SPrior Reset our priority back to normal | |
3170 L1609 lda #Prgrm+Objct Std 6809 module | |
3171 ldx <u0010 Get ptr to some other module name (?) | |
3172 bne L1611 There is one, unlink it instead | |
3173 ldx <u0004 Get ptr to command name | |
1505 | 3174 L1611 |
3175 IFGT Level-1 | |
3176 os9 F$UnLoad Bump link count down back to normal? | |
3177 ELSE | |
3178 pshs a,b,x,y,u | |
3179 os9 F$Link | |
3180 os9 F$Unlink | |
3181 os9 F$Unlink | |
3182 puls a,b,x,y,u | |
3183 ENDC | |
714 | 3184 clra |
3185 clrb | |
3186 std <u0010 Zero out other module name ptr | |
3187 std <u0004 Clear out ptr to main command name | |
3188 lda <u0060 Check if data module needs to be unlinked too | |
3189 cmpa #$01 Just 1 link to it? | |
3190 bne L1627 No, skip ahead | |
3191 lda #Data Data module | |
3192 ldx <u0061 Get ptr to name of data module | |
1505 | 3193 IFGT Level-1 |
714 | 3194 os9 F$UnLoad Bump link count down back to normal |
1505 | 3195 ELSE |
3196 pshs a,b,x,y,u | |
3197 os9 F$Link | |
3198 os9 F$Unlink | |
3199 os9 F$Unlink | |
3200 puls a,b,x,y,u | |
3201 ENDC | |
714 | 3202 L1627 puls cc,d Get back F$FORK error/process # |
3203 leas 1,s Eat priority byte | |
3204 puls pc,u,y,x Restore regs & return | |
3205 | |
3206 L1629 ldb #E$NEMod Non-existing module error | |
3207 L162B coma | |
3208 puls pc,u,y,x | |
3209 | |
3210 L162E fcc '/pipe' | |
3211 fcb C$CR | |
3212 | |
3213 L1634 pshs x | |
3214 leax <L162E,pc Point to '/pipe' | |
3215 ldd #$0103 | |
3216 lbsr L0C0E | |
3217 puls x | |
3218 bcs L169E | |
3219 lbsr L1459 | |
3220 bcs L169E | |
3221 lda ,u | |
3222 bne L1653 | |
3223 os9 I$Dup | |
3224 bcs L169E | |
3225 sta ,u | |
3226 L1653 clra | |
3227 os9 I$Close | |
3228 lda #$01 | |
3229 os9 I$Dup | |
3230 lda #$01 | |
3231 lbsr L0BA8 | |
3232 lda #$02 | |
3233 lbra L0BA8 | |
3234 | |
3235 * Filename for shell log-append mode because of leading '+' | |
3236 L1666 fcc '+/dd/log/uxxx' | |
3237 fcb $0d | |
3238 | |
3239 * Make shell logging filename @ u0CBD,u | |
3240 L1674 leax <L1666,pc Point to log name string (append mode) | |
3241 leay >u0CBD,u Point to buffer to hold shell log name | |
3242 lbsr L1320 Copy name to buffer | |
3243 leay -4,y Point to where 1st digit will go | |
3244 lda <u005A+1 Get LSB of user #? | |
3245 pshs y,x,d Preserve regs | |
3246 leay <L1693,pc Point to routine | |
3247 bra L16B9 Go convert digits & append to logname | |
3248 | |
3249 L168A lda <u0047 | |
3250 pshs y,x,d | |
3251 leay <L1693,pc | |
3252 bra L16B9 | |
3253 | |
3254 L1693 ldy $0B,s Get ptr to where shell log # goes | |
3255 ldd $03,s Get 1st 2 digits of # | |
3256 std ,y++ Save in shell log pathname | |
3257 lda $05,s Get last digit | |
3258 sta ,y Save it too | |
3259 L169E rts | |
3260 | |
3261 L169F ldd 4,s Get last 2 digits of process # (ASCII) | |
3262 std >u01EC,u Save it & return | |
3263 rts | |
3264 | |
3265 L16A6 pshs y,x,d Preserve End of parm ctr & others | |
3266 os9 F$ID Get user's ID # | |
3267 sty <u005A Save it | |
3268 leay <L169F,pc Point to routine | |
3269 bra L16B9 | |
3270 | |
3271 * Set up to write out process # when forked? | |
3272 L16B3 pshs y,x,d | |
3273 leay >L021B,pc | |
3274 | |
3275 * Entry: A=Process ID # | |
3276 * Exit: L01EC=2 lower digits of process # in ASCII format | |
3277 | |
3278 L16B9 pshs y,x,b Preserve regs | |
3279 leax 1,s Point X to X value on stack | |
3280 ldb #$2F Init B to start @ '0' in loop | |
3281 L16BF incb Bump ASCII # up | |
3282 suba #100 Start with 100's digit | |
3283 bhs L16BF More left, keep going | |
3284 stb ,x+ Save digit | |
3285 ldb #$3A Init so loop starts @ ASCII '9' | |
3286 L16C8 decb Bump ASCII # down | |
3287 adda #10 Do 10's digit | |
3288 bhs L16C8 Still more, keep going | |
3289 stb ,x+ Save 10's digit | |
3290 adda #$30 Bump 1's digit up to ASCII equivalent | |
3291 ldb #C$CR Add carriage return | |
3292 std ,x Save overtop Y on the stack | |
3293 leax ,s Point X to B on stack | |
3294 jsr ,y | |
3295 leas 5,s Eat stack | |
3296 puls pc,y,x,d Restore other regs & return | |
3297 | |
3298 * KILL command | |
3299 L16DD bsr L16EB Go get process # to kill | |
3300 cmpb #2 Trying to kill the system process or 1st shell? | |
3301 bls L170A Yes, print 'WHAT?' & ignore it | |
3302 tfr b,a Move process # to proper reg | |
3303 L16E5 clrb S$Kill signal | |
3304 os9 F$Send Send it to the process & return | |
3305 rts | |
3306 | |
3307 * Set priority - subroutine to calculate binary version of # | |
3308 * (used for both process # & priority values) | |
3309 L16EB clrb Initialize # for loop | |
3310 L16EC lda ,x+ This loop will calculate the binary version | |
3311 suba #$30 Of the ASCII # pointed to by X | |
3312 cmpa #9 | |
3313 bhi L16FD | |
3314 pshs a | |
3315 lda #10 | |
3316 mul | |
3317 addb ,s+ | |
3318 bcc L16EC Keep going until overflows past 255 | |
3319 L16FD lda ,-x Get last char done | |
3320 bcs L1708 If #>255, eat RTS & exit with error | |
3321 tst <u0014 If flag is set, return | |
3322 bne L169E | |
3323 tstb Otherwise, check if # is 0 | |
3324 bne L169E No, return | |
3325 L1708 leas 2,s Yes, eat RTS address & exit with error | |
3326 L170A lbra L0BCF Print 'WHAT?' | |
3327 * SETPR routine | |
3328 L170D bsr L16EB Go calculate process # | |
3329 stb <u0021 Save it | |
3330 lbsr L0907 Find next field (after commas/spaces) | |
3331 bsr L16EB Go calculate priority (into B) | |
3332 lda <u0021 Get process # | |
3333 os9 F$SPrior Set it's priority & return | |
3334 rts | |
3335 | |
3336 L171C fcc 'pwd: bad name in path' | |
3337 fcb C$CR | |
3338 L1732 fcc '.......................................' | |
3339 L1759 fcc '.' | |
3340 fcb C$CR | |
3341 L175B fcc 'pwd: read error' | |
3342 fcb C$CR | |
3343 | |
3344 L176B clr <u003D | |
3345 L176D pshs y,x | |
3346 leay >u02F2,u | |
3347 lda #$81 | |
3348 tst <u0037 | |
3349 beq L178F | |
3350 ldx <u0039 | |
3351 bra L17F7 | |
3352 * .PXD command | |
3353 L177D clr <u003D | |
3354 pshs y,x | |
3355 leay >u0375,u | |
3356 lda #$85 | |
3357 tst <u0038 | |
3358 beq L178F | |
3359 ldx <u003B | |
3360 bra L17F7 | |
3361 L178F sta <u0029 | |
3362 sty <u003E | |
3363 L1794 leax >$0080,y | |
3364 lda #$0D | |
3365 sta ,x | |
3366 stx <u002A | |
3367 leax <L1759,pc | |
3368 stx <u0040 | |
3369 bsr L1801 | |
3370 lbsr L183C | |
3371 L17A9 ldd <u002C | |
3372 std <u0032 | |
3373 lda <u002E | |
3374 sta <u0034 | |
3375 bsr L1828 | |
3376 beq L17D3 | |
3377 lda <u0012 | |
3378 os9 I$Close | |
3379 lbcs L188C | |
3380 ldx <u0040 | |
3381 leax -$01,x | |
3382 stx <u0040 | |
3383 bsr L1801 | |
3384 bsr L183C | |
3385 bsr L1817 | |
3386 leax >u03F8,u | |
3387 lbsr L1859 | |
3388 bra L17A9 | |
3389 L17D3 lda <u0012 | |
3390 ldb #SS.DevNm | |
3391 leax >u00B5,u | |
3392 os9 I$GetStt Get device name | |
3393 bsr L1859 | |
3394 L17E0 lda <u0012 | |
3395 os9 I$Close | |
3396 ldx <u002A | |
3397 lda <u0029 | |
3398 bita #$04 | |
3399 bne L17F3 | |
3400 inc <u0037 | |
3401 stx <u0039 | |
3402 bra L17F7 | |
3403 L17F3 inc <u0038 | |
3404 stx <u003B | |
3405 L17F7 ldy #$0083 | |
3406 lda #$01 | |
3407 clrb | |
3408 lbra L18A0 | |
3409 L1801 lda <u0029 | |
3410 os9 I$Open | |
3411 sta <u0012 | |
3412 rts | |
3413 L1809 lda <u0012 | |
3414 leax >u03F8,u | |
3415 ldy #$0020 | |
3416 os9 I$Read | |
3417 rts | |
3418 L1817 bsr L1809 | |
3419 bcs L1896 | |
3420 leax >u0415,u | |
3421 leay >u0032,u | |
3422 bsr L1830 | |
3423 bne L1817 | |
3424 rts | |
3425 L1828 leax >u002C,u | |
3426 leay >u002F,u | |
3427 L1830 ldd ,x++ | |
3428 cmpd ,y++ | |
3429 bne L183B | |
3430 lda ,x | |
3431 cmpa ,y | |
3432 L183B rts | |
3433 L183C bsr L1809 | |
3434 ldd >u0415,u | |
3435 std <u002F | |
3436 lda >u0417,u | |
3437 sta <u0031 | |
3438 bsr L1809 | |
3439 ldd >u0415,u | |
3440 std <u002C | |
3441 lda >u0417,u | |
3442 sta <u002E | |
3443 rts | |
3444 L1859 os9 F$PrsNam | |
3445 bcs L1890 | |
3446 ldx <u002A | |
3447 pshs b | |
3448 incb | |
3449 clra | |
3450 std <u0032 | |
3451 tfr x,d | |
3452 subd <u0032 | |
3453 cmpd <u003E | |
3454 bls L1881 | |
3455 puls b | |
3456 L1871 lda ,-y | |
3457 anda #$7F | |
3458 sta ,-x | |
3459 decb | |
3460 bne L1871 | |
3461 lda #$2F | |
3462 sta ,-x | |
3463 stx <u002A | |
3464 rts | |
3465 | |
3466 L1881 lda #'* | |
3467 sta ,-x | |
3468 stx <u002A | |
3469 leas 3,s | |
3470 lbra L17E0 | |
3471 | |
3472 L188C pshs b,cc | |
3473 bra L18AB | |
3474 | |
3475 L1890 leax >L171C,pc | |
3476 bra L189A | |
3477 | |
3478 L1896 leax >L175B,pc | |
3479 L189A leas $02,s | |
3480 ldd #$02FF | |
3481 L18A0 stx <u002A | |
3482 pshs b,cc | |
3483 tst <u003D | |
3484 bne L18AB | |
3485 os9 I$WritLn | |
3486 L18AB puls b,cc | |
3487 puls y,x,pc | |
3488 | |
3489 L18DB leax >u0124,u Point to PD.OPT work copy area | |
3490 clrb Change to CLRB | |
3491 os9 I$GetStt Get current PD.OPT settings | |
3492 tst ,x Check device type | |
3493 bne L1914 If not SCF, don't bother changing stuff | |
3494 inc >u1812,u Set flag that we are changing key defs | |
3495 ldd <$10,x Get PD.INT & PD.QUT chars (<CTRL>-<C> & <E>) | |
3496 sta >u180F,u Save copy of PD.INT | |
3497 stb >u180E,u Save copy of PD.QUT | |
3498 ldd #$0A0C Reload with up & down arrows | |
3499 std <$10,x Save 'em | |
3500 lda $06,x Get PD.NUL count (normally 0) | |
3501 sta >u1811,u Save copy | |
3502 lda #$05 Replace with 5 | |
3503 sta $06,x | |
3504 clra | |
3505 clrb Reset path options to new settings | |
3506 os9 I$SetStt Do SS.OPT Setstat | |
3507 | |
3508 * Non-SCF devices go here (ex. a script file would be RBF) | |
3509 L1914 ldb #SS.SSig Send signal on data ready | |
3510 ldx #$000B Signal code to send is $B | |
3511 rts Do SetStt, clear <E signal copy, and go to L191C | |
3512 | |
3513 * X still is $B from L1914 | |
3514 * Called when F$Sleep @ L0171 is interrupted by keyboard/mouse signal | |
3515 L191C ldb <u000E Get Signal code | |
3516 clr <u000E Clear memory copy of signal code | |
3517 cmpb #S$Abort Keyboard abort signal (<CTRL>-<E>)? | |
3518 bne L1928 No, check next | |
3519 bsr L1932 Write CR out if no history yet | |
3520 bra L1967 Go backwards in history | |
3521 | |
3522 L1928 cmpb #S$Intrpt Keyboard interrupt signal (<CTRL>-<C>)? | |
3523 lbne L017B No check for $B signal (ignore rest) | |
3524 bsr L1932 Write CR out if no history yet | |
3525 bra L1991 Go forwards in history | |
3526 | |
3527 * Keyboard abort or Keyboard interrupt signal | |
3528 L1932 tst >u180D,u Any history entries yet? | |
3529 bne L193D Yes, exit | |
3530 bsr L1959 Otherwise, put CR into the buffer | |
3531 os9 I$WritLn Write it out to standard out | |
3532 L193D rts | |
3533 | |
3534 L193E os9 I$ReadLn Read in line | |
3535 bcc L194E No error, skip ahead | |
3536 * NOTE: WHEN THE ABORT A SUB-FORKED PROGRAM BUG OCCURS, THE ABOVE READLN | |
3537 * EXITS WITH CARRY SET & B=0 (ERROR 0) | |
3538 cmpb #$02 Go backward in history buffer signal? | |
3539 beq L1967 Yes, go process | |
3540 cmpb #$03 Go forward in history buffer signal? | |
3541 beq L1991 Yes, go process | |
3542 lbra L1AAA Go to parse routine with unknown error in B | |
3543 L194E cmpy #$0001 Just 1 char. read? | |
3544 lbeq L1AA3 Yes, go do normal parsing (no error) | |
3545 lbra L1A37 Otherwise, change chars <$0D to spaces | |
3546 | |
3547 * Change A to be standard output??? | |
3548 L1959 lda #C$CR Carriage return | |
3549 leax >u0124,u ??? Point to a buffer | |
3550 sta ,x Save CR there | |
3551 clra Prepare to write the CR out to standard input | |
3552 ldy #$0001 | |
3553 rts | |
3554 * PD.QUT (redefined to be go back 1 in history buffer) | |
3555 L1967 tst >u180C,u Any lines in history buffer? | |
3556 bne L1972 Yes, go move between them | |
3557 bsr L1959 Otherwise, put CR into buffer | |
3558 lbra L1AA3 Go to normal command parse routine (no error) | |
3559 | |
3560 L1972 ldb >u180D,u Get 'current' history buffer entry # | |
3561 cmpb #$01 On the first one? | |
3562 bls L1987 Yes, go wrap to end | |
3563 cmpb >u180C,u Somehow point past last one? | |
3564 bhi L1987 Yes, bump back to last one | |
3565 decb Bump to previous one | |
3566 stb >u180D,u Save it as 'current' history entry # | |
3567 bra L19B3 | |
3568 | |
3569 L1987 ldb >u180C,u Get highest history entry # | |
3570 stb >u180D,u Make it the current | |
3571 bra L19B3 | |
3572 | |
3573 * PD.INT (redefined to be go forward 1 in history buffer) | |
3574 L1991 tst >u180C,u Any lines in history buffer? | |
3575 bne L199C Yes, go move between them | |
3576 bsr L1959 Otherwise, put CR into buffer | |
3577 lbra L1AA3 Go to normal command parse routine (no error) | |
3578 | |
3579 L199C ldb >u180D,u Get current history entry # | |
3580 cmpb >u180C,u Higher or same as last one? | |
3581 bhs L19AD Yes, wrap to beginning | |
3582 incb Bump to next one | |
3583 stb >u180D,u Save it as 'current' history entry # | |
3584 bra L19B3 | |
3585 | |
3586 L19AD ldb #$01 Set history entry # to 1st one | |
3587 stb >u180D,u Save as 'current' entry # | |
3588 L19B3 bsr L19D3 Go get ptr to history entry buffer we want | |
3589 sty >u1813,u Save 'current' history buffer ptr | |
3590 leax >u0213,u Point to expanded shell prompt | |
3591 ldy >u01F7,u Get size of expanded shell prompt | |
3592 lda #$02 Std Err | |
3593 os9 I$WritLn Write out shell prompt | |
3594 bsr L19EA Go Pre-load Read buffer with history entry | |
3595 bcc L1A0E No error, continue | |
3596 lbra L1AAA Normal parse with error | |
3597 | |
3598 * Find history entry # we want | |
3599 * Entry: B=history entry # (1-xx) | |
3600 * Exit: Y=Ptr to history buffer entry we wanted | |
3601 L19D3 ldy >u180A,u Get ptr to start of history buffers | |
3602 L19D8 decb Bump down counter to find entry we want | |
3603 beq L19E9 Found it, skip ahead | |
3604 L19DB tst ,y+ Wrong one, search for end of one we are checking | |
3605 beq L19E4 Found it, skip ahead | |
3606 lbsr L1A97 Wrap buffer ptr if we hit end of all history | |
3607 bra L19DB Keep searching for end of current entry | |
3608 | |
3609 L19E4 lbsr L1A97 Wrap buffer ptr if we hit end of all history | |
3610 bra L19D8 Go into next entry in history buffers | |
3611 | |
3612 L19E9 rts Found it, leave | |
3613 | |
3614 L19EA leax >u0124,u Point to temp buffer | |
3615 ldy >u1813,u Get ptr to current history buffer | |
3616 clrb Set counter to 0 (size of buffer) | |
3617 L19F4 lda ,y+ Get char from history buffer | |
3618 beq L1A00 Found end, continue | |
3619 sta ,x+ Put it in temp buffer | |
3620 incb Bump up size counter | |
3621 lbsr L1A97 Wrap buffer ptr if we hit end of all history | |
3622 bra L19F4 Continue copying into temp buffer | |
3623 L1A00 clra D=Size of history buffer | |
3624 decb | |
3625 tfr d,y Move to proper register | |
3626 leax >u0124,u Point to buffer history copy | |
3627 ldb #SS.Fill Fill it with current selected history command | |
3628 os9 I$SetStt | |
3629 rts | |
3630 | |
3631 * Successfull SS.Fill of history buffer goes here | |
3632 L1A0E lda #$01 Write copy of history buffer to std out | |
3633 os9 I$Write | |
3634 leax >u0124,u Point to current history buffer again | |
3635 tfr y,d Transfer # bytes written to D | |
3636 lda #C$BSP Backspace char | |
3637 L1A1B sta ,x+ Fill buffer with backspaces | |
3638 decb | |
3639 bne L1A1B | |
3640 leax >u0124,u Write them to reset cursor to start of line | |
3641 lda #$01 | |
3642 os9 I$Write | |
3643 ldd #SS.Relea Eat keyboard signal (SS.Fill cleared it out of | |
3644 os9 I$SetStt the read buffer already) | |
3645 ldb #SS.SSig Setup for re-enabling it | |
3646 ldx #$000B Signal Code to send on keypress=$B | |
3647 lbra L016A Go re-enable signal send on keyboard/mouse input | |
3648 | |
3649 * Put new entry into history buffers, adjusting # used, etc.) | |
3650 * Entry: Y=# bytes read in ReadLn <>1 | |
3651 L1A37 pshs y Preserve # bytes read | |
3652 tfr y,d Move to D reg | |
3653 ldy >u1808,u Get ptr to where next history entry will go | |
3654 leax >u0124,u Point to line entered by user | |
3655 L1A44 lda ,x+ Get char | |
3656 cmpa #C$CR Control char <$0d? | |
3657 bhs L1A4C No, save the character | |
3658 lda #C$SPAC Replace with space char if it is | |
3659 L1A4C sta ,y+ Save char into history buffer | |
3660 bsr L1A97 Wrap to beginning if we hit end | |
3661 cmpy >u180A,u Point to entry #1? | |
3662 bne L1A59 No, continue | |
3663 bsr L1A7B Yes, make new #1 entry & drop # of entries | |
3664 L1A59 decb Drop # bytes left in new entry | |
3665 bne L1A44 Not done, continue | |
3666 clr ,y+ mark end with NUL | |
3667 bsr L1A97 Wrap to beginning if at end | |
3668 cmpy >u180A,u Pointing to entry #1? | |
3669 bne L1A69 No, skip ahead | |
3670 bsr L1A7B Yes, make new #1 entry & drop # of entries | |
3671 L1A69 inc >u180C,u Increase # of entries | |
3672 sty >u1808,u Save ptr to where next history entry will go | |
3673 puls y Restore # bytes read | |
3674 clra Point to temp buffer again | |
3675 leax >u0124,u | |
3676 bra L1AA3 Normal parse, no error | |
3677 | |
3678 * Reset ptr to new 1st entry in history buffer | |
3679 L1A7B pshs y Preserve current location in history buffer | |
3680 ldy >u180A,u Point to start of 1st entry | |
3681 L1A82 tst ,y+ End of current entry? | |
3682 beq L1A8A Yes, skip ahead | |
3683 bsr L1A97 No, wrap if we need to | |
3684 bra L1A82 Keep going until we find end | |
3685 L1A8A bsr L1A97 Wrap if we need to | |
3686 dec >u180C,u Dec # lines in history buffer | |
3687 sty >u180A,u Save new 'start of history' ptr | |
3688 puls pc,y Restore current location & return | |
3689 * If we are at end of history buffers, wrap to beginning (raw, has nothing to | |
3690 * do with entry #'s) | |
3691 L1A97 cmpy >u1806,u Are we at end of buffer for history entries? | |
3692 bne L1AA2 No, continue on | |
3693 leay >u1815,u Yes, reset to beginning of history buffers | |
3694 L1AA2 rts | |
3695 | |
3696 L1AA3 bsr L1AB1 Reset std paths to normal <CTRL>-<E>/<C> settings | |
3697 andcc #^Carry No error | |
3698 lbra L018B Normal command processing | |
3699 | |
3700 L1AAA bsr L1AB1 Reset std paths to normal <CTRL>-<E>/<C> settings | |
3701 orcc #Carry Error | |
3702 lbra L018B Normal command processing | |
3703 | |
3704 * Reset all 3 standard paths' NUL counts/Keyboard Interrupt/Terminate settings | |
3705 L1AB1 pshs x,d Preserve regs | |
3706 tst >u1812,u Check flag | |
3707 beq L1AD6 If 0 skip ahead | |
3708 leas <-PD.OPT,s Make 32 byte buffer on stack | |
3709 leax ,s Point X to buffer | |
3710 clrb CHANGE TO CLRB | |
3711 clra Standard input path | |
3712 bsr L1AD8 Restore NUL counts, Keyboard Intrpt/Terminate | |
3713 lda #$01 Do same for Standard output path | |
3714 bsr L1AD8 | |
3715 lda #$02 Do same for Standard Error path | |
3716 bsr L1AD8 | |
3717 leas <PD.OPT,s Eat stack buffer | |
3718 clr >u1812,u Reset PD.OPT flags to 0 | |
3719 clr >u180D,u | |
3720 L1AD6 puls pc,x,d Restore regs & return | |
3721 | |
3722 * Restore path options to preserved Keyboard terminate/interrupt & end of | |
3723 * line NUL counts | |
3724 L1AD8 pshs a Preserve path # | |
3725 os9 I$GetStt Get current PD.OPT settings | |
3726 lda >u180E,u Get copy of Keyboard terminate char | |
3727 sta <PD.QUT-PD.OPT,x Save into buffered copy | |
3728 lda >u180F,u Get copy of Keyboard interrupt char | |
3729 sta <PD.INT-PD.OPT,x Save into buffered copy | |
3730 lda >u1811,u Get copy of end of line NUL count | |
3731 sta $6,x Save into buffered copy | |
3732 puls a Get path # back | |
3733 os9 I$SetStt Reset path options with restored values & return | |
3734 rts | |
3735 | |
3736 emod | |
3737 eom equ * | |
3738 end | |
3739 |