dml@loral.UUCP (11/18/86)
Well, I've been busy again...here's something to make it easier to
read those source listings. If you keep your listing format within
certain limits, it works OK, although it can't handle NAM and TTL --
it thinks the strings are comments because they're not quoted. It's
keyed to the way I write source, so it may not work as well for you.
I've gone to making my source completely unformatted since finishing
this; it saves on disk space and makes editing easier. Assemble it and
run it on its own source for a good demo.
For a disk containing sources and binaries of this and a lot of other
OS-9 programs, send $10.00 to:
Dave Lewis
4417 Idaho apt 4
San Diego CA 92116
If it assembles properly the Ident should look like this:
Header for: Sourcefmt
Module size: $00E9 #233
Module CRC: $43B116 (Good)
Hdr parity: $C2
Exec. off: $0017 #23
Data Size: $01FF #511
Edition: $03 #3
Ty/La At/Rv: $11 $82
Prog mod, 6809 obj, re-en, R/O
****************************************************************
*
* Sourcefmt copyright 1986 by Dave Lewis
*
* Use it to process 6809 assembly source listings into a more
* readable form. Within limits, Sourcefmt will sort out labels,
* mnemonics, operands, quoted strings, and comments and put
* each in an appropriate column. The output looks much like
* an assembler listing, without the address and code fields.
* Line numbers are included if present in the source.
*
* Sourcefmt [pathname]
*
* Output is to stdout, so redirect it to your file
* Defaults to stdin, can be used with a pipe:
*
* List filename ! Sourcefmt
*
****************************************************************
*
NAM Sourcefmt
TTL Sourcecode formatter
*
* Copyright 1986 by Dave Lewis
* 4417 Idaho apt 4
* San Diego CA 92116
*
IFP1
USE /D0/DEFS/OS9Defs
USE /D0/DEFS/SCFDefs
ENDC
*
REV EQU 2
TYPE EQU PRGRM+OBJCT
ATTR EQU REENT+REV
*
MOD SIZE,NAME,TYPE,ATTR,EXEC,STORG
NAME FCS 'Sourcefmt'
FCB 3 Version number
*
INPATH RMB 1 Input path number
INBUFFER RMB 120 Input line buffer
OUTBUFER RMB 120 Output line buffer
RMB 200 Stack area
RMB 70 Parameter area
STORG EQU .
*
EXEC PSHS Y Stash end-of-memory pointer
CLR INPATH Default to stdin
CMPX ,S Compare to end of memory
BEQ NOPATH Skip path search if so
SRCHLOOP LDA ,X+ Get parameter character
CMPA #C$CR Test for CR
BEQ NOPATH Stop searching for path
CMPA #C$SPAC Test for space
BEQ SRCHLOOP Keep looking if so
LEAX -1,X Point back to start of path
LDA #READ. Access mode: read
OS9 I$OPEN Open input file
STA INPATH Save input path number
NOPATH LEAS 2,S Take end pointer off stack
BCS OUT Quit if error
LINELOOP LEAX INBUFFER,U Point to input buffer
LDA INPATH Get input path number
LDY #120 Maximum line length
OS9 I$READLN Read a line from input
BCC DOLINE Continue if no error
CMPB #E$EOF Was it an end-of-file error?
ORCC #CARRY Set carry again
BNE OUT Report any other error
CLRB Clear error condition
OUT OS9 F$EXIT Quit
*
DOLINE LEAY OUTBUFER,U Point to output buffer
DOLINE2 LDA ,X Get first character
CMPA #C$SPAC If non-printing character,
BLO DOCOMM spit it right back out
BEQ DOLABEL If space, output line
CMPA #'* Test for comment line
BEQ DOCOMM Process comment
ANDA #$5F Make upper case
CMPA #'A Compare to lowest letter
BLO DOLINUM Must be a number if less
CMPA #'Z Compare to highest letter
BLS DOLABEL Must be label if letter
DOLINUM LDA ,X+ Get next source character
STA ,Y+ Store in destination buffer
CMPA #C$SPAC Was it a space?
BNE DOLINUM Keep moving stuff if not
BRA DOLINE2 Check rest of line
*
DOLABEL LDB #9 Nine columns in label field
BSR DOFIELD Print out the label
LDB #6 Six columns in mnemonic field
BSR DOFIELD2 Print the mnemonic
LDA ,X Get first character
CMPA #C$SPAC Is it a space?
BEQ SKIPOPR Must be comment then
CMPA #'' Is it apostrophe?
BEQ DOCOMM Probably FCC or FCS if so
CMPA #'" Is it double-quote?
BEQ DOCOMM Another likely FCC or FCS
CMPA #'/ Is it slash?
BEQ DOCOMM Path name, FCC or FCS if so
ANDA #$5F Make upper case
CMPA #'A Compare to lowest letter
BLO OPERAND Operand if not letter
CMPA #'Z Compare to highest letter
BHI OPERAND Operand if not letter
LDA 1,X Get second character
CMPA #'a Compare to lowest letter
BLO OPERAND Not a comment
CMPA #'z Compare to highest letter
BHI OPERAND Must be operand
SKIPOPR LDB #16 Width of operand field
LDA #C$SPAC Fill with spaces
BSR DOFIELD3 Do the fill
BRA DOCOMM Print out the comment
*
OPERAND LDB #16 Sixteen columns for operand
BSR DOFIELD2 Print out the operand
DOCOMM LDA ,X+ Get next source character
STA ,Y+ Store in destination buffer
CMPA #C$CR Test for end of line
BNE DOCOMM Continue until end
LEAX OUTBUFER,U Point to output buffer
LDY #120 Maximum line length
LDA #1 Stdout
OS9 I$WRITLN Write out modified line
BCS OUT Quit if error
LBRA LINELOOP Process entire file
*
DOFIELD BSR DOFIELD2 Go print the field
SRCHNEXT LDA ,X+ Get next source character
CMPA #C$CR Check for end of line
BEQ LINEND Stop here if so
CMPA #C$SPAC Search for start of next
BEQ SRCHNEXT object
LINEND LEAX -1,X Point back to first char
DFEXIT RTS
*
DOFIELD2 LDA ,X+ Get next source character
STA ,Y+ Store in destination buffer
DECB Count off the character
CMPA #C$CR Was it end of line?
BEQ DFEXIT Stop if so
CMPA #C$SPAC Was it a space?
BNE DOFIELD2 Continue until space
DOFIELD3 DECB Check the count
BMI DFEXIT Field is filled
STA ,Y+ Store space in output buffer
BRA DOFIELD3 Continue until full
*
EMOD Insert CRC Bytes
SIZE EQU *
END
-------------------------------
Dave Lewis Loral Instrumentation San Diego
hp-sdd --\ ihnp4 --\
sdcrdcf --\ bang --\ kontron -\
csndvax ---\ calmasd -->-->!crash --\
celerity --->------->!sdcsvax!sdcc3 --->--->!loral!dml (uucp)
dcdwest ---/ gould9 --/
All these computers connected together, dialing each other up
automatically -- what do they talk about late at night when no
people are using the net?
-------------------------------