Mercurial > hg > Members > kono > nitros9-code
annotate level1/cmds/dump.asm @ 1211:f54f04a78c54
Rodney Hamilton fixes
author | boisy |
---|---|
date | Mon, 23 Jun 2003 17:45:27 +0000 |
parents | b8608857a4a2 |
children | 84ea83668304 |
rev | line source |
---|---|
0 | 1 ******************************************************************** |
2 * Dump - Show file contents in hex | |
3 * | |
4 * $Id$ | |
5 * | |
945 | 6 * Dump follows the function of the original Microware version but now |
7 * supports large files over 64K, and is free from the problems of garbage | |
8 * in wide listings. | |
9 * | |
10 * In addition it now allows dumping of memory modules and command modules | |
11 * in the execution directory. | |
12 * | |
1211 | 13 * Ed. Comments Who YY/MM/DD |
0 | 14 * ------------------------------------------------------------------ |
1211 | 15 * 5 From Tandy OS-9 Level One VR 02.00.00 |
16 * 6 Incorporated R. Telkman's additions from 1987, BGP 02/12/23 | |
17 * added -d option, added defs to conditionally | |
18 * assemble without help or screen size check | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
19 * |
1211 | 20 * Removed -d option BGP 03/01/17 |
21 * Narrow screen now shows properly, only dumps BGP 03/01/21 | |
22 * 16 bits worth of address data to make room. | |
23 * Fixed bug where header would be shown even if BGP 03/03/03 | |
24 * there was no data in a file. | |
25 * 7 Restored Rubout processing for terminals RVH 03/06/06 | |
0 | 26 |
1211 | 27 nam Dump |
28 ttl Show file contents in hex | |
0 | 29 |
1211 | 30 ifp1 |
31 use defsfile | |
32 endc | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
33 |
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
34 * Tweakable options |
1211 | 35 DOSCSIZ set 1 1 = include SS.ScSiz code, 0 = leave out |
36 DOHELP set 0 1 = include help message, 0 = leave out | |
37 BUFSZ set 80 | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
38 |
1211 | 39 tylg set Prgrm+Objct |
40 atrv set ReEnt+rev | |
41 rev set 1 | |
42 edition set 7 | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
43 |
1211 | 44 org 0 |
45 nonopts rmb 1 | |
46 D.Prm rmb 2 | |
47 D.Hdr rmb 1 | |
48 D.Mem rmb 1 | |
49 IFNE DOSCSIZ | |
50 narrow rmb 1 | |
51 ENDC | |
52 Mode rmb 1 | |
53 D.Opn rmb 1 | |
54 D.Beg rmb 2 | |
55 D.End rmb 2 | |
56 D.Adr rmb 4 | |
57 D.Len rmb 2 | |
58 D.Ptr rmb 2 | |
59 D.Txt rmb 2 | |
60 Datbuf rmb 16 | |
61 Txtbuf rmb BUFSZ | |
62 rmb 128 | |
63 datsz equ . | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
64 |
1211 | 65 mod length,name,tylg,atrv,start,datsz |
0 | 66 |
1211 | 67 name fcs /Dump/ |
68 fcb edition | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
69 |
1211 | 70 title fcc /Address 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 2 4 6 8 A C E/ |
71 titlelen equ *-title | |
72 caret fcb C$CR | |
73 flund fcc /-------- ---- ---- ---- ---- ---- ---- ---- ---- ----------------/ | |
74 fcb C$CR | |
75 IFNE DOSCSIZ | |
76 short fcc / 0 1 2 3 4 5 6 7 0 2 4 6/ | |
77 fcb C$LF | |
78 fcc /Addr 8 9 A B C D E F 8 A C E/ | |
79 fcb C$CR | |
80 shund fcc /==== +-+-+-+-+-+-+-+- +-+-+-+-/ | |
81 fcb C$CR | |
82 ENDC | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
83 |
1211 | 84 start stx <D.Prm |
85 clra | |
86 sta <D.Hdr | |
87 sta <D.Mem | |
88 sta <nonopts assume no non-opts | |
89 inca | |
90 sta <Mode READ. | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
91 |
1211 | 92 IFNE DOSCSIZ |
93 clr <narrow assume wide | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
94 |
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
95 * Check screen size |
1211 | 96 ldb #SS.ScSiz |
97 os9 I$GetStt | |
98 bcs Pass1 | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
99 |
1211 | 100 cmpx #titlelen+1 |
101 bge PrePass | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
102 |
1211 | 103 sta <narrow |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
104 |
1211 | 105 PrePass ldx <D.Prm |
106 ENDC | |
0 | 107 |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
108 * Pass1 - process any options |
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
109 * Entry: X = ptr to cmd line |
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
110 Pass1 |
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
111 * Skip over spaces |
1211 | 112 lda ,x+ |
113 cmpa #C$SPAC | |
114 beq Pass1 | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
115 |
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
116 * Check for EOL |
1211 | 117 cmpa #C$CR |
118 beq Pass2 | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
119 |
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
120 * Check for option |
1211 | 121 cmpa #'- |
122 bne Pass1 | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
123 |
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
124 * Here, X points to an option char |
1211 | 125 OptPass lda ,x+ |
126 cmpa #C$SPAC | |
127 beq Pass1 | |
128 cmpa #C$CR | |
129 beq Pass2 | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
130 |
1211 | 131 anda #$DF |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
132 |
1211 | 133 IsItH cmpa #'H |
134 bne IsItM | |
0 | 135 |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
136 * Process H here |
1211 | 137 sta <D.Hdr |
138 bra OptPass | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
139 |
1211 | 140 IsItM cmpa #'M |
141 bne IsItX | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
142 |
1211 | 143 * Process M here |
144 sta <D.Mem | |
145 bra OptPass | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
146 |
1211 | 147 IsItX cmpa #'X |
148 bne ShowHelp | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
149 |
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
150 * Process X here |
1211 | 151 lda <Mode |
152 ora #EXEC. | |
153 sta <Mode | |
154 bra OptPass | |
155 | |
156 IFNE DOHELP | |
157 ShowHelp leax HelpMsg,pcr | |
158 lda #2 | |
159 ldy #HelpLen | |
160 os9 I$Write | |
161 bra ExitOk | |
162 ENDC | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
163 |
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
164 * Pass2 - process any non-options |
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
165 * Entry: X = ptr to cmd line |
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
166 Pass2 |
1211 | 167 ldx <D.Prm |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
168 Pass21 |
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
169 * Skip over spaces |
1211 | 170 lda ,x+ |
171 cmpa #C$SPAC | |
172 beq Pass21 | |
173 cmpa #'- | |
174 bne Pass22 | |
0 | 175 |
1211 | 176 EatOpts lda ,x+ |
177 cmpa #C$SPAC | |
178 beq Pass21 | |
179 cmpa #C$CR | |
180 bne EatOpts | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
181 |
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
182 * Check for EOL |
1211 | 183 Pass22 cmpa #C$CR |
184 beq EndOfL | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
185 |
1211 | 186 Call leax -1,x |
187 sta nonopts,u | |
188 bsr DumpFile | |
189 bra Pass21 | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
190 |
1211 | 191 EndOfL tst <nonopts any non-options on cmd line? |
192 bne ExitOk | |
193 tst <D.Mem memory option specified? | |
194 bne ShowHelp yes, no module specified, show help | |
195 clra stdin | |
196 bsr DumpIn | |
197 IFEQ DOHELP | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
198 ShowHelp |
1211 | 199 ENDC |
200 ExitOk clrb | |
201 DoExit os9 F$Exit | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
202 |
1211 | 203 mlink clra |
204 pshs u | |
205 os9 F$Link | |
206 stu <D.Beg | |
207 puls u | |
208 bcc DumpIn | |
209 bra DoExit | |
0 | 210 |
1211 | 211 DumpFile tst <D.Mem |
212 bne mlink | |
213 lda <Mode | |
214 opath tfr x,y | |
215 os9 I$Open | |
216 bcc DumpIn | |
217 tfr y,x | |
218 ora #DIR. try directory mode | |
219 os9 I$Open open it | |
220 bcs DoExit branch if error | |
221 DumpIn stx <D.Prm | |
222 sta <D.Opn | |
223 ldx <D.Beg | |
224 ldd M$Size,x | |
225 leax d,x | |
226 stx <D.End | |
227 clra | |
228 clrb | |
229 tfr d,x | |
230 onpas std <D.Adr+2 | |
231 bcc notbg | |
232 leax 1,x | |
233 notbg stx <D.Adr | |
234 tst <D.Hdr | |
235 bne nohed | |
236 IFNE DOSCSIZ | |
237 tst <narrow | |
238 beq flpag | |
239 aslb | |
240 ENDC | |
241 flpag tstb | |
242 bne nohed | |
243 lbsr iseof | |
244 bcc flpag2 | |
245 ldx <D.Prm | |
246 rts | |
247 flpag2 leax caret,pcr | |
248 lbsr print | |
249 ldb #16 | |
250 leax title,pcr | |
251 leay flund,pcr | |
252 IFNE DOSCSIZ | |
253 tst <narrow | |
254 beq doprt | |
255 ldb #8 | |
256 leax short,pcr | |
257 leay shund,pcr | |
258 ENDC | |
259 doprt pshs y | |
260 clra | |
261 std <D.Len | |
262 bsr print | |
263 puls x | |
264 bsr print | |
265 nohed leax Txtbuf,u | |
266 stx <D.Ptr | |
267 ldb <D.Len+1 | |
268 lda #3 | |
269 mul | |
270 addd #2 | |
271 IFNE DOSCSIZ | |
272 tst <narrow | |
273 beq leayit | |
274 subd #4 | |
275 ENDC | |
276 leayit leay d,x | |
277 sty <D.Txt | |
278 lda #C$SPAC | |
279 ldb #BUFSZ-1 | |
280 clbuf sta b,x | |
281 decb | |
282 bpl clbuf | |
283 ldb #D.Adr | |
284 IFNE DOSCSIZ | |
285 tst <narrow | |
286 beq adlop | |
287 incb we skip first two bytes ... | |
288 incb ... if on a narrow screen | |
289 ENDC | |
290 adlop lda b,u | |
291 lbsr onbyt | |
292 incb | |
293 cmpb #D.Adr+4 | |
294 bne adlop | |
295 ldx <D.Ptr | |
296 leax 1,x | |
297 stx <D.Ptr | |
298 bsr readi | |
299 bcs eofck | |
300 onlin lbsr onchr | |
301 decb | |
302 ble enlin | |
303 lbsr onchr | |
304 decb | |
305 ble enlin | |
306 IFNE DOSCSIZ | |
307 tst <narrow | |
308 bne onlin | |
309 ENDC | |
310 lda #C$SPAC | |
311 lbsr savec | |
312 bra onlin | |
313 enlin lda #C$CR | |
314 ldx <D.Txt | |
315 sta ,x | |
316 leax Txtbuf,u | |
317 bsr print | |
318 ldd <D.Adr+2 | |
319 ldx <D.Adr | |
320 addd <D.Len | |
321 lbra onpas | |
322 print ldy #BUFSZ | |
323 lda #1 | |
324 os9 I$WritLn | |
325 lbcs DoExit | |
326 rts | |
327 readi ldy <D.Len | |
328 clrb | |
329 tst <D.Mem | |
330 bne redad | |
331 leax Datbuf,u | |
332 lda <D.Opn | |
333 os9 I$Read | |
334 bcs reded | |
335 tfr y,d | |
336 reded rts | |
1002 | 337 |
1211 | 338 redad bsr iseofm |
339 bcc setct | |
340 rts | |
341 setct subd <D.Len | |
342 bcs redof | |
343 clra | |
344 clrb | |
345 redof addd <D.Len | |
346 clr -1,s | |
347 leay d,x | |
348 sty <D.Beg | |
349 rts | |
1002 | 350 |
1211 | 351 eofck cmpb #E$EOF |
352 orcc #Carry | |
353 lbne DoExit | |
354 clrb | |
355 ldx <D.Prm | |
356 rts | |
0 | 357 |
1211 | 358 iseof tst <D.Mem |
359 bne iseofm | |
360 lda <D.Opn | |
361 ldb #SS.EOF | |
362 os9 I$GetStt | |
363 cmpb #E$EOF | |
364 beq iseofex | |
365 clrb | |
366 iseofok rts | |
367 iseofex orcc #Carry | |
368 ldb #E$EOF | |
369 rts | |
370 iseofm ldd <D.End | |
371 ldx <D.Beg | |
372 subd <D.Beg | |
373 beq iseofex | |
374 andcc #^Carry | |
375 rts | |
1002 | 376 |
1211 | 377 onibl anda #$0F |
378 cmpa #9 | |
379 bls nocom | |
380 adda #7 | |
381 nocom adda #'0 | |
382 savec pshs x | |
383 ldx <D.Ptr | |
384 sta ,x+ | |
385 stx <D.Ptr | |
386 puls x,pc | |
387 onchr lda ,x+ | |
388 bsr onbyt | |
389 pshs x,a | |
390 anda #$7F | |
391 cmpa #C$SPAC control char? | |
392 blo cntrl | |
393 cmpa #$7F rubout? | |
394 blo savet | |
395 cntrl lda #'. make printable | |
396 savet ldx <D.Txt | |
397 sta ,x+ | |
398 stx <D.Txt | |
399 puls a,x,pc | |
400 onbyt pshs a | |
401 lsra | |
402 lsra | |
403 lsra | |
404 lsra | |
405 bsr onibl | |
406 lda ,s | |
407 bsr onibl | |
408 puls a,pc | |
0 | 409 |
1211 | 410 IFNE DOHELP |
411 HelpMsg fcc "Use: Dump [opts] [<path>] [opts]" | |
412 fcb C$CR,C$LF | |
413 fcc " -h = no header" | |
414 fcb C$CR,C$LF | |
415 fcc " -m = module in memory" | |
416 fcb C$CR,C$LF | |
417 fcc " -x = file in exec dir" | |
418 fcb C$CR,C$LF | |
419 HelpLen equ *-HelpMsg | |
420 ENDC | |
660
a4d2474884b4
Edition 6 now supports -d, -m, -h and -x options, more robust command line
boisy
parents:
200
diff
changeset
|
421 |
1211 | 422 emod |
423 length equ * | |
424 end |