/ EDIT #102
/
/ COPYRIGHT 1969, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/
/ CHAIN V1A	     26 JAN 70	        H. KREJCI
/
/ COMMAND INPUT -- ALL KEYED IN INFORMATION IS ACCEPTED IN LOGICAL
/ LINES.  A CARRIAGE RETURN IS USED TO CONTINUE A LOGICAL LINE
/ ONTO THE NEXT PHYSICAL LINE.  AN ALTMODE IS USED TO TERMINATE
/ A LOGICAL LINE.  A LINE CONSISTS OF NAMES (ROUTINES, OPTIONS,
/ PARAMETERS), LIBRARY INDICATORS, AND BREAK CHARACTERS (NAME
/ TERMINATORS).  BLANKS ARE IGNORED.  NAMES MAY CONSIST OF 1-6
/ ALPHANUMERIC CHARACTERS.  A LIBRARY INDICATOR (#) MAY APPEAR ANY
/ WHERE WITHIN A NAME TO INDICATE THAT THE BINARY UNIT OF
/ A ROUTINE IS NOT TO BE FOUND ON THE USER'S DEVICE, BUT RATHER
/ WITHIN A LIBRARY.
/ THE FOLLOWING CHARACTERS ARE RECOGNIZED AS BREAK CHARACTERS,
/ BUT ONLY ACCEPTED AS VALID BREAK CHARACTERS WHEN APPROPRIATE:
/ EQUAL SIGN, COLON, COMMA, SLASH, & ALTMODE.  WHEN A COMMAND
/ INPUT ERROR IS DETECTED, THE ENTIRE LOGICAL LINE IS REJECTED.
/ IOPS ASCII EDITING (RUBOUT AND ^U) APPLY ONLY TO PHYSICAL LINES.
/
/ ^P USES:
/ TO RESTART CHAIN DURING COMMAND INPUT
/ TO RESTART A READ OPERATION AFTER EOM
/ TO READ A FILE FROM A NON-FILE-ORIENTED DEVICE
/ (THE REQ'D FILE NAME IS TYPED OUT BEFORE READING)
/ TO CONTINUE AFTER A PAUSE
/ AT ANY OTHER TIME, ^P WILL EXIT TO MONITOR.
/
/ INDICATOR WORDS -- INDICATOR WORDS USED IN TABLES (RCL, LDT, ODT, 
/ & TTL'S) HAVE THE FOLLOWING BIT DESIGNATIONS:
/    BIT 17 -- THIS ENTRY DEFINES A LINK NAME
/    BIT 16 -- THIS ENTRY DEFINES AN EXTERNAL LINK COMPONENT
/    BIT 15 -- THIS ENTRY DEFINES AN INTERNAL LINK COMPONENT
/    BIT 14 -- ROUTINE IS ON USER'S DEVICE
/    BIT 13 -- ROUTINE IS IN A LIBRARY
/    BIT 11 -- ROUTINE IS RESIDENT (RCL ENTRY)
/
/ CHAIN IS WRITTEN TO RUN AS AN ABSOLUTE SYSTEM PROGRAM (BANK
/ ADDRESSING) ON A PDP-15 UNDER THE KEYBOARD MONITOR.  DEFINING
/ THE FOLLOWING PARAMETERS WILL CONDITIONALIZE CHAIN FOR OTHER
/ ENVIRONMENTS.
/
/ PDP9=0	PDP-9
/ BF=0	B/F MONITOR
/ PTP=0	I/O (PAPER TAPE) MONITOR
/	WHEN ASSEMBLING FOR A PAPER TAPE MONITOR, THE SYSTEM 
/	CORE SIZE MUST BE SPECIFIED AS FOLLOWS.
/	FOR A PDP-15, DEFINE:
/	PAGE=N	WHERE N IS ONE LESS THAN THE NUMBER OF 4K PAGES
/	FOR A PDP-9, DEFINE:
/	BANK=N	WHERE N IS ONE LESS THAN THE NUMBER OF 8K BANKS
/
	.EJECT
	.ABS
/
	.IFUND	PTP
	.LOC	10000
	.ENDC
	.IFDEF	PTP
	.IFUND	PDP9
	.IFUND	PAGE
	.END	ERR -- PAGE MUST BE DEFINED
	.ENDC
	.LOC	PAGE+1/2*2-1*10000
	.ENDC
	.IFDEF	PDP9
	.IFUND	BANK
	.END	ERR -- BANK MUST BE DEFINED
	.ENDC
	.LOC	BANK*20000+10000
	.ENDC
	.ENDC
/
	.IFDEF	BF
BFM=0
	.ENDC
/
.SCOM=100
SL=-1	/SYSTEM LIBRARY
CI=-2	/COMMAND INPUT
TO=-3	/TYPED OUTPUT
UD=-4	/USER PROGRAM DEVICE
UL=-5	/USER'S LIBRARY
RO=-6	/RELOCATED OUTPUT
	.EJECT
/ PROGRAM ENTRY
/
START	LAC*	(.SCOM)	/SAVE BANK BITS
	AND	(060000)
	DAC	BNKBTS
	LAC	(BRTBL-1)	/SET BANK BITS ON ALL ADDRESSES
	JMS	SETBBS	/LISTED IN THE BANK RELOCATION
	DAC*	(10)	/TABLE (BRTBL)
BRL	LAC*	10
	SPA
	JMP	INTLIZ
	JMS	SETBBS
	DAC	TEMP1
	LAC*	TEMP1
	JMS	SETBBS
	DAC*	TEMP1
	JMP	BRL
/
	.EJECT
INTLIZ	DZM	MAX.XX	/INITIALIZE MAX BLANK COMMON BLOCK SIZE
ICIZ	.INIT CI,0,CPTYPD	/SETUP ^P TRANSFER ADDRESS
	JMS	TYPE	/TYPE PROGRAM NAME AND VERSION
	MES1
/
/ DETERMINE XCT FILE NAME AND .ENTER IN OUTPUT DEVICE DIRECTORY
/
	JMS	CRTN	/REQUEST XCT FILE NAME
	JMS	TYPE
	MES20
/
DXNSNL	JMS	RFAN	/READ A LINE AND FETCH FIRST NAME
	LAC	FANM	/ERR 101 IF 0 OR 7 CHAR NAME
	SZA
	JMP	.+4
	JMS	ERR1
	MES101
	JMP	DXNSNL
	DAC	ROFNAM
	LAC	FANM+1
	DAC	ROFNAM+1
	LAC	FANB	/ERR 103 IF OTHER THAN ALTMODE BREAK
	SAD	(175)
	JMP	.+4
	JMS	ERR3
	MES103
	JMP	DXNSNL
	JMS	CRTN
IROD	.INIT	RO,1,0	/OPEN XCU OR DUMMY XCT FILE
ERO1Z	.ENTER	RO,ROFNAM
	LAC	IROD+3	/SET DUMMY FILE SWITCH IF RO DEVICE IS
	AND	(700)	/FILE-ORIENTED.  OTHERWISE, CLEAR SWITCH
	DAC	DFSW
	.EJECT
/ FETCH AND RECORD OPTIONS AND PARAMETERS
/
	JMS	TYPE	/REQUEST OPTIONS & PARAMETERS
	MES30
FROSNL=.			/SET DEFAULT PARAMETERS & OPTIONS
	.IFUND	BFM
	.IFUND	PDP9
	LAC*	(.SCOM+20)
	SMA
	JMP	.+4
	AND	(070000)
	XOR	(007777)
	JMP	.+4
	.ENDC
	.ENDC
	LAC*	(.SCOM)
	AND	(070000)
	TAD	BSADR
	DAC	LDLMT
	DZM	BFFLAG
	DZM	SZFLAG
	DZM	GMFLAG
	DZM	PSFLAG
	LAC	(+1)
	DAC	LMFLAG
	LAW	-1
	DAC	FGDBSE
	.IFDEF	PDP9
	LAC	(17777)
	.ENDC
	.IFUND	PDP9
	LAC	(07777)
	.ENDC
	DAC	ADRMSK
	CMA
	DAC	OPCMSK
/
	JMS	RFAN	/READ LINE AND FETCH FIRST NAME
	JMS	ZLLX	/ZERO LENGTH LINE?
	JMP	FROENV	/YES -- NO OPTIONS OR PARAMETERS SPECIFIED
FRONX	LAC	FANM	/NO -- ERR 101 IF 0 OR 7 CHAR NAME
	SZA
	JMP	.+4
	JMS	ERR1
	MES101
	JMP	FROSNL
	LAC	FANB	/ERR 103 IF BREAK CHAR IS NOT A
	SAD	(054)	/COMMA, ALTMODE, OR COLON
	JMP	FRONC
	SAD	(175)
	JMP	FRONC
	SAD	(072)
	SKP		/COLON BREAK, ACCEPT ONLY IF 
	JMP	FRO103	/FGD OPTION
	LAC	FANM
	SAD	(060704)
	JMP	FROFFB
FRO103	JMS	ERR3
	MES103
	JMP	FROSNL
/
FROFFB	DZM	FGDBSE	/SPECIAL CASE -- FGD:XXX -- ACCEPT
FROFB1	JMS	FAC	/OCTAL CHARACTERS (0-7) TERMINATED BY A
	SAD	(054)	/COMMA OR ALTMODE.  IF MORE THAN 
	JMP	FROFB2	/FIVE OCTAL CHARACTERS, ACCEPT ONLY 
	SAD	(175)	/THE LAST FIVE.  ERR 32 IF A NON-OCTAL
	JMP	FROFB2	/CHARACTER IS FOUND.
	AND	(077)
	XOR	(060)
	DAC	TEMP11
	AND	(070)
	SZA
	JMP	FROFB3
	LAC	FGDBSE
	RCL
	RTL
	AND	(077770)
	XOR	TEMP11
	DAC	FGDBSE
	JMP	FROFB1
/
FROFB2	DAC	FANB	/SET BREAK CHAR AS IF FOUND BY SUB 'FAN'
	JMP	FROFGD
/
FROFB3	LAC	(727777)	/NON-OCTAL CHAR FOUND, TYPE:
	DAC	FANM+1	/   UNRECOGNIZED SYMBOL -- FGD:??
	JMP	FRO32
/
FRONC	LAC	FANM+1	/COMPARE NAME WITH RECOGNIZED OPTION
	SZA		/AND PARAMETER SYMBOLS, ERR 32 IF MATCH 
	JMP	FRO32	/NOT FOUND
	LAC	FANM
	SAD	(060704) /FGD
	JMP	FROFGD
	SAD	(020704) /BGD
	JMP	FROBGD
	SAD	(200122) /PAR
	JMP	FROPAR
	SAD	(200114) /PAL
	JMP	FROPAL
	SAD	(207100) /P9
	JMP	FROP9
	SAD	(206165) /P15
	JMP	FROP15
	SAD	(161500) /NM
	JMP	FRONM
	SAD	(071500) /GM
	JMP	FROGM
	SAD	(233200) /SZ
	JMP	FROSZ
	SAD	(701300) /8K
	JMP	FRO8K
	SAD	(616613) /16K
	JMP	FRO16K
	SAD	(626413) /24K
	JMP	FRO24K
	SAD	(636213) /32K
	JMP	FRO32K
	SAD	(616213) /12K
	JMP	FRO12K
	SAD	(626013) /20K
	JMP	FRO20K
	SAD	(627013) /28K
	JMP	FRO28K
FRO32	JMS	ERR2	/SYMBOL NOT RECOGNIZED
	MES32
	JMP	FROSNL
/
FROFGD	LAC	(001)	/SET B/F FLAG = 1 (FGD)
	SKP
FROBGD	CLA		/SET B/F FLAG = 0 (BGD)
	DAC	BFFLAG
	JMP	FROLNX
FROPAR	LAC	PSFLAG	/SETUP TO 'PAUSE AFTER RESIDENT' IF PAUSE
	SNA		/FLAG IS CLEARED (ZERO).
	LAW	-1
	SKP
FROPAL	LAC	(+1)	/SETUP TO 'PAUSE AFTER LINK' (INCLUDING 
	DAC	PSFLAG	/RESIDENT CODE)
	JMP	FROLNX
FROP9	LAC	(017777)	/SET ADDRESS AND OPCODE MASKS FOR PDP-9
	DAC	ADRMSK
	CMA
	DAC	OPCMSK
	JMP	FROLNX
FROP15	LAC	(007777)	/SET ADDRESS AND OPCODE MASKS FOR PDP-15
	DAC	ADRMSK
	CMA
	DAC	OPCMSK
	JMP	FROLNX
FRONM	DZM	LMFLAG	/CLEAR LOAD MAP FLAG
	JMP	FROLNX
FROGM	ISZ	GMFLAG	/SET GLOBAL MAP FLAG
	JMP	FROLNX
FROSZ	ISZ	SZFLAG	/SET SIZE FLAG
	JMP	FROLNX
FRO8K	LAC	(10000)	/SETUP MAX ADDRESS FOR AN "8K SYSTEM"
	SKP
FRO16K	LAC	(30000)
	SKP
FRO24K	LAC	(50000)
	SKP
FRO32K	LAC	(70000)
	TAD	BSADR
	DAC	LDLMT
	JMP	FROLNX
FRO12K	LAC	(27777)	/SETUP MAX ADDRESS FOR A "12K SYSTEM"
	SKP
FRO20K	LAC	(47777)
	SKP
FRO28K	LAC	(67777)
	DAC	LDLMT
	JMP	FROLNX
/
FROLNX	LAC	FANB	/LAST NAME TEST
	SAD	(175)	/ALTMODE BREAK?
	JMP	FROINT	/YES -- INITIALIZE PER ACCEPTED OPTIONS & PARAMS
	JMS	FAN	/NO -- FETCH ANOTHER NAME
	JMP	FRONX
/
FROINT	LAC	SZFLAG	/INCREASE MAP LINE LENGTH IF SIZE OPTION
	SNA
	JMP	FROENV
	LAC	(016000)
	DAC	MAPBUF
	LAC	(040)
	DAC	MAPFAD+13
FROENV	LAC	ADRMSK	/SET ENVIRONMENT INDICATOR
	AND	(010000)	/  BIT-16 FOR PDP-9
	RCL		/  BIT-17 FOR FGD
	JMS	LCS7
	XOR	BFFLAG
	DAC	ENVIND
	LAC	ADR10	/SETUP CORE-LIMITS-TABLE (CLT) CONSISTING
	DAC	CLTX1	/OF UPPER LIMITS OF EACH EXITSING CORE
	LAC	LDLMT	/BANK OR PAGE (PDP-9/PDP-15) TERMINATED BY
FROCT1	DAC*	CLTX1	/A -1 (MAX 9 WORDS)
	SAD	(-1)
	JMP	FROCT2
	AND	OPCMSK
	TAD	(-1)
	ISZ	CLTX1
	JMP	FROCT1
/
FROCT2	LAC	CLT	/"12K SYSTEM"?
	AND	(7777)
	SAD	(7777)
	SKP		/YES -- TEST FOR "12K PDP-9"
	JMP	FROLMT	/NO -- CLT IS COMPLETE
	LAC	ADRMSK	/PDP-9 (NON 12-BIT ADDRESS)?
	SAD	(07777)
	JMP	.+4
	JMS	ERR1	/YES -- ERR 33
	MES33
	JMP	FROSNL
	LAC	CLT+1	/NO -- ADJUST SECOND CLT WORD FOR
	AND	(770000)	/BOOTSTRAP
	XOR	BSADR
	DAC	CLT+1
/
FROLMT	LAC	BFFLAG	/SET LDLMT TO A LOW CORE LIMIT IF 
	SNA		/BUILDING A FGD CHAIN
	JMP	FRORCL
	LAC	FGDBSE
	SPA
	.IFUND	BFM
	LAC	FGDLMT
	.ENDC
	.IFDEF	BFM
	LAC*	(.SCOM+106)
	.ENDC
	DAC	LDLMT
/
	.EJECT
/ READ ONE LINE OF RESIDENT CODE NAMES (MINIMUN, ONE NAME) AND
/ CONSTRUCT THE RESIDENT-CODE-LIST (RCL).
/ RCL ENTRY FORMAT:
/    INDICATOR WORD
/    ROUTINE NAME (TWO WORDS
/    .SIXBT RT FILLED WITH ZEROS)
/
FRORCL	JMS	CRTN		/REQUEST RESIDENT CODE LIST
	JMS	TYPE
	MES50
	LAC*	(.SCOM+2)		/SET BASE OF RCL 
	DAC	RCLBSE		/RCL ENTRY INDEX
/
RCLSNL	LAC	RCLBSE		/START NEW LINE -- SET ENTRY
	DAC	LDTX1		/INDEX
	JMS	RFAN		/READ A LINE AND FETCH AN NAME
	LAC	FANM
	SZA			/ ERR 51 IF ZERO LENGTH LINE
	JMP	RCLIX		/ OTHERWISE, ERR 101 IF 0 OR 7 CHARACTER NAME
	LAC	FANM+1		/
	SNA			/ OTHERWISE, ACCEPT NAME
	JMP	.+4		/ AS NAME OF MAIN PROGRAM
RCL101	JMS	ERR1		/ IF COMMA OR ALTMODE BREAK
	MES101			/ CHARACTER
	JMP	RCLSNL
	LAC	FANB
	SAD	(175)
	SKP
	JMP	RCL101
	JMS	ERR1
	MES51
	JMP	RCLSNL
RCLIX	LAC	FANI		/ERR 52 IF LIB INDICATOR
	AND	(020)		/ON MAIN PROG NAME
	SNA
	JMP	RCLBX
	JMS	ERR1
	MES52
	JMP	RCLSNL
RCLBX	LAC	FANB		/BREAK CHARACTER TEST --
	SAD	(054)		/ERR 103 IF OTHER THAN
	JMP	RCLNX		/COMMA OR ALTMODE.
	SAD	(175)
	JMP	RCLNX
	JMS	ERR3
	MES103
	JMP	RCLSNL
RCLNX	LAC	RCLBSE		/ERR 118 IF NAME HAS
	JMS	LDTSCN		/ALREADY BEEN ENTERED IN RCL
	SPA
	JMP	.+4
	JMS	ERR2
	MES118
	JMP	RCLSNL
	LAC	FANI		/MAKE RCL ENTRY
	AND	(070)
	XOR	(100)
	DAC	FANI
	JMS	LDTENT
/
	LAC	FANB		/ALTMODE BREAK CHARACTER?
	SAD	(175)
	JMP	RCLLDT		/YES -- END OF LIST
/
	JMS	FAN		/NO -- FETCH ANOTHER NAME
	LAC	FANM		/ ERR 101 IF 0 OR 7 CHARS
	SZA
	JMP	RCLBX
	JMP	RCL101
/
	.EJECT
RCLLDT	LAC	LDTX1	/END RCL AND START LDT.  RCL WILL BE
	DAC	LDTBSE	/FOLLOWED BY AN INDICATOR FOR A LINK DEFINITION
	DAC	LDTLSX	/(001) EVEN IF THERE ARE NO LINK DEFINITIONS.
			/THIS IS NECESSARY WHEN RELOCATING THE RESIDENT
			/CODE (TERMINATES LIST SCAN IN SUBROUTINE RAO).
/
/ READ LINK DEFINITIONS (IF ANY) AND CONSTRUCT THE
/ LINK-DEFINITION-TABLE (LDT) FOLLOWING THE RCL.
/ LDT ENTRY FORMAT
/    INDICATOR -- SAME AS RCL
/    NAME -- SAME AS RCL
/
	JMS	CRTN
	JMS	TYPE		/TYPE --
	MES60			/"DESCRIBE LINKS & STRUCTURE"
/
LDTSNL	DZM	LDTEIF		/START NEW LINE, SET E/I FLAG TO EXT.
	JMS	RFAN		/READ LINE AND FETCH FIRST NAME
	LAC	FANM		/ERR 101 IF 0 OR 7 CHAR NAME
	SZA
	JMP	LDTECX
	LAC	FANM+1	/INTERPRET ZERO LENGTH LINE AS 'RESIDENT ONLY' 
	SNA
	JMP	RCO
	JMS	ERR1
	MES101
	JMP	LDTRSL
LDTECX	LAC	FANB		/TEST FOR EQUALS OR COLON BREAK CHAR
	SAD	(075)		/ IF EQUAL SIGN -- LINK DEFINITION
	JMP	LDTSN1		/ IF COLON -- END LINK DEFINITIONS
	SAD	(072)		/ AND START OVERLAY DESCRIPTION
	JMP	LDTODT		/ IF OTHER -- ERR 103
	JMS	ERR3
	MES103
	JMP	LDTRSL
LDTSN1	LAC	RCLBSE		/SCAN RCL & LDT FOR NAME
	JMS	LDTSCN		/JUST FETCHED FROM COMMAND STRING
	SPA			/ERR 102 IF FOUND
	JMP	.+4
	JMS	ERR2
	MES102
	JMP	LDTRSL
	LAC	FANI		/TEST FETCHED NAME INDICATOR FOR
	AND	(020)		/BIT-13. ERR 113 IF 
	SNA			/SET. OTHERWISE, SET INDICATOR
	JMP	.+4		/FOR A LINK NAME LDT ENTRY.
	JMS	ERR2		/I.E., SET BIT-17 & CLEAR OTHERS.
	MES113
	JMP	LDTRSL
	LAC	(001)
	DAC	FANI
	JMS	LDTENT		/ENTER INDICATOR & NAME IN LDT
/
LDTFAN	JMS	FAN		/FETCH ANOTHER NAME
	LAC	FANM		/ERR 101 IF 0 OR 7 CHAR NAME
	SZA
	JMP	.+4
	JMS	ERR1
	MES101
	JMP	LDTRSL
	LAC	FANB		/TEST FOR COMMA, ALTMODE, OR SLASH
	SAD	(054)		/BREAK CHARACTER. ERR 103 IF OTHER.
	JMP	LDTSFX
	SAD	(175)
	JMP	LDTSFX
	SAD	(057)
	JMP	LDTSSF
	JMS	ERR3
	MES103
	JMP	LDTRSL
LDTSSF	LAC	LDTEIF		/SLASH BREAK, ERR 103 IF
	SNA			/E/I FLAG IS ALREADY SET
	JMP	.+4		/INTERNAL.  OTHERWISE, SET E/I
	JMS	ERR3		/TO EXTERNAL 
	MES103
	JMP	LDTRSL
	ISZ	LDTEIF
	JMP	LDTSN3
LDTSFX	LAC	LDTEIF		/COMMA OR ALTMODE BREAK, TEST FOR
	SNA			/SLASH READ
	JMP	LDTSN3
	LAC	RCLBSE		/INTERNAL COMPONENT NAME -- SCAN
LDTSN2	JMS	LDTSCN		/RCL & LDT FOR NAME.  ERR 116
	SPA			/IF NAME IS FOUND AND IS NOT
	JMP	LDTSN4		/ALSO AN INTERNAL COMPONENT
	DAC	TEMP1		/NAME
	LAC*	TEMP1
	AND	(004)
	SNA
	JMP	.+4
	LAC	TEMP1
	TAD	LDTESZ
	JMP	LDTSN2
	JMS	ERR2
	MES116
	JMP	LDTRSL
/
LDTSN4	LAC	LDTLSX		/ERR 104 IF NAME IS FOUND IN 
	JMS	LDTSCN		/CURRENT LINE
	SMA
	JMP	.+3
	LAC	(004)		/(BIT-15 FOR INT SUB NAME)
	JMP	LDTEN2
	JMS	ERR2
	MES104
	JMP	LDTRSL
				/EXTERNAL LINK COMPONENT NAME --
LDTSN3	LAC	RCLBSE		/SCAN RCL & LDT FOR NAME, ERR 105
	JMS	LDTSCN		/IF FOUND.
	SMA
	JMP	.+3
	LAC	(002)		/(BIT-16 FOR EXT SUB NAME)
	JMP	LDTEN2
	JMS	ERR2
	MES105
	JMP	LDTRSL
LDTEN2	XOR	FANI		/SET INDICATOR AND MAKE
	DAC	FANI		/LDT ENTRY
	JMS	LDTENT
	LAC	FANB		/END OF LINE?
	SAD	(175)
	SKP
	JMP	LDTFAN		/NO -- FETCH ANOTHER NAME
	LAC	LDTX1		/YES -- UPDATE LINE START
	DAC	LDTLSX		/INDEX AND START A NEW
	JMP	LDTSNL		/LINE
/
LDTRSL	LAC	LDTLSX	/ERROR DETECTED, RESTART LOGICAL LINE
	DAC	LDTX1
	JMP	LDTSNL
/
/ LDTENT -- SUBROUTINE TO MAKE A RCL OR LDT ENTRY.
/           THE INDICATOR AND NAME ARE TAKEN FROM FANI, FANM,
/           & FANM+1.
/           LDTX1 IS UPDATED TO POINT TO THE NEXT LDT ENTRY
/
LDTENT	0
	LAC	FANI
	JMS	LDTENS
	LAC	FANM
	JMS	LDTENS
	LAC	FANM+1
	JMS	LDTENS
	JMP*	LDTENT
/
LDTENS	0
	DAC*	LDTX1
	ISZ	LDTX1
	JMP*	LDTENS
/
/ LDTSCN -- SUBROUTINE TO SCAN THE RCL OR LDT FOR
/           THE NAME CONTAINED IN FANM & FANM+1.  THE SCAN 
/           START INDEX IS TAKEN FROM AC.  IF NAME IS
/           FOUND, THE LDT ENTRY INDEX IS RETURNED IN AC.
/           IF NOT FOUND, AC IS SET TO -1
/           TEMP1 IS USED TO SCAN ENTRIES
/           TEMP2 IS USED TO SCAN WITHIN ENTRIES
/
LDTSCN	0
LDTSC1	SAD	LDTX1	/TEST FOR END OF TABLE
	JMP	LDTSC3
	DAC	TEMP1
	DAC	TEMP2
	ISZ	TEMP2	/COMPARE TWO WORD NAME
	LAC*	TEMP2
	SAD	FANM
	SKP
	JMP	LDTSC2	/FIRST WORD, NO MATCH
	ISZ	TEMP2
	LAC*	TEMP2
	SAD	FANM+1
	SKP
	JMP	LDTSC2	/SECOND WORD, NO MATCH
	LAC	TEMP1	/NAME MATCH, EXIT WITH AC CONTAINING THE
	JMP*	LDTSCN	/INDEX OF ENTRY WITH MATCHING NAME.
/
LDTSC2	LAC	TEMP1	/NO MATCH, AUGMENT ENTRY INDEX
	TAD	LDTESZ
	JMP	LDTSC1
/
LDTSC3	LAW	-1	/NAME NOT FOUND IN LDT, EXIT WITH
	JMP*	LDTSCN	/AC=-1
/
	.EJECT
LDTODT	LAC	(001)	/TERMINATE LDT WITH AN INDICATOR FOR A
	DAC*	LDTX1	/LINK DEFINITION.
	LAC	LDTX1	/INITIALIZE ODT
	TAD	(001)
	DAC	ODTX1	/ODT IS PRECEDED BY AN ALTMODE TO PROVIDE
	LAC	(175)	/A 'PREVIOUS BREAK CHARACTER' FOR THE
	DAC*	ODTX1	/FIRST ODT ENTRY.
	ISZ	ODTX1
	LAC	ODTX1
	DAC	ODTBSE
	DAC	ODTLSX
	JMP	ODTSN1
/
/ READ OVERLAY DESCRIPTION COMMANDS AND CONSTRUCT THE
/ OVERLAY DESCRIPTION TABLE (ODT) FOLLOWING THE LDT.
/ ODT ENTRY FORMAT:
/    INDICATOR--SAME AS IN LDT
/    NAME--SAME AS IN LDT
/    REGISTER USED WHEN PROCESSING LDT (BACK POINTER)
/    BREAK CHARACTER (IMAGE ALPHA)
/
ODTSNL	NOP			/START NEW LINE
	JMS	RFAN		/READ COMMAND LINE  & FETCH FIRST NAME
	LAC	FANM		/TEST FOR NAME SIZE ERROR
	SZA
	JMP	ODTCX1
	LAC	FANM+1		/NAME SIZE ERROR -- IF ZERO
	SNA			/LENGTH NAME & ALTMODE BREAK
	JMP	.+4		/(I.E., ZERO LENGTH LINE), TERMINATE
ODT101	JMS	ERR1		/ODT, OTHERWISE ERR 101
	MES101
	JMP	ODTRSL
	LAC	FANB
	SAD	(175)
	SKP
	JMP	ODT101
	LAC	ODTX1		/ZERO LENGTH LINE, TERMINATE
	SAD	ODTBSE		/ODT, UNLESS ZERO LENGTH ODT.
	JMP	ODT101
	JMP	ODTTTL
ODTCX1	LAC	FANB		/BREAK FOLLOWING FIRST NAME MUST
	SAD	(072)		/BE A COLON--ERROR IF NOT.
	JMP	ODTSN1		/  EQUAL SIGN, ERR 107
	SAD	(075)		/  OTHER, ERR 108
	JMP	.+4
	JMS	ERR1
	MES108
	JMP	ODTRSL
	JMS	ERR1
	MES107
	JMP	ODTRSL
/
ODTFAN	JMS	FAN		/FETCH ANOTHER NAME
	LAC	FANM		/ERR 101 IF 0 OR 7 CHAR NAME
	SNA
	JMP	ODT101
ODTSN1	LAC	RCLBSE		/SCAN RCL & LDT FOR NAME
	JMS	LDTSCN
	SMA
	JMP	ODTS1A
	LAC	FANI		/NOT FOUND--SET EXTERNAL NAME
	XOR	(002)		/BIT (16) IN FETCHED NAME INDICATOR
	DAC	FANI
	JMP	ODTCX2
ODTS1A	DAC	TEMP1		/NAME FOUND--
	LAC*	TEMP1		/ ERR 106 IF NAME IS A LINK COMPONENT
	AND	(100)		/ERR 117 IF NAME OF RESIDENT ROUTINE
	SNA
	JMP	.+4
	JMS	ERR2
	MES117
	JMP	ODTRSL
	LAC*	TEMP1
	AND	(001)		/ERR 113 IF NAME IS A LINK NAME
	SZA			/ AND A LIBRARY INDICATOR WAS
	JMP	.+4		/ KEYED IN.
	JMS	ERR2		/ OTHERWISE, ACCEPT NAME AND
	MES106			/ SET INDICATOR BIT-17 (CLEAR OTHERS)
	JMP	ODTRSL		/ IN NAME FETCH INDICATOR (PREPARE
	LAC	FANI		/ FOR OTD ENTRY
	AND	(020)
	SNA
	JMP	.+4
	JMS	ERR2
	MES113
	JMP	ODTRSL
	LAC	(001)
	DAC	FANI
ODTCX2	LAC	FANB		/TEST BREAK CHARACTER FOR COLON.
	SAD	(072)		/COMMA OR ALTMODE.
	JMP	ODTLC		/ERR 103 IF OTHER
	SAD	(054)
	JMP	ODTRC
	SAD	(175)
	JMP	ODTRC
	JMS	ERR3
	MES103
	JMP	ODTRSL
ODTRC	LAC	ODTBSE		/BREAK CHARACTER IS COMMA OR ALTMODE.
	JMS	ODTSCN		/SINCE FIRST NAME MUST BE FOLLOWED
	SPA			/BY A COLON, THIS NAME MUST FOLLOW
	JMP	ODTE1		/A COLON.  A NAME MAY APPEAR ONCE
	JMS	ERR2		/ON THE RIGHT OF A COLON AND IF
	MES110			/USED LEFT OF A COLON IT MUST
	JMP	ODTRSL		/HAVE BEEN USED ON THE RIGHT FIRST.
				/THEREFORE, ERR 110 IF NAME IS
				/ALREADY IN THE ODT.
/
ODTLC	LAC	ODTX1		/COLON BREAK CHAR, I.E., NAME IS
	TAD	(-1)		/USED LEFT OF COLON -- TEST PREVIOUS
	DAC	TEMP1		/BREAK CHARACTER FOR COLON OR
	LAC*	TEMP1		/ALTMODE.  ERR 109 IF OTHER.
	SAD	(072)
	JMP	ODTCNC
	SAD	(175)
	JMP	ODTANC
	JMS	ERR1
	MES109
	JMP	ODTRSL
ODTCNC	LAC	ODTBSE		/COLON-NAME-COLON  NAME USED BOTH
	JMS	ODTSCN		/RIGHT & LEFT OF COLONS, AND
	SPA			/SHOULD NOT APPEAR AGAIN
	JMP	ODTE1		/IN THE ODT. ERR 111 IF FOUND
	JMS	ERR2
	MES111
	JMP	ODTRSL
ODTANC	LAC	ODTBSE		/ALTMODE-NAME-COLON  NAME IS USED
	JMS	ODTSCN		/LEFT OF COLON.  THEREFORE IF NAME
	SPA			/CAN BE FOUND IN THE ODT, IT MUST
	JMP	ODTE1		/BE RIGHT OF A COLON AND NOT ALSO
	TAD	(-1)		/LEFT OF A COLON (I.E., IT MUST
	TAD	ODTESZ		/NOT HAVE A COLON BREAK).  ERR 112
	DAC	TEMP1		/IF NAME IS FOUND WITH COLON BREAK.
	LAC*	TEMP1
	ISZ	TEMP1
	SAD	(072)
	SKP
	JMP	.+4
	JMS	ERR2
	MES112
	JMP	ODTRSL
	LAC	TEMP1		/NAME FOUND, BUT RIGHT OF COLON ONLY.
	JMS	ODTSCN		/CONTINUE ODT SCAN, ERR 111 IF
	SPA			/NAME IS FOUND AGAIN.
	JMP	ODTE1
	JMS	ERR2
	MES111
	JMP	ODTRSL
/
ODTE1	JMS	ODTENT		/MAKE ODT ENTRY
	LAC	FANB		/END OF LINE?
	SAD	(175)
	SKP
	JMP	ODTFAN		/NO--FETCH ANOTHER NAME
	LAC	ODTX1		/YES -- UPDATE LINE START
	DAC	ODTLSX		/INDEX AND START A NEW
	JMP	ODTSNL		/LINE
/
ODTRSL	LAC	ODTLSX	/ERROR DETECTED, RESTART LOGICAL LINE
	DAC	ODTX1
	JMP	ODTSNL
/
/ ODTENT -- SUBROUTINE TO MAKE AN OVERLAY-DESCRIPTION-TABLE ENTRY.
/	    THE INDICATOR, NAME, & BREAK CHARACTER ARE
/	    TAKEN FROM FANI, FANM, FANM+1, & FANB
/	    ODTX1 IS UPDATED TO POINT TO THE NEXT ODT ENTRY
/
ODTENT	0			/FORMAT: INDICATOR
	LAC	FANI		/         NAME
	JMS	ODTENS		/         NAME
	LAC	FANM		/         ZERO
	JMS	ODTENS		/         BREAK
	LAC	FANM+1
	JMS	ODTENS
	CLA
	JMS	ODTENS
	LAC	FANB
	JMS	ODTENS
	JMP*	ODTENT
/
ODTENS	0
	DAC*	ODTX1
	ISZ	ODTX1
	JMP*	ODTENS
/
/ ODTSCN -- SUBROUTINE TO SCAN THE OVERLAY-DESCRIPTION-TABLE
/	    FOR THE NAME CONTAINED IN FANM & FANM+1.  THE
/	    SCAN START INDEX IS TAKEN FROM AC.  IF NAME
/	    IS FOUND, THE LDT ENTRY INDEX IS LEFT IN AC.
/	    IF NOT FOUND, AC IS SET TO -1.
/             TEMP1 IS USED TO SCAN ENTRIES
/             TEMP2 IS USED TO SCAN WITHIN ENTRIES
/
ODTSCN	0
ODTSC1	SAD	ODTX1		/TEST FOR END OF TABLE
	JMP	ODTSC3
	DAC	TEMP1
	DAC	TEMP2
	ISZ	TEMP2		/COMPARE TWO WORDS
	LAC*	TEMP2
	SAD	FANM
	SKP
	JMP	ODTSC2		/FIRST WORD, NO MATCH
	ISZ	TEMP2
	LAC*	TEMP2
	SAD	FANM+1
	SKP
	JMP	ODTSC2		/SECOND WORD, NO MATCH
	LAC	TEMP1		/NAME MATCH, EXIT WITH AC CONTAINING THE
	JMP*	ODTSCN		/INDEX OF ENTRY WITH MATCHING NAME
ODTSC2	LAC	TEMP1		/NO MATCH, AUGMENT ENTRY INDEX
	TAD	ODTESZ
	JMP	ODTSC1
ODTSC3	LAW	-1		/NOT FOUND, EXIT WITH AC=-1
	JMP*	ODTSCN
/
	.EJECT
ODTTTL	LAC	ODTX1	/END OF ODT, START TTL
	DAC	TTLBSE
	DAC	TTLX1
	JMP	TTLSNL
/
/ PROCESS ODT TO BUILD "TRUNK-TO-TWIG LISTS" (TTL'S).
/ ONE LIST FOR EACH SET OF "LINKS WITH SOME COMMON CORE".
/ EACH LIST BEGINS WITH A LINK THAT IS NOT DEFINED AS OVERLAYING
/ ANOTHER LINK (TRUNK), FOLLOWED BY LINKS THAT ARE DEFINED AS 
/ BOTH OVERLAYING AND OVERLAYED (IF ANY), AND ENDING WITH
/ A LINK THAT IS NOT DEFINED AS OVERLAYED BY ANOTHER LINK (TWIG).
/ TTL ENTRY FORMAT (3 WDS):
/    INDICATOR -- SAME AS IN LDT
/    LINK NAME -- SAME AS IN LDT
/ EACH LIST IS TERMINATED BY ONE WORD SET TO -1
/
TTLSNL	LAW	-1	/START NEW LIST -- SET POINTER TO -1
	DAC	TTLPNT
	LAC	ODTBSE	/SET TTLX2 TO POINT TO FIRST ODT ENTRY
	DAC	TTLX2
TTLFO1	LAC	TTLX2	/FETCH ODT ENTRY PER TTLX2
	JMS	TTLFOE
	LAC	TTLOEN	/BLANK (ZERO) NAME?
	SZA
	JMP	TTLE1	/NO -- ENTER INDICATOR AND NAME IN TTL
	LAC	TTLX2	/YES -- TEST FOR END OF ODT.  IF NOT, FETCH
	TAD	ODTESZ	/ANOTHER ODT ENTRY
	DAC	TTLX2	/IF END OF ODT AND THE ENTIRE ODT HAS NOT BEEN
	SAD	ODTX1	/BLANKED (ZEROED), TERMINATE THIS TLL
	SKP		/AND PROCEDE TO START ANOTHER TTL
	JMP	TTLFO1	/IF ENTIRE ODT HAS BEEN BLANKED (POINTER=-1)
	LAC	TTLPNT	/ALL TTL'S HAVE BEEN MADE.
	SMA
	JMP	TTLTRM
	JMP	TTLLTB
/
TTLE1	LAC	TTLOEI	/NON-BLANK  NAME FOUND -- ENTER INDICATOR
	JMS	TTLENT	/AND NAME IN TTL
	LAC	TTLOEN
	JMS	TTLENT
	LAC	TTLOEN+1
	JMS	TTLENT
/
TTLSP1	LAC	TTLX2	/SET POINTER IN ODT, SET ODT ENTRY
	TAD	(003)	/INDEX IN POINTER, AND AUGMENT ODT INDEX
	DAC	TEMP1
	LAC	TTLPNT
	DAC*	TEMP1
	LAC	TTLX2
	DAC	TTLPNT
	TAD	ODTESZ
	DAC	TTLX2
	LAC	TTLOEB	/SEARCH FOR AN OVERLAYING LINK.  IF A 
	SAD	(072)	/COLON BREAK CHAR, AN OVERLAYING LINK
	JMP	TTLFO1	/FOLLOWS IN ODT.  OTHERWISE, REMAINDER
	LAC	TTLOEN	/ODT MUST BE SEARCHED.
	DAC	TEMP3
	LAC	TTLOEN+1
	DAC	TEMP4
TTLOS1	LAC	TTLX2	/SCAN ODT FOR NAME IN TEMP3 & TEMP4
	SAD	ODTX1
	JMP	TTLTRM	/NOT FOUND, TERMINATE TTL & BLANK NAME
	JMS	TTLFOE
	LAC	TTLOEN
	SAD	TEMP3
	SKP
	JMP	TTLOS2
	LAC	TTLOEN+1
	SAD	TEMP4
	JMP	TTLSP1	/NAME FOUND, SET POINTER IN ODT AND 
			/SEARCH FOR ANOTHER OVERLAYING LINK.
TTLOS2	LAC	TTLX2
	TAD	ODTESZ
	DAC	TTLX2
	JMP	TTLOS1
/
TTLTRM	LAW	-1	/TERMINATE A TTL
	JMS	TTLENT
/
TTLBE1	LAC	TTLPNT	/SAVE POINTER-1 (TO FETCH PREVIOUS
	DAC*	(10)	/BREAK CHAR), BLANK (ZERO) NAME IN ODT
	TAD	(-1)	/ENTRY INDICATED BY POINTER, AND NEW
	DAC	TEMP1	/POINTER FROM BLANKED ODT ENTRY.
	DZM*	10
	DZM*	10
	LAC*	10
	DAC	TTLPNT
/
TTLBE2	LAC*	TEMP1	/SCAN PREVIOUS BREAK CHARACTERS TIL A
	SAD	(072)	/COLON OR ALTMODE IS FOUND.
	JMP	TTLBE3
	SAD	(175)
	JMP	TTLBE3
	LAC	TEMP1
	TAD	ODTMES
	DAC	TEMP1
	JMP	TTLBE2
/
TTLBE3	LAC	TEMP1	/SCAN ODT FROM NAME FOLLOWING COLON OR
	TAD	(001)	/ALTMODE THRU A NAME TERMINATED BY COLON
	DAC	TTLX2	/OR ALTMODE FOR A NON-BLANK NAME.  IF NOT
TTLBE4	JMS	TTLFOE	/FOUND, FOLLOW POINTER BACK TO BLANK THE
	LAC	TTLOEN	/NAME OF THE LINK OVERLAYED BY THIS
	SZA		/LINK OR GROUP OF LINKS.
	JMP	TTLSNL	/IF FOUND, START NEW LIST
	LAC	TTLOEB
	SAD	(072)
	JMP	TTLBE5
	SAD	(175)
	JMP	TTLBE5
	LAC	TTLX2
	TAD	ODTESZ
	DAC	TTLX2
	JMP	TTLBE4
/
TTLBE5	LAC	TTLPNT
	SMA
	JMP	TTLBE1
	JMP	TTLSNL
/
/ TTLFOE -- SUBROUTINE TO FETCH THE ODT ENTRY WHOSE INDEX IS IN AC.
/           THE ENTRY IS LEFT IN THE FIVE FOLLOWING REGISTERS:
/
TTLOEI	0	/INDICATOR
TTLOEN	.BLOCK 2	/NAME
TTLOEP	0	/POINTER
TTLOEB	0	/BREAK CHAR
/
TTLFOE	0
	TAD	(-1)
	DAC*	(10)
	LAC	ADR5
	DAC*	(11)
	LAW	-5
	DAC	TTLFOC
TTLFOL	LAC*	10
	DAC*	11
	ISZ	TTLFOC
	JMP	TTLFOL
	JMP*	TTLFOE
/
TTLFOC	0
/
/ TTLENT -- SUBROUTINE TO ENTER THE WORD IN AC IN TTL
/
TTLENT	0
	DAC*	TTLX1
	ISZ	TTLX1
	JMP*	TTLENT
/
	.EJECT
/ RFAN -- SUBROUTINE TO READ A COMMAND LINE (LOGICAL) AND
/	  FETCH THE FIRST NAME. I.E. TO SET THE FOUR
/	  FOLLOWING WORDS. THE BREAK CHARACTER IS LEFT IN AC.
/		FANI	INDICATOR
/		FANM	6-SIX BIT CHARACTER NAME (TWO WORDS)
/		FANM+1
/		FANB	BREAK CHARACTER (TERMINATING NAME)
/	  INDICATOR BITS SET AS FOLLOWS:
/		BIT-14 USER FILE
/		BIT-13 USER LIBRARY
/		BIT-12 SYSTEM LIBRARY
/	NAME IS RIGHT JUSTIFIED, LEFT FILLED WITH ZEROS.
/	FANM IS SET ZERO TO INDICATE A NAME LENGTH ERROR.
/	FANM+1 IS SET: 0 FOR ZERO LENGTH NAME
/	FANM+1 IS SET -1 FOR LENGTH GREATER THAN SIX CHAR
/
FANI	0		/FILE SOURCE INDICATOR
FANM	.BLOCK	2	/FILE NAME BUFFER
FANB	0		/BREAK CHAR BUFFER
CBUF	.BLOCK	42	/COMMAND BUFFER (80 CHARACTERS)
/
RFAN	0
	JMS	CRTN	/RETURN CARRIAGE
	JMS	TYPE	/TYPE ANGLE BRACKET
	CAGB
	JMS	RFRD	/READ COMMAND LINE (PHYSICAL LINE)
	JMS	FAN	/FETCH FIRST NAME
	JMP*	RFAN	/EXIT
/
CAGB	.ASCII	/>/<175>
CHYP	.ASCII	/-/<175>
/
RFRD	0		/SUBROUTINE TO READ A LINE AND RESET
RFRDZ	.READ	CI,2,CBUF,34	/FACX1 & FACX2 IN FAC
	.WAIT	CI
	LAC	ADR9
	DAC	FACX1
	LAC	ADR13
	DAC	FACX2
	JMP*	RFRD
/
/ FAN -- SUBROUTINE TO "FETCH A NAME". REGISTERS FANI, FANM, & FANB
/	 ARE SET AS DESCRIBED UNDER "RFAN".
/
FAN	0
	LAC	(010)		/SET INDICATOR BIT-14
	DAC	FANI		/TO INDICATE USER DEVICE SRC
	DZM	FANM
	DZM	FANM+1
	LAC	ADR14		/SETUP TO READ UP TO SIX CHARACTERS
	DAC*	(10)		/INTO FANBF THRU FANBF+5
	LAW	-7
	DAC	FANX1
FAN1	JMS	FAC		/FETCH A CHARACTER
	SAD	(043)		/TEST FOR LIB INDICATOR (#)
	JMP	FAN5
	SAD	(072)		/BREAK CHARACTERS TEST --
	JMP	FAN2		/COLON
	SAD	(054)
	JMP	FAN2		/COMMA
	SAD	(075)
	JMP	FAN2		/EQUAL SIGN
	SAD	(057)
	JMP	FAN2		/SLASH
	SAD	(175)
	JMP	FAN2		/ALTMODE
	AND	(077)		/MASK TO SIX-BIT
	DAC*	10		/SAVE CHAR
	ISZ	FANX1
	JMP	FAN1
	DAC	FANB		/NAME TOO LONG--USE SEVENTH CHARACTER
	DZM	FANM		/AS BREAK CHAR, CLEAR FIRST NAME
	LAW	-1		/WORD AND SET SECOND NAME WORD
	DAC	FANM+1		/TO -1, AND EXIT
	JMP	FAN4
FAN2	DAC	FANB		/SAVE BREAK CHARACTER
	DZM*	10		/CLEAR TRAILING CHARACTERS THRU
	ISZ	FANX1		/SEVENTH (EXTRA WORD TO SAVE CODE)
	JMP	.-2
	LAC	ADR14		/SETUP TO PACK SIX CHARACTERS
	DAC*	(10)		/INTO FANM & FANM+1
	LAC	ADR18
	DAC	FANX1
	LAW	-6
	DAC	FANX2
FAN3	LAC*	FANX1		/PACK NAME
	CLL
	JMS	LCS6
	XOR*	10
	DAC*	FANX1
	LAC	FANX2
	SAD	(-4)
	ISZ	FANX1
	ISZ	FANX2
	JMP	FAN3
FAN4	LAC	FANB		/LOAD AC WITH BREAK CHARACTER
	JMP*	FAN		/AND EXIT
/
FAN5	LAC	(020)		/LIBRARY INDICATOR FOUND
	DAC	FANI		/SET INDICATOR BIT-13
	JMP	FAN1		/(CLEAR OTHER BITS)
/
FANX1	0
FANX2	0
FANBF	.BLOCK	7
/
/ FAC -- SUBROUTINE TO FETCH A CHARACTER FROM THE COMMAND
/	 BUFFER AND LEAVE IT IN AC. IF CHAR IS A CARRIAGE
/	 RETURN, ANOTHER LINE WILL BE READ. IF CHAR IS
/	 AN ALTMODE (END OF LINE), IT WILL RETURNED FOR THIS
/	 AND ALL SUCCEEDING CALLS UNTIL A NEW LINE IS READ.
/          IF CHARACTER IS A BLANK, IT WILL BE IGNORED.
/	 FACX1 & FACX2 ARE RESET WHEN A NEW LINE IS READ.
/
FAC	0
FAC0	LAC	FACX1		/TEST FOR EMPTY CHARACTER FACB
	SAD	ADR9
	JMP	FAC2
FAC1	LAC*	FACX1		/FETCH CHARACTER FROM FACB
	AND	(177)
	SAD	(040)		/IGNORE BLANKS
	JMP	FAC4
	SAD	(015)		/IF THE CARRIAGE RETURN, READ A
	JMP	FAC3		/CONTINUATION LINE, TO FETCH CHARACTER.
	SAD	(175)		/AUGMENT FACB INDEX & EXIT, UNLESS
	JMP*	FAC		/CHARACTER WAS ALTMODE, THEN
	ISZ	FACX1		/EXIT WITHOUT AUGMENTING THE
	JMP*	FAC		/FACB INDEX.
/
FAC2	LAC*	FACX2		/UNPACK FIVE CHARACTERS FROM COMMAND
	ISZ	FACX2		/BUFFER AND STORE AS 7-BIT IMAGE
	RCL
	JMS	LCS7
	DAC	FACB
	JMS	LCS7
	DAC	FACB+1
	JMS	LCS7
	AND	(170)
	DAC	FACB+2
	LAC*	FACX2
	ISZ	FACX2
	RTL
	RTL
	DAC	FACB+3
	AND	(007)
	XOR	FACB+2
	DAC	FACB+2
	LAC	FACB+3
	JMS	LCS7
	DAC	FACB+3
	JMS	LCS7
	DAC	FACB+4
	LAC	ADR15		/RESET FACB INDEX
	DAC	FACX1
	JMP	FAC1		/TO FETCH A CHAR FROM FACB
/
FAC3	JMS	TYPE		/TYPE HYPHEN TO INDICATE CONTINUATION
	CHYP			/OF IS EXPECTED.
	JMS	RFRD		/READ A NEW LINE & RESET FACX1 & FACX2
	JMP	FAC2		/TO FETCH A CHAR FROM FACB
/
FAC4	ISZ	FACX1
	JMP	FAC0
/
FACX1	0			/FACB INDEX
FACX2	0			/COMMAND BUFFER INDEX
FACB	.BLOCK	5		/FIVE CHARACTER BUFFER
/
/ ERR1, ERR2, & ERR3 -- SUBROUTINES TO OUTPUT ERROR MESSAGES.
/ EACH TAKES THE ADDRESS OF THE MESSAGE FROM THE WORD FOLLOWING
/ THE CALL (JMS).
/ ERR1  OUTPUTS A MESSAGE AND RETURNS
/ ERR2  OUTPUTS A MESSAGE, THE NAME IN FANM&FANM+1, AND RETURNS
/ ERR3  OUTPUTS A MESSAGE, THE BREAK CHAR IN FANB, AND RETURNS.
/
ERR1	0
	LAC*	ERR1
	ISZ	ERR1
	JMS	ERRTO
	JMP*	ERR1
/
ERR2	0
	LAC*	ERR2
	ISZ	ERR2
	JMS	ERRTO
	JMS	TYPE
	MES100
	LAC	FANM
	JMS	ERR6BO
	LAC	FANM+1
	JMS	ERR6BO
	JMP*	ERR2
/
ERR3	0
	LAC*	ERR3
	ISZ	ERR3
	JMS	ERRTO
	JMS	TYPE
	MES100
	LAC	FANB
	DAC	ERR6BF+2
ERR3Z	.WRITE	TO,3,ERR6BF,0
	.WAIT	TO
	JMP*	ERR3
/
ERR6BO	0	/.SIXBT OUTPUT
	DAC	TEMP1
	LAW	-3
	DAC	TEMP3
ERR6BL	LAC	TEMP1
	JMS	LCS7
	DAC	TEMP2
	RAR
	DAC	TEMP1
	LAC	TEMP2
	AND	(077)
	SNA
	JMP	ERR6BA
	XOR	(040)
	TAD	(040)
	DAC	ERR6BF+2
ERR6BZ	.WRITE	TO,3,ERR6BF,0
	.WAIT	TO
ERR6BA	ISZ	TEMP3
	JMP	ERR6BL
	JMP*	ERR6BO
/
ERR6BF	002000
	0
	0
	177
/
/
ERRTO	0
	JMS	SETBBS
	TAD	(-2)
	DAC	ERRTOW+2
	JMS	CRTN
ERRTOW	.WRITE	TO,2,XX,0
	.WAIT	TO
	JMP*	ERRTO
/
/ ZLLX -- SUBROUTINE TO TEST FOR A ZERO 
/         LENGTH LINE (ALTMODE ONLY)
/	RETURN AT JMS+1 IF YES
/	RETURN AT JMS+2 IF NO
/
ZLLX	0
	LAC	FANM
	SZA
	JMP	ZLL1
	LAC	FANM+1
	SZA
	JMP	ZLL1
	LAC	FANB
	SAD	(175)
	JMP*	ZLLX	/YES
ZLL1	ISZ	ZLLX	/NO
	JMP*	ZLLX
/
/
/ TELETYPE OUTPUT MESSAGES.  THE TWO WORDS PRECEDING EACH
/ MESSAGE ARE USED AS AN IOPS ASCII HEADER.  THE ONLY HEADER
/ REQUIREMENT FOR TTY OUTPUT IS A GREATER THAN ONE WORD-
/ PAIR COUNT.
/
MES1	.ASCII	/CHAIN V2A/<15>
MES20	.ASCII	/NAME XCT FILE/<175>
MES30	.ASCII	/LIST OPTIONS & PARAMETERS/<175>
MES32	.ASCII	/^ UNRECOGNIZED SYMBOL/<175>
MES33	.ASCII	/^ 12K PDP-9/<175>
MES50	.ASCII	/DEFINE RESIDENT CODE/<175>
MES51	.ASCII	/^ RES ROUTINE REQ'D/<175>
MES52	.ASCII	/^ LIB IND ON MAIN PROG NAME/<175>
MES60	.ASCII	/DESCRIBE LINKS & STRUCTURE/<175>
MES100	.ASCII	/ -- /<175>
MES101	.ASCII	/^ NAME LENGTH ERR/<175>
MES102	.ASCII	/^ LINK NAME USED PRV/<175>
MES103	.ASCII	/^ IMPROPER BREAK CHAR/<175>
MES104	.ASCII	/^ INTERNAL NAME REPEATED IN LINE/<175>
MES105	.ASCII	/^ EXTERNAL NAME USED PRV/<175>
MES106	.ASCII	/^ COMPONENT NAME USED AS LINK NAME/<175>
MES107	.ASCII	/^ LINK DEF WITHIN OVERLAY DESCRIPTION/<175>
MES108	.ASCII	/^ COLON MUST FOLLOW FIRST LINK NAME/<175>
MES109	.ASCII	/^ MORE THAN ONE LINK OVERLAYED/<175>
MES110	.ASCII	/^ NAME RIGHT OF COLON USED PRV/<175>
MES111	.ASCII	/^ NAME USED MORE THAN TWICE/<175>
MES112	.ASCII	/^ NAME USED LEFT OF COLON TWICE/<175>
MES113	.ASCII	/^ LIB IND ON LINK NAME/<175>
MES116	.ASCII	/^ INTERNAL NAME USED PRV/<175>
MES117	.ASCII	/^ RES ROUTINE NAME USED AS LINK NAME/<175>
MES118	.ASCII	/^ NAME USED MORE THAN ONCE/<175>
/
/
/ BANK RELOCATION ADDRESS TABLE -- EACH POSITIVE WORD CONTAINS
/ THE ADDRESS OF A TRANSFER VECTOR REQUIRING BANK BITS (EACH
/ ADDRESS ALSO REQUIRES BANK BIT INITIALIZATION).  THE TABLE
/ IS TERMINATED BY A NEGATIVE ENTRY.
/
BRTBL	RFRDZ+2
	ERR3Z+2
	ERR6BZ+2
	ERO1Z+2
	ERO2Z+2
	ERO3Z+2
	T6BNZ+2
	TMAPZ+2
	READ1+2
	PAUSZ+2
	WOB1+2
	ICIZ+2
	TRTTL
	OUTBEG
	OUTEND
	CPTVA
	ADR1
	ADR2
	ADR3
	ADR4
	ADR5
	ADR6
	ADR7
	ADR8
	ADR9
	ADR10
	ADR11
	ADR12
	ADR13
	ADR14
	ADR15
	ADR16
	ADR17
	ADR18
	ADR19
	ADR20
	-1	/BRT
	-1	/  PATCH
	-1	/    AREA
	-1		/END OF TABLE
	.EJECT
/ ALL COMMAND INPUT HAS BEEN ACCEPTED
/
/ THE OVERLAY-DESCRIPTION-TABLE, AND THE CODE REQUIRED TO GENERATE 
/ THE RCL, LDT, ODT, & TTL'S, ARE NO LONGER NEEDED -- LEAVE  
/ RCL &  LDT IN THEIR PRESENT LOW CORE POSITION AND MOVE THE TTL'S 
/ TO AS HIGH CORE AS POSSIBLE.
/
TTLLTB	LAC	ADR2	/RESTART VIA ^P IS NO LONGER POSSIBLE,
	DAC	CPTVA	/SET ^P TRANSFER ADDRESS TO EXIT IF ^P.
	LAC	TTLBSE		/CHANGE TTLBSE & TTLX1 AND
	TAD	(-1)		/SETUP TO MOVE TTL'S
	DAC*	(10)
	LAC	TTLX1
	JMS	TWC
	TAD	TTLBSE
	DAC	TEMP1
	LAC	TRTTL
	TAD	(001)
	TAD	TEMP1
	DAC	TTLBSE
	TAD	(-1)
	DAC*	(11)
	LAC	TRTTL
	DAC	TTLX1
	JMS	CRTN
	JMP	MOVTTL
TRTTL	.	/THE TOP OF THE RELOCATED TTL'S WILL OVERLAY 
		/THIS WORD.
/
/^^^^^^^^^^^^^^^^^^^^^ CORE PRECEDING THIS ^^^^^^^^^^^^^^^^^^^^^
/^^^^^^^^^^^^^^^^^^^ LOCATION IS WRITTEN OVER ^^^^^^^^^^^^^^^^^^
/
MOVTTL	LAC*	10	/MOVE TTL'S
	DAC*	11
	ISZ	TEMP1
	JMP	MOVTTL
/
	.EJECT
/ CONSTRUCT THE PRELIMINARY LINK TABLE (LTB) BY SCANNING THE
/ TTL'S AND GENERATING AN LTB ENTRY FOR EACH NEW ROUTINE (LINK
/ OR LINK COMPONENT) NAME.  THE ONLY PERMANENT ENTRY ELEMENT IN THE
/ PRELIMINARY LTB IS THE LINK NUMBER.
/
/ LINK TABLE ENTRY FORMATS:
/
/   PRELIMINARY	FINAL		WHEN LINK
/   CONSTRUCTION	CONSTRUCTION	IS RESIDENT
/
/     IND. (TTL)	  0		  0
/     LINK-	  DAC  BUF	  DAC  BUF
/        NAME	  JMS* (EXU)	  LAC  .-2
/     COMPONENT	  DAC* .+3	  DAC* .+3
/        NAME	  LAC  BUF	  LAC  BUF
/     R-FLAG	  JMP* .+2	  JMP* .+2
/     0		  ENTRY		  ENTRY
/     0		  ENTRY+1		  ENTRY+1
/     LINK #	  LINK #		  LINK #
/     INDEX	  MIN ADR		  MIN ADR
/     0		  MAX ADR		  MAX ADR
/
/ IND AND LINK NAME ARE
/ USED ONLY IN THE FIRST
/ LDT ENTRY FOR EACH LINK
/ (ZEROED IN OTHERS)
/
/ R-FLAG IS INITIALLY ZERO
/ AND IS SET NON-ZERO WHEN 
/ LINK IS RELOCATED & OUTPUT.
/
/ INDEX -- THE LDT INDEX OF
/ THE FIRST COMPONENT OF THIS
/ LINK.  ZERO IF LINK NAME AND
/ LONE COMPONENT ARE THE SAME
/ (NO LINK DEFINITION).
/
/ DEFINITION: SCL -- SINGLE COMPONENT LINK.  A LINK WHOSE SINGLE
/ COMPONENT HAS THE SAME NAME.  I.E., A LINK THAT IS NOT DEFINED
/ IN THE LINK DEFINITION TABLE (LDT).
/
	LAC	TTLBSE	/INITIALIZE LTB
	DAC	LTBX2
	TAD	(-1)
	DAC	LTBTOP
	DAC	LTBBSE
	DZM	LNKNUM
	LAC	TTLBSE	/SETUP FOR TTL SCAN (LTBX3)
	JMP	CPLT1A
CPLT1	LAC	LTBX3	/FETCH NEXT TTL ENTRY
	TAD	TTLESZ
CPLT1A	DAC	LTBX3
	JMS	FETTTL
	LAC	TTLETY	/END OF TTL?
	SMA
	JMP	CPLT2	/NO -- SCAN LTB FOR LINK NAME
	LAC	LTBX3	/YES -- END OF LAST TTL?
	SAD	TTLX1
	JMP	DLTBL	/YES -- DETERMINE SIZE AND LOCATION 
			/       AT EXECUTE TIME
	TAD	(001)	/NO -- AUGMENT LTBX3 AND FETCH
	JMP	CPLT1A	/      NEXT TTL ENTRY
CPLT2	LAC	LTBTOP	/SETUP FOR LTB SCAN (LTBX2)
	DAC	LTBX2	/(SCAN FROM TOP TO BASE)
CPLT3	LAC	LTBX2	/INDEX AT BASE?
	SAD	LTBBSE
	JMP	CPLT4	/YES -- NAME NOT FOUND, ADD ENTRY AT BASE
	TAD	LTBMES	/NO -- DECREMENT INDEX AND FETCH NEXT
	DAC	LTBX2	/LTB ENTRY
	JMS	FETLTB
	LAC	LTBETY+1	/NAME FOUND?
	SAD	TTLETY+1
	SKP
	JMP	CPLT3	/NO -- FETCH NEXT LTB ENTRY
	LAC	LTBETY+2
	SAD	TTLETY+2
	JMP	CPLT1	/YES -- FETCH NEXT TTL
	JMP	CPLT3	/NO -- FETCH NEXT LTB ENTRY
/
CPLT4	LAC	TTLETY+1	/SETUP LTB ENTRY FOR A SCL (SINGLE COMPONENT 
	DAC	LTBETY+1	/LINK).
	DAC	LTBETY+3
	LAC	TTLETY+2
	DAC	LTBETY+2
	DAC	LTBETY+4
	DZM	LTBETY+5
	DZM	LTBETY+6
	DZM	LTBETY+7
	ISZ	LNKNUM
	LAC	LNKNUM
	DAC	LTBETY+10
	DZM	LTBETY+11
	DZM	LTBETY+12
	LAC	TTLETY	/TEST FOR A SCL
	DAC	LTBETY
	AND	(001)
	SZA
	JMP	CPLT5	/NO -- ENTER EXTERNAL COMPONENTS IN LTB
	LAC	LTBBSE	/YES -- MAKE SINGLE LTB ENTRY
	TAD	LTBMES
	DAC	LTBBSE
	JMS	SETLTB
	JMP	CPLT1
/
CPLT5	LAC	LDTBSE	/SCAN LDT FOR LINK NAME
	DAC	LTBX4
CPLT6	LAC	LTBX4
	JMS	FETLDT
	LAC	LTBX4
	TAD	LDTESZ
	DAC	LTBX4
	LAC	LDTETY+1
	SAD	LTBETY+1
	SKP
	JMP	CPLT6
	LAC	LDTETY+2
	SAD	LTBETY+2
	SKP
	JMP	CPLT6
	LAC	LTBX4	/NAME FOUND, SET INDEX OF FIRST COMPONENT 
	DAC	LTBETY+11	/IN LTB ENTRY
CPLT7	JMS	FETLDT	/FETCH COMPONENT NAME
	LAC	LDTETY	/EXTERNAL NAME?
	AND	(002)
	SNA
	JMP	CPLT1	/NO -- END OF ENTRIES FOR THIS LINK
	LAC	LDTETY+1	/YES -- SET COMPONENT NAME IN LDT ENTRY
	DAC	LTBETY+3
	LAC	LDTETY+2
	DAC	LTBETY+4
/
	LAC	LTBBSE	/ADD LTB ENTRY
	TAD	LTBMES
	DAC	LTBBSE
	JMS	SETLTB
	DZM	LTBETY	/BLANK (ZERO) IND, NAME, AND INDEX
	DZM	LTBETY+1
	DZM	LTBETY+2
	DZM	LTBETY+11
	LAC	LTBX4
	TAD	LDTESZ
	DAC	LTBX4
	JMP	CPLT7
/
/ DETERMINE THE LIMITS OF CORE THAT WILL BE OCCUPIED
/ BY THE LINK TABLE (LOW CORE FOR FOREGROUND, HIGH CORE FOR
/ BACKGROUND), SET THE MAX (BGD) OR MIN (FGD) REGISTER 
/ REQUIRED, ADJUST LOAD LIMIT 'LDLMT'.
/(THE LINK TABLE INCLUDES A ONE WORD BUFFER BELOW LTBBSE OR LTBBAD)
/
DLTBL	LAC	BFFLAG	/BGD OR FGD CHAIN?
	SZA
	JMP	DLTBLF
	LAC	LDLMT	/BGD CHAIN -- THE LINK TABLE WILL RESIDE IN 
	DAC	LTBTAD	/DECREASING CORE FORM LDLMT
	DAC	MAXREG	/SET MAX REG REQ
	LAC	LTBBSE
	JMS	TWC
	TAD	LTBTOP
	JMS	TWC
	TAD	LDLMT
	DAC	LTBBAD
	TAD	(-2)	/(INCLUDE AC BUFFER BELOW LTBBSE)
	DAC	LDLMT	/UPDATE LDLMT
	DAC	CLT
	JMP	CGST
/
DLTBLF	LAC	LTBBSE	/FGD CHAIN -- LINK TABLE WILL RESIDE IN INCREASING
	JMS	TWC	/CORE FROM LDLMT2
	TAD	LTBTOP	/IF NECESSARY, LDLMT IS INCREASED TO PREVENT THE
	DAC	TEMP10	/LINK TABLE FROM CROSSING A PAGE OR BANK BOUND
	TAD	(001)
	TAD	LDLMT
	AND	OPCMSK
	DAC	TEMP11
	LAC	LDLMT
	AND	OPCMSK
	SAD	TEMP11
	JMP	.+3
	LAC	TEMP11
	DAC	LDLMT
	LAC	LDLMT	/AVIOD AUTO-INDEX REGISTERS
	AND	ADRMSK
	AND	(777760)
	SZA
	JMP	.+4
	LAC	TEMP11
	XOR	(020)
	DAC	LDLMT
	LAC	LDLMT
	DAC	MINREG	/SET MIN REG REQ
	TAD	(001)
	DAC	LTBBAD	/SET LTB LIMITS
	TAD	TEMP10
	DAC	LTBTAD
	TAD	(001)	/UPDATE LDLMT
	DAC	LDLMT
/
/ CONSTRUCT GLOBAL SYMBOL TABLE ENTRIES FOR ALL EXTERNAL LINK
/ COMPONENT NAMES.  SYMBOLS ARE DEFINED AS POINTING TO
/ THE REGISTER THAT THE FIRST WORD OF THE CORESPONDING 
/ LINK TABLE WILL OCCUPY AT EXECUTE TIME.
/
CGST	LAC	LTBBSE	/INITIALIZE SYMBOL TABLE TO BE CONSTRUCTED
	TAD	(-1)	/IN DECREASING CORE BELOW THE LINK TABLE
	DAC	SYMBEG
	DAC	SYMEND
	LAC	LTBTAD
	DAC	TEMP5
	LAC	LTBTOP
	DAC	LTBX2
CGST1	LAC	LTBX2
	SAD	LTBBSE
	JMP	CGST2
	TAD	LTBMES
	DAC	LTBX2
	JMS	FETLTB
	LAC	LTBETY+3
	JMS	CTR50
	DAC	SYM1
	LAC	LTBETY+4
	JMS	CTR50
	DAC	SYM2
	SNA
	JMP	.+4
	LAC	SYM1
	XOR	(400000)
	DAC	SYM1
	LAC	TEMP5
	TAD	LTBMES
	DAC	TEMP5
	XOR	(500000)
	DAC	SYMDEF
	JMS	DEFSYM
	JMP	CGST1
/
CGST2	LAC	SYMEND
	DAC	SYMEB1
/
/ INITIALIZE PATCH TABLE TO BE CONSTRUCTED IN INCREASING CORE
/ FROM THE END OF THE LINK DEFINITION TABLE (LTB).  I.E., TO 
/ WRITE OVER THE OVERLAY DESCRIPTION TABLE (OTB)
/
	LAC	ODTBSE
	DAC	PTBBSE
	JMP	WRC
	.EJECT
/ NO OVERLAY DESCRIPTION -- RESIDENT CODE ONLY
/
RCO	ISZ	ROFLAG	/SET 'RESIDENT ONLY' FLAG
	LAC	(001)	/TERMINATE RCL WITH AN LDT INDICATOR
	DAC*	LDTX1	/TO STOP RESIDENT CODE SCAN
	LAC	LDTX1	/INITIALIZE PATCH TABLE TO FOLLOW THE RCL
	TAD	(001)
	DAC	PTBBSE
	LAC	TRTTL	/INITIALIZE SYMBOL TABLE TO START WHERE THE
	DAC	SYMBEG	/TTL'S WOULD HAVE STARTED IF OVERLAYS 
	DAC	SYMEB1	/EXISTED
	DZM	LTBTAD	/INDICATE ZERO LENGTH LINK TABLE.  THIS WILL
	DZM	LTBBAD	/CAUSE EXECUTE TO NOT LOAD A LINK 
			/AND TO NOT SET A T.V. IN ITS HIGHEST REG.
	JMS	CRTN	/RETURN CARRIAGE
	LAC	BFFLAG	/BGD OR FGD CHAIN?
	SZA
	JMP	RCO1
	LAC	LDLMT	/BGD CHAIN, SET MAX REG
	DAC	MAXREG
	JMP	WDXCT
RCO1	LAC	LDLMT	/FGD CHAIN, SET MIN REG
	DAC	MINREG
	JMP	WDXCT
/
	.EJECT
WRC	LAC	LDLMT	/INITIALIZE BLANK COMMON LOAD LIMIT
	DAC	LDLMT3
/
	LAC	LMFLAG	/IF MAP FLAG IS SET, TYPE:
	SNA
	JMP	WDXCT	/   LINK TABLE
	JMS	TYPE	/          XXXXX XXXXX
	MES602		/   RESIDENT CODE
	DZM	SYM1
	JMS	SYMMAP
	LAC	LTBBAD
	TAD	(-1)	/(INCL AC BUFFER IN LTB SIZE)
	DAC	SLIMFA
	LAC	LTBTAD
	DAC	SLIMLA
	JMS	SLIM
	JMS	TYPMAP
	JMS	CRTN
	JMS	TYPE
	MES603
/
/ WRITE DUMMY XCT FILE (XCU EXTENSION) IF DUMMY FILE SWITCH IS SET
/ (THIS IS TO RESERVE PRIME SPACE FOR THE XCT FILE)
/
WDXCT	LAC	DFSW	/IS SWITCH SET?
	SZA
	JMP	WXCTF	/YES -- WRITE DUMMY XCT FILE
	JMP	WXCUF	/NO -- WRITE XCU FILE
/
WDXCTR	DZM	DFSW	/DUMMY FILE WRITTEN, CLEAR SWITCH
	.INIT	RO,1,0	/AND OPEN ACTUAL XCU FILE
ERO2Z	.ENTER	RO,ROFNAM
/
/ WRITE XCU FILE
/
WXCUF	DZM	LNKNUM	/RELOCATE AND OUTPUT RESIDENT CODE
	LAC	RCLBSE
	DAC	RAOX
	JMS	RAO
	LAC	LDLMT2	/UPDATE LDLMT
	DAC	LDLMT
	LAC	SYMEND	/SYMBOL TABLE ENTRIES GENERATED BEYOND THIS
	DAC	SYMEB1	/POINT ARE DELETED AFTER RELOCATION OF
			/EACH LINK.
/
	LAC	ROFLAG	/SKIP RELOCATION OF LINKS IF 'RESIDENT ONLY'
	SNA
	JMP	REL1
/
	LAC	LDLMT2	/SETUP BLANK COMMON LIMIT FOR RESIDENT ONLY
	DAC	LDLMT3
	JMP	REL70
/
	.EJECT
/ RELOCATION LOOP --
/ THE TTL'S AND THE LTB HAVE BEEN ORDERED SUCH THAT AS A
/ LINK NAME IF FETCHED FROM THE TTL'S AND THE LTB IS SCANNED
/ FOR THAT NAME, THE NAMES PASSED ARE NAMES OF LINKS THAT HAVE
/ BEEN RELOCATED AND OUTPUT AND ARE NOT OVERLAYED BY THE LINK 
/ WHOSE NAME WAS FETCHED FROM THE TTL'S.  I.E., THEY DETERMINE
/ A LOAD LIMIT FOR THE LINK WHOSE NAME WAS FETCHED FROM THE TTL'S.
/
REL1	LAC	TTLBSE	/RESET TTL SCAN INDEX (LTBX3)
	DAC	LTBX3
REL10	LAC	LTBTOP	/RESET LTB SCAN INDEX (LTBX2)
	DAC	LTBX2
REL20	LAC	LTBX3	/FETCH A TTL ENTRY
	JMS	FETTTL
	LAC	TTLETY	/END OF TTL?
	SMA
	JMP	REL30	/NO -- FETCH AN LTB ENTRY
	LAC	LTBX3	/YES -- END OF LAST TTL?
	SAD	TTLX1
	JMP	REL70	/YES -- ALL LINKS RELOCATED & OUTPUT
	TAD	(001)	/NO -- AUGMENT TTL SCAN INDEX, RESET LTB
	DAC	LTBX3	/      SCAN INDEX, AND CONTINUE SCANNING
	JMP	REL10
/
REL30	LAC	LTBX2	/FETCH NEXT LTB ENTRY
	TAD	LTBMES
	DAC	LTBX2
	JMS	FETLTB
	LAC	LTBETY+1	/SKIP ENTRY IF BLANK LINK NAME
	SNA
	JMP	REL30
	SAD	TTLETY+1	/DO LINK NAMES (TTL & LTB) MATCH?
	SKP
	JMP	REL40	/NO -- UPDATE LOAD LIMIT
	LAC	LTBETY+2
	SAD	TTLETY+2
	JMP	REL50	/YES -- RELOCATE AND OUTPUT UNLESS R-FLAG 
REL40	LAC	BFFLAG	/BGD OR FGD CHAIN?
	SZA
	JMP	REL42
	LAC	LTBETY+11	/BGD -- UPDATE LDLMT
	JMS	TWC
	TAD	LDLMT
	SPA
	JMP	REL30
	LAC	LTBETY+11
	TAD	(-1)
	DAC	LDLMT
	JMP	REL30
REL42	LAC	LDLMT	/FGD -- UPDATE LDLMT
	JMS	TWC
	TAD	LTBETY+12
	SPA
	JMP	REL30
	LAC	LTBETY+12
	TAD	(+1)
	DAC	LDLMT
	JMP	REL30
/
REL50	LAC	LTBETY+5	/IS R-FLAG SET?
	SZA		/NO -- RELOCATE AND OUTPUT LINK
	JMP	REL60	/YES -- LINK HAS ALREADY BEEN RELOCATED & OUTPUT
/
	JMS	PAUSX	/PAUSE IF PAUSE FLAG IS SET -- THE PAUSE IS FOR
			/THE PREVIOUSLY OUTPUT LINK.  THIS IS DONE SO
			/THE PAUSE AFTER THE LAST LINK CAN BE DONE
			/AFTER THE XCU FILE 'CLOSE', THUS PREVENTING
			/AN ISOLATED EOF RECORD ON PAPER TAPE
			/IF MANUAL FEED AT PAUSE.
/
/ PREPARE TO RELOCATE AND OUTPUT A LINK
/
	LAC	LTBETY+10	/SET LINK NUMBER
	DAC	LNKNUM
/
	LAC	LTBETY+11	/SETUP DUMMY LDT ENTRY IF SINGLE
	SZA		/COMPONENT LINK
	JMP	REL51
	LAC	LTBETY
	DAC	DUMLDT
	LAC	LTBETY+1
	DAC	DUMLDT+1
	LAC	LTBETY+2
	DAC	DUMLDT+2
	LAC	ADR16
REL51	DAC	RAOX	/SET RAOX TO POINT TO THE FIRST
			/COMPONENT DESCRIPTION.
	LAC	LMFLAG	/TYPE LINK NAME IF
	SNA		/MAP FLAG IS SET
	JMP	REL53
	JMS	CRTN
	JMS	TYPE
	MES604
	LAC	LTBETY+1
	DAC	T6BW1
	LAC	LTBETY+2
	DAC	T6BW2
	JMS	T6BN
	JMS	CRTN
			/------------------------
REL53	JMS	RAO	/RELOCATE AND OUTPUT LINK
			/------------------------
	LAC	BFFLAG	/BGD OR FGD CHAIN?
	SZA
	JMP	REL52
	LAC	LDLMT3	/BGD -- UPDATE BLANK COMMON LIMIT
	JMS	TWC
	TAD	LDLMT2
	SMA
	JMP	REL54
	LAC	LDLMT2
	DAC	LDLMT3
	JMP	REL54
REL52	LAC	LDLMT2	/FGD -- UPDATE BLANK COMMON LIMIT
	JMS	TWC
	TAD	LDLMT3
	SMA
	JMP	REL54
	LAC	LDLMT2
	DAC	LDLMT3
	JMP	REL54
/
/ SET CORE LIMITS IN ALL LTB ENTRIES FOR THE LINK JUST
/ RELOCATED AND OUTPUT.
/
REL54	LAC	BFFLAG	/BGD OR FGD CHAIN?
	SZA
	JMP	REL56
	LAC	LDLMT2	/BGD
	TAD	(+1)
	DAC	MINLAD
	LAC	LDLMT
	DAC	MAXLAD
	JMP	REL57
REL56	LAC	LDLMT2	/FGD
	TAD	(-1)
	DAC	MAXLAD
	LAC	LDLMT
	DAC	MINLAD
/
REL57	LAC	LTBX2
	JMS	FETLTB
REL55	LAC	LTBETY+5	/IS R-FLAG SET?
	SNA
	JMP	REL58	/NO -- TERMINAL ERROR
	LAC	MINLAD	/YES -- SET CORE LIMITS IN LTB ENTRY
	DAC	LTBETY+11
	LAC	MAXLAD
	DAC	LTBETY+12
	LAC	LTBX2
	JMS	SETLTB
	LAC	LTBX2
	SAD	LTBBSE
	JMP	REL60
	TAD	LTBMES
	JMS	FETLTB
	LAC	LTBETY+1
	SZA
	JMP	REL60
	LAC	LTBX2
	TAD	LTBMES
	DAC	LTBX2
	JMP	REL55
/
REL58	JMS	TYPE	/R-FLAG WAS NOT SET DURING RAO.
	MES720		/I.E., A GLOBAL DEFINITION FOR THE 
	LAC	LTBETY+3	/EXTERNAL LINK COMPONENT NAME DID NOT
	DAC	T6BW1	/EXIST. 
	LAC	LTBETY+4	/TYPE:
	DAC	T6BW2	/  "MISSING GLOBAL DEFINITION -- NAME"
	JMS	T6BN
	JMS	CRTN
	JMP	EXIT
/
REL60	LAC	LTBX3	/AUGMENT TTL SCAN INDEX
	TAD	TTLESZ
	DAC	LTBX3
	JMP	REL20
	.EJECT
/ ALL LINKS HAVE BEEN RELOCATED AND OUTPUT
/
REL70	LAC	LDLMT2
	DAC	LDLMT
	.CLOSE	RO	/CLOSE XCU FILE
	JMS	PAUSX	/PAUSE IF PAUSE FLAG IS SET
	LAW	-1	/CHANGE EXTENSION FROM XCU TO XCT
	TAD	ROFNAM+2
	DAC	ROFNAM+2
	.INIT	RO,1,0	/OPEN XCT FILE
ERO3Z	.ENTER	RO,ROFNAM
/
/ WRITE XCT FILE RECORD (LINK #377777)
/
WXCTF	LAC	(377777)
	DAC	LNKNUM
	DAC	OUTBUF+3
	LAC	(010000)
	DAC	OUTBUF
	LAC	(100000)
	DAC	OUTBUF+2
	LAC	BFFLAG	/BGD OR FGD CHAIN?
	SZA
	JMP	WXCT1
	LAC	MAX.XX	/BGD -- BASE OF BLANK COMMON
	CMA
	TAD	(002)
	TAD	LDLMT3
	DAC	LDLMT2	/SAVE BLK COM BASE IN LDLMT2
	DAC	OUTBUF+4
	DAC	MINREG	/SET MIN REG REQ
	SMA
	JMP	WXCT2
	JMS	TYPE	/MIN REG IS NEGATIVE -- TERMINAL ERROR
	MES702
	JMP	EXIT
WXCT1	LAC	LDLMT3	/FGD -- BASE OF BLANK COMMON
	DAC	LDLMT2	/SAVE BASE OF BLK COM IN LDLMT2
	DAC	OUTBUF+4
	TAD	(-1)
	TAD	MAX.XX
	DAC	MAXREG	/SET MAX REG REQ
	TAD	MAX.XX	/CORRECT LDLMT2 IF MAX.XX=0
	SAD	MAXREG
	DAC	LDLMT2
WXCT2	LAC	MAINEP	/MAIN PROG ENTRY POINT
	DAC	OUTBUF+5
	LAC	LTBBAD	/ADDRESS OF BASE OF LTB
	DAC	OUTBUF+6
	LAC	LTBTAD	/ADDRESS OF TOP OF LTB
	DAC	OUTBUF+7
	LAC	MINREG	/MINIMUM REGISTER REQUIRED
	DAC	OUTBUF+10
	LAC	MAXREG	/MAXIMUM REGISTER REQUIRED
	DAC	OUTBUF+11
	LAC	ENVIND	/ENVIRONMENT INDICATOR
	DAC	OUTBUF+12
	LAC	DATMAP	/.IODEV INFORMATION
	DAC	OUTBUF+13
	LAC	DATMAP+1
	DAC	OUTBUF+14
	LAC	DATMAP+2
	DAC	OUTBUF+15
	LAC	DATMAP+3
	DAC	OUTBUF+16
	JMS	WOB
/
	LAC	ROFLAG	/DON'T WRITE LINK TABLE IF RESIDENT ONLY
	SZA
	JMP	WLTB3
/
/ WRITE OUT LINK TABLE
/
	LAC	LTBBAD
	DAC	LOADADR
	LAC	LTBBSE
WLTB1	DAC	LTBX2
	SAD	LTBTOP
	JMP	WLTB2
	JMS	FETLTB	/FETCH AN LTB ENTRY
			/"DAC*  LOADADR" EACH WORD OF ENTRY
/
	CLA		/ZERO
	JMS	WLTS
	LAW	-1	/DAC   BUF
	TAD	LTBBAD
	AND	ADRMSK
	DAC	TEMP10
	XOR	(040000)
	JMS	WLTS
	LAC	LTBTAD	/JMS*  (EXECUTE)
	AND	ADRMSK
	XOR	(120000)
	JMS	WLTS
	LAC	LOADADR	/DAC*  .+3
	TAD	(003)
	AND	ADRMSK
	XOR	(060000)
	JMS	WLTS
	LAC	TEMP10	/LAC   BUF
	XOR	(200000)
	JMS	WLTS
	LAC	LOADADR	/JMP*  .+2
	TAD	(002)
	AND	ADRMSK
	XOR	(620000)
	JMS	WLTS
	LAC	LTBETY+6	/ENTRY POINT
	JMS	WLTS
	LAC	LTBETY+7	/ENTRY POINT PLUS ONE
	JMS	WLTS
	LAC	LTBETY+10	/LINK NUMBER
	JMS	WLTS
	LAC	LTBETY+11	/MIN ADR
	JMS	WLTS
	LAC	LTBETY+12	/MAX ADR
	JMS	WLTS
	LAC	LTBX2
	TAD	LTBESZ
	JMP	WLTB1
/
WLTS	0
	JMS	STORE
	ISZ	LOADADR
	JMP*	WLTS
/
WLTB2	JMS	FROP	/WRITE PARTIAL RECORD
WLTB3	JMS	WNPPR	/WRITE DUMMY CODE-3 RECORD
/
	.CLOSE	RO	/CLOSE XCT FILE
	LAC	DFSW	/DUMMY XCT FILE?
	SZA		/NO -- OUTPUT COMPLETE
	JMP	WDXCTR	/YES -- WRITE XCU FILE
/
	JMS	PAUSX	/PAUSE IF PAUSE FLAG IS SET
	LAC	LMFLAG	/TYPE BLANK COMMON (.XX) BOUNDS
	SNA		/IF BLANK COMMON EXISTS AND IF
	JMP	TOCREQ	/MAP FLAG IS SET
	LAC	MAX.XX
	SNA
	JMP	TOCREQ
	JMS	CRTN
	JMS	TYPE
	MES605
	LAC	(131330)
	DAC	SYM1
	DZM	SYM2
	JMS	SYMMAP
	LAC	LDLMT2
	DAC	SLIMFA
	TAD	(-1)
	TAD	MAX.XX
	DAC	SLIMLA
	JMS	SLIM
	JMS	TYPMAP
TOCREQ	JMS	CRTN	/TYPE OUT CORE REQUIRED
	JMS	TYPE
	MES690
	DZM	SYM1
	JMS	SYMMAP
	LAC	MINREG
	DAC	SLIMFA
	LAC	MAXREG
	DAC	SLIMLA
	JMS	SLIM
	ISZ	LMFLAG
	JMS	TYPMAP
/
EXIT	.EXIT
	.EJECT
/WFCP -- SUBROUTINE TO WAIT FOR ^P AND RETURN CONTROL TO CALLER
/
WFCP	0
	LAC	CPTVA	/SAVE ^P TRANS VECTOR
	DAC	CPBUF
	LAC	ADR1	/SET ^P TV TO TRANSFER TO WFCPR 
	DAC	CPTVA	/WHEN ^P IS TYPED IN
	JMP	.	/WAIT HERE FOR ^P
WFCPR	LAC	CPBUF	/RESTORE CONTENTS OF ^P TV
	DAC	CPTVA
	JMP*	WFCP	/EXIT
/
CPTVA	START
CPBUF	0
/
/ ^P HANDLER -- TRANSFER CONTROL PER CPTVA
/
CPTYPD	JMS	CRTN
	JMP*	CPTVA
/
/ FETLDT -- SUBROUTINE TO FETCH THE LDT ENTRY WHOSE INDEX IS IN AC.
/           THE ENTRY IS RETURNED IN LDTETY THRU LDTETY+2
/
FETLDT	0
	TAD	(-1)
	DAC*	(10)
	LAC*	10
	DAC	LDTETY
	LAC*	10
	DAC	LDTETY+1
	LAC*	10
	DAC	LDTETY+2
	JMP*	FETLDT
/
/ FETTTL -- SUBROUTINE TO FETCH THE TTL ENTRY WHOSE INDEX IS IN AC.
/           THE ENTRY IS RETURNED IN TTLETY THRU TTLETY+2
/
FETTTL	0
	TAD	(-1)
	DAC*	(10)
	LAC*	10
	DAC	TTLETY
	LAC*	10
	DAC	TTLETY+1
	LAC*	10
	DAC	TTLETY+2
	JMP*	FETTTL
/
/ FETLTB -- SUBROUTINE TO FETCH THE LTB ENTRY WHOSE INDEX IS IN AC.
/           THE ENTRY IS RETURNED IN LTBETY THRU LTBETY+10
/
FETLTB	0
	TAD	(-1)
	DAC*	(10)
	LAC	ADR17
	DAC*	(11)
	LAW	-13
	DAC	TEMP1
	LAC*	10
	DAC*	11
	ISZ	TEMP1
	JMP	.-3
	JMP*	FETLTB
/
/ SETLTB -- SUBROUTINE TO SET THE LTB ENTRY WHOSE INDEX IN IN AC
/           THE ENTRY IS TAKEN FROM LTBETY TO LTBETY+10
/
SETLTB	0
	TAD	(-1)
	DAC*	(11)
	LAC	ADR17
	DAC*	(10)
	LAW	-13
	DAC	TEMP1
	LAC*	10
	DAC*	11
	ISZ	TEMP1
	JMP	.-3
	JMP*	SETLTB
/
/ TWC -- SUBROUTINE TO TWO'S COMPLIMENT AC
/
TWC	0
	CMA
	TAD	(001)
	JMP*	TWC
/
/ T6BN -- SUBROUTINE TO TYPE THE .SIXBT NAME IN T6BW1 & T6BW2
/         THRU THE FIRST BLANK OR SIXTH CHARACTER
/
T6BN	0
	LAC	T6BW1
	JMS	T6BNS
	LAC	T6BW2
	JMS	T6BNS
	JMP*	T6BN
/
T6BNS	0
	DAC	T6BX1
	LAW	-3
	DAC	T6BX3
T6BNL	LAC	T6BX1
	JMS	LCS7
	DAC	T6BX2
	RAR
	DAC	T6BX1
	LAC	T6BX2
	AND	(077)
	SNA
	JMP*	T6BN
	XOR	(040)
	TAD	(040)
	DAC	T6BNB+2
T6BNZ	.WRITE	TO,3,T6BNB,0
	.WAIT	TO
	ISZ	T6BX3
	JMP	T6BNL
	JMP*	T6BNS
/
T6BW1	0
T6BW2	0
T6BX1	0
T6BX2	0
T6BX3	0
T6BNB	002000
	0
	XX
	177
/
/ TYPE -- SUBROUTINE TO TYPE A MESSAGE
/
/ CALLING SEQUENCE:
/	JMS	TYPE
/	MESXX
/	...
/ MESXX	.ASCII	/MESSAGE/
/
/ THE TWO WORDS PRECEDING THE MESSAGE ARE USED AS AN IOPS ASCII
/ HEADER.  THE ONLY HEADER REQUIREMENTS FOR TTY OUTPUT IS A GREATER
/ THAN ONE WORD PAIR COUNT.
/
TYPE	0
	LAC*	TYPE
	JMS	SETBBS
	TAD	(-2)
	DAC	.+3
	.WRITE	TO,2,XX,0
	.WAIT	TO
	ISZ	TYPE
	JMP*	TYPE
/
/ CRTN -- SUBROUTINE TO RETURN CARRIAGE
/
CRTN	0
	JMS	TYPE
	CRTNX
	JMP*	CRTN
/
CRTNX	.ASCII	<015>
/
/ SETBBS -- SUBROUTINE TO OR BANK BITS INTO THE WORD (ADR) IN AC
/
SETBBS	0
	AND	(017777)
	XOR	BNKBTS
	JMP*	SETBBS
/
/ LCS6 -- LEFT-CIRCULAR-SHIFT SIX
/
LCS6	0
	RTL
	RTL
	RTL
	JMP*	LCS6
/
/ LCS7 -- LEFT-CIRCULAR-SHIFT SEVEN
/
LCS7	0
	RAL
	RTL
	RTL
	RTL
	JMP*	LCS7
/
	.EJECT
RCLBSE	0	/BASE OF RESIDENT CODE LIST
LDTBSE	0	/BASE OF LINK DEFINITION TABLE
LDTLSX	0	/LDT LINE START INDEX
LDTEIF	0	/LDT EXTERNAL (000)/INTERNAL (001) SUB NAME FLAG
LDTX1	0	/RCL & LDT ENTRY INDEX (POINTS TO NEXT ENTRY)
LDTESZ	3	/LDT & RCL ENTRY SIZE
ODTBSE	0	/BASE OF OVERLAY-DESCRIPTION-TABLE
ODTLSX	0	/ODT LINE START INDEX
ODTX1	0	/ODT ENTRY INDEX (POINTS TO NEXT ENTRY)
ODTESZ	+5	/ODT ENTRY SIZE
ODTMES	-5	/2S COMP OF ODT ENTRY SIZE
TTLBSE	0	/BASE OF TRUNK-TO-TWIG LISTS
TTLPNT	0	/BACK POINTER (TO REF'ING ODT ENTRY)
TTLESZ	3	/TTL ENTRY SIZE
TTLX1	0	/TTL INDEX (POINTS TO NEXT ENTRY)
TTLX2	0	/INDEX USED TO SCAN ODT
LTBTOP	0	/TOP OF LINK TABLE (ADR OF T.V. TO EXECUTE)
LTBBSE	0	/BASE OF LTB
LTBMES	-13	/2S COMPL OF LDTB ENTRY SIZE
LTBESZ	+13	/LTB ENTRY SIZE
LTBTAD	0	/LTB TOP ADR (AT EXECUTE TIME)
LTBBAD	0	/LTB BASE ADR (AT EXECUTE TIME)
LTBX2	0	/INDEX USED TO SCAN LTB
LTBX3	0	/INDEX USED TO SCAN TTL'S
LTBX4	0	/INDEX USED TO SCAN LDT
PTBBSE	0	/BASE OF PATCH TABLE (PTB)
PTBX1	0	/PTB INDEX (POINTS TO NEXT ENTRY)
PTBX2	0	/PTB SCAN INDEX
LNKNUM	0	/LINK NUMBER
MINLAD	0	/MIN LINK ADR
MAXLAD	0	/MAX LINK ADR
MINREG	0	/MIN REGISTER REQUIRED FOR OVERLAY SYSTEM TO RUN
MAXREG	0	/MAX REGISTER REQUIRED 
MAINEP	0	/ENTRY POINT TO MAIN PROG
MAX.XX	0	/SIZE OF LARGEST BLANK COMMON
BNKBTS	0	/BANK BITS (FOR BANK RELOCATION)
LDLMT	0	/LOAD LIMIT BEFORE RELOCATION (TO SUB RAO)
LDLMT2	0	/LOAD LIMIT AFTER RELOCATION (FROM SUB RAO)
LDLMT3	0	/LIMIT OF BLANK COMMON
LTBETY	.BLOCK 13	/LTB ENTRY BUFFER
TTLETY	.BLOCK 3	/TTY ENTRY BUFFER
LDTETY	.BLOCK 3	/LDT ENTRY BUFFER
DUMLDT	.BLOCK 3	/DUMMY LDT ENTRY
	000001	/(MUST FOLLOW DUMLDT)
CLT	.BLOCK 11	/CORE LIMITS TABLE (CLT)
CLTX1	0	/POINTS TO END OF CLT (TERMINATOR)
CLTX2	0	/CLT SCAN INDEX
ADR1	WFCPR
ADR2	EXIT
ADR3	DATA1
ADR4	MAPNAM
ADR5	TTLOEI-1
ADR6	MAPFAD
ADR7	DATMAP
ADR8	SKDATA
ADR9	FACB+5
ADR10	CLT
ADR11	FITRHL
ADR12	CODTAB+31
ADR13	CBUF+2
ADR14	FANBF-1
ADR15	FACB
ADR16	DUMLDT
ADR17	LTBETY-1
ADR18	FANM
ADR19	INBUF
ADR20	PSNB+2
TEMP1	0
TEMP2	0
TEMP3	0
TEMP4	0
TEMP5	0
TEMP10	0
TEMP11	0
FGDBSE	0	/FGD BASE OPTION (NEG IF NOT SET)
FGDLMT	17500	/LOW CORE LIMIT FOR FGD CHAINS
BSADR	07636	/12-BIT BOOTSTRAP ADDRESS MINUS ONE
LMFLAG	1	/LOAD MAP FLAG   ZERO:OFF::NON-ZERO:ON
GMFLAG	0	/GLOBAL MAP FLAG   ZERO:OFF::NON-ZERO:ON
SZFLAG	0	/SIZE OUTPUT FLAG   ZERO:OFF::NON-ZERO:ON
BFFLAG	0	/BGD/FGD FLAG   0:OFF::NON-ZERO:ON
ROFLAG	0	/RESIDENT ONLY FLAG   0:OFF::NON-ZERO:ON
PSFLAG	0	/PAUSE FLAG:
		/NON-ZERO -- PAUSE AFTER RELOCATION OF A LINK OR
		/THE RESIDENT CODE.  FLAG IS INCREMENTED AT EACH PAUSE.
		/ZERO -- NO PAUSE
		/NOTE: SETTING PSFLAG=-1 WILL RESULT IN A PAUSE ONLY
		/AFTER RELOCATING THE RESIDENT CODE.
/ PDP 9/15 MASKS	PDP-9	PDP-15
ADRMSK	0 /	017777	007777
OPCMSK	0 /	760000	770000
/
ROFNAM	.SIXBT	/------XCU/
DFSW	0	/DUMMY FILE SWITCH  ZERO:OFF::NON-ZERO:ON
ENVIND	0	/ENVIRONMENT INDICATOR
		/  BIT-16 SET FOR FGD, RESET FOR BGD
		/  BIT-17 SET FOR PDP-9, RESET FOR PDP-15
	.EJECT
/ RAO -- SUBROUTINE TO RELOCATE AND OUTPUT A LINK
/
/ 'RAOX' POINTS TO EITHER:
/ 1. THE FIRST RCL ENTRY WHEN RELOCATING THE RESIDENT CODE.
/ 2. THE SECOND LDT ENTRY OF A LINK DESCRIPTION WHEN RELOCATING
/    A NON-SCL LINK.
/ 3. THE DUMMY LDT ENTRY WHEN RELOCATING A SCL.
/
/ IN ANY CASE 'RAOX' POINTS TO AN TABLE ENTRY THAT DEFINES
/ A ROUTINE TO BE RELOCATED & OUTPUT (AN INDICATOR WORD
/ AND A TWO-WORD NAME).  IN THE CASE OF A MULTI-ROUTINE
/ LINK OR MORE THAN ONE RESIDENT ROUTINE, SUCCEDING ENTRIES
/ INDICATE OTHER ROUTINES TO BE RELOCATED.  IN ANY CASE,
/ NAMES OF ROUTINES ARE FETCHED AND THE ROUTINES RELOCATED
/ AND OUTPUT UNTIL AN INDICATOR WITH BIT-17 SET IS FOUND.
/
/ ROUTINES ARE RELOCATED BELOW (BGD) OR ABOVE (FGD) THE
/ ADDRESS IN 'LDLMT'.  WHEN FINISHED RELOCATING A LINK (OR THE
/ RESIDENT CODE), 'LDLMT2' POINTS TO THE WORD BELOW (BKG) OR ABOVE
/ (FGD) THE LAST ROUTINE RELOCATED & OUTPUT.
/
/ LDLMT2 IS LEFT POINTING TO THE NEXT AVAILABLE REGISTER
/ LDLMT IS NOT ALTERED
/
/ SYMBOL TABLE ENTRY CODES:
/	0 -- DELETED GLOBAL SYMBOL ENTRY
/	1 -- UNRESOLVED GLOBAL SYMBOL REFERENCE *
/	5 -- GLOBAL SYMBOL DEFINITION, OR RESOLVED
/	     GLOBAL SYMBOL REFERENCE *
/	6 -- DUMMY GLOBAL SYMBOL ENTRY  
/	     USED TO INSURE THE RELOCATION OF A
/	     LIBRARY ROUTINE. (IT MIGHT NOT BE 
/	     REFERENCED FROM WITHIN THE LINK OR
/	     RESIDENT CODE BEING RELOCATED, OR
/	     IT MAY BE ONLY REFERENCED BY ROUTINES
/	     FOLLOWING IT IN THE LIBRARY.)
/	7 -- UNDEFINED COMMON BLOCK NAME *
/	3 -- DEFINED COMMON BLOCK NAME *
/	4 -- COMMON ELEMENT REFERENCE *
/ 			* SAME AS LINKING LOADER
/
RAOX	0
/
RAO	0
	LAC	SYMEB1	/RESET END OF SYMBOL TABLE
	DAC	SYMEND
	LAC	PTBBSE	/RESET BEGINNING OF PATCH TABLE
	DAC	PTBX1
	LAC	ADR8	/SETUP SEEK DATA POINTER
	DAC	SDPTR
	LAC	ADR11	/RESET REMAINING HOLES LIST INDEX
	DAC	FITX1
	LAC	(002000)	/WRITE LINK HEADER RECORD
	DAC	OUTBUF
	LAC	(100000)
	DAC	OUTBUF+2
	LAC	LNKNUM
	DAC	OUTBUF+3
	JMS	WOB
	LAC	LDLMT
	DAC	LDLMT2
	LAC	RAOX
RAOFCN	JMS	FETLDT	/FETCH COMPONENT LDT ENTRY
	LAC	LDTETY	/NEXT LINK DESCRIPTION?
	AND	(001)
	SZA		/NO -- RELOCATE OR MAKE DUMMY SYMTAB ENTRY
	JMP	RAOCUD	/YES -- CLOSE FILE ON USER'S DEV
/
	LAC	LDTETY+1	/SET FILE NAME IN SEEK DATA AND IN
	DAC	SKDATA	/SYM1 & SYM2 (RADIX50).
	JMS	CTR50
	DAC	SYM1
	LAC	LDTETY+2
	DAC	SKDATA+1
	JMS	CTR50
	DAC	SYM2
	SNA
	JMP	.+4
	LAC	SYM1
	XOR	(400000)
	DAC	SYM1
	LAC	LDTETY	/WAS THIS ROUTINE FLAGED AS RESIDING IN
	AND	(020)	/IN A LIBRARY?
	SNA
	JMP	RAORAO	/NO -- RELOCATE AND OUTPUT
	LAC	(677777)	/YES -- MAKE DUMMY SYMBOL TABLE ENTRY
	DAC	SYMDEF	/TO INSURE LOADING DURING LIBRARY SEARCH
	JMS	DEFSYM	/EVEN IF ROUTINE IS NOT CALLED OR CALLING
	JMP	RAOAUX	/ROUTINE(S) FOLLOW THIS ROUTINE IN LIBRARY.
/
RAORAO	JMS	SYMMAP	/SET NAME IN MEMORY MAP LINE
	LAW	UD	/'SEEK' A FILE ON THE USER'S DEVICE
	JMS	SEEK
	LAW	-1
	DAC	NUFILE
	LAW	UD
	JMS	LDPROG
/
RAOAUX	LAC	RAOX	/AUGMENT RAOX
	TAD	LDTESZ
	DAC	RAOX
	JMP	RAOFCN
/
/ ALL ROUTINES FROM USER'S DEVICE HAVE BEEN RELOCATED
/
RAOCUD	.CLOSE	UD	/CLOSE FILE ON USER'S DEVICE
	JMS	VIRTUAL	/ARE THERE ANY UNRESOLVED GLOBALS?
	JMP	TROR	/NO -- TERMINATE RELOCATED OUTPUT RECORD
	LAC	SDPTR
	TAD	(003)
	DAC	SDPTR
	LAC*	DATP	/YES -- SCAN USER'S LIBRARY IF 
	TAD	(UL)	/A DEVICE IS ASSIGNED
	DAC	TEMP1
	LAC*	TEMP1
	SNA
	JMP	RAOSSL	/(NO USER'S LIB, SCAN SYS LIB)
	LAW	UL
	JMS	LIBRARY
/
	JMS	VIRTUAL	/ARE THERE ANY UNRESOLVED GLOBALS?
	JMP	TROR	/NO -- TERMINATE RELOCATED OUTPUT RECORD
RAOSSL	LAC	SDPTR	/YES -- SCAN SYS LIB
	TAD	(003)
	DAC	SDPTR
	LAW	SL
	JMS	LIBRARY
/
	JMS	VIRTUAL	/ARE THERE ANY UNRESOLVED GLOBALS?
	JMP	TROR	/NO -- TERMINATE RELOCATED OUTPUT RECORD
	JMS	TYPE	/YES -- TYPE OUT NAMES AND EXIT
	MES710
	JMS	SHTMAP	/SHORTEN MAP LINE AND SET MAP FLAG
GLBERR	JMS VIRTUAL	/ANY UNDEFINED GLOBALS?
	JMP	EXIT	/NO -- EXIT
	DZM* SYMWD1	/YES. KILL THE ENTRY IN THE SYMBOL TABLE
			/TO AVOID SEEING IT AGAIN.
	JMS NEXSYM	/PICK UP GLOBAL NAME
	DAC SYM1
	JMS NEXSYM
	DAC SYM2
	JMS	SYMMAP	/SET NAME IN MAP LINE
	JMS	TYPMAP	/TYPE MAP LINE
	JMP GLBERR	/CONTINUE UNTIL THEY'RE ALL DONE
/
TROR	JMS	FROP	/TERMINATE AND WRITE RELOCATED OUTPUT
			/RECORD.
/
/ RESOLVE UNDEFINED COMMON BLOCKS
/
	JMS	BEGSYM	/SCAN SYMBOL TABLE FOR UNDEFINED COMMON 
RCB1	SAD	SYMEND	/BLOCK ENTRIES (CODE=7). 
	JMP	OUTPTB
	LAC*	SYMWD1
	AND	(700000)
	SAD	(700000)
	JMP	RCB10
RCB2	JMS	NXNTRY
	JMP	RCB1
/
RCB10	LAC*	SYMPTR	/UNDEFINED COMMON BLOCK ENTRY FOUND
	AND	(077777)	/SAVE BLOCK SIZE
	DAC	TEMP1
	JMS	TWC	/SAVE 2'S COMPL OF SIZE AND SET BLOCK FLAG
	DAC	SIZE
	DAC	BLKFLG
	JMS	DECSPT	/GET NAME AND TEST FOR BLANK COMMON
	LAC*	SYMPTR	/DEFINITION (RADIX 50 FOR '.XX' IS 131330)
	SAD	(131330)
	JMP	RCB20
/
			/NAMED COMMON FOUND --
	DAC	SYM1	/SAVE NAME FOR MAP LINE
	SMA
	JMP	.+4
	JMS	DECSPT
	LAC*	SYMPTR
	DAC	SYM2
	JMS	SYMMAP	/ENTER NAME IN MAP LINE
	JMS	FIT	/FIND CORE
	JMS	TYPMAP	/TYPE MAP LINE IF MAP FLAG IS SET
	LAC*	SYMWD1	/COMMON BLOCK IS NOW DEFINED, CHANGE SYMBOL
	AND	(377777)	/TABLE CODE FROM 7 TO 3.
	DAC*	SYMWD1
	JMS	DECSPT	/SET BASE OF BLOCK (DEFINITION) IN
	JMS	DECSPT	/SYMBOL TABLE, AND LEAVE SYMPTR POINTING
	LAC	LOADADR	/TO THE SYMTAB CHAIN ADDRESS
	DAC*	SYMPTR
	ISZ	SYMPTR
/
	JMS	DEFCOM	/FOLLOW SYMBOL TABLE CHAIN MAKING PATCH
	JMP	RCB2	/TABLE ENTRIES (CODE=0) FOR EACH TRANSFER 
			/VECTOR  TO THIS NAMED COMMON BLOCK.
/
			/BLANK COMMON FOUND --
RCB20	LAC	TEMP1	/UPDATE LARGEST-BLANK-COMMON-BLOCK
	JMS	TWC	/IF NECESSARY.
	TAD	MAX.XX
	SPA
	CLA
	TAD	TEMP1
	DAC	MAX.XX
/
	JMS	DECSPT	/FOLLOW SYMBOL TABLE CHAIN MAKING 
	LAC*	SYMPTR	/PATCH TABLE ENTRIES (CODE=2) FOR
			/EACH TRANSFER VECTOR TO BLANK COMMON
/
	DZM*	SYMPTR	/INDICATE NO STRING (FOR FUTURE ENTRIES)
RCB21	SNA
	JMP	RCB2
	DAC	SYMPTR
	JMS	DECSPT
	LAC*	SYMPTR
	AND	(077777)
	XOR	(200000)
	DAC	PTBW1
	JMS	DECSPT
	LAC*	SYMPTR
	DAC	PTBW2
	JMS	PTBENT
	ISZ	SYMPTR
	ISZ	SYMPTR
	LAC*	SYMPTR
	AND	(077777)
	JMP	RCB21
/
/ OUTPUT PATCH TABLE
/
OUTPTB	LAC	PTBBSE	/SETUP HEADER --
	JMS	TWC	/  BITS 0-2 -- CODE=3
	TAD	PTBX1	/  BITS 3-17 -- WORD LENGTH OF PATCH TBL
	SNA
	JMP	OPTB4	/SPECIAL CASE: ZERO LENGTH PATCH TABLE
	RCR
	XOR	(300000)
	DAC	OUTBUF+2
	LAC	PTBBSE
	DAC	PTBX2
	LAC	OUTBEG
	TAD	(002)
	DAC	TEMP1
OPTB1	LAC	TEMP1
	DAC	TEMP2
	DZM	OUTBUF+3
	LAC	(002000)
	DAC	OUTBUF
OPTB2	LAC	PTBX2
	SAD	PTBX1
	JMP	OPTB3
	LAC*	PTBX2
	ISZ	PTBX2
	DAC*	TEMP2
	ISZ	TEMP2
	LAC*	PTBX2
	ISZ	PTBX2
	DAC*	TEMP2
	ISZ	TEMP2
	ISZ	OUTBUF+3
	LAC	OUTBUF
	TAD	(001000)
	DAC	OUTBUF
	SAD	(021000)
	SKP
	JMP	OPTB2
	JMS	WOB
	JMP	OPTB1
/
OPTB3	LAC	OUTBUF
	SAD	(002000)
	SKP
	JMS	WOB
	JMP*	RAO
/
OPTB4	JMS	WNPPR	/WRITE NO PATCH PATCH-RECORD
/
	JMP*	RAO	/EXIT RAO SUBROUTINE
/
/ PAUSX -- SUBROUTINE TO PAUSE AND TYPE OUT LINK 
/          NUMBER IF PAUSE FLAG IS SET
/
PAUSX	0
	LAC	PSFLAG	/IS PAUSE FLAG SET?
	SNA
	JMP*	PAUSX	/NO -- EXIT
	ISZ	PSFLAG	/YES -- TURN OFF IF 'PAUSE AFTER RESIDENT'
	NOP
	JMS	TYPE	/TYPE "PAUSE #XXX "
	MES610
	LAC	ADR20
	DAC	MAPX1
	LAC	LNKNUM
	JMS	ADROUT
	LAW	040
	DAC	PSNB+2
	LAW	043
	DAC	PSNB+3
PAUSZ	.WRITE	TO,3,PSNB,0
	JMS	WFCP	/WAIT FOR ^P
	JMP*	PAUSX	/EXIT
/
	.EJECT
/ GLEANED FROM:
/ B/F .SYSLD V1A - 21 MAY 1969 - JEAN-CLAUDE P. PROTEAU
/
/ MAIN SUBROUTINE LDPROG: LOAD A PROGRAM UNIT VIA THE 'CAL .DAT SLOT' IN
/ THE AC. NORMALLY, RETURN IS BY A JMP* LDPROG WITH THE 15-BIT STARTING
/ ADDRESS (OF THE PROGRAM UNIT JUST LOADED) IN THE AC. WHEN LOADING FROM
/ A LIBRARY FILE, IF END-OF-FILE IS ENCOUNTERED, RETURN IS A 'JMP LIBCLOS'.
/
IDX=ISZ
SET=ISZ
/
LDPROG	0		/CAL .DAT SLOT IS IN THE AC.
	AND (777
	DAC	READ1
	DAC	WAIT1
	LAC	SYMEND	/SAVE SYMEND TO BE RESTORED IF LIBRARY
	DAC	SYMEB2	/ROUTINE IS NOT RELOCATED
	DZM	DGSNB	/CLEAR DUPLICATE GLOBAL NAME INDICATION
	DZM	BLKFLG	/CLEAR BLOCK FLAG
	LAC	NUFILE
	SNA
	JMP	BUFCHK
	DZM	NUFILE
BUFMPTY	LAC	ADR19
	DAC	BUFPTR
READ1	.READ	0,0,INBUF,50
WAIT1	.WAIT	0
/ TEST THE HEADER WORDS IN THE BUFFER JUST READ INTO.
 
	LAC* BUFPTR	/PICKUP HEADER WORD 1.
	AND	(017)	/MASK TO FUNCTION BITS
	SAD	(006)	/END OF MEDIUM?
	JMP PRTEOM
	SAD (5		/END OF FILE?
	JMP LIBCLOS	/YES. ABNORMAL EXIT. CLOSE LIBRARY FILE.
	LAC* BUFPTR
	AND (60		/GET BITS 12 AND 13.
	SNA		/PARITY, CHECKSUM, BUFFER OVERFLOW?
	JMP	PLIT9
	LAC	(MES705)
	JMP	TERR
PLIT9	LAW -1000		/LAC (777000
	TAD* BUFPTR	/PICKUP WORD PAIR COUNT, SUBTRACT
	AND .-2		/1 FOR HEADER PAIR, MULTIPLY BY 2
	CLL!RAL		/TO GET WORD COUNT (IN BITS 0 THRU 8).
	DAC WRDCNT
 
/ HEADER IS OK. NOW UPDATE THE BUFFER POINTER TO 1ST DATA WORD - 1.
/ INITIALIZE CODE WORD COUNT SO 1ST WORD IS TAKEN TO BE A CODE WORD.
/ ISSUE NEXT READ.
 
	IDX BUFPTR
	LAW -1
	DAC CDWCNT
 
 
/ CHECK IF BUFFER IS EMPTY. RETURN HERE WHENEVER READY TO PROCESS
/ ANOTHER DATA WORD.
 
BUFCHK	IDX BUFPTR	/POINT TO NEXT BUFFER WORD.
	LAC WRDCNT	/IS BUFFER EMPTY?
	SNA
	JMP BUFMPTY	/YES. READ IN SOME MORE.
	TAD PLIT9		/(777000
	DAC WRDCNT	/SUBTRACT 1 FROM THE WORD COUNT.
	ISZ CDWCNT	/READY FOR NEXT CODE WORD?
	JMP GETCOD	/NO. THERE ARE MORE CODES LEFT IN OLD ONE.
	LAW -4		/YES. RESET COUNT FOR 3 CODES PER WORD.
	DAC CDWCNT
	LAC* BUFPTR	/GET NEXT CODE WORD.
	DAC CODEWD
	JMP BUFCHK
 
	.EJECT
/ UNPACK THE NEXT CODE.
 
GETCOD	LAC CODEWD	/SHIFT CODE WORD SO THAT NEXT CODE
	RTL		/IS IN LOW ORDER AC BITS (12 THRU 17).
	RTL
	RTL
	DAC CODEWD
	RAL
	AND (77
	DAC TEMP1		/SAVE CODE FOR TESTING.
 
	LAC LIBFLG	/IS LIBRARY SEARCH MODE IN EFFECT?
	SNA
	JMP LOADIT	/NO. ALL LOADER CODES ARE IN EFFECT.
 
/ WHILE LIBRARY SEARCH MODE IS IN EFFECT, EXAMINE ONLY SPECIFIC
/ LOADER CODES; IGNORE ALL OTHERS.
 
	LAC TEMP1
	SAD (001)		/CODE 1 - PROGRAM SIZE.
	JMP LOADIT
	SAD (7		/CODE 7 - SYMBOL (1ST 3 CHARS).
	JMP LOADIT
	SAD (10		/CODE 8 - SYMBOL (2ND 3 CHARS).
	JMP LOADIT
	SAD (012)		/CODE 10 - INTERNAL GLOBAL DEFINITION.
	JMP LOADIT
	SAD (27		/CODE 23 - END OF PROGRAM UNIT.
	JMP LOADIT
	SAD (13		/CODE 11 - BLOCK DATA SUBPROGRAM.
	SKP
	JMP BUFCHK	/IGNORE ALL OTHER CODES.
	DZM LIBFLG	/CLEAR SELECTIVE LOADING FLAG SO THAT
			/THIS BLOCKDATA SUBPROGRAM IN THE USER'S
			/LIBRARY WILL BE LOADED IN (A FEATURE!!)
 
/ CODE ACCEPTED FOR PROCESSING. PICKUP THE ASSOCIATED DATA WORD AND
/ JUMP TO THE APPROPRIATE DATA PROCESSING ROUTINE.
 
LOADIT	LAW -31		/-25 DECIMAL.
	TAD TEMP1
	SMA		/IS THIS CODE >24 DECIMAL?
	JMP ERR106	/YES. BAD CODE.
 
	TAD ADR12		/(CODTAB+31
	DAC TEMP1		/SAVE DISPATCH ADDRESS.
	LAC* BUFPTR	/PICKUP DATA WORD.
	JMP* TEMP1	/PROCESS IT.
 
	.EJECT
/ DISPATCH TABLE TO CODE PROCESSING ROUTINES.
/ CODES 11 THRU 18, 20 AND 21 ARE GENERATED ONLY BY FORTRAN.
 
CODTAB	JMP ERR106	/CODE 0 IS ILLEGAL.
	JMP CODE1
	JMP CODE2
	JMP CODE3
	JMP CODE4
	JMP CODE5
	JMP CODE6
	JMP CODE7
	JMP CODE8
	JMP CODE9
	JMP CODE10
	JMP CODE11
	JMP CODE12
	JMP CODE8		/CODE 13 IS PROCESSED JUST LIKE CODE 8.
	JMP CODE14
	JMP CODE15
	JMP CODE16
	JMP CODE17
	JMP CODE18
	JMP CODE19
	JMP CODE20
	JMP CODE21
	JMP CODE22
	JMP CODE23
	JMP BUFCHK	/CODE 24 (18-BIT PARAMETER ASSIGNMENT)
			/IS PASSED ON BY MACRO BUT IS IGNORED.
 
/ WHEN END OF MEDIUM IS DETECTED WHILE TRYING TO READ IN A PROGRAM,
/ TRANSFER HERE. PRINT ^P AND WAIT FOR THE USER TO TYPE CONTROL P.
 
PRTEOM	JMS	TYPE
	MES703
	JMS	WFCP	/WAIT FOR ^P
	JMP	READ1
	.EJECT
/ CODE 1 PROCESSOR: PROGRAM UNIT'S SIZE. COMPUTE LOAD ADDRESS AND
/ RELOCATION FACTORS.
 
CODE1	SPA!CMA		/ABSOLUTE OR RELOCATABLE PROGRAM?
	JMP ERR115	/ABSOLUTE.
	TAD (001)
	DAC SIZE		/SAVE 2'S COMPLEMENT OF PROGRAM SIZE.
 
/ IF IN LIBRARY SEARCH MODE, DON'T CHECK IF THIS PROGRAM UNIT CAN FIT
/ IN CORE UNTIL IT IS KNOWN THAT IT WILL BE LOADED (SEE CODE 10).
 
	LAC LIBFLG	/ARE WE IN LIBRARY SEARCH MODE?
	SZA
	JMP ABSOLU	/YES. DON'T CHECK FOR FIT YET.
 
/ SEE IF PROGRAM WILL FIT IN AVAILABLE CORE. COMPUTE THE PROGRAM'S
/ LOAD ADDRESS AND RELOCATION FACTOR.
 
	JMS FIT
	JMP BUFCHK
 
ABSOLU	DZM RELOC		/0 THE RELOCATION FACTOR.
	JMP BUFCHK	/GO TO PROCESS THE NEXT DATA WORD.
 
	.EJECT
/ CODE 2 PROCESSOR: PROGRAM'S LOAD ADDRESS.
 
CODE2	SPA
	JMP	ERR115
	TAD	RELOC
	DAC	LOADADR
	JMP BUFCHK
 
/ CODE 3 PROCESSOR: RELOCATABLE INSTRUCTION.
 
/ CODE 4 PROCESSOR: A NON-MEMORY REFERENCING INSTRUCTION, A NON-
/ RELOCATABLE MEMORY REFERENCING INSTRUCTION, AN ABSOLUTE ADDRESS,
/ OR A CONSTANT.
 
CODE3	DAC	TEMP1	/ADD IN THE RELOCATION FACTOR
	LAC	RELOC	/(MODULO 13-BITS) TO THE ADDRESS
	AND	ADRMSK	/FIELD.
	TAD	TEMP1
CODE4	JMS STORE		/STORE THE WORD IN CORE.
	IDX LOADADR
	JMP	BUFCHK
 
/ CODE 5 PROCESSOR: RELOCATABLE PROGRAM ADDRESS (VECTOR).
 
CODE5	TAD RELOC		/ADD IN THE 15-BIT
	JMP CODE4		/RELOCATION FACTOR.
 
	.EJECT
/ CODE 6 PROCESSOR: NON-COMMON VARIABLE AND ARRAY STORAGE ALLOCATION.
 
CODE6	TAD LOADADR	/INCREASE THE PRESENT LOAD ADDRESS BY THE
	DAC	LOADADR	/STORAGE SIZE.
	JMP	BUFCHK
 
 
/ CODE 7 PROCESSOR: 1ST 3 CHARACTERS OF A SYMBOL.
 
CODE7	DAC SYM1		/SAVE RADIX 50 SYMBOL CODE.
	JMP BUFCHK
 
 
/ CODE 8 PROCESSOR: LAST 3 CHARACTERS OF A SYMBOL.
/ (CODE 13 ALSO STARTS HERE).
 
CODE8	DAC SYM2		/SAVE RADIX 50 SYMBOL CODE.
	JMP BUFCHK
 
 
/ CODE 9 PROCESSOR:  GLOBAL SYMBOL REFERENCE.
/ CONTAINS UNRELOCATED ADDRESS OF A TRANSFER VECTOR, WHICH
/ HAS BEEN SETUP TO POINT TO ITSELF.
 
CODE9	TAD RELOC		/ADD RELOCATION FACTOR,
	TAD (100000)		/ADD CODE (1) FOR A VIRTUAL GLOBAL,
	JMS SCAN		/SCAN THE SYMBOL TABLE TO SEE IF THIS SYMBOL
			/HAS ALREADY BEEN ENTERED.
	JMP CDE9A		/YES.
	JMS DEFSYM	/ENTER IN SYMTAB.
	LAC	SYMDEF
	AND	(077777)
 
/ GLOBAL SYMBOL IS  IN THE SYMBOL TABLE. IF UNRESOLVED, AC HAS
/ THE ADDRESS OF THE 1ST TRANSFER VECTOR IN THE CHAIN. IF RESOLVED,
/ AC HAS TRUE ADDRESS OF THE GLOBAL. IN EITHER CASE, STORE THIS
/ ADDRESS IN THE TRANSFER VECTOR.
/
CDE9A	DAC	PTBW2	/STORE 15-BIT DEFINITION IN A
	LAC	SYMDEF	/TRANSFER VECTOR IN THE PATCH TABLE
	AND	(077777)
	DAC	PTBW1
	JMS	PTBENT
	LAC* SYMWD1	/GET 1ST WORD OF GLOBAL ENTRY.
	SPA		/IS IT STILL VIRTUAL?
	JMP BUFCHK	/NO. PROCESS NEXT DATA WORD.
 
/ SINCE THE GLOBAL IS STILL VIRTUAL, ENTER THE ADDRESS OF THE LATEST
/ TRANSFER VECTOR INTO THE SYMBOL TABLE ENTRY FOR THE GLOBAL, THEREBY
/ RECLOSING THE CHAIN.
 
	LAC SYMDEF
	DAC* SYMWD1
	JMP BUFCHK
 
/ CODE 10 PROCESSOR:  GLOBAL SYMBOL DEFINITION -- AC  CONTAINS
/ THE UNRELOCATED DEFINITION (ADDRESS) OF THE LAST SYMBOL 
/ (CODES 7 & 8) ENCOUNTERED.
/
/ 1. IF THE SYMBOL HAS NOT BEEN REFERENCED (OR DEFINED), 
/    ENTER THE DEFINITION IN THE SYMBOL TABLE.
/    IF IN LIBRARY SEARCH AND THE ROUTINE IN NOT RELOCATED, 
/    THE END OF THE SYMBOL TABLE IS RETRACTED, EFFECTIVELY 
/    DELETING ANY DEFINITIONS MADE FOR THE ROUTINE THAT WAS
/    READ THRU BUT NOT RELOCATED.
/ 2. IF THE SYMBOL HAS BEEN REFERENCED, DEFINE SYMBOL AND 
/    RESOLVE ALL REFERENCES TO IT.  IF IN LIBRARY SEARCH, 
/    SETUP TO RELOCATE FROM LIBRARY (JMS SUTLFL).
/ 3. IF THE SYMBOL HAS BEEN DEFINED AND THE DEFINITION 
/    IS A LINK TABLE ENTRY, SET THE ACTUAL DEFINITION IN
/    THE LINK TABLE ENTRY.
/ 4. IF THE SYMBOL HAS BEEN DEFINED AND THE DEFINITION IS
/    NOT A LINK TABLE ENTRY, SAVE THE SYMBOL NAME TO FLAG
/    A DUPLICATE SYMBOL DEFINITION.  IF THE ROUTINE IS REL-
/    OCATED (NOT IN LIBRARY SEARCH, OR IN LIB SEARCH AND 
/    ANOTHER DEFINITION MATCHED AN UNRESOLVED REFERENCE), THE
/    SET DUPLICATE SYMBOL FLAG WILL RESULT IN A TERMINAL
/    ERROR. 
/
CODE10	TAD RELOC		/ADD RELOCATION FACTOR.
	DAC TEMP3
	TAD (500000)	/(500000 ADD CODE FOR DEFINED GLOBAL.
	JMS SCAN		/IS THERE A GLOBAL WITH THE SAME NAME
			/ALREADY IN THE SYMBOL TABLE?
	JMP INTABLE	/YES.
/ SYMBOL NOT IN TABLE -- ENTER DEFINITION (CODE 5).
/   IF IN LIB SEARCH AND ROUTINE IS NOT RELOCATED, THE ENTRY
/   WILL BE DELETED.
/   IF IN LIB SEARCH, AND THE ROUTINE IS LOADED, ANY GLOBAL
/   SYMBOL DEFINITIONS MADE WILL BE RELOCATED WHEN CORE FOR
/   THE ROUTINE IS ALLOCATED.
	JMS DEFSYM	/ENTER SYMBOL AND ITS DEFINITION.
/
/ GLOBAL DEF DOES NOT MATCH AN UNRESOLVED GLOBAL REF --
/ IF IN LIBRARY SEARCH, TEST FOR: GLOBAL SYMBOL DEF
/ MATCHING A DUMMY GLOBAL SYMBOL REF.  IF FOUND, SET UP TO
/ LOAD FROM LIBRARY (JMS SUTLFL)
/
	LAC	LIBFLG
	SNA
	JMP	BUFCHK
	LAC	(600000)
	JMS	SCAN
	JMS	SUTLFL
	JMP	BUFCHK
/
	.EJECT
/ GLOBAL ALREADY IN SYMBOL TABLE.
 
INTABLE	DAC TEMP4		/SAVE 15-BIT DEFINITION FROM SYMTAB ENTRY.
	LAC* SYMWD1	/IS IT ALREADY DEFINED?
	SPA!CLA
	JMP	LTBCHK	/YES
	SAD LIBFLG	/NO. ARE WE IN LIBRARY SEARCH MODE?
	JMP RESOLVE	/NO. DEFINE THE GLOBAL ENTRY.
	JMS	SUTLFL
	JMP	RESOLVE
 
/ LIBFLG ON MEANS THE LOADER IS SEARCHING THRU SOME LIBRARY FOR INTERNAL
/ (DEFINED) GLOBALS WHICH ARE REQUESTED IN THE SYMBOL TABLE. JUST FOUND
/ ONE. NOW TEST IF THIS LIBRARY PROGRAM WILL FIT IN AVAILABLE CORE AND
/ SETUP THE RELOCATION FACTOR. IF IT FITS,
/ CLEAR LIBFLG TO INDICATE THAT A GLOBAL WAS RESOLVED (SEE INSTRUCTIONS
/ AT NEXLIB) AND ALSO SO THAT THE REMAINDER OF THIS PROGRAM ( UP TO THE
/ END-OF-PROGRAM CODE (23) ) WILL BE LOADED IN (INCLUDING SUBSEQUENT
/ GLOBAL DEFINITIONS).
/
SUTLFL	0		/SET UP TO LOAD FROM LIBRARY
	JMS	SYMMAP	/ENTER NAME IN MEM MAP BUFFER
	JMS FIT		/TEST IF LIBRARY PROGRAM FITS IN CORE AND
			/COMPUTE LOAD ADDRESS AND RELOC FACTOR.
	DZM LIBFLG	/CLEAR LIBRARY MODE FLAG SO REST OF PROGRAM
			/WILL BE LOADED AND TO SIGNAL THAT IT WAS.
/
	LAC	SYMPTR	/SCAN SYMBOL TABLE ENTERIES GENERATED
	DAC	TEMP10	/SINCE THIS LIB ROUTINE WAS FIRST ENCOUNTERED
	LAC	SYMWD1	/AND RELOCATE ANY GLOBAL SYMBOL DEFINITIONS
	DAC	TEMP11	/(SYMWD1 & SYMPTR WILL BE RESTORED)
	LAC	SYMEB2
	DAC	SYMWD1
SUTL1	SAD	SYMEND
	JMP	SUTL2
	LAC*	SYMWD1
	AND	(700000)
	SAD	(500000)
	SKP
	JMP	.+4
	LAC*	SYMWD1
	TAD	RELOC
	DAC*	SYMWD1
	JMS	NXNTRY
	JMP	SUTL1
SUTL2	LAC	(600000)	/SCAN FOR A DUMMY GLOBAL SYMBOL ENTRY
	JMS	SCAN	/AND KILL IF FOUND.
	DZM*	SYMWD1
	LAC	TEMP10	/(RESTORE SYMWD1 & SYMPTR)
	DAC	SYMPTR
	LAC	TEMP11
	DAC	SYMWD1
	LAC TEMP3		/ADD RELOCATION FACTOR AGAIN (TO GLOBAL
	TAD RELOC		/ADDRESS) BECAUSE IT WAS 0 PREVIOUSLY.
	DAC TEMP3
	TAD (500000)	/(500000
	DAC SYMDEF	/SAVE FOR SYMBOL DEFINITION.
	JMP*	SUTLFL
/
/ GLOBAL SYMBOL ALREADY IN TABLE AND DEFINED!
/
LTBCHK	LAC	TEMP4	/SAVE LAST DUPL NAME UNLESS ORIGINAL
	JMS	TWC	/DEFINITION POINTED TO A LINK TABLE ENTRY.
	TAD	LTBTAD	/THEN, THE NEW DEFINITION IS THE ENTRY
	SPA		/POINT TO AN EXTERNAL LINK COMPONENT.
	JMP	DUPGBL
	LAC	LTBBAD
	JMS	TWC
	TAD	TEMP4
	SPA
	JMP	DUPGBL
/
	LAC	LIBFLG	/GLOBAL SYMBOL DEFINED AS LINK TABLE ENTRY.
	SNA		/IF IN LIBRARY SEARCH, SETUP TO LOAD ONLY
	JMP	SLTEPO	/IF A DUMMY GLOBAL (CODE 6) EXISTS.
	LAC	(600000)
	JMS	SCAN
	SKP
	JMP	BUFCHK
	JMS	SUTLFL
SLTEPO	LAC	LTBTAD	/SET R-FLAG TO INDICATE THAT THIS
	JMS	TWC	/COMPONENT HAS BEEN RELOCATED, SET ENTRY
	TAD	LTBTOP	/POINT, AND ENTRY POINT PLUS ONE,
	TAD	TEMP4	/IN THE APPROPRIATE LINK TABLE ENTRY.
	TAD	(005)
	DAC	TEMP5
	ISZ*	TEMP5	/(R-FLAG)
	ISZ	TEMP5
	LAC	TEMP3	/(ENTRY)
	DAC*	TEMP5
	ISZ	TEMP5
	TAD	(001)	/(ENTRY+1)
	DAC*	TEMP5
	JMP	BUFCHK
/
DUPGBL	LAC	SYM1	/SAVE LAST DUPLICATE GLOBAL NAME
	DAC	DGSNB
	LAC	SYM2
	DAC	DGSNB+1
	JMP	BUFCHK
/
	.EJECT
/ RESOLVE THE VIRTUAL GLOBAL ENTRY IN THE SYMBOL TABLE BY FOLLOWING THE
/ CHAIN (OF TRANSFER VECTORS POINTING TO OTHER TRANSFER VECTORS) AND
/ REPLACING EACH LINK WITH THE REAL DEFINITION.
 
RESOLVE	LAC*	SYMWD1	/SAVE TRANSFER VERTOR POINTER AND MAKE
	AND	(077777)	/DEFINITION ENTRY IN SYMBOL TABLE
	DAC	TEMP1
	LAC	SYMDEF
	DAC*	SYMWD1
	AND	(077777)	/SAVE 15-BIT DEFINITION
	DAC	TEMP3
/
RVPRS1	LAC	PTBBSE	/FOLLOW CHAIN OF TRANSFER VECTORS
	DAC	PTBX2	/(IN PATCH TABLE) REPLACING POINTERS
RVPRS2	LAC*	PTBX2
	SAD	TEMP1
	JMP	.+4
	ISZ	PTBX2
	ISZ	PTBX2
	JMP	RVPRS2
	ISZ	PTBX2
	LAC*	PTBX2
	DAC	TEMP2
	LAC	TEMP3
	DAC*	PTBX2
	LAC	TEMP2
	SAD	TEMP1
	JMP	BUFCHK
	DAC	TEMP1
	JMP	RVPRS1
/ CODE 11 PROCESSOR: BLOCK DATA SUBPROGRAM DECLARATOR.
 
CODE11	JMS TWC
	DAC SIZE		/2'S COMPLEMENT OF BLOCKDATA PROGRAM SIZE.
	DAC BLKFLG	/TELL FIT THAT BLOCKDATA IS BEING LOADED.
	JMS FIT		/SEE IF BLOCK FITS IN CORE; COMPUTE LOAD
			/ADDRESS AND RELOCATION FACTOR.
	LAC RELOC		/NEW RELOCATION FACTOR STORED AS BLOCK
	DAC BLKFLG	/BASE ADDRESS IN BLOCK DATA FLAG WHICH
	JMP BUFCHK	/SETS THE FLAG NON-ZERO.
 
	.EJECT
/ CODE 12 PROCESSOR: COMMON BLOCK DEFINITION (SIZE). IF BLOCK DATA FLAG
/ IS SET, THEN THE COMMON BLOCK IS DEFINED NOW RATHER THAN AFTER ALL THE
/ LIBRARY PROGRAMS HAVE BEEN LOADED.
/
/ COMMON BLOCK MAY HAVE BEEN DEFINED BY RESIDENT CODE
/ AND REFERENCED BY A LINK.  I.E., A BLOCK MAY BE DEFINED
/ WITH BLOCK DATA FLAG OFF.
/
CODE12	DAC TEMP1		/SAVE COMMON BLOCK SIZE.
	LAC BLKFLG	/IS BLOCK DATA FLAG ON?
	SNA!CLA
	TAD (400000	/NO. ADD UNDEFINED BLOCK CODE (7).
	TAD (300000	/YES. ADD DEFINED BLOCK CODE (3).
	TAD TEMP1
	JMS SCAN		/DOES THE SYMBOL TABLE ALREADY HAVE AN
			/ENTRY FOR THIS COMMON BLOCK?
	JMP COM.IN	/YES.
 
/ NO. THIS IS THE FIRST TIME THIS COMMON BLOCK NAME HAS BEEN SEEN.
/ ENTER IT INTO THE SYMBOL TABLE.
 
	JMS DEFSYM	/ENTER INTO SYMBOL TABLE.
	LAC SYMEND	/SETUP POINTER TO COMMON CHAIN POINTER IN
	DAC COMCHN	/THE SYMTAB ENTRY.
	DZM* COMCHN	/INIT ENTRY'S POINTER TO 0 TO INDICATE
			/THERE'S NO CHAIN YET.
	JMS UPSYM		/MOVE SYMEND DOWN ONE.
	LAC SYMEND	/SETUP POINTER TO THE WORD IN THE COMMON
	DAC COMDEF	/BLOCK ENTRY WHICH HAS THE BLOCK ADDRESS.
	JMS UPSYM		/MOVE SYMEND DOWN ONE.
 
/ IF BLKFLG=0, THE BASE ADDRESS OF THIS COMMON BLOCK IS SET TO 0
/ INDICATING THAT IT IS UNDEFINED. OTHERWISE, BLKFLG CONTAINS THE
/ BASE ADDRESS OF THE COMMON BLOCK.
 
DACDEF	LAC BLKFLG	/SET COMMON BLOCK BASE ADDRESS IN THE
	DAC* COMDEF	/SYMBOL TABLE ENTRY.
	SNA		/IS BLOCK DATA MODE ON?
	JMP BUFCHK	/NO. PROCESS NEXT DATA WORD.
	DAC RELOC
	TAD TEMP1		/YES. ADD THE COMMON BLOCK SIZE
	DAC BLKFLG	/TO GET THE BASE ADDRESS OF THE NEXT
			/COMMON BLOCK.
	LAC	COMCHN	/DEFINE ALL MEMBERS OF THE COMMON CHAIN.
	DAC	SYMPTR
	LAC*	COMDEF
	DAC	LOADADR
	JMS	DEFCOM
	JMP BUFCHK
 
	.EJECT
/ AN ENTRY FOR THIS COMMON BLOCK ALREADY EXISTS IN THE SYMBOL TABLE.
 
COM.IN	DAC TEMP2		/SAVE THE BLOCK SIZE PICKED UP
			/FROM THE SYMTAB ENTRY.
	LAC SYMPTR	/SETUP POINTERS TO THE COMMON CHAIN POINTER
	TAD (-1)		/AND THE COMMON BLOCK ADDRESS.
	DAC COMCHN
	TAD (-1)
	DAC COMDEF
 
/ IF THE BLOCK HAS ALREADY BEEN DEFINED AND THE NEW SIZE IS LARGER THAN
/ THE ONE IN THE SYMBOL TABLE, THAT'S AN ERROR.
 
	LAC TEMP2		/SYMTAB BLOCK SIZE.
	CMA
	TAD TEMP1		/NEW BLOCK SIZE.
	SPA		/SKIP IF NEW SIZE > OLD SIZE.
	JMP EQLTST
 
DEFTST	LAC* COMDEF	/IS BLOCK ALREADY DEFINED?
	SZA
	JMP	LCBSZE	/YES. ERROR.
	LAC SYMDEF	/NO. REPLACE OLD SIZE WITH THE NEW ONE.
	DAC* SYMWD1
	JMP DACDEF
 
/ IF BLOCK DATA MODE IS ON, THE SIZES HAD BETTER BE THE SAME.
 
EQLTST	SAD (-1)	
	SKP!CLA		/SIZES ARE EQUAL.
	JMP LESSTH	/NOT EQUAL.
 
	SAD BLKFLG	/BLOCK DATA MODE ON?
	JMP BUFCHK	/NO. PROCESS NEXT DATA WORD.
	JMP DEFTST	/YES. EVEN THOUGH THE SIZES ARE THE
			/SAME, SINCE THIS IS BLOCK DATA MODE,
			/THE BLOCK HAD BETTER NOT BE DEFINED YET.
 
/ NEW SIZE < OLD SIZE. BLOCK DATA MODE BETTER BE OFF.
 
LESSTH	LAC BLKFLG
	SNA
	JMP BUFCHK	/OK.
	JMP	LCBSZE	/BLOCK DATA MODE ON AND THE BLOCK SIZE
			/IN THE SYMBOL TABLE IS LARGER THAN THE
			/ONE IN THIS BLOCKDATA SUBPROGRAM.
/
/ LABELED COMMON BLOCK SIZE ERROR
/
LCBSZE	JMS	TYPE	/TYPE:
	MES707		/  COMMON BLOCK SIZE ERR -- XXXXXX
	JMS	SYMMAP
	JMS	SHTMAP
	JMS	TYPMAP
	JMP	EXIT
/ CODE 13 PROCESSOR: COMMON SYMBOL DEFINITION (ADDRESS RELATIVE TO THE
/ START OF THE COMMON BLOCK). USE SAME CODE AS CODE8.
/ (RELATIVE ADDRESS TO SYM2)
 
 
/ CODE 14 PROCESSOR: COMMON SYMBOL REFERENCE DEFINITION (UNRELOCATED
/ ADDRESS OF THE TRANSFER VECTOR).
 
CODE14	TAD RELOC		/ADD THE RELOCATION FACTOR TO
	AND	(077777)	/POINT TO WHERE THE TV IS NOW
	DAC	PTBW1	/SAVE TV ADR FOR POSSIBLE PATCH TBL ENTRY
	XOR	(400000)	/SAVE TV ADR FOR POSSIBLE SYMBOL TBL ENTRY
	DAC	SYM1
	LAC* COMDEF	/0 OR THE BLOCK'S BASE ADDRESS.
	TAD SYM2		/COMMON SYMBOL'S RELATIVE POSITION.
	DAC	PTBW2	/SAVE TV FOR POSSIBLE PATCH TBL ENTRY
	DAC	SYM2	/SAVE REL POS FOR POSSIBLE SYMBOL TBL ENTRY
	LAC* COMDEF	/IS THE BLOCK DEFINED?
	SZA
	JMP	CDE14A	/YES -- MAKE PATCH TABLE ENTRY
 
/ BLOCK IS NOT DEFINED. MAKE AN ENTRY IN THE SYMBOL TABLE AND INSERT
/ THE ENTRY IN THE COMMON CHAIN.
 
	LAC* COMCHN	/POINTER TO 1ST LINK IN CHAIN.
	TAD (400000	/TACK ON CODE 4.
	DAC SYMDEF
	LAC SYMEND	/END OF SYMBOL TABLE IS WHERE THE 1ST
			/WORD OF THIS ENTRY WILL GO.
	DAC* COMCHN	/MAKE THE NEW ENTRY BECOME THE 1ST LINK.
	JMS	DEFSYM	/MAKE 3-WORD ENTRY IN THE SYMBOL TABLE.
	JMP	BUFCHK
/
CDE14A	JMS	PTBENT	/MAKE PATCH TABLE ENTRY (CODE=0) FOR
	JMP	BUFCHK	/A REFERENCE TO A DEFINED COMMON BLOCK.
 
/ CODE 15 PROCESSOR: DATA INITIALIZATION CONSTANT (1ST WORD).
 
CODE15	DAC DATA1
	JMP BUFCHK
 
 
/ CODE 16 PROCESSOR: DATA INITIALIZATION CONSTANT (2ND WORD).
 
CODE16	DAC DATA2
	JMP BUFCHK
 
	.EJECT
/ CODE 17 PROCESSOR: DATA INITIALIZATION CONSTANT (3RD WORD).
 
CODE17	DAC DATA3
	JMP BUFCHK
 
 
/ CODE 18 PROCESSOR: DATA INITIALIZATION CONSTANT DEFINITION. 
/  BITS 1-2 INDICATE DATA TYPE (NUMBER OF WORDS) AND BITS 3-17 CONTAIN
/  THE LOCATION OF THE FIRST WORD OF THE CONSTANT RELATIVE TO THE
/  LOAD ADDRESS OF OF THE ROUTINE (RELOC) OR, IF BLOCK DATA, RELATIVE
/  TO THE BASE OF THE LAST COMMON BLOCK DEFINED (* COMDEF)
CODE18	DAC TEMP1		/SAVE DATA WORD.
	LAC	BLKFLG
	SNA
	JMP	.+4
	LAC*	COMDEF
	AND	(077777)
	SKP
	LAC	RELOC
	TAD	TEMP1
	DAC	TEMP1	/DETERMINE 2S COMPLIMENT OF NUMBER
	RTL		/OF WORDS TO BE STORED FROM CODE BITS
	RTL		/IN THE ADDRESS WORD
	AND	(003)
	CMA
	SAD	(-4)
	LAW	-1
	DAC	TEMP10
	LAC	ADR3
	DAC	TEMP11
	LAC*	TEMP11
	DAC	ROPWB
	LAC	TEMP1
	JMS	ROP
	ISZ	TEMP1
	ISZ	TEMP11
	ISZ	TEMP10
	JMP	.-7
	JMP BUFCHK
 
	.EJECT
/ CODE 19 PROCESSOR: INTERNAL SYMBOL OR PROGRAM NAME
/
CODE19	AND	(400000)	/IGNORE INTERNAL SYMBOL
	SNA
	JMP	BUFCHK
	LAC	GMFLAG	/IGNORE  PROG NAME IF GLOBAL MAP FLAG
	SNA		/IS SET, OTHERWISE, SET NAME IN 
	JMS	SYMMAP	/MAP LINE
	JMP	BUFCHK
/
	.EJECT
/ CODE 20 PROCESSOR: STRING CODE (FIRST HALF) - UNRELOCATED POINTER
/ TO AN INSTRUCTION WHOSE ADDRESS PART IS TO BE REPLACED (CODE 21).
 
CODE20	TAD RELOC		/ADD RELOCATION FACTOR.
	DAC STRING	/SAVE POINTER TO THE INSTRUCTION.
	JMP BUFCHK
 
/ CODE 21 PROCESSOR: STRING CODE (SECOND HALF) - UNRELOCATED ADDRESS
/ WHICH IS TO REPLACE THE ADDRESS PART OF AN INSTRUCTION (SEE CODE 20).
 
CODE21	TAD	RELOC	/MAKE PATCH TABLE ENTRY FOR
	AND	ADRMSK	/STRING CODE MODIFICATION
	DAC	PTBW2
	LAC	STRING
	XOR	(100000)
	DAC	PTBW1
	JMS	PTBENT
	JMP BUFCHK
 
/ CODE 22 PROCESSOR -- .IODEV REQUESTS -- OR APPROPRIATE
/ BIT (OR BITS IF .IODEV ALL) INTO DATMAP
/
	JMP	.+3	/(SET ALL IF ZERO)
	LAW	-1
	JMP	CDE22A
CODE22	SNA
	JMP	CDE22D	/.IODEV ALL
	TAD	(777400)
	XOR	(777400)
	DAC	TEMP1
	.DEC
	TAD	(+18)	/ACCEPTABLE RANGE:  -19<.DAT>+54
	SPA		/IGNORE OUT OF RANGE .DAT SLOT NOS.
	JMP	BUFCHK
	TAD	(-72)
	SMA
	JMP	BUFCHK
	LAC	ADR7
	DAC	TEMP2
	LAC	TEMP1
CDE22A	SPA
	JMP	CDE22B
	TAD	(-18)
	.OCT
	ISZ	TEMP2
	JMP	CDE22A
CDE22B	DAC	TEMP3
	CLA!STL
CDE22C	RAL
	ISZ	TEMP3
	JMP	CDE22C
	DAC	TEMP3
	CMA
	AND*	TEMP2
	XOR	TEMP3
	DAC*	TEMP2
	JMP	BUFCHK
/
CDE22D	LAC	(277600)	/.IODEV ALL (1-10)
	DAC	DATMAP+1
	JMP	BUFCHK
/
/ CODE 23 PROCESSOR: END OF PROGRAM UNIT (PROGRAM START ADDRESS).
 
CODE23	DZM BLKFLG	/TURN OFF BLOCKDATA SUBPROGRAM FLAG
			/IN CASE IT WAS ON.
	TAD RELOC		/ADD RELOCATION FACTOR TO THE
	AND (77777	/PROGRAM START ADDRESS.
	DAC	TEMP1	/USE FIRST ENTRY POINT FOUND AS 
	LAC	MAINEP	/ENTRY TO MAIN PROG
	SZA
	JMP	.+3
	LAC	TEMP1
	DAC	MAINEP
	LAC	LIBFLG	/WAS A ROUTINE RELOCATED?
	SZA
	JMP	CDE23A	/NO -- DELETE ANY SYM TAB ENTRIES MADE
	JMS	TYPMAP	/YES -- TYPE MAP LINE IF MAP FLAG IS SET
	LAC	DGSNB	/WERE THERE ANY DUPL GLOBAL SYMBOL
	SZA		/NAMES DURING THIS ROUTINE?
	JMP	CDE23B	/YES -- TERMINAL ERROR
	LAC	TEMP1	/NO -- EXIT LDPROG
	JMP*	LDPROG
/
CDE23A	LAC	SYMEB2	/ROUTINE NOT LOADED, RESTORE SYMEND TO
	DAC	SYMEND	/VALUE BEFORE THIS ROUTINE WAS ENCOUNTERED
	JMP*	LDPROG
/
CDE23B	JMS	TYPE	/DUPLICATE GLOBALS FOUND -- TYPE
	MES721		/NAME OF LAST DUPLICATE FOUND AND
	LAC	DGSNB	/EXIT TO MONITOR
	DAC	SYM1
	LAC	DGSNB+1
	DAC	SYM2
	JMS	SYMMAP
	JMS	SHTMAP
	JMS	TYPMAP
	JMP	EXIT
	.EJECT
/ SUBROUTINE FIT: DETERMINE IF PROGRAM SEGMENT WILL FIT INTO AVAILABLE
/ CORE AND COMPUTE THE LOAD ADDRESS AND RELOCATION FACTOR.
 
FIT	0
	LAC	BFFLAG	/BGD OR FGD FIT?
	SZA		/BGD FIT
	JMP	FITFGD	/FGD FIT
/
/ BACKGROUND FIT REQUEST
/
	LAC	ADR10
	DAC	CLTX2
	LAC	ADR11
	DAC	FITX2
	LAC	BLKFLG	/SETUP TO EFFECTIVELY INCREASE SIZE OF
	SNA		/PROGRAM (NOT BLK DATA OR COMMON BLOCK)
	LAW	-20	/BY 20 REGISTERS TO PREVENT RELOCATING
	DAC	FITXTR	/CODE TO LOCATIONS 10-17 OF A BANK OR PAGE.
/
FIT1	LAC	FITX2	/IS THERE ANY UNUSED CORE WITHIN THIS LINK
	SAD	FITX1	/AND ABOVE LDLMT2 (HOLES) THAT HAS NOT BEEN 
			/CHECKED FOR POSSIBLE USE?
	JMP	FIT3	/NO -- RELOCATE BELOW LDLMT2
	LAC*	FITX2	/YES -- WILL ROUTINE FIT IN HOLE?
	JMS	FITX
	JMP	FIT10	/YES -- UPDATE HOLE LIMIT AND ASSIGN LOAD ADR
	ISZ	FITX2	/NO -- NEXT HOLE
	JMP	FIT1
/
FIT3	LAC	BLKFLG	/TEST FOR BLOCK DATA OR COMMON BLOCK FIT
	SZA		/REQUEST -- SKIP CORE BOUND TEST IF FOUND
	JMP	FIT5
	LAC	LDLMT2	/WILL ROUTINE FIT BELOW LDLMT2 AND WITHIN
	JMS	FITX	/THIS CORE BANK OR PAGE?
	JMP	FIT20	/YES -- UPDATE LDLMT2 AND ASSIGN LOAD ADR
	LAC	LDLMT2	/NO -- LEAVE A HOLE
	DAC*	FITX1
	ISZ	FITX1
FIT4	ISZ	CLTX2	/MOVE LDLMT2 TO THE NEXT LOWEST MEMORY BOUND
	LAC*	CLTX2
	SPA
	JMP	FIT99	/NO MORE CORE
	JMS	TWC
	TAD	LDLMT2
	SPA!SNA
	JMP	FIT4
	LAC*	CLTX2
	DAC	LDLMT2
	JMP	FIT3
/
FIT5	LAC	LDLMT2	/BLOCK DATA OR COMMON BLOCK FIT REQUEST
	DAC	FITTAD
	JMP	FIT20
/
FIT10	LAC*	FITX2	/UPDATE HOLE LIMIT
	TAD	SIZE
	DAC*	FITX2
	JMP	FIT30
/
FIT20	LAC	LDLMT2	/UPDATE LDLMT2
	TAD	SIZE
	DAC	LDLMT2
	SPA
	JMP	FIT99
/
FIT30	LAC	FITTAD	/ASSIGN LOAD ADDRESS AND RELOCATION BIAS
	TAD	SIZE
	TAD	(001)
	DAC	LOADADR
	DAC	RELOC
	LAC	LOADADR	/SET LOAD LIMITS (AND SIZE) IN MAP LINE
	DAC	SLIMFA
	LAC	FITTAD
	DAC	SLIMLA
	JMS	SLIM
/
	JMP*	FIT	/EXIT FIT ROUTINE
/
/ FITX -- SUBROUTINE TO DETERMINE WHETHER BGD ROUTINE WILL FIT IN THE
/ REMAINDER OF A PAGE OR BANK.  THE FIRST AVAILABLE REGISTER IS IN AC AT
/ ENTRY.  RETURN AT JMS+1 IF FIT.  RETURN AT JMS+2 IF NO FIT.
/
FITX	0
	DAC	FITTAD
	AND	ADRMSK
	TAD	(001)
	TAD	SIZE
	TAD	FITXTR
	SPA
	ISZ	FITX
	JMP*	FITX
FITXTR	0
/
/ FOREGROUND FIT REQUEST
/
FITFGD	LAC	SIZE	/RE-COMPLIMENT ROUTINE SIZE
	JMS	TWC
	DAC	SIZE
	LAC	CLTX1
	DAC	CLTX2
	LAC	ADR11
	DAC	FITX2
/
FFT1	LAC	FITX2	/IS THERE ANY UNUSED CORE WITHIN THIS LINK
	SAD	FITX1	/AND BELOW LDLMT2 (HOLES) THAT HAS NOT BEEN 
			/CHECKED FOR POSSIBLE USE?
	JMP	FFT3	/NO -- RELOCATE ABOVE LDLMT2
	LAC*	FITX2	/YES -- WILL ROUTINE FIT IN HOLE?
	JMS	FFTX
	JMP	FFT10	/YES -- UPDATE HOLE LIMIT AND ASSIGN LOAD ADR
	ISZ	FITX2	/NO -- NEXT HOLE
	JMP	FFT1
/
FFT3	LAC	BLKFLG	/TEST FOR BLOCK DATA OR COMMON BLOCK FIT
	SZA		/REQUEST -- SKIP CORE BOUND TEST IF FOUND
	JMP	FFT20
	LAC	LDLMT2	/WILL ROUTINE FIT ABOVE LDLMT2 AND WITHIN
	JMS	FFTX	/THIS CORE BANK OR PAGE?
	JMP	FFT20	/YES -- UPDATE LDLMT2 AND ASSIGN LOAD ADR
	LAC	LDLMT2	/NO -- LEAVE A HOLE
	DAC*	FITX1
	ISZ	FITX1
FFT4	LAC	CLTX2	/MOVE LDLMT2 TO THE NEXT HIGHEST MEMORY BOUND
	SAD	ADR10
	JMP	FIT99	/TERMINAL ERROR IF OUT OF CORE
	TAD	(-1)
	DAC	CLTX2
	LAC	LDLMT2
	JMS	TWC
	TAD*	CLTX2
	SPA!SNA
	JMP	FFT4
	LAC	BLKFLG	/AVOID AUTO INDEX REGISTERS UNLESS BLOCK DATA
	SNA		/OR COMMON BLOCK FIT REQUEST
	LAC	(020)
	TAD	(001)
	TAD*	CLTX2
	DAC	LDLMT2
	JMP	FFT3
/
FFT10	LAC*	FITX2	/UPDATE HOLE LIMIT
	DAC	FITT1
	TAD	SIZE
	DAC*	FITX2
	JMP	FFT30
/
FFT20	LAC	LDLMT2	/UPDATE LDLMT2
	DAC	FITT1
	TAD	SIZE
	DAC	LDLMT2
/
FFT30	LAC	FITT1	/ASSIGN LOAD ADDRESS AND RELOCATION BIAS
	DAC	LOADADR
	DAC	RELOC
	DAC	SLIMFA	/SET LOAD LIMITS (AND SIZE) IN MAP LINE
	TAD	SIZE
	TAD	(-1)
	DAC	SLIMLA
	JMS	SLIM
/
	LAC	SIZE	/RE-RE-COMPLIMENT ROUTINE SIZE
	JMS	TWC
	DAC	SIZE
	JMP*	FIT	/EXIT FIT ROUTINE
/
/ FFTX -- SUBROUTINE TO DETERMINE WHETHER FGD ROUTINE WILL FIT IN THE
/ REMAINDER OF A PAGE OR BANK.  THE FIRST AVAILABLE REGISTER IS IN AC AT
/ ENTRY.  RETURN AT JMS+1 IF FIT.  RETURN AT JMS+2 IF NO FIT.
/
FFTX	0
	DAC	FITT1
	AND	ADRMSK
	TAD	SIZE
	TAD	(-1)
	AND	OPCMSK
	SZA
	ISZ	FFTX
	JMP*	FFTX
/
/
FITT1	0
FITTAD	0
FITRHL	.BLOCK 11	/REMAINING-HOLES-LIST (RHL)
FITX1	0	/RHL INDEX (POINTS TO NEXT ENTRY)
FITX2	0	/RHL SCAN INDEX
/
FIT99	JMS	TYPE	/OUT OF CORE -- TYPE ERROR MESSAGE
	MES702		/AND EXIT TO MONITOR
	JMP	EXIT
/
	.EJECT
/ VIRTUAL -- SUBROUTINE TO SEARCH FOR AN UNRESOLVED GLOBAL
/            SYMBOL REFERENCE (CODES 1 OR 5) OR A DUMMY 
/	  GLOBAL SYMBOL ENTRY (CODE 6).
/
VIRTUAL	0
 
	JMS BEGSYM	/START AT BEG OF SYMTAB.
	JMS FINDCOD	/SEARCH FOR
	100000		/VIRTUAL GLOBAL ENTRY.
	JMP	.+3	/RETURN HERE IF NOT FOUND
	IDX VIRTUAL	/HERE IF FOUND.
	JMP* VIRTUAL
	JMS	BEGSYM	/START AT BEG OF SYMTAB
	JMS	FINDCOD	/SEARCH FOR
	600000		/DUMMY GLOBAL ENTRY
	JMP*	VIRTUAL	/RETURN HERE IF NOT FOUND
	IDX	VIRTUAL	/HERE IF FOUND
	JMP*	VIRTUAL
/
/ SUBROUTINE FINDCOD: STARTING AT THE CURRENT POSITION OF SYMWD1, SEARCH THRU
/ THE SYMBOL TABLE FOR AN ENTRY WHOSE CODE MATCHES THE CODE FOLLOWING THE
/ JMS FINDCOD. SKIP ON RETURN IF FOUND.
 
FINDCOD	0
 
	LAC SYMWD1	/ARE WE AT THE END OF
NEXCOD	SAD SYMEND	/THE SYMBOL TABLE?
	JMP NOFIND	/YES.
 
	LAC* SYMWD1	/GET 1ST WORD OF ENTRY IN SYMTAB.
	AND (700000)	/(700000 MASK TO CODE BITS.
	SAD* FINDCOD	/MATCH?
	JMP .+3		/YES.
 
NOMATCH	JMS NXNTRY	/MOVE POINTER TO THE NEXT ENTRY.
	JMP NEXCOD
 
FOUND	IDX FINDCOD
NOFIND	IDX FINDCOD
	JMP* FINDCOD
 
	.EJECT
/ LIBRARY SEARCH SUBROUTINE: LOAD IN ALL REQUESTED
/ LIBRARY ROUTINES.
 
LIBRARY	0
	AND (777
	DAC LIBCLOS		/SETUP LIBRARY .CLOSE.
	JMS	SEEK		/'SEEK' FILE ON DEVICE WHOSE
				/.DAT SLOT NUMBER IS IN AC
	SET NUFILE		/TELL SUBROUTINE LDPROG THAT A .SEEK
				/WAS JUST DONE.
MORLIB	SET LIBFLG		/SET LIBR MODE FLAG FOR SELECTIVE
				/LOADING.
	JMS VIRTUAL		/ARE THERE ANY UNRESOLVED GLOBALS?
	JMP LIBCLOS		/NO.
 
NEXLIB	LAC	LIBCLOS		/GET CAL TO THE CORRECT DAT SLOT.
	JMS LDPROG		/LOAD IN LIBRARY SUBPROGRAM ONLY
				/IF IT IS REQUESTED IN THE SYMBOL
				/TABLE AS A VIRTUAL GLOBAL. IF
				/LIBRARY END OF FILE IS ENCOUN-
				/TERED, CONTROL IS RETURNED TO
				/LOCATION 'LIBCLOS'. IF THE NEXT
				/PROGRAM IN THE LIBRARY WAS
				/INDEED LOADED, LIBFLG WILL BE 0
				/ON RETURN.
	LAC LIBFLG		/WAS NEXT LIBR PROGRAM READ IN?
	SZA
	JMP NEXLIB		/NO. TRY NEXT SUBPROGRAM.
	JMP MORLIB		/YES. DO ANY MORE NEED TO BE READ IN?
 
/ IF SUBROUTINE LDPROG DETECTS THE LIBRARY END-OF-FILE,
/ IT WILL RETURN CONTROL HERE.
 
LIBCLOS	.CLOSE 0			/.CLOSE THE LIBRARY FILE.
	DZM LIBFLG
	JMP* LIBRARY
 
/ SUBROUTINE DEFSYM: ENTER 3 WORDS INTO THE SYMBOL TABLE: SYMBOL
/ DEFINITION, SYMBOL 1, AND SYMBOL 2.
 
DEFSYM	0
 
	LAC SYMDEF	/1ST WORD IS THE DEFINITION.
	JMS ENTSYM
	LAC SYM1		/IF BIT0=1, THERE IS A SYM2.
	SMA
	JMP .+3		/SYMBOL NAME IS <4 CHARS.
	JMS ENTSYM	/ENTER 1ST HALF OF SYMBOL NAME.
	LAC SYM2		/2ND HALF OF SYMBOL NAME.
	JMS ENTSYM	/ENTER WORD2 OR WORD3.
	JMP* DEFSYM
 
/ SUBROUTINE ENTSYM: ENTER THE WORD IN THE AC AT THE END OF THE SYMBOL
/ TABLE AND MOVE THE POINTER TO THE END OF THE SYMBOL TABLE UP ONE.
 
ENTSYM	0
 
	DAC* SYMEND	/STORE DATA AT END OF TABLE.
	JMS UPSYM		/INDEX END POINTER.
	JMP* ENTSYM
 
/ SUBROUTINE UPSYM: INDEX POINTER TO END OF SYMBOL TABLE AND TEST
/ FOR OVERFLOW.
 
UPSYM	0
 
	LAW -1
	TAD SYMEND
	DAC SYMEND
	JMS TWC
	TAD PTBX1		/LOWEST REGISTER AVAILABLE TO SYMTAB.
	SPA!SNA		/OVERFLOW?
	JMP* UPSYM	/NO.
	LAC	(MES701)
	JMP	TERR
 
	.EJECT
/ SUBROUTINE NXNTRY: MOVE SYMBOL TABLE POINTERS OVER THE CURRENT ENTRY
/ TO THE BEGINNING OF THE NEXT ENTRY.
 
NXNTRY	0
 
	LAC SYMWD1	/POINTER TO 1ST WORD OF CURRENT ENTRY.
	DAC SYMPTR
	JMS NEXSYM	/GET 1ST HALF OF SYMBOL NAME.
	SPA		/IF BIT0=1, NAME IS 2 WORDS LONG.
	JMS DECSPT
	JMS DECSPT
 
	LAC* SYMWD1	/LOOK AT CODE BITS IN WORD 1.
	AND (300000	/LOOK FOR COMMON BLOCK CODE: 3 OR 7.
	SAD (300000	/COMMON BLOCK?
	SKP		/YES.
	JMP .+3		/NO.
	JMS DECSPT	/COMMON BLOCK ENTRY IS 2 WORDS LONGER
	JMS DECSPT	/THAN ALL OTHERS.
 
	LAC SYMPTR	/POINTING AT 1ST WORD OF NEXT ENTRY.
	DAC SYMWD1
	JMP* NXNTRY
 
/ SUBROUTINE NEXSYM: INDEX THE SYMBOL TABLE POINTER AND PICK UP THE
/ NEXT WORD.
 
NEXSYM	0
 
	JMS DECSPT
	LAC* SYMPTR
	JMP* NEXSYM
 
/ SUBROUTINE DECSPT:
 
DECSPT	0
 
	LAW -1
	TAD SYMPTR
	DAC SYMPTR
	JMP* DECSPT
 
/ SUBROUTINE BEGSYM:
 
BEGSYM	0
 
	LAC SYMBEG
	DAC SYMWD1
	DAC SYMPTR
	JMP* BEGSYM
 
	.EJECT
/ SCAN -- SUBROUTINE TO SCAN THE SYMBOL TABLE FOR THE NAME
/	IN SYM1 & SYM2 WITH THE SAME CODE BITS 1 & 2 AS THE
/	WORD IN AC.
/
/ IF FOUND -- RETURN AT JMS+1 WITH 15-BIT DEFINITION IN AC
/ IF NOT FOUND -- RETURN AT JMS+2 WITH ZERO IN AC
/
/ SEARCH FROM THE BEGINNING OF THE SYMBOL TABLE FOR:
/ A COMMON BLOCK NAME ENTRY (CODE 3 OR 7), A GLOBAL
/ SYMBOL ENTRY (CODE 1 OR 5), OR A DUMMY GLOBAL ENTRY (CODE 6)
/ WHOSE NAME MATCHES SYM1 AND SYM2. RETURN 0 IF NOT FOUND. RETURN
/ 15-BIT DEFINITION OF THE ENTRY IF FOUND.
/
/ WHEN A NAME MATCH IS FOUND, SYMPTR IS LEFT POINTING TO THE LAST WORD
/ OF THE NAME & SYMWD1 IS LEFT POINTING TO THE ID/BLOCK-SIZE WORD.
/
SCAN	0
	DAC	SYMDEF	/SAVE SYMBOL DEFINITION WITH CODE BITS
	JMS BEGSYM	/START AT BEGINNING OF SYMTAB.
NEXSCAN	SAD SYMEND	/END OF SYMBOL TABLE?
	JMP RTNZERO	/YES. NO MATCH. RETURN 0.
 
	LAC* SYMWD1	/PICKUP ENTRY'S 1ST WORD.
	XOR SYMDEF	/MATCH WITH SEARCH CODE BITS.
	AND (300000
	SZA		/SKIP IF PROPER CODE.
	JMP MORSCAN
 
	JMS NEXSYM	/GET 1ST HALF OF SYMBOL NAME.
	SAD SYM1		/MATCH?
	SKP		/YES.
	JMP MORSCAN	/NO.
 
	SMA		/IS NAME 2 WORDS LONG?
	JMP RTNDEF	/NO. ENTRY HAS BEEN FOUND.
 
	JMS NEXSYM	/GET 2ND HALF OF SYMBOL NAME.
	SAD SYM2		/MATCH?
	JMP RTNDEF	/YES. ENTRY HAS BEEN FOUND.
 
MORSCAN	JMS NXNTRY	/NO. SKIP TO BEGINNING OF NEXT ENTRY.
	JMP NEXSCAN
 
RTNZERO	CLA!SKP		/RETURN 0 IN AC WHEN NOT FOUND.
RTNDEF	LAC* SYMWD1	/RETURN 15-BIT DEFINITION OF THE ENTRY
	AND (77777	/WITHOUT THE CODE BITS.
	SNA		/0 RETURNED IN AC IF NOT FOUND.
	IDX SCAN		/NOT FOUND.
	JMP* SCAN		/FOUND.
 
/ SUBROUTINE DEFCOM: GO THROUGH THE COMMON BLOCK CHAIN AND DEFINE
/ EACH MEMBER (IF ANY) OF THE COMMON BLOCK.
 
DEFCOM	0
 
	LAC*	SYMPTR	/GET STARTING ADDRESS OF THE CHAIN.
	DZM*	SYMPTR	/SET CHAIN WORD TO 0 TO INDICATE THAT
			/THERE ARE NO UNRESOLVED CHAIN MEMBERS.
 
DEFLOOP	SNA		/ARE THERE ANY MORE CHAIN MEMBERS?
	JMP* DEFCOM	/NO.
	DAC	SYMPTR	/FOLLOW SYMBOL TABLE CHAIN, MAKING
	JMS	DECSPT	/A PATCH TABLE ENTRY (CODE=0) FOR EACH
	LAC*	SYMPTR	/TRANSFER VECTOR TO THE DEFINED COMMON BLOCK.
	AND	(077777)
	DAC	PTBW1
	JMS	DECSPT
	LAC*	SYMPTR
	TAD	LOADADR
	DAC	PTBW2
	JMS	PTBENT
	ISZ	SYMPTR
	ISZ	SYMPTR
	LAC*	SYMPTR
	AND	(077777)
	JMP	DEFLOOP
/
ERR106	LAC	(MES706)
	JMP	TERR
ERR115	LAC	(MES715)
	JMP	TERR
/
/ TELETYPE OUTPUT MESSAGES.  THE TWO WORDS PRECEDING EACH
/ MESSAGE ARE USED AS AN IOPS ASCII HEADER.  THE ONLY HEADER
/ REQUIREMENT FOR TTY OUTPUT IS A GREATER THAN ONE WORD-
/ PAIR COUNT.
/
MES602	.ASCII	/LINK TABLE/<015>
MES603	.ASCII	/RESIDENT CODE/<015>
MES604	.ASCII	/LINK -- /<175>
MES605	.ASCII	/BLANK COMMON/<015>
MES610	.ASCII	/PAUSE/<175>
MES620	.ASCII	/LOAD: /<175>
MES621	.ASCII	/ & ^P /<175>
MES690	.ASCII	/CORE REQ'D/<015>
MES701	.ASCII	/TABLE OVERLAP/<15>
MES702	.ASCII	/CORE OVERFLOW/<15>
MES703	.ASCII	/EOM, ^P TO RESTART /<175>
MES705	.ASCII	/READ ERROR/<15>
MES706	.ASCII	/ILLEGAL LOADER CODE/<15>
MES707	.ASCII	/LABELED COMMON BLK SIZE ERR -- /<175>
MES710	.ASCII	/UNRESOLVED GLOBAL(S):/<15>
MES715	.ASCII	/ABS PROG/<15>
MES720	.ASCII	/MISSING GLOBAL DEF -- /<175>
MES721	.ASCII	/DUPLICATE GLOBAL DEF -- /<175>
/
SIZE	0		/2'S COMPLEMENT OF PROGRAM SIZE.
WRDCNT	0		/IOPS BINARY BLOCK WORD COUNT.
CDWCNT	0		/CODE WORD BLOCK COUNTER.
CODEWD	0		/CODE WORD CONTAINS 3 LOADER CODES.
SYMDEF	0		/TEMP REGISTER FOR THE 1ST WORD OF A SYMTAB
			/ENTRY: CODE + DEFINITION.
SYM1	0		/1ST 3 CHARS OF A SYMBOL.
SYM2	0		/2ND 3 CHARS OF A SYMBOL.
DATA1	0		/TEMP STORAGE FOR A DATA INITIALIZATION CONSTANT.
DATA2	0		/(DATA1, DATA2, & DATA3 MUST BE CONTIGUOUS
DATA3	0		/AND IN THIS ORDER)
DGSNB	.BLOCK 2		/DUPL GLOBAL SYMBOL NAME BUFFER
COMCHN	0
COMDEF	0
STRING	0
		/.DAT MAP
DATMAP	0	/-18  -1
	0	/  0  +17
	0	/+18  +35
	0	/+36  +53
/
DATP=.			/.DAT ZERO POINTER
	.IFDEF	BFM
	117
	.ENDC
	.IFUND	BFM
	.IFDEF	PDP9
	135
	.ENDC
	.IFUND	PDP9
	136
	.ENDC
	.ENDC
	.EJECT
/ SYMMAP -- SUBROUTINE TO CONVERT THE SYMBOL NAME IN SYM1 & SYM2
/           FROM RADIX 50 TO 7-BIT IMAGE ALPHA AND STORE THE
/           RESLUTING SIX WORDS IN MAPNAM THRU MAPNAM+5
/
SYMMAP	0
	LAC	ADR4
	DAC	MAPX1
	LAC	SYM1
	AND	(377777)
	JMS	CONVERT
	LAC	SYM1
	SMA
	DZM	SYM2
	LAC	SYM2
	AND	(377777)
	JMS	CONVERT
	JMP*	SYMMAP
/
CONVERT	0
	JMS	DIVIDE
	-3100
	JMS	DIVIDE
	-50
	JMS	DIVIDE
	-1
	JMP*	CONVERT
/
DIVIDE	0
	DZM	DIVQUO
DIVLP	DAC	DIVREM
	TAD*	DIVIDE
	SPA
	JMP	.+3
	ISZ	DIVQUO
	JMP	DIVLP
/
	LAC	DIVQUO
	SNA
	LAW -40
	SAD (33
	LAW -33
	SAD (34
	LAC (33
	SAD (47
	LAW -35
	TAD (-33
	SPA
	TAD (55
	TAD (56
	DAC*	MAPX1
	ISZ	MAPX1
	LAC	DIVREM
	ISZ	DIVIDE
	JMP*	DIVIDE
/
DIVQUO	0
DIVREM	0
/
/ ADROUT -- SUBROUTINE TO CONVERT THE OCTAL ADDRESS (5-DIGITS)
/           IN AC TO IMAGE ALPHA AND STORE THE FIVE RESULTING
/           WORDS STARTING AT THE ADDRESS IN 'MAPX1'
/	  MAPX1 IS LEFT POINTING TO THE LAST CHARACTER
/	  ADDRESS PLUS TWO.
/
ADROUT	0
	RTL
	RTL
	DAC	CTRBF
	LAW	-5
	DAC	CTRC1
ADROT1	LAC	CTRBF
	RAL
	RTL
	DAC	CTRBF
	AND	(007)
	XOR	(060)
	DAC*	MAPX1
	ISZ	MAPX1
	ISZ	CTRC1
	JMP	ADROT1
	ISZ	MAPX1
	JMP*	ADROUT
	.EJECT
/ CTR50 -- SUBROUTINE TO CONVERT THE THREE SIXBIT CHARACTERS IN
/          AC TO RADIX 50 AND LEAVE THE RESULT IN AC
/
CTR50	0
	DAC	CTRBF
	LAW	-3
	DAC	CTRC1
	DZM	CTRAC
CTRLOP	LAC	CTRBF
	RTL
	RTL
	RTL
	RAL
	DAC	CTRCB
	RAR
	DAC	CTRBF
	LAC	CTRCB	/PROCESS .SIXBT CHARACTER (BLANK=00)
	AND	(077)
	TAD	(-33)
	SPA
	JMP	CTRAZB	/ A-Z  BLANK
	SAD	(23)
	LAC	(24)	/ .
	SAD	(12)
	LAC	(23)	/ %
	SAD	(10)
	LAC	(37)	/ #
	TAD	(-23)	/ 0-9  .  %  #
CTRAZB	TAD	(+33)	/ A-Z  BLANK  0-9  .  %  #
	TAD	CTRAC
	ISZ	CTRC1
	SKP
	JMP*	CTR50
	DAC	CTRAC
	LAW	-50
	DAC	CTRC2
	CLA
	TAD	CTRAC
	ISZ	CTRC2
	JMP	.-2
	DAC	CTRAC
	JMP	CTRLOP
/
CTRBF	0
CTRCB	0
CTRAC	0
CTRC1	0
CTRC2	0
	.EJECT
/ SEEK -- SUBROUTINE TO PREPARE A FILE TO BE READ.
/         IF FROM A FILE-ORIENTED DEVICE, SEEK FILE.
/         IOPS13 IF FILE NOT FOUND.
/         IF FROM A NON FILE ORIENTED DEVICE, THE REQ'D 
/         FILE NAME IS TYPED OUT, AND CHAIN WAITS FOR
/         A ^P BEFORE READING THE FILE.
/
SEEK	0		/ENTER WITH .DAT SLOT NO IN AC 
	AND	(0777)	/SET .DAT SLOT NOS IN CALLS
	DAC	SKIT
	DAC	SKSK
/
SKIT	.INIT	0,0,0	/INITIALIZE DEVICE HANDLER
	LAC	SKIT+3	/FILE ORIENTED DEVICE (BUF SIZE > 63)?
	AND	(700)
	SNA		/YES -- SEEK FILE 
	JMP	SKCP	/NO -- TYPE NAME & WAIT FOR ^P
SKSK	.SEEK	0,0	/SEEK FILE & EXIT
	JMP*	SEEK
SDPTR=SKSK+2	/EXTERNALLY MODIFIED SEEK DATA POINTED IS
		/WITHIN .SEEK MACRO.
/
SKCP	LAC	SDPTR	/TYPE:
	DAC	TEMP11	/   LOAD XXXXX & ^P
	LAC*	TEMP11
	DAC	T6BW1
	ISZ	TEMP11
	LAC*	TEMP11
	DAC	T6BW2
	JMS	TYPE
	MES620
	JMS	T6BN
	JMS	TYPE
	MES621
	JMS	WFCP	/WAIT FOR ^P
	JMP*	SEEK
/
/ SEEK DATA TABLE
SKDATA	.SIXBT /------BIN/	/NO INSERTION BETWEEN SEEK DATA TRIPLITS!!
	.SIXBT /.LIBR5BIN/
	.IFDEF	BFM
	.SIXBT /.F4LIBBIN/
	.ENDC
	.IFUND	BFM
	.SIXBT /.LIBR@BIN/
	.ENDC
	.EJECT
INBUF	.BLOCK 62
/
OUTBUF	021000
	.BLOCK 41
OUTEND	.
OUTBEG	OUTBUF+2
/
PSNB	004000	/PAUSE NUMBER BUFFER
	.BLOCK 6
	040
/
MAPBUF	013000	/MAP LINE HEADER -- WORD-PAIR COUNT IS SET 
	0	/TO 016 IF SIZE IS TO BE OUTPUT
MAPNAM	.BLOCK 6	/NAME
	040
MAPFAD	.BLOCK 5	/FIRST WORD ADDRESS
	055
	.BLOCK 5	/LAST WORD ADDRESS
	015
	012	/SIZE IF SZFLAG IS SET
	.BLOCK 4
	015
	012
MAPX1	0	/MAP LINE INDEX
/
/ SLIM -- SUBROUTINE TO SET THE CORE LIMITS IN 'SLIMFA' & 'SLIMLA'
/	INTO THE LOAD MAP LINE BUFFER.  IF SZFLAG IS SET, THE
/	SIZE (SLIMLA-SLIMFA+1) IS ALSO SET IN THE MAP LINE.
/
SLIMFA	0	/FIRST WORD ADDRESS
SLIMLA	0	/LAST WORD ADDRESS
/
SLIM	0
	LAC	ADR6
	DAC	MAPX1
	LAC	SLIMFA
	JMS	ADROUT
	LAC	SLIMLA
	JMS	ADROUT
	LAC	SZFLAG
	SNA
	JMP*	SLIM
	LAC	SLIMFA
	JMS	TWC
	TAD	(001)
	TAD	SLIMLA
	JMS	ADROUT
	JMP*	SLIM
	.EJECT
/ SHTMAP -- SUBROUTINE TO SET MAP FLAG AND
/           TO SHORTEN MAP LINE TO NAME ONLY
/
SHTMAP	0
	LAC	(005000)
	DAC	MAPBUF
	DAC	LMFLAG
	LAC	ADR6
	TAD	(-1)
	DAC	MAPX1
	LAC	(015)
	DAC*	MAPX1
	ISZ	MAPX1
	LAC	(012)
	DAC*	MAPX1
	JMP*	SHTMAP
/
/ TYPMAP -- SUBROUTINE TO TYPE A MAP LINE
/           IF MAP FLAG IS SET
/
TYPMAP	0
	LAC	LMFLAG
	SNA
	JMP*	TYPMAP
TMAPZ	.WRITE	TO,3,MAPBUF,0
	.WAIT	TO
	JMP*	TYPMAP
	.EJECT
/ POINTERS:
 
SYMBEG	0		/TO BEG OF SYMBOL TABLE.
SYMEND	0		/TO LAST SYMTAB REGISTER - 1.
SYMEB1	0		/SYMEND BUFFER (TO RESTORE SYMEND 
			/FOR A NEW LINK)
SYMEB2	0		/SYMEND BUFFER (TO RESTORE SYMEND
			/FOR NON-RELOCATED LIBRARY ROUTINE)
SYMWD1	0		/TO 1ST WORD OF A SYMTAB ENTRY.
SYMPTR	0		/TO SOMEWHERE WITHIN A SYMTAB ENTRY.
LOADADR	0		/PROGRAM'S LOAD ADDRESS.
LAST	0		/PROGRAM'S LAST REGISTER.
RELOC	0		/RELOCATION FACTOR.
BUFPTR	0		/TO LINE BUFFER #1 OR #2.
 
/ FLAGS:
 
NUFILE	0		/SET NON-0 AFTER A .SEEK.
LIBFLG	0		/SET NON-0 WHEN IN LIBRARY SEARCH MODE.
BLKFLG	0		/SET NON-0 (WITH THE LOAD ADDRESS) WHEN
			/A BLOCKDATA SUBPROGRAM IS BEING LOADED.
	.EJECT
/ STORE -- SUBROUTINE TO EFFECT:  DAC*  LOADADR
/
STORE	0
	DAC	ROPWB
	LAC	LOADADR
	JMS	ROP
	JMP*	STORE
/
/ ROP --  SUBROUTINE TO OUTPUT THE RELOCATED WORD IN ROPWB
/	TO BE LOADED AT THE ADDRESS IN AC.
/
/	RECORD FORMAT:
/	    IOPS BINARY HEADER
/	    SUB-RECORD HEADER	(SUB-RECORDS ARE
/	    RELOCATED WORD(S)	BLOCKS OF CONTIGUOUS
/	    SUB-RECORD HEADER	CORE LOADINGS)
/	    RELOCATED WORD(S)
/	      .         .
/	      .         .
/	    END-OF-RECORD IND.
/	SUB-RECORD HEADER FORMAT:
/	    TYPE CODE (BITS 0-8) & WORD COUNT (BITS 9-17)   CODE=0
/	    LOAD ADDRESS OF FIRST WORD
/
ROP	0			/ENTER WITH ADDRESS IN AC
	DAC	ROPLA
	LAC	ROPFEF		/FIRST ENTRY TEST
	SZA
	JMP	ROP10
	ISZ	ROPFEF
	DZM	ROPBWC
	JMP	ROP35
ROP10	LAC	ROPLA		/BREAK IN ADDRESS SEQUENCE?
	SAD	ROPLLA
	JMP	ROP20		/NO -- SET WORD IN BUFFER
	LAC	OUTEND		/YES -- SET NEW SUB-HDR & WORD IN BUF
	CMA			/IS THERE ROOM IN BUFFER FOR FOUR
	TAD	(004)		/MORE WORDS (HDR,WORD, & END-OF REC)?
	TAD	ROPX1
	SMA
	JMP	ROP30		/NO -- END RECORD & SET WDS IN NEXT BUF
	JMP	ROP40		/YES -- SET THREE WORDS IN BUFFER
/
ROP20	LAC	OUTEND		/IS THERE ROOM IN BUFFER FOR TWO
	CMA			/MORE WORDS (WORD & END-OF-REC)?
	TAD	(002)
	TAD	ROPX1
	SMA
	JMP	ROP30		/NO -- END RECORD & SET WORD IN NEXT BUF
	JMP	ROP50		/YES -- SET WORD IN BUFFER
/
ROP30	LAW	-1		/SET END-OF-RECORD INDICATOR (-1) IN
	JMS	ROPSW		/BUFFER AND OUTPUT
	JMS	ROPWOB		/WRITE OUTPUT BUFFER
/
ROP35	LAC	OUTBEG		/SETUP FOR NEW RECORD
	DAC	ROPX1
/
ROP40	LAC	ROPX1		/SET NEW SUB-RECORD HEADER IN BUFFER,
	DAC	ROPX2		/SAVE HEADER INDEX, & SET LAST-
	LAC	(200000)		/LOAD-ADR-PLUS-ONE
	JMS	ROPSW
	LAC	ROPLA
	DAC	ROPLLA
	JMS	ROPSW
/
ROP50	LAC	ROPWB		/SET RELOCATED WORD IN BUFFER, UPDATE
	JMS	ROPSW		/LAST-LOAD-ADR-PLUS-ONE, & AGUMENT SUB-
	ISZ	ROPLLA		/RECORD WORD COUNT
	ISZ*	ROPX2
/
	JMP*	ROP		/EXIT
/
ROPSW	0			/SET WORD SUBROUTINE
	DAC*	ROPX1
	ISZ	ROPX1
	ISZ	ROPBWC
	JMP*	ROPSW
/
ROPWOB	0
	LAC	ROPBWC
	TAD	(003)
	JMS	LCS6
	RTL
	AND	(777000)
	DAC	OUTBUF
	JMS	WOB
	DZM	ROPBWC
	JMP*	ROPWOB
/
ROPLA	0			/LOAD ADDRESS
ROPLLA	-1			/LAST LOAD ADDRESS PLUS ONE
ROPFEF	0			/FIRST ENTRY FLAG
ROPX1	0			/BUF INX AT WHICH WORD IS TO BE STORED
ROPX2	0			/INDEX OF LAST SUB-RECORD HEADER
ROPBWC	0			/BUFFER WORD COUNT
ROPWB	0			/WORD BUFFERS
/
/ FROP -- FINISH PARTIAL RECORD STARTED BY ROP
/
FROP	0
	LAC	ROPX1
	SAD	OUTBEG
	JMP*	FROP
	LAW	-1
	JMS	ROPSW
	JMS	ROPWOB
	DZM	ROPFEF
	JMP*	FROP
/
/ WNPPR -- SUBROUTINE TO WRITE A NO PATCH PATCH-RECORD
/
WNPPR	0
	LAC	(002000)
	DAC	OUTBUF
	LAC	(300000)
	DAC	OUTBUF+2
	DZM	OUTBUF+3
	JMS	WOB
	JMP*	WNPPR
/
/ WOB -- SUBROUTINE TO WRITE OUTPUT BUFFER
/
WOB	0
WOB1	.WRITE RO,0,OUTBUF,0
	.WAIT  RO
	JMP*	WOB
/
/ PTBENT -- SUBROUTINE TO ENTER PTBW1 & PTBW2 IN THE PATCH TABLE
/
PTBW1	0	/BITS 0-2 CODE
		/BITS 3-17 ADDRESS
		/	CODE=0 -- STORE THE WORD IN PTBW2
		/		AT ADDRESS
		/	CODE=1 -- SET BITS 5=17 OF THE WORD IN
		/		IN PTBW2 IN BITS 5-17 AT ADDRESS
		/	CODE=2 -- ADD THE BASE OF BLANK COMMON
		/		TO THE WORD IN PTBW2 AND STORE
		/		AT ADDRESS
PTBW2	0	/WORD TO BE STORED PER CODE
		/ IF AN ENTRY FOR AN ADDRESS ALREADY EXISTS, IT
		/WILL BE WRITTEN OVER.
/
PTBENT	0
	LAC	PTBBSE	/SCAN PATCH TABLE FOR AN ENTRY FOR THE
PTBEN1	DAC	PTBX2	/ADDRESS IN PTBW1 BITS 3-17
	SAD	PTBX1
	JMP	PTBEN3	/ADR NOT FOUND (END OF TABLE)
	LAC*	PTBX2
	XOR	PTBW1
	AND	(077777)
	SNA
	JMP	PTBEN2	/ADDRESS FOUND
	LAC	PTBX2
	TAD	(002)
	JMP	PTBEN1
/
PTBEN2	LAC	PTBW1	/ENTER PTBW1 & PTBW2 OVER PREVIOUS ENTRY
	DAC*	PTBX2	/FOR SAME ADDRESS
	ISZ	PTBX2
	LAC	PTBW2
	DAC*	PTBX2
	JMP*	PTBENT	/EXIT
/
PTBEN3	LAC	PTBW1	/ADD PTBW1 & PTBW2 TO PATCH TABLE
	DAC*	PTBX1
	ISZ	PTBX1
	LAC	PTBW2
	DAC*	PTBX1
	ISZ	PTBX1
	LAC	SYMEND	/DO SYMBOL AND PATCH TABLES OVERLAP?
	CMA
	TAD	PTBX1
	SPA!SNA
	JMP*	PTBENT	/NO -- EXIT
	LAC	(MES701)	/YES -- TERMINAL ERROR
/
/ TERMINAL ERROR WHILE RELOCATING A ROUTINE -- TYPE OUT 
/  THE MESSAGE WHOSE ADDRESS IS IN AC.  FOLLOWED BY
/ A MAP LINE (IF MAP FLAG IS SET).
/ AND EXIT TO MONITOR
/
TERR	JMS	SETBBS
	TAD	(-2)
	DAC	.+3
	.WRITE	TO,2,XX,0
	.WAIT	TO
	JMS	TYPMAP
	JMP	EXIT
/
	.IFDEF	PTP
	.IFUND	PDP9
	.END	PAGE+1/2*2-1*10000+7720
	.ENDC
	.IFDEF	PDP9
	.END	BANK*20000+17720
	.ENDC
	.ENDC
	.IFUND	PTP
	.END
	.ENDC
