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