comparison level1/cmds/xmode.asm @ 963:7cecd837bcab

Added new commands as part of standard CMDS distribution
author boisy
date Fri, 31 Jan 2003 17:37:19 +0000
parents
children 64a0273a846a
comparison
equal deleted inserted replaced
962:8a0993b04c8a 963:7cecd837bcab
1 ********************************************************************
2 * EXMode - Extended SCF device descriptor utility
3 *
4 * $Id$
5 *
6 * Ed. Comments Who YY/MM/DD
7 * ------------------------------------------------------------------
8 * 1 Bruce Isted version released to PD BRI 89/06/21
9
10 nam EXMode
11 ttl Extended SCF device descriptor utility
12
13 ifp1
14 use defsfile
15 endc
16
17 BuffSize equ 10 max. CHAR string length
18 Edtn equ 1
19 MaxSize equ $80 maximum module size
20 NameSize equ 4 maximum module name length
21 Vrsn equ 1
22
23 org 0
24 Count rmb 1 number of option bytes
25 DataPtr rmb 2 current option ptr
26 HexIn rmb 2 2 byte hex number
27 ModAddr rmb 2 module address
28 ModSize rmb 2 module size
29 OptEnd rmb 2 option table end offset
30 ParmPtr rmb 2 next name DataPtr
31 PathNmbr rmb 1 file path
32 TxtPtr rmb 2 option name ptr
33 Buffer rmb BuffSize miscellaneous output buffer
34 ModBuff rmb MaxSize module work copy buffer
35 stack rmb $0200 stack and parameter space
36 MemSize equ .
37
38 mod Size,Name,Prgrm+Objct,ReEnt+Vrsn,Entry,MemSize
39
40 Name fcs "EXMode"
41 fcb Edtn edition number
42
43 OptTable
44 fcc " nam" option name
45 fcb Sign+M$Name,NameSize offset to string offset & max. byte count to change
46 fcc " mgr"
47 fcb Sign+M$FMgr,0 offset to string offset & no changes allowed
48 fcc " ddr"
49 fcb Sign+M$PDev,0
50 fcc " hpn"
51 fcb M$Port,1 option offset & byte count
52 fcc " hpa"
53 fcb M$Port+1,2
54 fcc " upc"
55 fcb IT.UPC,1
56 fcc " bso"
57 fcb IT.BSO,1
58 fcc " dlo"
59 fcb IT.DLO,1
60 fcc " eko"
61 fcb IT.EKO,1
62 fcc " alf"
63 fcb IT.ALF,1
64 fcc " nul"
65 fcb IT.NUL,1
66 fcc " pau"
67 fcb IT.PAU,1
68 fcc " pag"
69 fcb IT.PAG,1
70 fcc " bsp"
71 fcb IT.BSP,1
72 fcc " del"
73 fcb IT.DEL,1
74 fcc " eor"
75 fcb IT.EOR,1
76 fcc " eof"
77 fcb IT.EOF,1
78 fcc " rpr"
79 fcb IT.RPR,1
80 fcc " dup"
81 fcb IT.DUP,1
82 fcc " psc"
83 fcb IT.PSC,1
84 fcc " int"
85 fcb IT.INT,1
86 fcc " qut"
87 fcb IT.QUT,1
88 fcc " bse"
89 fcb IT.BSE,1
90 fcc " ovf"
91 fcb IT.OVF,1
92 fcc " par"
93 fcb IT.PAR,1
94 fcc " bau"
95 fcb IT.BAU,1
96 fcc " xon"
97 fcb IT.XON,1
98 fcc " xof"
99 fcb IT.XOFF,1
100 fcc " col"
101 fcb IT.COL,1
102 fcc " row"
103 fcb IT.ROW,1
104 IFGT Level-1
105 fcc " xtp"
106 fcb IT.XTYP,1
107 fcc " wnd"
108 fcb IT.WND,1
109 fcc " val"
110 fcb IT.VAL,1
111 fcc " sty"
112 fcb IT.STY,1
113 fcc " cpx"
114 fcb IT.CPX,1
115 fcc " cpy"
116 fcb IT.CPY,1
117 fcc " fgc"
118 fcb IT.FGC,1
119 fcc " bgc"
120 fcb IT.BGC,1
121 fcc " bdc"
122 fcb IT.BDC,1
123 ENDC
124 TablOpts equ (*-OptTable)/6 number of table entries
125 fcb $80 end of option table
126
127 UseMsg
128 fcb C$LF
129 fcc "Usage: EXMode [/<device> || -<pathlist> || -?] [option] [option] [...]"
130 fcb C$LF,C$LF
131 fcc "Purpose: To report or alter current option settings of SCF device"
132 fcb C$LF
133 fcc " descriptors in memory or on disk in single module files."
134 fcb C$LF,C$LF
135 fcc "Options: nam, mgr, ddr, hpn, hpa, upc, bso, dlo, eko, alf, nul, pau,"
136 fcb C$LF
137 fcc " pag, bsp, del, eor, eof, rpr, dup, psc, int, qut, bse, ovf,"
138 fcb C$LF
139 fcc " par, bau, xon, xof, col, row, xtp, wnd, val, sty, cpx, cpy,"
140 fcb C$LF
141 fcc " fgc, bgc, bdc"
142 fcb C$LF,C$LF
143 fcc "Examples: exmode /t2"
144 fcb C$LF
145 fcc " Prints the current option settings of the /T2 descriptor"
146 fcb C$LF
147 fcc " in memory."
148 fcb C$LF
149 fcc " exmode -modules/t4.dd nam=T2 bau=6 hpa=ff6c eof=1B"
150 fcb C$LF
151 fcc " Changes the module name in the MODULES/T4.dd file to T2,"
152 fcb C$LF
153 fcc " sets the baud rate code to 6, the hardware port address"
154 fcb C$LF
155 fcc " to $FF6C, and the end of file character to $1B."
156 fcb C$LF
157 fcc " exmode -?"
158 fcb C$LF
159 fcc " Prints more complete information on all of the options."
160 fcb C$CR
161 UseLen equ *-UseMsg
162
163 HelpMsg
164 fcb C$LF
165 fcc "The NAM option accepts only a legal OS-9 module name with a maximum of"
166 fcb C$LF
167 fcc "4 characters. It is up to the user to ensure that there is adequate"
168 fcb C$LF
169 fcc "room for the module name, and if required to rename the disk file to"
170 fcb C$LF
171 fcc "suit the new module name. The MGR and DDR options can't be changed."
172 fcb C$LF
173 fcc "All other options require hexadecimal numbers (0 through FFFF). XTP is"
174 fcb C$LF
175 fcc "for certain ACIA descriptors only. WND, VAL, STY, CPX, CPY, FGC, BGC,"
176 fcb C$LF
177 fcc "and BDC are for window descriptors only."
178 fcb C$LF,C$LF
179 fcc "nam Device Name mgr File Manager Name ddr Device Driver Name"
180 fcb C$LF
181 fcc "hpn H'ware Page Number hpa H'ware Port Address upc Case Lock Flag"
182 fcb C$LF
183 fcc "bso Backspace Method dlo Delete Line Method eko Screen Echo Flag"
184 fcb C$LF
185 fcc "alf Auto Linefeed Flag nul End Of Line Nulls pau Page Pause Flag"
186 fcb C$LF
187 fcc "pag Page Length bsp Backspace Character del Delete Line Char"
188 fcb C$LF
189 fcc "eor End Of Record Char eof End Of File Char rpr Reprint Line Char"
190 fcb C$LF
191 fcc "dup Duplicate Line Char psc Pause Character int Interrupt Character"
192 fcb C$LF
193 fcc "qut Quit Character bse Backspace Echo Char ovf Overflow Character"
194 fcb C$LF
195 fcc "par Type (Parity) Code bau Baud Rate Code xon XON Character"
196 fcb C$LF
197 fcc "xof XOFF Character col Display Columns row Display Rows"
198 fcb C$LF
199 fcc "xtp Extended Type Code wnd Window Number val Valid Window Flag"
200 fcb C$LF
201 fcc "sty Window Screen Type cpx X Corner Position cpy Y Corner Position"
202 fcb C$LF
203 fcc "fgc Foreground Colour bgc Background Colour bdc Border Colour"
204 fcb C$CR
205 HelpLen equ *-HelpMsg
206
207 Equal fcc "="
208
209 TypeMsg
210 fcb C$LF
211 fcc "Not an SCF descriptor!"
212 CR fcb C$CR
213 TypeLen equ *-TypeMsg
214
215 Sizemsg
216 fcb C$LF
217 fcc "Module size out of range!"
218 fcb C$CR
219 Sizelen equ *-Sizemsg
220
221 SynMsg
222 fcb C$LF
223 fcc "Syntax error: "
224 SynLen equ *-SynMsg
225
226 ****************
227 * miscellaneous error and help routines
228
229 MuchHelp
230 leax HelpMsg,pc
231 ldy #HelpLen
232 bra Helpprnt
233
234 BadSize
235 leax Sizemsg,pc
236 ldy #Sizelen
237 bra AddHelp
238
239 BadType
240 leax TypeMsg,pc
241 ldy #TypeLen
242 AddHelp
243 lda #2
244 os9 I$WritLn
245 Help
246 leax UseMsg,pc
247 ldy #UseLen
248 Helpprnt
249 lda #2
250 os9 I$WritLn
251 lbra OkayEnd2
252
253 ****************
254 Entry
255 ldd #0
256 std <ModAddr zero mod flag
257 sta <PathNmbr zero file flag
258 ldd ,x+ check for device name
259 cmpa #'- file option?
260 bne Link
261 cmpb #'? help option?
262 beq MuchHelp
263 * Use Filename to Get Desc:
264 lda #Updat. open path to module file
265 os9 I$Open
266 bcs Help
267 stx <ParmPtr
268 sta <PathNmbr save path number
269 ldy #MaxSize max size
270 leax ModBuff,u module buff
271 os9 I$Read get it
272 lbcs Error
273 ldb M$Opt,x
274 clra [D] = option table size
275 addd #M$DTyp add options start offset
276 std <OptEnd save options end offset
277 ldd M$Size,x get module size
278 cmpd #MaxSize module size OK?
279 bhi BadSize no, go return error...
280 std <ModSize
281 bra GotIt
282
283 Link
284 cmpa #'/ else must be /<devicename>
285 bne Help
286 pshs u
287 lda #Devic
288 os9 F$Link link to module
289 bcs Help
290 stx <ParmPtr update after name
291 tfr u,x
292 puls u
293 stx <ModAddr
294 ldb M$Opt,x
295 clra [D] = option table size
296 addd #M$DTyp add options start offset
297 std <OptEnd save options end offset
298 ldd M$Size,x get module size
299 cmpd #MaxSize module size OK?
300 lbhi BadSize no, go report error...
301 std <ModSize
302 tfr d,y copy module size...
303 pshs u save data area pointer
304 leau ModBuff,u
305
306 GetModLp
307 lda ,x+
308 sta ,u+
309 leay -1,y
310 bne GetModLp
311 puls u recover data area pointer
312
313 GotIt
314 ldd <OptEnd get option table end offset
315 cmpd <ModSize is option table size OK?
316 lbhs BadSize no, go report error...
317 leax ModBuff,u
318 lda M$DTyp,x get device type
319 lbne BadType SCF = $00
320 ldx <ParmPtr point to input parms
321 lbsr SkipSpac go skip leading spaces...
322 cmpa #C$CR no options?
323 lbeq Info ..yes, give info
324 leax -1,x
325
326 ****************
327 * X=ParmPtr
328 * Find and Set Options:
329
330 FindLp10
331 lbsr SkipSpac get next input param
332 stx <ParmPtr save for syntax error use
333 cmpa #C$CR end?
334 lbeq Verify ..yes, update module CRC
335 leay OptTable-6,pc ready option table ptr
336 pshs u
337 ldu ,x++ get next two chars
338 ora #$20 convert 1st param char to lower case
339 exg d,u move [U] where we can convert param chars
340 ora #$20 convert 2nd param char...
341 orb #$20 convert 3rd...
342 exg d,u move back again
343
344 FindLp20
345 leay 6,y next option entry
346 tst ,y last entry?
347 bmi Syntax ..yes, bad option
348 cmpa 1,y
349 bne FindLp20 same name?
350 cmpu 2,y
351 bne FindLp20 ..no, loop
352 * Found Option
353 puls u
354 sty <TxtPtr
355 ldd ,x+ must be followed by "=", leave [X] pointing at char after "="
356 cmpa #'=
357 bne Syntax
358 cmpb #C$CR rest of option missing?
359 beq Syntax yes, go report error
360 cmpb #C$SPAC rest of option missing?
361 beq Syntax yes, go report error
362 ldb 5,y get # of bytes
363 beq Syntax 0 bytes, not allowed to change this option
364 stb <Count
365 ldb 4,y get option offset or offset to option offset
366 bpl NumOpt option offset, go set hexadecimal option
367 * Get CHAR input and set option:
368 andb #^Sign clear sign bit of offset to string offset
369 clra [D] = offset to string offset within module
370 cmpd <ModSize is it OK?
371 bhs Syntax no, go report error...
372 leay ModBuff,u point to module
373 ldd b,y get offset to string
374 cmpd <ModSize is it OK?
375 bhs Syntax no, go report error...
376 leay d,y point to option
377 pshs y save option pointer
378 os9 F$PrsNam valid OS-9 name?
379 puls y recover option pointer (end of name pointer lost)
380 bcs Syntax no, go report error
381 cmpa #C$SPAC space delimiter char?
382 beq ChkLen yes, go check name length...
383 cmpa #C$CR <CR> delimiter char?
384 bne Syntax no, go report error
385
386 ChkLen
387 cmpb <Count name length OK?
388 bhi Syntax no, go report error...
389
390 SetChrLp
391 lda ,x+ get character
392 sta ,y+ save it to module copy
393 decb done yet?
394 bne SetChrLp no, go copy another char...
395 lda -1,y get last char
396 ora #Sign set sign bit
397 sta -1,y save last char
398 lbra FindLp10 go do next...
399
400 * Syntax Error:
401 Syntax
402 leax SynMsg,pc
403 ldy #SynLen
404 lda #2
405 os9 I$Write
406 ldx <ParmPtr
407 leax -1,x
408 pshs x
409 ldy #0
410
411 CntLoop
412 leay 1,y
413 lda ,x+
414 cmpa #C$CR
415 beq SynSay
416 cmpa #C$SPAC
417 bne CntLoop
418
419 SynSay
420 puls x
421 lda #2
422 os9 I$Write output err
423 lbra OkayEnd
424
425 * Get Hex Input and Set Option:
426 NumOpt
427 clra [D] = option offset within module
428 cmpd <OptEnd is it OK?
429 bhs Syntax no, go report error...
430 clr <HexIn zero hex input bytes
431 clr <HexIn+1
432
433 SetNumLp
434 lda ,x+ get next #
435 cmpa #C$SPAC end of number?
436 beq SetNum2 ..yes, set option
437 cmpa #C$CR end of line?
438 beq SetNum1 ..yes, set option
439 * Convert ASCII Hex-->Byte:
440 suba #$30 make number from ASCII
441 bmi Syntax
442 cmpa #10 is it number?
443 bcs Num
444 anda #$5F make uppercase
445 suba #$11-$0A make hex $A-$F
446 cmpa #$0A
447 bcs Syntax
448 cmpa #$10 not hex char?
449 bcc Syntax
450
451 Num
452 ldb #16 fancy asl *4
453 mul
454 pshs b save top 4 bits
455 ldd <HexIn
456 rol ,s
457 rolb
458 rola
459 rol ,s
460 rolb
461 rola
462 rol ,s
463 rolb
464 rola
465 rol ,s
466 rolb
467 rola
468 std <HexIn
469 puls b drop temp
470 bra SetNumLp ..loop
471
472 SetNum1
473 leax -1,x reset so can find <CR>
474
475 SetNum2
476 ldb 4,y get option offset
477 leay ModBuff,u point to module
478 leay b,y point to option
479 ldd <HexIn pick up hex input
480 dec <Count
481 beq SetOne
482 std ,y set two byte option
483 lbra FindLp10
484
485 SetOne
486 tsta
487 lbne Syntax
488 stb ,y set one byte option
489
490 SetNDone
491 lbra FindLp10
492
493 * --------------
494 * Skip Spaces:
495 SkipSpac
496 lda ,x+
497 cmpa #C$SPAC
498 beq SkipSpac
499 rts
500
501 * --------------
502 * Update Module CRC:
503 Verify
504 pshs u save data ptr
505 leau ModBuff,u
506 tfr u,x X is mod address
507 ldy M$Size,x Y is mod size
508 leay -3,y beginning of chksum
509 tfr y,d Y is byte count
510 leau d,u set U to chksum
511 lda #$FF init chksum
512 sta ,u
513 sta 1,u
514 sta 2,u
515 pshs u
516 os9 F$CRC calc new crc
517 puls u
518 com ,u+ fix it up right
519 com ,u+
520 com ,u
521 lda <PathNmbr was it file?
522 beq MemMod ..no, in memory
523 ldx #0
524 tfr x,u
525 os9 I$Seek go back to file begin
526 bcs Error
527 puls u
528 leax ModBuff,u
529 ldy <ModSize
530 os9 I$Write update module file
531 bra OkayEnd
532
533 MemMod
534 ldu ,s get data area pointer
535 leax ModBuff,u
536 ldy <ModSize
537 ldu <ModAddr
538
539 PutModLp
540 lda ,x+
541 sta ,u+
542 leay -1,y
543 bne PutModLp
544 puls u recover data area pointer
545 bra OkayEnd2
546
547 OkayEnd
548 bsr OutCR
549
550 OkayEnd2
551 clrb okay
552
553 Error
554 pshs b,cc
555 ldu <ModAddr
556 beq Bye
557 os9 F$UnLink
558
559 Bye
560 puls b,cc
561 os9 F$Exit we're done...
562
563 * --------------
564 * Print a <CR>:
565 OutCR
566 leax CR,pc
567 ldy #1
568 lda #1
569 os9 I$WritLn
570 rts
571
572 ****************
573 * Output Current Desc Info:
574 Info
575 bsr OutCR do a <CR>
576 ldb #TablOpts number of table entries
577 pshs b save counter
578 leax OptTable,pc point to text table
579 stx <TxtPtr
580
581 InfoLoop
582 ldx <TxtPtr
583 ldy #4
584 lbsr OutPut print option name
585 leax Equal,pc
586 ldy #1
587 lbsr OutPut print =
588 ldx <TxtPtr
589 ldb 4,x get offset to HEX option; if minus, offset to option offset
590 bpl PrintHex go do simple offset to HEX option
591 andb #^Sign clear sign bit
592 clra [D] = offset to string offset within module
593 cmpd <ModSize is it OK?
594 bhs MovePtr no, skip this option...
595 leay ModBuff,u point [Y] to module work copy
596 ldd b,y get string offset within module
597 cmpd <ModSize is string offset OK?
598 bhs MovePtr no, skip this option...
599 leay d,y point [Y] to CHAR string
600 lda #BuffSize get max. chars to print
601 leax Buffer,u point [X] to CHAR string buffer
602 clr <Count init counter
603
604 CharCopy ldb ,y+ get char
605 bpl NotLast sign bit clear so not last, go on...
606 andb #^Sign clear sign bit
607 lda #1 set up as last char
608
609 NotLast stb ,x+
610 inc <Count count chars in string
611 deca done yet?
612 bne CharCopy no, go do another char...
613 ldb <Count get chars in string ([A]=0, so [D]=char count)
614 tfr d,y module name length into [Y]
615 leax Buffer,u point [X] to CHAR string copy
616 bsr OutPut print CHAR string
617 bra MovePtr skip HEX output routine
618
619 * Print Hex Option Values:
620 PrintHex
621 ldx <TxtPtr
622 ldb 5,x get # of digits
623 stb <Count
624 ldb 4,x get option offset in module
625 clra [D] = option offset within module
626 cmpd <OptEnd is option offset OK?
627 bhs MovePtr no, skip this option...
628 leax ModBuff,u point [X] to module work copy
629 abx point [X] to option
630 stx <DataPtr
631
632 * Print One Byte:
633 NumLoop
634 ldx <DataPtr
635 lda ,x+
636 stx <DataPtr
637 pshs a
638 lsra
639 lsra
640 lsra
641 lsra
642 bsr OutOne
643 puls a
644 anda #$0F
645 bsr OutOne
646 dec <Count
647 bne NumLoop
648
649 MovePtr
650 ldx <TxtPtr
651 leax 6,x
652 stx <TxtPtr
653 dec ,s
654 lbeq OkayEnd done...
655 ldb ,s
656 bitb #$07 # of options remaining evenly divisible by eight?
657 lbne InfoLoop no, go print next option on same line
658 lbsr OutCR <CR> after every 8th option
659 lbra InfoLoop ..loop
660
661 * --------------
662 * Print 1/2 Byte Hex Char:
663 OutOne
664 cmpa #10
665 bcs Number
666 adda #$11-10 make alpha
667
668 Number
669 adda #$30 make ASCII
670 sta <Buffer
671 leax Buffer,u
672 ldy #1
673
674 OutPut
675 lda #1 std out
676 os9 I$Write
677 lbcs Error
678 rts
679
680 emod
681 Size equ *
682 end
683