Trailing-Edge
-
PDP-10 Archives
-
SRI_NIC_PERM_SRC_3_19910112
-
midas/cvtoz.mid
There are no other files named cvtoz.mid in the archive.
;-*-MIDAS-*-
.SYMTAB 5000. ; need room for symbols
TITLE CVT
SUBTTL Mark Crispin, Stanford University
; Makes the MIDAS .INSRT file TNXDFS.MID out of the MACRO universal files
; SYS:MACSYM.UNV and SYS:MONSYM.UNV
.DECSAV ; specify EXE file output
INJFN: BLOCK 1 ; save area for input JFN
OUTJFN: BLOCK 1 ; save area for output JFN
DEFINE LOSE TEXT
JRST [ HRROI 1,[ASCIZ/TEXT - /]
ESOUT
JRST DIE]
TERMIN
; Start here
CVT: RESET ; initialize all I/O
MOVSI 1,(GJ%SHT\GJ%NEW) ; open up TNXDFS.MID for write
HRROI 2,[ASCIZ/TNXDFS.MID.-1/]
GTJFN
LOSE [Can't get TNXDFS.MID]
HRRZM 1,OUTJFN
MOVE 2,[7_12.,,OF%WR] ; 7-bit write
OPENF
LOSE [Can't open TNXDFS.MID]
HRROI 2,[ASCIZ/;;TNXDFS - TOPS-20 symbol definition file for MIDAS
;; MONSYM Symbols
/] ; output header
SETZ 3,
SOUT
MOVSI 1,(GJ%OLD\GJ%SHT) ; open up SYS:MONSYM.UNV for read
HRROI 2,[ASCIZ/SYS:MONSYM.UNV/]
GTJFN
LOSE [Can't get SYS:MONSYM.UNV]
HRRZM 1,INJFN ; current input JFN
MOVEI 2,OF%RD ; 36-bit read
OPENF
LOSE [Can't open SYS:MONSYM.UNV]
JSR GO ; process the file
MOVE 1,INJFN ; close up MONSYM
CLOSF
LOSE [Can't close MONSYM]
MOVE 1,OUTJFN ; output MACSYM banner
HRROI 2,[ASCIZ/
;; MACSYM Symbols
/]
SETZ 3,
SOUT
MOVSI 1,(GJ%OLD\GJ%SHT) ; open up SYS:MACSYM.UNV for read
HRROI 2,[ASCIZ/SYS:MACSYM.UNV/]
GTJFN
LOSE [Can't get SYS:MACSYM.UNV]
HRRZM 1,INJFN
MOVEI 2,OF%RD
OPENF
LOSE [Can't open SYS:MACSYM.UNV]
JSR GO ; do it
MOVE 1,INJFN ; close MACSYM
CLOSF
LOSE [Can't close MACSYM]
MOVE 1,OUTJFN
CLOSF
LOSE [Can't close TNXDFS]
HALTF ; return to EXEC
JRST .-1 ; no continuing allowed
DIE: MOVEI 1,.PRIOU ; primary output
HRLOI 2,.FHSLF ; this fork,,last error
ERSTR ; output error
NOP ; ignore failure
NOP
HALTF
JRST .-1
; Universal flag definitions
SYMF==400000 ; symbol
TAGF==200000 ; tag
NOOUTF==100000 ; no DDT output
SYNF==040000 ; synonym
MACF==020000 ; macro
OPDF==010000 ; opdef
PNTF==004000 ; "value" in symbol table in
; pointer to 36-bit value
UNDF==002000 ; undefined
EXTF==001000 ; external
INTF==000400 ; internal
ENTF==000200 ; entry
ARF==000100 ; variable
NCRF==000040 ; don't CREF
MDFF==000020 ; multiply defined
SPTR==000010 ; special external pointer
SUPRBT==000004 ; suppress output to REL and listing
LELF==000002 ; LH relocatable
RELF==000001 ; RH relocatable
GO: 0 ; PC return point
MOVE 1,INJFN
REPEAT 5,[
BIN ; slurp up header words
];REPEAT 5
IOLP: BIN ; read a symbol
JUMPE 2,[JRST 4,IOLP] ; spurious end of file?
IOLP1: CAMN 2,[373737373737] ; special symbol meaning end of universal file
JRST 2,@GO ; at end, return to caller
MOVE 10,2 ; save symbol for safekeeping
BIN ; read flags word
MOVE 11,2 ; save flags as well
TLNN 11,MACF ; macro?
JRST NOTMAC ; no, look at it further
; Have to flush a macro...great pain involved.
FLSMAC: BIN ; word 1 of leaf, LH 0 if last leaf
MOVE 11,2 ; save it
REPEAT 3,[
BIN ; rest of leaf
];REPEAT 3
TLNE 11,-1 ; last leaf?
JRST FLSMAC ; no, get next leaf
;;; I don't think this code is right, but it seems to work...
BIN ; check for arguments
TLNE 2,770000 ; look like SIXBIT?
JRST IOLP1 ; yes, back to top level loop
HLRZ 11,2 ; looks like a macro argument, get arg count-1
FLSARG:
REPEAT 5,[
BIN ; default value plus leaf
];REPEAT 5
SOJGE 11,FLSARG ; flush remaining arguments
JRST IOLP
NOTMAC: MOVE 1,OUTJFN ; get ready to output this symbol
HRROI 2,[ASCIZ/;;; /] ; see if we need to comment it out
TLNN 11,TAGF\UNDF\EXTF\ENTF\MDFF\SPTR\LELF\RELF ; any of these
CAMN 10,['.SYMTA] ; or if .SYMTAB
SOUT ; will cause it to be commented out
HRROI 2,[ASCIZ/DEFSYM /] ; output DEFSYM line
SOUT
JSR SIXOUT ; output the symbol name
TRNN 10,77 ; right justify the symbol name
JRST [ LSH 10,-6
JRST .-1]
ANDI 10,77 ; now get its last character
CAIN 10,'% ; did the symbol end in "%"?
SKIPA 2,[-1,,[ASCIZ/=:/]] ; yes, new-style JSYS name
HRROI 2,[ASCIZ/==:/] ; otherwise suppress DDT typeout of it
SOUT
TLNN 11,PNTF\SPTR ; see if pointer block
JRST [ HRRZ 2,11 ; no, easy case right halfword symbol
MOVE 3,[NO%LFL\NO%ZRO\<6.,,8.>]
NOUT
LOSE [NOUT failed]
JRST TERPRI] ; output CRLF and do next symbol
MOVE 1,INJFN ; pointer, get next word
BIN
TLNE 11,EXTF ; simple external?
JRST [ BIN ; yes, get symbol it references
MOVE 10,2
MOVE 1,OUTJFN ; output the symbol
JSR SIXOUT
JRST TERPRI] ; output CRLF and do next symbol
MOVE 1,OUTJFN ; otherwise it looks like a fullword symbol
MOVE 3,[NO%MAG\NO%LFL\NO%ZRO\<12.,,8.>]
NOUT
LOSE [NOUT failed]
TLNN 11,SPTR ; simple numeric value?
JRST TERPRI ; yes, output CRLF and do next
MOVEI 2,"+ ; no, plus some relocatable or Polish stuff
BOUT
MOVE 1,INJFN ; get what sort of thing the extra stuff is
BIN
JUMPL 2,POLAK ; if negative, Polish expression
BIN ; I forget what this word was supposed to be...
BIN ; finally the symbol added in
MOVE 10,2 ; output it
MOVE 1,OUTJFN
JSR SIXOUT
TERPRI: HRROI 2,[ASCIZ/
/] ; output CRLF
SETZ 3,
SOUT
MOVE 1,INJFN ; set JFN back
JRST IOLP ; and get next symbol
POLAK: MOVE 1,OUTJFN ; Polish expression -- don't even try to win
HRROI 2,[ASCIZ/<Polish expression>/]
SETZ 3,
SOUT
MOVE 1,INJFN
FLSPOL: BIN ; link word
JUMPN 2,FLSPOL ; can't be EOF
BIN
SKIPL 2
CAIL 2,14 ; look like a Polish block?
JRST [MOVE 1,OUTJFN ; no, probably an external block, done
JRST TERPRI]
REPEAT 4,[
BIN ; remainder of block
];REPEAT 4
REPEAT 2,[
BIN ; consistency block
];REPEAT 2
JRST FLSPOL ; continue flushing Polish cruft
SIXOUT: 0 ; simple SIXBIT output routine
MOVE 4,[440600,,10]
SIXOU1: ILDB 2,4
JUMPE 2,@SIXOUT
ADDI 2,"A-'A
BOUT
TLNE 4,770000
JRST SIXOU1
JRST 2,@SIXOUT
..LIT: CONSTA
END CVT