Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_SRC_3_19910112 - utilities/typrel.mac
There are no other files named typrel.mac in the archive.
	TITLE TYPREL ANALYZES THE CONTENTS OF A REL FILE
	SUBTTL J. BURCHFIEL AUG 29,1970
SEARCH STENEX
IFDEF .REQUIRE,<.REQUIRE SYS:STENEX>

	MLON

	A=1
	B=2
	C=3
	D=4
	P=17

	DEFINE TABLE(NAM)
	<IRP NAM,
<	ASCIZ /NAM/
>>

TYPREL:	RESET
	SETZM TOTAL
	SETZM ZERFLG
	MOVE P,[IOWD 20,PDL]
	MOVEI A,400000	;THIS FORK
	MOVE B, [XWD LEVTAB,CHNTAB]	;PSI DISPATCH
	SIR
	MOVSI B,(17B13)		;CHANNELS 10,11,12,13
	AIC
	EIR
	HRROI A,[ASCIZ/
OUTPUT FILE= /]
	PSOUT
	MOVEI A,JBLKO	;OUTPUT, CONFIRM
	SETZ B,
	GTJFN
	PUSHJ P,ERROR
	HRRZM A,OUTJFN
	MOVE  B,[7B5+1B20]	;ASCII OUTPUT
	OPENF
	PUSHJ P,ERROR
	HRROI A,[ASCIZ/
REL FILE= /]
	PSOUT
	SETZ B,
	MOVEI A,JBLKI
	GTJFN
	PUSHJ P,ERROR
T1:	HRRZM A,RELJFN
	MOVE B,[44B5+1B19]	;BINARY INPUT
	OPENF
	PUSHJ P,ERROR
	MOVE A,OUTJFN
	HRROI B,[ASCIZ/
TYPE    DATA    TOTAL
/]
	SETZ C,
	SOUT
BLK:	MOVE A,RELJFN
	BIN			;BLOCK HEADER WORD

BLK2:	MOVE A,OUTJFN
	MOVE D,B
	HLRZ B,B
	MOVEM B,BLKTYP
	PUSHJ P,CRLF
	CAIE B,14		;SEPARATE PROGRAMS, INDEX BLOCKS
	CAIN B,4
	PUSHJ P,CRLF
	JUMPE D,ENDCHK

T4:	MOVE C,[XWD 10,10]	;8-COLUMN OCTAL
	NOUT
	PUSHJ P,ERROR
	CAIG B,17		;STRANGE BLOCK?
	JRST T8			;NO
	CAIN B,400		;FORTRAN?
	JRST FORTR		;YES
	CAIE B,100		;ASSIGN?
	JRST ERR1		;NO

T8:	HRRZ B,D
	MOVEM B,DATAW
	NOUT
	PUSHJ P,ERROR
	MOVEI C,14
	CAMN C,BLKTYP		;IS IT AN INDEX BLOCK?
	JRST T3			;YES, NO RELOCATION WORDS
	IDIVI B,^D18
	IMULI B,^D19
	SKIPN C
	SKIPN B		;RELOCATION WORD FOR EMPTY BLOCK
	ADDI B,1(C)

T3:	MOVEM B,BLKSIZ		;DATA PLUS RELOCATION WORDS
	MOVE C,[XWD 10,10]
	ADDI B,1
	ADDM B,TOTAL
	NOUT
	PUSHJ P,ERROR
	HLRZ D,D
T2:	SETZ C,
	CAIN D,100		;ASSIGN?
	MOVEI D,<TABEND-TYPTAB>/2-2		;YES
	LSH D,1
	HRROI B,TYPTAB(D)
	SOUT

	MOVE D,BLKTYP
	CAIN D,100		;ASSIGN?
	JRST ASSN		;YES.
	CAIG D,7
	CAIGE D,4
	JRST FLUSH
	JRST @TAB2-4(D)
TAB2:	EXP ENTR,LAST,NAME,START

ENTR:	MOVE D,DATAW	;NUMBER OF ENTRY POINTS
	JUMPE D,FLUSH
	CAILE D,4	;TYPE AS MANY AS 4
	MOVEI D,4
	JRST NAM2

NAME:	MOVEI D,1

NAM2:	MOVE A,RELJFN
	BIN		;SKIP RELOCATION WORD
	SOS BLKSIZ	;BUT ACCOUNT FOR IT
	PUSHJ P,TYPSYM		;TYPE NEXT SYMBOL
	JRST FLUSH

ASSN:	MOVEI D,2		;TYPE TWO SYMS
	MOVE A,RELJFN		;AFTER SKIPPING THE RELOCATION WD
	BIN
	SOS BLKSIZ
	PUSHJ P,TYPSYM		;TYPE VAR AND PC
	MOVE A,RELJFN		;GET LENGTH
	BIN
	SOS BLKSIZ
	MOVE A,OUTJFN		;OUTPUT LENGTH
	MOVEI C,10
	NOUT
	  PUSHJ P,ERROR
	JRST FLUSH
LAST:	START:
	MOVE A,RELJFN
	BIN		;THROW AWAY RELOCATION WORD
	SOS BLKSIZ		;BUT ACCOUNT FOR IT
	TLNN B,(1B1)		;IS ADDRESS RELOCATED?
	JRST ST2		;NO
	MOVE A,OUTJFN		;YES, TYPE QUOTE MARK
	MOVEI B, "'"
	BOUT
	MOVE A,RELJFN

ST2:	BIN		;START OR LAST ADDRESS
	SOS BLKSIZ
	MOVE A,OUTJFN
	MOVEI C,10		;OCTAL TYPEOUT
	NOUT
	PUSHJ P,ERROR


FLUSH:	MOVE A,RELJFN
	RFPTR
	PUSHJ P,ERROR
	ADD B,BLKSIZ
	SFPTR
	PUSHJ P,ERROR
	JRST BLK
TYPSYM:	MOVE A,RELJFN
	BIN	;RADIX50 SYMBOL
	SOS BLKSIZ	;ACCOUNT FOR IT
	MOVE A,OUTJFN
	PUSHJ P,R50ASC	;CONVERT IT TO ASCII
	HRROI B,WRDBUF
	SETZ C,
	SOUT
	SOJG D,TYPSYM
	POPJ P,

ENDCHK:	PUSHJ P,CRLF
	MOVE A,RELJFN
	GTSTS
	TLNE B,(1B8)
	JRST FIN	;END OF FILE
	MOVEI B,1
	MOVEM B,TOTWD	;COUNT NUMBER OF ZEROES
	AOS TOTAL
	SETOM ZERFLG

FLSHZ:	BIN
	JUMPN B,T5	;SOMETHING NONZERO?
	AOS TOTWD
	AOS TOTAL
	JRST FLSHZ

T5:	PUSHJ P,ERRBLK
	JRST BLK2


ERRBLK:	SETZM ZERFLG
	PUSH P,B	;SAVE NONZERO THING
	MOVE A,OUTJFN
	SETZ B,
	MOVE C,[XWD 10,10]	;TYPE 0
	NOUT			;8 COLUMNS
	PUSHJ P,ERROR
	NOUT			;0 DATA WORDS
	PUSHJ P,ERROR
	MOVE B,TOTWD		;NUMBER OF ZEROES
	NOUT
	PUSHJ P,ERROR
	HRROI B, [ASCIZ/NIL     /]
	SETZ C,
	SOUT
	POP P,B			;NEW HEADER WORD
	POPJ P,
FIN:	SKIPE ZERFLG
	PUSHJ P,ERRBLK
	MOVE A,OUTJFN
	PUSHJ P,CRLF
	HRROI B,[ASCIZ/
TOTAL FILE LENGTH (DECIMAL WORDS)  = /]
	SETZ C,
	SOUT
	MOVE B,TOTAL
	MOVEI C,^D10	;DECIMAL
	NOUT
	PUSHJ P,ERROR
	PUSHJ P,CRLF
	PUSHJ P,CRLF
	MOVEI A,400000
	CLZFF		;CLOSE FILES
	HRROI A,[ASCIZ /
DONE.
/]
	PSOUT
	HALTF

CRLF:	PUSH P,B
	MOVEI B,15
	BOUT
	MOVEI B,12
	BOUT
	POP P,B
	POPJ P,

FORTR:	SETZM DATAW
	MOVEI 2,1
	MOVEM 2,TOTWD		;KEEP WORD COUNTS
	MOVE A,RELJFN
LP40:	MOVE 2,[POINT 36,BUFF]
	MOVEI 3,1000		;READ 1000 WORDS
	MOVNI 4,2		;OR FIRST -2 WORD
	SIN
	HRREI C,-1000(C)
	MOVN C,C		;WORD COUNT
	ADDM 3,DATAW
	ADDM 3,TOTWD
	MOVE 3,0(2)		;LAST WORD
	CAME 3,[EXP -2]
	JRST LP40

	MOVE A,OUTJFN
	MOVE B,DATAW
	MOVE C,[XWD 10,10]	;8-COLUMN OCTAL
	NOUT
	PUSHJ P,ERROR
	MOVE B,TOTWD
	ADDM B,TOTAL
	NOUT
	PUSHJ P,ERROR
	HRROI B,TABEND-2	;FORTRAN
	SETZ C,
	SOUT

KLUDGE:	SETZ C,		;WORD COUNT
	MOVE A,RELJFN
	BIN
	BIN		;IGNORE TWO WORDS
	MOVEI D,5
	PUSHJ P,FLSH	;IGNORE FIVE BLOCKS
	BIN		;IGNORE ONE WORD
	MOVEI D,1
	PUSHJ P,FLSH	;IGNORE ONE BLOCK
	MOVEM C,DATAW	;DATA WORD COUNT
	ADDI C,11	;11 CONTROL WORDS
	MOVEM C,TOTWD
	MOVE A,OUTJFN
	PUSHJ P,CRLF
	SETZ B,
	MOVE C,[XWD 10,10]
	NOUT
	PUSHJ P,ERROR
	MOVE B,DATAW
	NOUT
	PUSHJ P,ERROR
	MOVE B,TOTWD
	ADDM B,TOTAL
	NOUT
	PUSHJ P,ERROR
	HRROI B,TABEND-2	;FORTRAN
	SETZ C,
	SOUT
	JRST BLK	;GET ANOTHER BLOCK
FLSH:	BIN
	ADDI C,(B)	;DATA WORD COUNT
	MOVEM B,BLKSIZ
	RFPTR
	PUSHJ P,ERROR
	ADD B,BLKSIZ
	SFPTR
	PUSHJ P,ERROR
	SOJG D,FLSH
	POPJ P,

TYPTAB:	TABLE<ALGSYM  ,PROG    ,SYM     ,HISEG   ,ENTRY   ,LAST    >
	TABLE<NAME    ,START   ,LOCD    ,POLFIX  ,LINK    ,LVARB   >
	TABLE<INDEX   ,ALGBLK  ,LDPRG   ,LDLIB   ,ASSIGN  ,FORTRAN >
TABEND:

R50ASC:	PUSH P,A
	MOVEI A,10	;8 COLUMNS
	TLZ B,740000
	PUSHJ P,R2	;CONVERT TO STRING
	MOVEI B,40	;FILL WITH TRAILING SPACES

R3:	JUMPLE A,R4	;ALL COLUMNS FULL?
	IDPB B,CHPTR
	SOJG A,R3	;UNTIL ALL FULL

R4:	POP P,A
	POPJ P,

R2:	IDIVI B,50
	CAIG C,44
	CAIGE C,1	;ALPHANUMERIC?
	JRST NOTALN	;NO
	ADDI C,57
	CAILE C,71	;ALPHA?
	ADDI C,7	;YES
	JRST STACK
NOTALN:	SUBI C,2
	CAIGE C,44	;DOL OR PERCENT?
	ADDI C,13	;NO,PERIOD

STACK:	HRLM C,(P)	;SAVE DIGIT
	SUBI A,1	;COLUMN COUNT
	JUMPE B,PACK
	PUSHJ P,R2

PACK2:	HLRZ B,(P)
	IDPB B,CHPTR
	POPJ P,

PACK:	MOVE B,[POINT 7,WRDBUF]
	MOVEM B,CHPTR
	SETZM WRDBUF
	SETZM WRDBUF+1
	JRST PACK2

ENDFIL:	MOVEI A,FIN
	SKIPA

DATERR:	MOVEI A,ERROR
	EXCH A,SAVPC
	MOVEM A,SAVPC2
	DEBRK
	HALTF

ERROR:	MOVE B,[XWD 400000,-1]	;MOST RECENT ERROR
	MOVEI A,101
	SETZ C,
	ERSTR
	JFCL
	JFCL
	HRROI B,[ASCIZ/
LOCATION = /]
	SOUT
	HRRZ B,(P)
	MOVE C,[XWD  10,10]
	NOUT
	PUSHJ P,ERROR
	HALTF
ERR1:	HRROI A,[ASCIZ/
ILLEGAL BLOCK TYPE
/]
	PSOUT
	HALTF
JBLKO:	1B0+1B3+1B4		;OUTPUT, CONFIRM
	XWD 100,101
	EXP 0,0,0,0,0,0,0

JBLKI:	1B2+1B4	;OLD FILE, CONFIRM
	XWD 100,101
	XWD -1,[ASCIZ /DSK/]
	EXP 0,0
	XWD -1,[ASCIZ /REL/]
	EXP 0,0,0

LEVTAB:	EXP SAVPC,0,0
CHNTAB:	REPEAT ^D10,< Z >
	XWD 1, ENDFIL
	REPEAT 3,< XWD 1, DATERR >
	REPEAT ^D22, < Z >

	LIT
CODEND:

PATCH:	BLOCK 20
PDL:	BLOCK 20
RELJFN:	BLOCK 1
OUTJFN:	BLOCK 1
TOTAL:	BLOCK 1
WRDBUF:	BLOCK 2
CHPTR:	BLOCK 1
BLKSIZ:	BLOCK 1
BLKTYP:	BLOCK 1
DATAW:	BLOCK 1
TOTWD:	BLOCK 1
SAVPC:	BLOCK 1
SAVPC2:	BLOCK 1
ZERFLG:	BLOCK 1
BUFF:	BLOCK 1000

	END TYPREL