1
0
mirror of https://github.com/PDP-10/its.git synced 2026-05-02 22:33:27 +00:00
Files
PDP-10.its/src/midas/cvtunv.4
Lars Brinkhoff 4b061741b0 CVTUNV - convert MACRO universal files to MIDAS syntax.
This is a TOPS-20 program.
2017-02-05 08:08:22 -08:00

310 lines
7.4 KiB
Groff
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
;-*-MIDAS-*-
.SYMTAB 5000. ; need room for symbols
TITLE CVT
SUBTTL Mark Crispin, Stanford University
; Makes the MIDAS .INSRT file TNXDFU.MID out of the MACRO universal files
; SYS:MACSYM.UNV and SYS:MONSYM.UNV
; Modified by KLH so runtime will work on either 10X/T20.
.DECSAV ; specify direct SAV/EXE file output
INJFN: BLOCK 1 ; save area for input JFN
OUTJFN: BLOCK 1 ; save area for output JFN
.SCALAR FLG20X ; -1 if on 20X
DEFINE LOSE TEXT
JRST [ HRROI 1,[ASCIZ/TEXT - /]
ESOUT
JRST DIE]
TERMIN
DEFINE TYPE &TEXT&
HRROI 1,[ASCIZ TEXT]
PSOUT
TERMIN
DEFINE TYPFIL (JFN)
MOVE 2,JFN
MOVEI 1,.PRIOU
SETZ 3,
JFNS
TERMIN
; Start here
CVT: RESET ; initialize all I/O
SETZM FLG20X ; Determine sys; assume 10X
MOVE 1,[SIXBIT /LOADTB/] ; So far only 10X has this table.
SYSGT
CAIN 2,0
SETOM FLG20X ; Table not defined, so must be 20X.
MOVSI 1,(GJ%FOU\GJ%SHT\GJ%NEW) ; open up TNXDFU.MID for write
HRROI 2,[ASCIZ/TNXDFU.MID/]
GTJFN
LOSE [Can't gtjfn TNXDFU.MID]
HRRZM 1,OUTJFN
MOVE 2,[7_12.,,OF%WR] ; 7-bit write
OPENF
LOSE [Can't open TNXDFU.MID]
TYPE "Writing file "
TYPFIL OUTJFN
TYPE "
"
MOVE 1,OUTJFN
HRROI 2,[ASCIZ ";;TNXDFU - TOPS-20/TENEX 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/<SYSTEM>MONSYM.UNV/]
SKIPE FLG20X
HRROI 2,[ASCIZ/SYS:MONSYM.UNV/]
GETLP: GTJFN
JRST [ HRROI 1,[ASCIZ/Can't find default MONSYM.UNV file, specify
file to use: /]
PSOUT
MOVSI 1,(GJ%OLD\GJ%SHT\GJ%FNS)
MOVE 2,[.PRIIN,,.PRIOU]
JRST GETLP]
HRRZM 1,INJFN ; current input JFN
MOVEI 2,OF%RD ; 36-bit read
OPENF
LOSE [Can't open MONSYM file]
TYPE "using "
TYPFIL INJFN
TYPE " ..."
JSR GO ; process the file
MOVE 1,INJFN ; close up MONSYM
CLOSF
LOSE [Can't close MONSYM]
TYPE "
"
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/<SYSTEM>MACSYM.UNV/]
SKIPE FLG20X
HRROI 2,[ASCIZ/SYS:MACSYM.UNV/]
GETLP2: GTJFN
JRST [ HRROI 1,[ASCIZ/Can't find default MACSYM.UNV file, specify
file to use: /]
PSOUT
MOVSI 1,(GJ%OLD\GJ%SHT\GJ%FNS)
MOVE 2,[.PRIIN,,.PRIOU]
JRST GETLP2]
HRRZM 1,INJFN
MOVEI 2,OF%RD
OPENF
LOSE [Can't open MACSYM file]
TYPE "using "
TYPFIL INJFN
TYPE " ..."
JSR GO ; do it
MOVE 1,INJFN ; close MACSYM
CLOSF
LOSE [Can't close MACSYM]
TYPE "
"
MOVE 1,OUTJFN
CLOSF
LOSE [Can't close TNXDFU]
TYPE "Done.
"
PSOUT
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
COMMENT |
Stuff about UNIVERSAL file format, taken from MACRO source.
;UNIVERSAL VERSION BIT DEFINITION
;THE FIRST WORD OF A UNV FILE MUST CONTAIN:
; LEFT HALF 777
; RIGHT HALF UNIVERSAL VERSION NUMBER
;WHEN WRITING A UNV FILE, MACRO WRITES OUT:
; 777,,UWVER FOR THE FIRST WORD
; .JBVER FOR THE SECOND WORD( MACRO VERSION NUMBER)
;WHEN READING A UNV FILE, MACRO READS THE FIRST WORD AND CHECKS FOR:
; 777 IN LEFT HALF, AND
; CHECKS THE RIGHT HALF AGAINST MASK .URVER
; WILL SKIP THE SECOND WORD IF A VERSION NUMBER IS EXPECTED THERE
;
UMACV==000020 ;HAS MACRO VERSION IN 2ND WORD
USYN==000010 ;NEW SYN HANDLING IN UNIVERSAL
UBAS==000004 ;MUST HAVE THIS BASIC BIT ON
;SAME AS THE FIRST VERSION #4
UPOL==000002 ;POLISH INCLUDED
UMAD==000001 ;MACRO ARG DEFAULT VALUE BUG FIXED
|
; 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