comparison CoCoOS9/level2v3/CMDS/xmode.asm @ 31:bd2b07db8917 cocoos9lv2v3

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