	.TITLE BFLOAD
 
/ .... EDIT #19 .... 19 DEC 69
 
/ COPYRIGHT 1968, 1969, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
 
/ VERSION V1A - JEAN-CLAUDE P. PROTEAU
/ PDP-9 BACKGROUND/FOREGROUND SYSTEM PROGRAM.
/ BACKGROUND LINKING LOADER: LOADS IN DDT AND/OR USER PROGRAMS.
 
 
/ CALLED BY MONITOR COMMANDS: $LOAD, $GLOAD, $DDT, AND $DDTNS.
 
 
/ SEQUENTIAL OPERATION:
 
/  1. INITIALIZE
/  2. LOAD IN DDT (IF REQUESTED)
/  3. READ USER'S COMMAND STRING
/  4. LOAD USER'S PROGRAMS
/  5. RESOLVE NON-I/O VIRTUAL GLOBALS
/  6. INITIALIZE BANK INFORMATION FOR LOADING I/O HANDLERS
/  7. RESOLVE I/O VIRTUAL GLOBALS
/  8. DEFINE COMMON BLOCKS
/  9. MATCH VIRTUAL GLOBALS TO COMMON
/ 10. TEST FOR UNRESOLVED GLOBALS
/ 11. SETUP .EXIT LIST WITH I/O HANDLER MOVES
/ 12. CONDENSE THE SYMBOL TABLE
/ 13. ASSIGN BUFFERS FOR I/O HANDLERS
/ 14. COMPUTE THE MEMORY PROTECT BOUND
/ 15. FINISH ASSEMBLING THE .EXIT LIST
/ 16. TEST FOR MEMORY OVERLAP
/ 17. CLEAN UP AND EXIT TO THE MONITOR
 
 
/ FUNCTION OF BACKGROUND .DATB SLOTS USED:
 
/ -7	INPUT FROM SYSTEM DEVICE: FORTRAN AND I/O LIBRARIES.
/ -5	USER'S LIBRARY FILE INPUT (IF ANY)
/ -4	USER'S PROGRAMS INPUT (IF ANY)
/ -3	OUTPUT TO THE TELETYPE
/ -2	INPUT FROM THE TELETYPE OR BATCH PROCESSING DEVICE
/ -1	INPUT OF DDT
 
 
/ LABELLING CONVENTIONS:
 
/ PERMANENT LITERALS ARE LABELLED: PLIT## .
/ THOSE WHICH SUGGEST OBVIOUS NAMES ARE SO LABELLED.
/ TEMPORARY LITERALS (THOSE WHICH GET CLOBBERED
/ DURING THE COURSE OF THE PROGRAM) ARE LABELLED: TLIT##.
 
	.EJECT
/ PROGRAM FLAGS:
 
/ NOT ALL PROGRAM FLAGS ARE LISTED BELOW.
 
/ DDTFLG: IS NEGATIVE (BIT0=1) WHILE DDT IS THE PROGRAM BEING LOADED
/ AND POSITIVE OTHERWISE. BIT 2 INFLUENCES THE STORING OF SYMBOLS IN
/ THE SYMBOL TABLE.
 
/ ABSFLG: SET NON-0 TO ALLOW LOADING OF USER ABSOLUTE PROGRAMS BEFORE
/ ANY RELOCATABLE PROGRAMS (EXCLUDING DDT). CLEARED WHENEVER A USER
/ RELOCATABLE PROGRAM OR LIBRARY FILE IS ENCOUNTERED. LOW LIMIT OF
/ ABSOLUTE PROGRAMS IS STORED IN THE FLAG.
 
/ NUFILE: IS SET NON-0 WHENEVER ENTRY TO SUBROUTINE LDPROG WAS PRECEDED
/ BY A .SEEK . IT HAS NO EFFECT WHEN DDT IS BEING LOADED SINCE DDTFLG
/ TAKES PRECEDENCE. IF NUFILE=0, WE ARE SOMEWHERE WITHIN A LIBRARY FILE
/ AND A .READ HAS ALREADY BEEN ISSUED.
 
/ LIBFLG: IS SET NON-0 WHEN IN LIBRARY SEARCH MODE. EACH LIBRARY FILE
/ CONSISTS OF PROGRAM UNITS (PROGRAM SIZE, INTERNAL GLOBALS, LOAD
/ ADDRESS, DATA WORDS, VIRTUAL GLOBALS, END CODE) AND IS TERMINATED BY
/ AN END-OF-FILE CODE. IF LIBFLG IS SET, A LIBRARY PROGRAM IS NOT LOADED
/ UNLESS ONE OF ITS INTERNAL GLOBALS MATCHES A VIRTUAL GLOBAL REQUEST IN
/ THE SYMBOL TABLE. IF MATCH FOUND, THEN LIBFLG IS CLEARED BOTH TO LOAD
/ IN THE REST OF THE PROGRAM AND TO SIGNAL THE LIBRARY SEARCHING ROUTINE
/ THAT A GLOBAL WAS RESOLVED.
 
/ BLKFLG: IS BOTH A FLAG AND A RELOCATION FACTOR. IT IS 0 WHEN NOT LOADING
/ A BLOCKDATA SUBPROGRAM. WHEN A BLOCKDATA SUBPROGRAM IS ENCOUNTERED, THE
/ LOAD ADDRESS OF THE SUBPROGRAM IS STORED IN BLKFLG, WHICH ALSO SETS THE
/ FLAG. BLKFLG IS TURNED OFF WHEN THE END-OF-PROGRAM CODE IS ENCOUNTERED.
 
/ IOFLAG: IS SET NON-0 WHEN SEARCHING IN .IOLIB FILE FOR I/O HANDLERS.
/ IF SO, THE RUN-TIME AND LOAD-TIME RELOCATION FACTORS MAY DIFFER.
/ I/O HANDLERS MUST LOAD AT AN ADDRESS EVENLY DIVISIBLE BY 4.
 
/ COMFLG: IS SET NON-0 WHEN DEFINING COMMON BLOCKS WHICH ARE NOT PART
/ OF BLOCKDATA SUBPROGRAMS.
 
/ BUFFLG: IS SET NON-0 WHEN ASSIGNING CORE SPACE FOR I/O HANDLER BUFFERS.
 
 
 
/ SYMBOL DEFINITIONS:
 
IDX=ISZ		/USED WHEN THE SKIP IS NOT INTENDED.
SET=ISZ		/USED WHEN THE INTENTION IS TO SET A
		/PROGRAM FLAG TO NON-ZERO.
.SCOM=100		/BEGINNING OF THE SYSTEM COMMUNICATION
		/TABLE WITHIN THE RESIDENT MONITOR.
 
	.EJECT
FIRST=.			/LOADER'S LOWEST REGISTER.
 
/ INPUT LINE BUFFER#1: 62 OCTAL (50 DECIMAL) REGISTERS. SIZE BASED ON
/ IOPS BINARY BLOCK SIZE. NORMALLY, INPUT OF
/ PROGRAMS IS DOUBLE-BUFFERED. HOWEVER, SINCE THE BUFFERS OVERLAY THE
/ BEGINNING OF THE LOADER, THE LOADING OF DDT IS SINGLE-BUFFERED.
/ BUFFER#1 MAY NOT EXTEND BEYOND THE JMS LDPROG.
 
LINBF1=.
 
/ THE NEXT 3 REGISTERS ARE THE DIRECTORY USED TO .SEEK DDT.
 
DDTDIR	040424		/DDT
	710000		/9
	021116		/BIN
 
/ THE LINKING LOADER STARTS HERE: SETUP POINTERS TO THE PROGRAM
/ DIRECTORIES TABLE, THE BEGINNING OF THE SYMBOL TABLE, AND THE
/ END OF THE SYMBOL TABLE. ZERO OUT FREE CORE. SETUP THE HIGHEST
/ FREE ADDRESS IN EACH OF THE 4 POSSIBLE MEMORY BANKS.
 
BFLOAD	LAC* DATB		/LAC* (.SCOM+17 CONTAINING CAL .DATB .
	DAC DATB		/SAVE ADDRESS OF BACKGROUND DAT TABLE.
	LAC* (.SCOM+2	/CONTAINS 1ST FREE ADDRESS ABOVE THE LOADER.
	DAC DIRPTR	/POINTER TO PROGRAM DIRECTORIES TABLE,
			/WHICH PRECEDES THE SYMBOL TABLE.
	DAC SYMBEG	/POINTER TO BEG OF SYMBOL TABLE.
	DAC SYMEND	/POINTER TO THE 1ST REGISTER AFTER THE
			/LAST ENTRY IN THE SYMBOL TABLE.
	TAD MINUS1	/(-1
	DAC IOCPTR	/POINTER TO LAST (HIGHEST) REGISTER IN
			/THE IO CONVERSION TABLE. THE TABLE IS
			/PLACED AFTER THE LOADER BY THE SYSTEM LOADER.
	DAC TEMP1		/POINTER FOR ZEROING FREE CORE.
	LAC* (.SCOM+25	/GET 1ST REGISTER ABOVE FOREGROUND JOB.
	DAC LOFREE
	LAC* (.SCOM+3	/CONTAINS HIGHEST FREE CORE ADDRESS.
	DAC HISYM		/POINTER TO HIGHEST REGISTER AVAILABLE
			/FOR USE BY THE SYMBOL TABLE.
	DAC HIFREE	/POINTER TO THE HIGHEST FREE REGISTER
			/BELOW THE USER'S PROGRAMS.
 
	IDX TEMP1		/LOOP TO ZERO FREE CORE.
	DZM* TEMP1
	SAD TEMP1
	SKP!RTL		/WHEN DONE, GET THE BANK BITS INTO
	JMP .-4
	RTL		/THE LOW ORDER AC BITS.
	RTL
	AND (3
 
	.EJECT
	TAD PBANK0	/(BANK0 COMPUTE BANK POINTER FOR
	DAC TEMP1		/HIGHEST AVAILABLE BANK.
	LAC HIFREE	/HIGHEST FREE ADDRESS GOES TO
	JMS STORE		/THE HIGHEST AVAILABLE BANK POINTER.
	LAC TEMP1
	SAD BANKS		/(BANK0+4 SKIP IF THERE ARE HIGHER BANKS.
	JMP .+3
	CLA		/ZERO GOES TO ALL HIGHER BANK POINTERS.
	JMP .-5
	LAC* TLIT1	/PTR TO BGD CTL CHAR TABLE.
	TAD (1
	DAC BCTL.P	/PTR TO BGD ^P REGISTER.
	TAD PLIT18	/(2
	DAC BCTL.T	/PTR TO BGD ^T REGISTER.
 
/ IS DDT SUPPOSED TO BE LOADED?
 
	LAC* (.SCOM+6	/CONTAINS TYPE-OF-LOAD CODE BITS 0,1,2.
	AND PLIT6		/(700000
	DAC SCOM6		/SAVE ONLY THE CODE BITS.
	SMA		/SKIP IF DDT IS GOING TO BE LOADED.
	JMP NO.DDT
	DAC DDTFLG	/SAVE CODE BITS IN FLAG. FLAG IS NEGATIVE
			/WHEN THE PROGRAM BEING LOADED IS DDT.
	LAC TLIT2		/SET.T SET FOR ^T RETURN ADDR
	DAC SET.T		/FOR DDT LOAD. 0 OTHERWISE.
 
	CAL 777		/.INIT -1 FOR INPUT.
	1
TLIT1	.SCOM+70		/POINTER TO BGD CTL CHAR TABLE.
TLIT2	CNTL.T+300000	/LITERAL: ADDR TO GO TO ON ^T+XM+MP.
 
/ END OF INPUT LINE BUFFER #1 = .-2
 
	CAL 777		/.SEEK DDT9 BIN ON -1.
	3
	DDTDIR
 
	LAC PLIT1		/(CAL 777
	JMS LDPROG	/LOAD IN DDT. START ADDRESS RETURNED
	DAC* (.SCOM+5	/IN AC AND SAVED.
 
PLIT1	CAL 777		/.CLOSE -1.
	6
 
	.EJECT
/ OVERLAY: THE FOLLOWING LOCATIONS ARE RECLAIMED LATER ON FOR STORING
/ FLAGS, POINTERS, DATA, AND COUNTS. THE ROUTINES WHICH USE THEM ARE
/ LISTED IN ().
 
/ FLAGS:
 
MAINFLG=.		/(NEXPRG) FLAG NON-0 MEANS MAIN PROGRAM.
SYMFLG=.+1	/(RESTART) FLAG NON-0 MEANS SYMBOL NAME IS FULL,
		/I.E. HAS 6 CHARACTERS.
OPFLAG=.+2	/(RESTART) 0=PROCESSING OPTION CHARACTERS;
		/NON-0=PROCESSING FILE NAMES.
 
/ DATA WORDS:
 
DLMITR=.+3	/(RESTART) DELIMITER CHAR. OF LAST COMMAND NAME.
RQUEST=.+4	/(IODEV.) CONTENTS OF REQUESTED DAT SLOT.
IOINWD=.+5	/(IODEV.) CONTENTS OF A .IOIN TABLE ENTRY.
 
/ COUNTS:
 
IOINCT=.+7	/(IODEV.) 2'S COMPL. OF # OF .IOIN ENTRIES.
MUDCNT=.+10	/(IODEV.)(BFTAB.) 2'S COMPL. OF # OF .MUD ENTRIES.
BUFSIZ=.+11	/(BFTAB.) SIZE OF I/O HANDLER BUFFER.
 
/ POINTERS:
 
SLOT=.+12		/(IODEV.) ADDRESS OF REQUESTED DAT SLOT.
HANDLR=.+13	/(IODEV.) ADDRESS OF HANDLER, IF IT'S IN CORE.
COMCHN=.+14	/(DEFCOM)(COMMON)(CODES 12,14) POINTER TO 4TH WORD
		/IN A COMMON BLOCK SYMTAB ENTRY, WHICH IN TURN POINTS
		/TO THE HEAD OF THE COMMON SYMBOL CHAIN.
COM.TV=.+16	/(DEFCOM) POINTER TO A TRANSFER VECTOR ASSOCIATED
		/WITH A COMMON CHAIN LINK.
COMDEF=.+17	/(DEFCOM)(COMMON)(CODES 12,14) POINTER TO 5TH WORD
		/IN A COMMON BLOCK SYMTAB ENTRY, WHICH CONTAINS THE
		/BLOCK'S ADDRESS (IF DEFINED).
STRING=.+20	/(CODES 20,21) POINTER TO AN INSTRUCTION WHOSE
		/ADDRESS PART IS TO BE REPLACED.
TBANK0=.+22	/(GETIO)(ALL.IN) TEMPORARY STORAGE FOR FREE
TBANK1=.+23	/REGISTER POINTERS TO EACH BANK.
TBANK2=.+24
TBANK3=.+25
 
	LAC DDTFLG
NO.DDT	AND PLIT7		/(100000 PRESERVE BIT 2.
	DAC DDTFLG	/SET FLAG POSITIVE SO THAT LDPROG WILL
			/KNOW THAT DDT IS NOT BEING LOADED.
	LAC HIFREE	/TOP OF CORE OR REGISTER BELOW DDT.
	DAC ABSFLG	/SET LOWEST ABS PROGRAM LOCATION.
	DAC UPRLIM	/SET HIGHEST LEGAL ABS PROGRAM LOCATION.
 
	.EJECT
/ NOW TELL THE USER THAT THIS IS THE LOADER AND PREPARE TO ACCEPT,
/ FROM THE TELETYPE OR BATCH INPUT DEVICE, THE LIST OF NAMES OF
/ PROGRAMS TO BE LOADED (IF ANY).
 
/ IF THE USER TYPES CONTROL P WHILE THE LOADER IS ACCEPTING PROGRAM
/ NAMES, THE LOADER WILL RESTART HERE.
 
RESTART	LAC DIRPTR	/CLEAR OUT PROGRAM DIRECTORIES TABLE
	DAC SYMEND	/BY RESETTING THE END OF SYMTAB PTR.
	DZM OPFLAG	/SET FLAG FOR OPTION CHAR PROCESSING.
	DZM MAPFUNC	/INIT MEMMAP FUNCTION BITS; 0=NO MAP.
 
	CAL 1775		/.INIT -3; PRINT CR LF; SETUP TO XFER
	1		/TO LOCATION 'RESTART' IF USER TYPES
	RESTART		/CONTROL P.
TEMP1	0
 
	CAL 2775		/.WRITE -3 IOPS ASCII ON THE TTY.
	11
	MSG1		/MESSAGE: 'BGLOAD V1A'<15>.
PLIT25	77000
 
	LAC SET.T		/SETUP BGD ^T REGISTER.
	DAC* BCTL.T	/WILL BE DISABLED (0) IF NO DDT.
 
NEXLIN	CAL 2775		/.WRITE -3 IOPS ASCII ON THE TTY.
	11
	MSG2		/MESSAGE: '>'<175>.
PLIT26	776000
 
/ END OF DATA WORD OVERLAY.
 
	CAL 2776		/.READ -2 IOPS ASCII FROM THE TTY OR THE
	10		/BATCH INPUT DEVICE INTO
PLIT2	LINBF1		/LINE BUFFER #1.
	-62
 
	CAL 776		/.WAIT -2 FOR COMPLETION OF READIN.
	12
 
	LAC (LINBF1+2	/SETUP POINTER TO 1ST DATA WORD.
	DAC TEMP1
MINUS1	LAW -1		/LITERAL USED ELSEWHERE.
	DAC TEMP2		/INIT 5/7 ASCII BYTE COUNT.
 
NEXNAM	DZM SYMFLG	/0 FLAG MEANS SYMBOL NOT FULL.
	DZM DLMITR	/0 SYMBOL DELIMITER MEANS
			/DELIMITER NOT YET ENCOUNTERED.
MINUS2	LAW -2
	DAC TEMP3		/INIT 2-WORD-PER-SYMBOL COUNT.
 
	.EJECT
NEXHAF	DZM SYM2		/0 TEMP. ACCUMULATOR OF SYMBOL.
MINUS3	LAW -3
	DAC TEMP4		/INIT 3-CHARS-PER-WORD COUNT.
	JMP DELTST
 
/ INPUT LINE BUFFER#2: 62 OCTAL (50 DECIMAL) REGISTERS. SAME SIZE AS
/ BUFFER#1. BUFFER#2 NOT USED UNTIL AFTER ROUTINE WITHIN THE BUFFER
/ HAS BEEN EXECUTED.
 
LINBF2=.
 
GETCHAR	ISZ TEMP2		/SKIP IF WORD PAIR EXHAUSTED.
	JMP GETNEX
	LAW -5		/RESET BYTE COUNT TO 5.
	DAC TEMP2
	LAC* TEMP1	/PICKUP NEXT ASCII WORD PAIR.
	DAC TEMP5		/SAVE WORD 1.
	IDX TEMP1
	LAC* TEMP1
	DAC TEMP6		/SAVE WORD 2.
	IDX TEMP1
 
GETNEX	LAW -10		/SETUP SHIFT COUNT TO DO 7+1/2 SHIFTS.
	DAC TEMP7
 
ROTATE	LAC TEMP6		/SHIFT WORD 2 WITH THE LINK.
	RAL
	ISZ TEMP7		/IS THE CHAR IN POSITION?
	JMP ROTWD1	/NO. SHIFT WORD 1 TOO.
	AND PLIT16	/YES. MASK TO 7 BITS: (177.
	DAC TEMP7		/SAVE CHAR FOR FURTHER REFERENCE.
	LAC OPFLAG	/PROCESSING MEMMAP OPTIONS?
	SZA
	JMP NAMES		/NO. FILE NAMES.
	LAC TEMP7		/GET CHAR.
	SAD (103
	JMP C		/C=COMMON BLOCKS.
	SAD (107
	JMP G		/G=GLOBALS.
	SAD (120
	JMP P		/P=PROGRAM NAMES.
	SAD (137		/_
	DAC OPFLAG	/OPTIONS TERMINATED; SET FLAG NON-0.
	SAD (175
	JMP RESTART	/ALTMODE. START OVER AGAIN.
	SAD (15
	JMP NEXLIN	/CAR RET. GO TO NEXT LINE.
	JMP DELTST	/IGNORE CHAR.
C	LAC (4
	SKP
G	LAC PLIT18	/(2
	SKP
P	LAC (1
 
	.EJECT
	XOR MAPFUNC	/XOR MEMMAP OPTION CODE
	DAC MAPFUNC	/INTO MAPFUNC.
	JMP DELTST	/PROCESS NEXT CHAR.
NAMES	LAC TEMP7		/GET CHAR.
	SAD (54
	JMP DELIMIT	/COMMA IS A DELIMITER.
	SAD (175
	JMP DELIMIT	/ALT MODE IS A DELIMITER.
	SAD PLIT14	/(15
	JMP DELIMIT	/CAR RET IS A DELIMITER.
	SAD PLIT15	/(12
	JMP DELTST	/IGNORE LINE FEEDS.
	SAD SPACE		/(40
	JMP DELTST	/IGNORE SPACES.
	LAC SYMFLG	/IS SYMBOL FULL?
	SZA!CLL
	JMP DELTST	/YES. IGNORE THIS CHARACTER.
	LAC TEMP7		/NO.
	AND (77		/TRIM TO 6 BITS.
FILLIT	XOR SYM2		/ADD IN ACCUMULATED SYMBOL.
	ISZ TEMP4		/IS THIS CHAR #3 OR #6?
	JMP MAKROOM	/NO.
	ISZ TEMP3		/YES. IS THIS CHAR #6?
	JMP HAFFUL	/NO. SYMBOL ONLY HALF FULL.
	SET SYMFLG	/NON-ZERO FLAG MEANS SYMBOL IS FULL.
	JMP STORE2
 
HAFFUL	DAC SYM1		/STORE FIRST HALF OF SYMBOL.
	JMP NEXHAF
 
MAKROOM	RTL		/SHIFT PARTIAL SYMBOL WORD TO MAKE
	RTL		/ROOM FOR NEXT CHARACTER.
	RTL
STORE2	DAC SYM2
	JMP DELTST
 
ROTWD1	DAC TEMP6		/WORD2.
	LAC TEMP5		/SHIFT WORD 1 TOO.
	RAL
 
/ END OF INPUT LINE BUFFER #2.
 
	DAC TEMP5
	JMP ROTATE	/CONTINUE SHIFTING.
 
	.EJECT
DELIMIT	DAC DLMITR	/SAVE SYMBOL DELIMITER.
DELTST	CLA!CLL
	SAD DLMITR	/HAS DELIMITER BEEN ENCOUNTERED?
	JMP GETCHAR	/NO. GET NEXT CHARACTER.
	SAD SYMFLG	/YES. IS SYMBOL FULL?
	JMP FILLIT	/NO. FILL IT WITH 0'S.
 
/ SYMBOL IS FULL AND SYMBOL DELIMITER WAS SEEN. ENTER THE PROGRAM
/ NAME, WITH AN EXTENSION OF 'BIN', IN THE PROGRAM DIRECTORIES TABLE.
 
	LAC SYM1
	JMS ENTSYM
	LAC SYM2
	JMS ENTSYM
	LAC BIN
	JMS ENTSYM
 
/ TEST DELIMITER TO SEE IF ANY MORE NAMES REMAIN.
 
	LAC DLMITR
	SAD (54		/COMMA?
	JMP NEXNAM	/YES. GET NEXT PROGRAM NAME.
	SAD PLIT14	/(15 CAR RET?
	JMP NEXLIN	/YES. READ IN NEXT COMMAND LINE.
 
/ DELIMITER WAS ALT MODE SIGNIFYING END OF INPUT.
 
	CAL 775		/.INIT -3; PRINT CR LF.
	1
	0		/DISABLE ^P.
TEMP3	0
 
	DZM* BCTL.T	/DISABLE ^T.
	LAC SYMEND	/SET BEGINNING OF SYMBOL TABLE JUST
	DAC SYMBEG	/ABOVE THE PROGRAM DIRECTORIES TABLE.
 
	.EJECT
/ LOAD IN EACH REQUESTED PROGRAM FROM THE USER'S INPUT DEVICE.
 
NEXPRG	LAC DIRPTR	/ARE THERE ANY MORE TO LOAD?
	SAD SYMBEG
	JMP CNTL.T	/NO.
	DAC PRGDIR
	TAD (3		/UPDATE POINTER TO
	DAC DIRPTR	/NEXT DIRECTORY ENTRY.
 
	CAL 774		/.INIT -4 FOR INPUT OF USER'S PROGRAM.
	1
TEMP4	0
TEMP5	0
 
PLIT3	CAL 774		/.SEEK ON -4 THE USER'S PROGRAM.
	3
PRGDIR	XX		/POINTER TO ENTRY IN PROGRAM DIRECTORIES TABLE.
 
	SET NUFILE	/SET FLAG THAT SAYS A .SEEK WAS JUST DONE.
	LAC PLIT3		/(CAL 774
	JMS LDPROG	/LOAD IN USER'S PROGRAM, RETURNING
			/15-BIT STARTING ADDRESS IN THE AC.
	XOR SCOM6
	DAC SCOM6		/SAVE CODE BITS+USER'S STARTING ADDRESS.
 
	CAL 774		/.CLOSE -4, USER'S PROGRAM INPUT DEVICE.
	6
 
	LAC MAINFLG	/FLAG IS NON-0 ONLY THE 1ST TIME THROUGH
	SNA		/INDICATING THAT THE MAIN PROGRAM WAS
	JMP NEXPRG	/JUST LOADED.
	DZM MAINFLG	/SET FLAG TO ZERO.
	LAC SCOM6
	DAC* (.SCOM+6	/STORE USER'S STARTING ADDRESS.
	JMP NEXPRG	/LOAD IN NEXT SUBPROGRAM.
 
/ IF DDT WAS LOADED, USER MAY TYPE CONTROL T WITHOUT HAVING TO LOAD
/ IN ANY PROGRAMS. THE MONITOR THEN TRANSFERS CONTROL HERE.
 
CNTL.T	CAL 775		/.INIT -3; PRINT CR LF;
	1		/DISABLE ^P.
	0
	0
 
	DZM* BCTL.T	/DISABLE BGD ^T.
 
	.EJECT
/ ARE THERE ANY NON-I/O VIRTUAL GLOBAL ENTRIES IN THE SYMBOL
/ TABLE? IF SO, TRY TO RESOLVE THEM BY SEARCHING FIRST THROUGH THE
/ USER'S LIBRARY (IF ANY) AND THEN THROUGH THE SYSTEM LIBRARY.
 
SUBRS	JMS ABSOFF	/PROHIBIT FURTHER ABS PROGRAM LOADING.
	LAC PLIT7		/(100000
	DAC DDTFLG	/INHIBIT LOADING OF LIBRARY SYMBOLS
			/INTO THE SYMBOL TABLE.
	JMS UNGLOB	/ARE THERE ANY NON-I/O UNRESOLVED GLOBALS?
	JMP GETIO		/MAYBE, BUT NONE THAT CAN BE RESOLVED.
 
MINUS5	LAW -5
	TAD DATB		/(.DATB
	JMS EXAMIN	/EXAMINE USER'S LIBRARY .DATB SLOT.
	SNA!CLA		/IF NO USER'S LIBRARY, USE SYSTEM LIBRARY.
	LAW -2
	TAD MINUS5
	AND PLIT1		/(777 CONVERT TO CAL INSTRUCTION.
 
/ WHEN I/O HANDLERS ARE TO BE LOADED, ENTRY POINT IS HERE.
 
LIBSET	DAC LIBINIT	/SETUP LIBRARY .INIT.
	DAC LIBSEEK	/SETUP LIBRARY .SEEK.
	DAC LIBCLOS	/SETUP LIBRARY .CLOSE.
	SAD (773
	JMP LIBINIT
	LAC IOFLAG	/ARE I/O HANDLERS BEING LOADED NOW?
	SZA!CLA
	TAD (3		/POINTER TO .IOLIB DIRECTORY.
	TAD (F4LIB	/POINTER TO .F4LIB DIRECTORY.
	DAC LIBPTR
 
LIBINIT	CAL .		/.INIT -7 OR -5 FOR LIBRARY INPUT.
	1
TEMP6	0
TEMP7	0
 
LIBSEEK	CAL .		/.SEEK THE LIBRARY FILE ON -7 OR -5.
	3
LIBPTR	USRLIB		/.LIBR BIN ON -5; .F4LIB BIN OR .IOLIB BIN ON -7.
 
	SET NUFILE	/SET FLAG THAT SAYS A .SEEK WAS JUST DONE.
 
MORLIB	SET LIBFLG	/SET LIBR MODE FLAG FOR SELECTIVE LOADING.
	LAC IOFLAG	/ARE I/O HANDLERS BEING LOADED NOW?
	SZA
	JMS IOGLOB	/YES. ARE THERE ANY UNRESOLVED I/O GLOBALS?
			/(IOGLOB ON RETURN DOES 1 OR DBL SKIP).
	JMS UNGLOB	/ARE THERE ANY NON-I/O UNRESOLVED GLOBALS?
	JMP LIBCLOS	/NO. CLOSE THIS LIBRARY FILE.
 
	.EJECT
NEXLIB	LAC LIBSEEK	/GET CAL .DATB OF THE LIBRARY 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 ENCOUNTERED, 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 LIBRARY SUBPROGRAM.
	JMP MORLIB	/YES. DO ANY MORE NEED TO BE READ IN?
 
/ CLOSE CURRENT LIBRARY FILE. IF IT WAS THE USER'S LIBRARY, GO BACK
/ AND TRY THE SYSTEM LIBRARY, IF NECESSARY.  PROGRAM LOADING SUBROUTINE
/ WILL RETURN CONTROL HERE IF LIBRARY END OF FILE IS ENCOUNTERED.
 
LIBCLOS	CAL .		/.CLOSE -7 OR -5 (LIBRARY FILES).
	6
 
	LAC (771
	SAD LIBCLOS	/ARE WE DONE WITH THE LIBRARIES?
	SKP
	JMP LIBSET	/NO. SWITCH TO SYSTEM LIBRARY.
	LAC IOFLAG	/HAVE WE JUST BEEN IN .IOLIB?
	SZA
	JMP ALL.IN	/YES.
 
/ THERE MAY STILL EXIST SOME NON-I/O UNRESOLVED GLOBALS AT THIS
/ POINT. AFTER COMMON BLOCK ASSIGNMENTS HAVE BEEN MADE, ALL
/ REMAINING UNDEFINED NON-I/O GLOBALS WILL BE DEFINED TO BE
/ THE ADDRESSES OF COMMON BLOCKS IF SYMBOLLIC NAMES MATCH.
 
/ FOR THE 4 POSSIBLE CORE BANKS, SET POINTERS TO THE
/ LOWEST FREE REGISTER IN EACH (0 IF NO ROOM).
 
GETIO	LAC (CORE0
	DAC TEMP1
 
HYERCOR	LAC* TEMP1	/GET BANK BITS OF NEXT CORE POINTER.
	XOR LOFREE	/MATCH AGAINST LOWEST FREE REGISTER.
	AND (60000
	SNA!CLA!CLL
	JMP .+3		/THIS IS THE LOWEST FREE BANK.
 
	JMS STORE		/0 THE POINTER FOR BANKS LOWER THAN THE
	JMP HYERCOR	/1ST FREE REGISTER TO INDICATE NO ROOM.
 
	.EJECT
/ STORE THE LOWEST FREE REGISTER IN THE POINTER FOR THE LOWEST FREE CORE
/ BANK. DETERMINE HOW MUCH ROOM EXISTS FROM THE LOWEST FREE REGISTER TO
/ THE BOTTOM OF THE LOADER; HANDLERS WILL BE LOADED BELOW THE LOADER NOW,
/ IF POSSIBLE.
 
	LAC LOFREE	/CHOOSE THE HIGHER OF THE TWO.
	JMS TWOS
	TAD* TEMP1	/BANK POINTER INITIALLY SETUP TO POINT
	LAC LOFREE	/AT REGISTER 20 IN THAT BANK.
	SZL
	LAC* TEMP1
	DAC LOFREE
	DAC* TEMP1
	DAC HIHAND	/REGISTER ABOVE THE HIGHEST HANDLER OR HANDLER
			/BUFFER AT RUN-TIME (NEEDED TO COMPUTE THE
			/MEMORY PROTECT BOUND).
	XOR .		/MATCH AGAINST ANY LOADER ADDRESS.
	AND (60000
	SZA		/SKIP IF LOADER IS IN THE SAME BANK.
	LAC (20		/NO. LOADER STARTS AT XXX20, BUT
	TAD LOFREE	/HANDLER CAN'T OVERLAP BANKS.
	JMS TWOS
	TAD (FIRST	/LOADER'S FIRST LOCATION.
	DAC LOROOM	/ROOM FOR LOADING BELOW THE LOADER.
 
/ NOW IF THERE ARE ANY I/O GLOBALS IN THE SYMBOL TABLE, LOAD HANDLERS
/ IN FROM THE SYSTEM DEVICE. FIRST, SAVE BANK POINTERS.
 
	LAC BANK0		/CURRENT STATUS OF HIGHEST FREE REGISTER
	DAC TBANK0	/IN EACH BANK IS SAVED AND WILL BE RESTORED
	LAC BANK1		/AFTER THE HANDLERS ARE LOADED. THIS
	DAC TBANK1	/IS SO THAT COMMON BLOCKS CAN OVERLAY THE I/O
	LAC BANK2		/HANDLERS IN UPPER MEMORY.
	DAC TBANK2
	LAC BANK3
	DAC TBANK3
	JMS IOGLOB	/ARE THERE ANY I/O GLOBALS?
PLIT18	2		/THIS LOCATION IS SKIPPED.
	JMP ALL.IN	/NO.
	SET IOFLAG	/YES. SET FLAG FOR LOADING OF HANDLERS.
	LAC (771
	JMP LIBSET	/LOAD IN REQUESTED HANDLERS.
 
/ PROGRAM LOADING TERMINATED. DEFINE REMAINING UNDEFINED COMMON BLOCKS.
 
ALL.IN	LAC TBANK0	/RESET THE STATUS OF THE HIGHEST FREE
	DAC BANK0		/REGISTER IN EACH BANK SO THAT
	LAC TBANK1	/COMMON CAN OVERLAY THE HANDLERS IN UPPER
	DAC BANK1		/CORE.
	LAC TBANK2
	DAC BANK2
	LAC TBANK3
	DAC BANK3
 
	.EJECT
	DZM LIBFLG
	DZM IOFLAG
	SET COMFLG	/COMMON IS NOW BEING DEFINED.
 
COMMON	JMS BEGSYM	/SEARCH FROM BEG OF SYMTAB.
	JMS FINDCOD	/SEARCH FOR
PLIT6	700000		/UNDEFINED COMMON BLOCKS.
	JMP GLOBE		/NONE REMAINING.
 
	JMS NEXSYM	/PICKUP 1ST WORD OF NAME.
	DAC SYM1
	SPA		/IS IT A 2-WORD NAME?
	JMS NEXSYM	/YES.
	DAC SYM2
	IDX SYMPTR
	LAC SYMPTR	/SETUP THE POINTER TO THE
	DAC COMCHN	/COMMON CHAIN POINTER
	TAD (1
	DAC COMDEF	/AND TO THE COMMON BLOCK START ADDRESS.
 
	LAC* SYMWD1	/CHANGE CODE 7(UNDEFINED) TO
	AND (377777	/CODE 3(DEFINED).
	DAC* SYMWD1
	AND (77777	/GET BLOCK SIZE AND NEGATE IT.
	JMS TWOS
	DAC SIZE
	JMS FIT		/COMPUTE THE LOAD ADDRESS OF THE BLOCK,
			/IF IT FITS IN CORE.
	LAC LOADADR
	DAC* COMDEF	/SET BASE ADDRESS OF BLOCK.
	LAC MAPFUNC	/MEMORY MAP FUNCTION BITS.
	AND (4
	SNA
	JMP .+3
	LAC (103		/ASCII FOR C.
	JMS MEMMAP	/PRINT COMMON DEF. IN MEMORY MAP.
	JMS DEFCOM	/DEFINE ALL EXISTING LINKS IN THE COMMON CHAIN.
	JMP COMMON	/SEE IF THERE ARE ANY MORE UNDEFINED BLOCKS.
 
	.EJECT
/ IF ANY UNRESOLVED NON-I/O GLOBAL REMAINS, SEARCH FOR A COMMON
/ BLOCK WITH THE SAME NAME. IF FOUND, DEFINE THE GLOBAL AS THE ADDRESS
/ OF THE COMMON BLOCK.
 
GLOBE	JMS BEGSYM	/START AT BEG OF SYMTAB.
NXGLOB	CLL		/CLEAR LINK FOR NON-I/O GLOBALS.
	JMS FINDCOD	/SEARCH FOR
PLIT7	100000		/VIRTUAL GLOBALS.
	JMP ALLDEF	/NONE LEFT THAT CAN BE RESOLVED.
 
	LAC SYMWD1	/YES. SAVE POINTER TO IT.
	DAC TEMP5
	JMS NEXSYM	/PICKUP GLOBAL'S NAME.
	DAC SYM1
	JMS NEXSYM
	DAC SYM2
PLIT8	LAW		/SET BIT 1-2 FOR CODE 3 SEARCH.
	JMS SCAN		/IS THERE A COMMON BLOCK WITH SAME NAME?
	SKP		/YES.
	JMP GLBRET	/NO. TRY NEXT GLOBAL.
 
	IDX SYMPTR
	JMS NEXSYM	/GET ADDRESS OF THE COMMON BLOCK.
	JMS COD10.	/LET CODE 10 PROCESSOR DEFINE THE GLOBAL.
 
GLBRET	LAC TEMP5
	DAC SYMWD1	/RESTORE POINTER TO THE GLOBAL.
	JMS NXNTRY	/SKIP TO NEXT SYMTAB ENTRY.
	JMP NXGLOB
 
/ AT THIS POINT ALL GLOBALS SHOULD BE DEFINED.
 
ALLDEF	JMS UNGLOB	/ARE THERE ANY MORE VIRTUAL GLOBALS?
	JMS IOGLOB
	JMP GLBERR	/YES.
	SKP		/NO. GOOD.
	JMP GLBERR	/YES.
 
	.EJECT
/ OK. SEARCH THRU THE SYMBOL TABLE FOR I/O HANDLER ENTRIES (CODE 0) AND
/ TRANSFER THEM TO THE .EXIT LIST (LOADING DOWN FROM HISYM).
 
	JMS BEGSYM	/START AT BEG OF SYMTAB.
 
BLDLOOP	JMS FINDCOD	/SEARCH FOR
	0		/.EXIT ENTRY - CODE 0.
	JMP SQUEEZE	/NO MORE LEFT.
	JMS BUILDX	/ENTER HANDLER MOVE IN THE .EXIT LIST.
	IDX XITCNT	/ADD 1 TO COUNT OF # OF .EXIT ENTRIES.
	JMS NXNTRY	/SKIP OVER THIS SYMTAB ENTRY.
	JMP BLDLOOP
 
/ OPTIMIZE THE SYMBOL TABLE BY GETTING RID OF ALL ENTRIES EXCEPT
/ 2 (INTERNAL SYMBOL) AND 6 (PROGRAM NAME).
 
SQUEEZE	LAC* (.SCOM+2	/1ST LOCATION ABOVE THE HANDLER NAME TABLE.
	DAC TEMP1
	JMS BEGSYM	/START AT BEG OF SYMTAB.
 
SCRUNCH	SAD SYMEND
	JMP THATSIT
	LAC* SYMWD1	/GET CODE FROM 1ST WORD OF ENTRY.
	AND (300000
	SAD (200000	/IS IT CODE 2 OR 6?
	JMP .+3		/YES. SAVE IT.
 
MORE	JMS NXNTRY
	JMP SCRUNCH
 
	LAC* SYMWD1	/PICKUP AND MOVE THE
	JMS STORE		/2 OR 3 WORD ENTRY.
	JMS NEXSYM
	JMS STORE
	SPA
	JMP .-3
	JMP MORE
 
THATSIT	LAC TEMP1		/SET NEW END OF SYMTAB POINTER.
	DAC SYMEND
	LAC* (.SCOM+2	/SET NEW BEGINNING OF
	DAC SYMBEG	/SYMTAB POINTER.
 
	.EJECT
/ GO THRU THE .MUD TABLE TO SEE WHICH DEVICES, IF ANY, NEED BUFFERS.
 
	LAC* (.SCOM+15	/CONTAINS: .BFTAB .
BFTAB.	DAC BFTAB.	/POINTER TO 1ST WORD IN .BFTAB CONTAINING
	TAD (1		/NEGATIVE COUNT OF # OF ENTRIES.
MAXCNT	DAC MAXCNT	/POINTER TO 2ND WORD IN .BFTAB CONTAINING
			/NEGATIVE OF MAXIMUM ENTRY COUNT.
	LAC* BFTAB.	/MOVE PTR TO 1ST FREE .BFTAB ENTRY.
	JMS TWOS
	RCL
	TAD PLIT18	/(2
	TAD MAXCNT
	DAC TEMP5
	LAC* (.SCOM+14	/CONTAINS: .MUD .
	DAC SYMPTR	/HERE SYMPTR IS USED AS A POINTER TO .MUD
			/TABLE ENTRIES.
DFILES	LAC* SYMPTR	/GET 2'S COMPLEMENT COUNT OF # OF ENTRY
	DAC MUDCNT	/WORD-PAIRS IN .MUD TABLE.
 
MOREMUD	JMS NEXSYM	/GET 1ST WORD OF NEXT ENTRY IN .MUD.
	AND (77		/MASK TO $FILES COUNT.
	IDX SYMPTR
	SNA
	JMP NOBUF		/COUNT=0.
	JMS TWOS
	DAC DFILES	/SAVE $FILES BUFFER COUNT.
	LAC* SYMPTR
 
	.EJECT
	RTR		/2ND WORD OF .MUD ENTRY CONTAINS THE BUFFER
	RTR		/SIZE IN BITS 0-11.
	RTR
	AND PLIT20	/(7777
	DAC BUFSIZ
	SNA		/0 IS A LEGAL BUFFER SIZE.
	JMP NOBUF
	JMS TWOS
	DAC SIZE		/2'S COMPLEMENT OF BUFFER SIZE.
	SET BUFFLG	/SET FLAG TO TELL SUBROUTINE FIT THAT
			/BUFFER SPACE IS BEING ASSIGNED.
 
/ FOR EACH REQUESTED BUFFER, ASSIGN A CORE POSITION FOR IT AND MAKE AN
/ ENTRY IN .BFTAB .
 
ONEMORE	JMS FIT		/ASSIGN BUFFER SPACE DOWN WHERE THE HANDLERS
			/WILL RUN.
	LAC* BFTAB.
	SAD* MAXCNT	/ANY MORE ROOM IN .BFTAB?
	JMP ERR102	/NO.
	TAD MINUS1
	DAC* BFTAB.	/INCREASE .BFTAB ENTRY COUNT BY 1.
	LAC BUFSIZ
	XOR (400000	/TACK ON CODE FOR NON-BUSY BACKGROUND BUFFER.
	DAC* TEMP5
	IDX TEMP5
	LAC RELRUN	/1ST ADDRESS OF THIS BUFFER.
	DAC* TEMP5
	IDX TEMP5
	ISZ DFILES	/ANYMORE BUFFERS TO BE ASSIGNED?
	JMP ONEMORE	/YES.
 
NOBUF	ISZ MUDCNT	/ARE THERE ANY MORE DEVICES TO CHECK ON?
	JMP MOREMUD	/YES.
 
	.EJECT
/ DETERMINE WHERE THE MEMORY PROTECT BOUND SHOULD GO (2000, 4000, ...),
/ WHICH IS WHERE THE SYMBOL TABLE WILL START WHEN IT IS MOVED (ASSUMING DDT
/ WAS LOADED). PUT 3-WORD ENTRY IN .EXIT LIST FOR THE SYMBOL TABLE MOVE,
/ THEN ENTER THE .EXIT CAL AT THE VERY BEGINNING.
 
	LAC HIHAND	/GET HIGHEST HANDLER/BUFFER LOCATION+1.
	DAC* (.SCOM+1	/START OF SYMBOL TABLE.
	DAC* (.SCOM+31	/SOFTWARE MEM. PROTECT BOUND.
	DAC DATA3		/WHERE TO MOVE SYMTAB TO.
	TAD MINUS1
	AND PLIT26	/(776000 COMPUTE THE HARDWARE PROTECT BOUND.
	TAD PLIT19	/(2000
NEWHPB	DAC .		/TEMP SAVE FOR NEW HARDWARE BOUND.
	LAC SCOM6		/DDT WAS LOADED IF BIT0=1.
	SMA
	JMP NOSTAB	/DON'T PUT SYMBOL TABLE MOVE IN .EXIT LIST.
	LAC SYMBEG	/CHECK IF SYMTAB SIZE=0. IF SO,
	SAD SYMEND	/DON'T PUT MOVE IN .EXIT LIST.
	JMP NOSTAB
	DAC DATA1		/1ST WORD=START OF SYMTAB.
	LAW -1
	TAD SYMEND
	DAC DATA2		/2ND WORD=LAST LOC IN SYMTAB.
	IDX XITCNT	/ADD 1 TO .EXIT LIST COUNT.
	LAC PDATA1	/(DATA1 POINT TO 3-WORD BLOCK.
	DAC SYMPTR
	JMS BUILDX	/MOVE BLOCK TO FRONT OF .EXIT LIST.
 
NOSTAB	DZM DATA1		/STORE 3 NULL WORDS IN .EXIT LIST.
	DZM DATA2		/IF THE TEST BELOW FAILS, YOU'LL
	DZM DATA3		/RETURN HERE TO STORE 3 MORE. A
	LAC PDATA1	/NULL ENTRY (3 WORDS 0) IS EFFECT-
	DAC SYMPTR	/IVELY IGNORED BY THE MONITOR.
	JMS BUILDX
 
	.EJECT
/ THE .EXIT LIST IS BUILT WITH A DAC* (.SCOM+32 IMMEDIATELY PRECEDING
/ IT TO STORE THE NEW VALUE OF THE MPB. THE LITERAL WILL BE BUILT JUST
/ BEFORE THE DAC* . THE LITERAL, THE DAC* , AND THE .EXIT CAL MUST
/ FALL IN THE SAME MEMORY BANK. THE LITERAL CANNOT FALL IN REGISTERS
/ 10-17 OF ANY BANK BECAUSE THE INDIRECT REFERENCE WOULD BE TO AN AUTO-
/ INDEX REGISTER INSTEAD.
 
	LAC HISYM		/POINTING AT WHERE LITERAL WILL GO.
	AND (17777
	SAD (17777
	JMP NOSTAB	/3 INSTRUCTIONS NOT IN SAME BANK.
	SAD (17776
	JMP NOSTAB	/SAME.
	TAD (-10
	SPA
	JMP .+4
	TAD (-10
	SPA
	JMP NOSTAB	/LITERAL WOULD FALL IN 10-17.
 
/ OK. RESET POINTER SO THAT THE LAST 3 NULL REGISTERS ENTERED INTO THE
/ .EXIT LIST WILL BE OVERLAYED BY WHAT SHOULD HAVE GONE THERE.
 
	LAC TEMP1
	DAC HISYM		/MOVE HISYM UP 3.
	LAC XITCNT	/.EXIT COUNT.
	CMA		/1'S COMP. IN RIGHT HALF.
	AND PLIT1		/(777 CONVERT TO A CAL
	DAC DATA2
	LAC PLIT14	/(15 : THE CODE FOR .EXIT .
	DAC DATA3
	LAW -3		/COMPUTE A DAC* .-1 (WHERE,
	TAD HISYM		/EFFECTIVE .-1 WILL POINT AT
	AND (17777	/.SCOM+32 TO SETUP NEW HMPB).
	XOR (DAC* 0
	DAC DATA1
	LAC PDATA1	/(DATA1.
	DAC SYMPTR
	JMS BUILDX	/MOVE .EXIT TO THE FRONT OF .EXIT LIST.
 
	LAC (.SCOM+32	/POINTER TO .SCOM+32 STORED
	DAC DATA3		/PRECEDING THE DAC* .-1.
	LAC PDATA1
	DAC SYMPTR
	JMS BUILDX	/MOVE 3 MORE WORDS TO .EXIT LIST;
	IDX HISYM		/MOVE POINTER UP TO SKIP 1ST TWO
	IDX HISYM		/OF THESE BECAUSE THEY DON'T MATTER.
 
	.EJECT
/ DO FINAL CHECK TO BE SURE THAT THERE IS NO OVERLAP BETWEEN
/ HANDLERS/BUFFERS/SYMTAB AND USER PROGRAMS/DDT/COMMON.
 
	LAC SCOM6		/SAVE SYMTAB IF DDT WAS LOADED.
	SMA!CLA
	JMP SETLOW	/NO SYMBOL TABLE.
	LAC SYMBEG	/WHERE SYMTAB STARTS NOW.
	JMS TWOS
	TAD SYMEND	/COMPUTE SIZE OF SYMTAB.
	IDX LAPERR	/CHANGE ERROR JUMP.
SETLOW	TAD* (.SCOM+31	/ADD SOFTWARE PROTECT BOUND.
	DAC* (.SCOM+2	/SAVE LOWEST FREE REGISTER.
	JMS TWOS
	TAD HISYM		/HIGHEST FREE REGISTER NOW.
	SPA		/OVERLAP?
	JMP LAPERR	/YES.
	LAC* (.SCOM+2
	JMS TWOS
	TAD HIFREE	/HIGHEST FREE REGISTER BELOW USER PROGRAMS.
	SPA
LAPERR	JMP ERR100	/JMP ERR100 OR JMP ERR101.
	LAC HIFREE
	DAC* (.SCOM+3	/SAVE HIGHEST FREE REGISTER.
	LAC XCTBND	/MAKE SURE THAT EXECUTABLE CODE
	CMA		/LIES ABOVE HARDWARE BOUND.
	TAD NEWHPB
	SMA!SZA
	JMP ERR100
 
/ CLEAR THE LOADER'S .DATB SLOTS IN CASE THE USER INADVERTANTLY TRIES TO USE THEM.
 
	LAW -7
	TAD DATB
	DAC DATB
	DZM* DATB		/0 .DATB -7
	IDX DATB
	IDX DATB
	DZM* DATB		/0 .DATB -5
	IDX DATB
	DZM* DATB		/0 .DATB -4
	IDX DATB
	IDX DATB
	IDX DATB
	DZM* DATB		/0 .DATB -1
 
	CAL 775		/.WAIT FOR ANY TTY OUTPUT TO FINISH.
	12
 
	LAC NEWHPB
	IDX HISYM
	IDX HISYM
	JMP* HISYM	/GO TO .EXIT .
 
	.EJECT
/ MAIN SUBROUTINE LDPROG: LOAD A PROGRAM UNIT VIA THE 'CAL .DATB 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'.
/ ALL PROGRAM LOADING, EXCEPT FOR DDT, IS DOUBLE BUFFERED. THE CODE IN
/ BUFFER 2 HASN'T BEEN EXECUTED AT THE TIME THAT DDT IS BEING LOADED.
 
LDPROG	0		/CAL .DATB SLOT IS IN THE AC.
 
	DAC WAIT		/SETUP .WAIT CAL.
	DAC READ1		/SETUP INITIAL READ CAL.
	DAC READ		/SETUP DOUBLE BUFFER READ CAL.
	LAC DDTFLG	/AM I NOW LOADING DDT?
	SPA
	JMP READ1		/YES. DON'T DOUBLE BUFFER.
	LAC NUFILE	/NO. AM I ABOUT TO READ A NEW FILE
			/(I.E. WAS A .SEEK JUST DONE) OR AM I
	SNA		/IN THE MIDDLE OF SOME LIBRARY FILE?
	JMP BUFCHK	/IT'S AN OLD FILE (.READ ALREADY ISSUED).
	DZM NUFILE	/SET FLAG 0 SO THAT NEXT TIME IT WILL LOOK
			/LIKE AN OLD FILE.
 
READ1	CAL		/.READ IOPS BINARY INTO LINE BUFFER #1.
	10		/THIS IS THE INITIAL READ FOR A NEW FILE.
	LINBF1		/ALL DDT READS COME HERE.
	-62
 
	JMP SETUP1	/SETUP POINTERS TO MAKE #1 THE CURRENT BUFFER.
 
/ CURRENT BUFFER IS EMPTY.
 
BUFMPTY	LAC DDTFLG	/AM I NOW LOADING IN DDT?
	SPA
	JMP READ1		/YES. READ MORE INTO BUFFER #1.
	LAC BF1OR2	/NO. DOUBLE BUFFER. WHICH BUFFER IS BEING
			/READ INTO?
	SAD PLIT2		/SAD (LINBF1 .
	JMP SETUP1	/BUFFER #1.
	LAC (LINBF2	/SETUP BUFFER POINTER TO 1ST WORD OF
	DAC BUFPTR	/BUFFER #2.
	LAC PLIT2		/(LINBF1
	JMP SETREAD	/PREPARE TO READ INTO BUFFER #1.
SETUP1	LAC PLIT2		/(LINBF1
	DAC BUFPTR	/SETUP BUFFER POINTER TO 1ST WORD OF
			/LINE BUFFER #1.
	LAC (LINBF2	/PREPARE TO READ INTO BUFFER #2.
SETREAD	DAC TEMP1
 
WAIT	CAL		/.WAIT ON LATEST .READ .
	12
 
	LAC TEMP1		/(LINBF1 OR (LINBF2 .
	DAC BF1OR2
 
	.EJECT
/ TEST THE HEADER WORDS IN THE BUFFER JUST READ INTO.
 
HDRTST	LAC* BUFPTR	/PICKUP HEADER WORD 1.
	AND PLIT11	/(17 MASK TO FUNCTION BITS.
	SAD (6		/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.
	SZA		/PARITY, CHECKSUM, BUFFER OVERFLOW?
	JMP ERR105	/YES.
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 IF DDT IS NOT BEING LOADED.
 
	IDX BUFPTR
	LAW -1
	DAC CDWCNT
	LAC DDTFLG	/AM I NOW LOADING DDT?
	SPA
	JMP BUFCHK	/YES. DON'T ISSUE NEXT READ.
 
READ	CAL		/.READ IOPS BINARY INTO
	10
BF1OR2	XX		/LINE BUFFER #1 OR #2.
	-62
 
/ 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.
MINUS4	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 (1		/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 PLIT15	/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 (CODTAB+31
	DAC TEMP2		/SAVE DISPATCH ADDRESS.
	LAC* BUFPTR	/PICKUP DATA WORD.
	JMP* TEMP2	/PROCESS IT.
 
	.EJECT
/ DISPATCH TABLE TO CODE PROCESSING ROUTINES.
 
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	CAL 2775		/.WRITE IOPS ASCII ON THE TTY.
	11
	MSG3		/MESSAGE: '^P'<175> .
PLIT19	2000
 
	LAC (CNTL.P+300000	/ENABLE ^P RETURN (XM + MP BITS).
	DAC* BCTL.P	/STORE IN BGD ^P REGISTER.
	JMP .		/WAIT HERE WHILE USER SETS UP HIS INPUT DEVICE.
 
CNTL.P	DZM* BCTL.P	/DISABLE ^P.
	CAL 775		/.CLOSE -3; PRINT CR LF AFTER USER TYPES
	6		/CONTROL P.
 
	JMP READ1		/GO BACK TO INITIAL READ.
 
	.EJECT
/ CODE 1 PROCESSOR: PROGRAM UNIT'S SIZE. COMPUTE LOAD ADDRESS AND
/ RELOCATION FACTORS.
 
CODE1	SPA!CMA		/ABSOLUTE OR RELOCATABLE PROGRAM?
	JMP ABSCHK	/ABSOLUTE.
	TAD (1
	DAC SIZE		/SAVE 2'S COMPLEMENT OF PROGRAM SIZE.
	JMS ABSOFF	/DISALLOW FURTHER LOADING OF ABS PROGRAMS.
 
/ 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 BOTH LOAD-TIME AND RUN-TIME RELOCATION FACTORS.
 
	JMS FIT
	JMP BUFCHK
ABSCHK	LAC ABSFLG	/IF FLAG=0, ABSOLUTE PROGRAMS
	SNA		/MAY NO LONGER BE LOADED.
	JMP ERR115
 
/ FOR ABSOLUTE PROGRAMS, NO TEST IS MADE TO SEE IF THEY FIT
/ COMPLETELY WITHIN ONE BANK OR IF THEY OVERLAY ONE ANOTHER.
 
ABSOLU	DZM RELRUN	/0 THE RUN-TIME RELOCATION FACTOR.
	DZM RELLOD	/0 THE LOAD-TIME RELOCATION FACTOR.
	JMP BUFCHK	/GO TO PROCESS THE NEXT DATA WORD.
 
	.EJECT
/ CODE 2 PROCESSOR: PROGRAM'S LOAD ADDRESS.
 
CODE2	TAD RELLOD	/ADD THE LOAD-TIME RELOCATION FACTOR
			/(WHICH IS 0 IF PROGRAM IS ABSOLUTE).
	DAC LOADADR	/BIT0=1 IF AN ABSOLUTE LOAD ADDRESS.
	RAL		/DON'T ALLOW MIXING OF ABS AND
	LAC ABSFLG	/RELOCATABLE PROGRAMS.
	SNA
	SNL!CML
	SNL
	JMP ERR115
	LAC LOADADR
	AND (377777
SAVLAD	DAC LOADADR
	LAC ABSFLG
	SNA!CMA		/SKIP IF AN ABS LOAD ADDRESS.
	JMP BUFCHK
	TAD LOADADR
	SMA		/SKIP IF NEW LOAD ADDRESS IS
	JMP .+6		/LOWEST SO FAR.
	LAC LOADADR
	DAC ABSFLG	/SAVE LOWEST ABS ADDRESS IN FLAG.
	TAD MINUS1
	DAC HISYM		/HIGHEST REGISTER AVAILABLE TO SYMTAB.
	DAC HIFREE	/HIGHEST REGISTER BELOW USER PROGRAMS.
	LAC LOADADR
	JMS TWOS
	TAD SYMEND
	SMA
	JMP ERR101	/SYMTAB OVERLAP.
	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	JMS MOD13		/ADD IN THE RUN-TIME RELOCATION FACTOR
			/(MODULO 13) TO THE ADDRESS PART.
CODE4	DAC TEMP5
	LAC ABSFLG	/IF PART OF AN ABSOLUTE PROGRAM,
	SNA
	JMP SAVWRD-1
	LAC LOADADR	/MAKE SURE IT DOESN'T LOAD OVER
	JMS TWOS		/DDT(IF THERE) OR OUT OF CORE RANGE.
	TAD UPRLIM
	SPA
	JMP ERR115	/CAN'T OVERLAP UPPER LIMIT.
	LAC TEMP5
SAVWRD	DAC* LOADADR	/STORE THE WORD IN CORE.
	IDX LOADADR
	JMP BUFCHK
 
	.EJECT
/ CODE 5 PROCESSOR: RELOCATABLE PROGRAM ADDRESS (VECTOR).
 
CODE5	TAD RELRUN	/ADD IN THE 15-BIT RUN-TIME
	JMP SAVWRD	/RELOCATION FACTOR.
 
/ CODE 6 PROCESSOR: NON-COMMON VARIABLE AND ARRAY STORAGE ALLOCATION.
 
CODE6	TAD LOADADR	/INCREASE THE PRESENT LOAD ADDRESS BY THE
	JMP SAVLAD	/STORAGE SIZE. THIS STORAGE AREA HAS BEEN
			/PREVIOUSLY INITIALIZED TO 0.
 
/ 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: VIRTUAL (EXTERNAL) GLOBAL SYMBOL REFERENCE.
/ CONTAINS UNRELOCATED ADDRESS OF A TRANSFER VECTOR.
 
CODE9	TAD RELLOD	/ADD LOAD-TIME RELOCATION FACTOR,
	TAD PLIT7		/ADD CODE (1) FOR A VIRTUAL GLOBAL,
	JMS SCAN		/SCAN THE SYMBOL TABLE TO SEE IF THIS SYMBOL
			/HAS ALREADY BEEN ENTERED.
	JMP .+3		/YES.
NTRSYM	JMS DEFSYM	/NOT IN SYMBOL TABLE.
	JMP BUFCHK
 
/ GLOBAL SYMBOL IS ALREADY 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.
 
	DAC* SYMDEF	/STORE 15-BIT DEFINITION IN THE TRANSFER
			/VECTOR. BITS 0-2 ARE 0.
	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
 
	.EJECT
/ CODE 10 PROCESSOR: INTERNAL GLOBAL SYMBOL DEFINITION. WHEN ENCOUNTERED
/ IN LIBRARY SEARCH MODE, INTERNAL GLOBAL DEFINITION DETERMINES WHETHER
/ OR NOT THE LIBRARY PROGRAM WHICH FOLLOWS IS TO BE LOADED. IF SO, ONLY
/ THEN IS THE LIBRARY PROGRAM TESTED TO SEE IF IT WILL FIT IN CORE AND
/ THE LOAD ADDRESS AND RELOCATION FACTORS COMPUTED.
 
CODE10	TAD RELRUN	/ADD RUN-TIME RELOCATION FACTOR.
	JMS COD10.
	LAC MAPFUNC	/MEMORY MAP FUNCTION BITS.
	RTR		/TEST BIT 16 (GLOBALS).
	SNL
	JMP BUFCHK	/NO MEMMAP OUTPUT.
	LAC RELRUN	/SAVE RELRUN TEMPORARILY.
	DAC TEMP5
	LAC MAPDEF	/GLOBAL'S DEFINITION.
	DAC RELRUN
	LAC (107		/ASCII FOR G.
	JMS MEMMAP
	LAC TEMP5		/RESTORE RELRUN.
	DAC RELRUN
	JMP BUFCHK
MAPDEF	0		/GLOBAL'S DEFINITION.
 
	.EJECT
COD10.	0		/ALSO CALLED BY GLOBE ROUTINE.
 
	DAC TEMP3
	DAC MAPDEF
	TAD PLIT12	/(500000 ADD CODE FOR DEFINED GLOBAL.
	JMS SCAN		/IS THERE A GLOBAL WITH THE SAME NAME
			/ALREADY IN THE SYMBOL TABLE?
	JMP INTABLE	/YES.
 
/ GLOBAL NOT IN THE SYMBOL TABLE YET.
 
	SAD LIBFLG	/SKIP IF IN LIBRARY SEARCH MODE.
	SKP
	JMP BUFCHK	/YES. IGNORE. GLOBAL WASN'T REQUESTED.
	JMS DEFSYM	/ENTER SYMBOL AND ITS DEFINITION.
	JMP* COD10.
 
/ GLOBAL ALREADY IN SYMBOL TABLE.
 
INTABLE	DAC TEMP4		/SAVE 15-BIT DEFINITION FROM SYMTAB ENTRY.
	LAC* SYMWD1	/IS IT ALREADY DEFINED?
	SPA!CLA
	JMP BUFCHK	/YES. IGNORE THIS DATA WORD.
	SAD LIBFLG	/NO. ARE WE IN LIBRARY SEARCH MODE?
	JMP RESOLVE	/NO. DEFINE THE GLOBAL ENTRY.
 
/ 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 LOAD-TIME AND RUN-TIME RELOCATION FACTORS. 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).
 
	JMS FIT		/TEST IF LIBRARY PROGRAM FITS IN CORE AND
			/COMPUTE LOAD ADDRESS AND RELOC FACTORS.
	DZM LIBFLG	/CLEAR LIBRARY MODE FLAG SO REST OF PROGRAM
			/WILL BE LOADED AND TO SIGNAL THAT IT WAS.
	LAC TEMP3		/ADD RELOCATION FACTOR AGAIN (TO GLOBAL
	TAD RELRUN	/ADDRESS) BECAUSE IT WAS 0 PREVIOUSLY.
	DAC TEMP3
	DAC MAPDEF
	LAC IOFLAG	/I/O HANDLER?
	SNA
	JMP .+5		/NO.
	LAC TEMP3		/YES. DEFINITION STORED AS ADDRESS/4.
	RCR
	RCR
	DAC TEMP3
	LAC TEMP3
	TAD PLIT12	/(500000
	DAC SYMDEF	/SAVE FOR SYMBOL DEFINITION.
 
	.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 SYMDEF	/DEFINE THE SYMBOL IN THE TABLE AS AN
	DAC* SYMWD1	/INTERNAL GLOBAL.
 
NXLINK	LAC* TEMP4	/CONTENTS OF NEXT CHAIN LINK.
	AND (77777	/POINTS TO ANOTHER LINK.
	DAC TEMP1		/SAVE POINTER TO OTHER LINK.
	LAC IOFLAG	/I/O HANDLER?
	SNA
	JMP .+7		/NO.
	LAC TEMP1		/YES. POINTER IS ONLY 13 BITS,
	AND (17777	/POINTING AT SOME LOC. IN BANK0.
	DAC TEMP1
	XOR* TEMP4	/PRESERVE UNIT #.
	AND (177777	/CLEAR BITS 0,1 IN .DAT SLOT.
	XOR (400000	/ADD "SETUP" BIT.
	XOR TEMP3		/ADD GLOBAL'S REAL ADDRESS.
	DAC* TEMP4	/STORE REAL DEFINITION IN THE NEXT
			/LINK (TRANSFER VECTOR).
 
	LAC TEMP1		/LAST LINK IN CHAIN POINTS TO
	SAD TEMP4		/ITSELF.
	JMP* COD10.	/CHAIN IS RESOLVED.
 
	DAC TEMP4		/OTHER LINK BECOMES NEXT LINK.
	JMP NXLINK
 
/ CODE 11 PROCESSOR: BLOCK DATA SUBPROGRAM DECLARATOR.
 
CODE11	JMS TWOS
	DAC SIZE		/2'S COMPLEMENT OF BLOCKDATA PROGRAM SIZE.
	DAC BLKFLG	/SET FLAG NON-0.
	JMS FIT		/SEE IF BLOCK FITS IN CORE; COMPUTE LOAD
			/ADDRESS AND RELOCATION FACTORS.
	LAC RELRUN	/NEW RELOCATION FACTOR STORED AS BLOCK
	DAC BLKFLG	/BASE ADDRESS IN BLOCK DATA FLAG WHICH
	JMP BUFCHK	/ALSO 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.
 
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 UP ONE.
	LAC SYMEND	/SETUP POINTER TO THE WORD IN THE COMMON
	DAC COMDEF	/BLOCK ENTRY WHICH HAS THE BLOCK ADDRESS.
	JMS UPSYM		/MOVE SYMEND UP 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 RELRUN	/FOR MEMMAP PRINTOUT.
	TAD TEMP1		/YES. ADD THE COMMON BLOCK SIZE
	DAC BLKFLG	/TO GET THE BASE ADDRESS OF THE NEXT
			/COMMON BLOCK.
	LAC MAPFUNC	/MEMORY MAP FUNCTION BITS.
	AND (4
	SNA
	JMP .+3
	LAC (103		/ASCII FOR C.
	JMS MEMMAP	/PRINT COMMON DEFINITION IN MAP.
	JMS DEFCOM	/DEFINE ALL MEMBERS OF THE COMMON CHAIN.
	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 ERR107	/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 MINUS1	/(-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 ERR107	/BLOCK DATA MODE ON AND THE BLOCK SIZE
			/IN THE SYMBOL TABLE IS LARGER THAN THE
			/ONE IN THIS BLOCKDATA SUBPROGRAM.
 
	.EJECT
/ CODE 13 PROCESSOR: COMMON SYMBOL DEFINITION (ADDRESS RELATIVE TO THE
/ START OF THE COMMON BLOCK). USE SAME CODE AS CODE8.
 
 
/ CODE 14 PROCESSOR: COMMON SYMBOL REFERENCE DEFINITION (UNRELOCATED
/ ADDRESS OF THE TRANSFER VECTOR).
 
CODE14	TAD RELLOD	/ADD THE LOAD-TIME RELOCATION FACTOR TO
	DAC SYM1		/POINT TO WHERE THE T.V. IS NOW.
 
	LAC* COMDEF	/0 OR BLOCK'S BASE ADDRESS.
	TAD SYM2		/COMMON SYMBOL'S RELATIVE POSITION.
	DAC* SYM1		/STORE IN THE TRANSFER VECTOR.
	LAC* COMDEF	/IS THE BLOCK DEFINED?
	SZA
	JMP BUFCHK	/YES. DONE.
 
/ BLOCK IS NOT DEFINED. MAKE AN ENTRY IN THE SYMBOL TABLE AND INSERT
/ THE ENTRY IN THE COMMON CHAIN.
 
NOTDEF	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.
	JMP NTRSYM	/MAKE 2-WORD ENTRY IN THE SYMBOL TABLE.
 
 
/ 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. CODE BITS
/ (1-2) TELL WHAT TYPE OF CONSTANT WAS JUST LOADED (CODES 15-17).
/ REMAINDER CONTAINS UNRELOCATED LOAD ADDRESS FOR THE CONSTANT.
 
CODE18	DAC TEMP1		/SAVE DATA WORD.
 
/ IF BLKFLG=0, ADD THE LOAD-TIME RELOCATION FACTOR TO THE RELATIVE
/ LOAD ADDRESS; OTHERWISE, ADD THE BASE ADDRESS OF THE LAST COMMON
/ BLOCK REFERENCED.
 
	LAC BLKFLG	/IF BLKFLG IS NON-0, COMMON
	SNA		/BLOCK IS ALREADY DEFINED.
	JMP .+3
	LAC* COMDEF	/COMMON BLOCK'S BASE ADDRESS.
	SKP
	LAC RELLOD	/USE LOAD-TIME RELOCATION FACTOR INSTEAD.
	TAD TEMP1		/ADD RELATIVE ADDRESS.
	DAC TEMP1		/LOAD ADDRESS FOR CONSTANT.
 
	LAC DATA1		/STORE 1ST CONSTANT WORD.
	JMS STORE
 
/ CODE BITS ARE IN THE LOAD ADDRESS WORD. 00 (INTEGER - 1 WORD);
/ 01 (REAL - 2 WORDS); 10 (DOUBLE - 3 WORDS); 11 (LOGICAL - 1 WORD).
 
	LAC TEMP1		/GET CODE BITS (1-2).
	AND (300000
	SZA
	SAD (300000
	JMP BUFCHK	/CODES 00 OR 11 HAVE ONLY 1 WORD.
 
	RTL		/LINK=0 IF CODE 01; LINK=1 IF CODE 10.
	LAC DATA2		/STORE 2ND CONSTANT WORD.
	JMS STORE
 
	LAC DATA3
	SZL		/SKIP IF CODE IS 01.
	DAC* TEMP1
	JMP BUFCHK
 
	.EJECT
/ CODE 19 PROCESSOR: INTERNAL SYMBOL DEFINITION OR PROGRAM NAME.
 
CODE19	TAD (200000	/BIT0=1 IF IT IS A PROGRAM NAME.
			/CHANGE CODE TO 6 FOR SYMBOL TABLE ENTRY
			/OF A PROGRAM NAME; TO 2 FOR INTERNAL SYMBOL.
	TAD RELRUN	/ADD THE RUN-TIME RELOCATION FACTOR.
	DAC SYMDEF
	RAL		/SET LINK TO 1 IF A PROGRAM NAME.
 
/ IF THE PROGRAM BEING LOADED IS DDT, DON'T MAKE ANY ENTRIES IN THE
/ SYMBOL TABLE AND DON'T OUTPUT THE PROGRAM NAME IN THE MEMORY MAP.
 
	LAC DDTFLG	/FLAG IS NEGATIVE WHILE LOADING DDT.
	SPA!CMA
	JMP BUFCHK	/IGNORE CODE19 WHILE LOADING DDT.
	SNL!RTL		/PROGRAM NAME?
	JMP NOMAP		/NO.
	LAC MAPFUNC	/MEMORY MAP FUNCTION BITS.
	RAR
	LAC (120		/ASCII FOR P.
	SZL
	JMS MEMMAP	/PRINT PROGRAM NAME IN MAP.
	JMP IONAME
 
/ IF DDT IS IN CORE (BIT0=1), THEN THE PROGRAM NAME IS ENTERED IN THE SYMBOL
/ TABLE EVEN IF $DDTNS REQUESTED. IF NOT A PROGRAM NAME, THEN AC BIT0
/ IS 1 ONLY IF REQUEST WAS $DDT. OTHERWISE, DON'T ENTER THE SYMBOL
/ INTO THE SYMBOL TABLE.
 
NOMAP	SMA		/ENTER IN SYMBOL TABLE?
	JMP BUFCHK	/NO.
IONAME	LAC IOFLAG	/IS IT AN I/O HANDLER?
	SNA
	JMS DEFSYM	/NO. MAKE SYMTAB ENTRY.
	JMP BUFCHK
 
/ CODE 20 PROCESSOR: STRING CODE (FIRST HALF) - UNRELOCATED POINTER
/ TO AN INSTRUCTION WHOSE ADDRESS PART IS TO BE REPLACED (CODE 21).
 
CODE20	TAD RELLOD	/ADD LOAD-TIME RELOCATION FACTOR.
	DAC STRING	/SAVE POINTER TO THE INSTRUCTION.
	JMP BUFCHK
 
	.EJECT
/ CODE 21 PROCESSOR: STRING CODE (SECOND HALF) - UNRELOCATED ADDRESS
/ WHICH IS TO REPLACE THE ADDRESS PART OF AN INSTRUCTION (SEE CODE 20).
 
CODE21	JMS MOD13		/ADD THE RUN-TIME RELOCATION FACTOR
	DAC TEMP1		/MODULO 13 TO THIS ADDRESS.
	LAW
	AND* STRING	/SAVE INSTRUCTION PART AND INDIRECT BIT.
	TAD TEMP1		/ADD THE REPLACEMENT ADDRESS.
	DAC* STRING
	JMP BUFCHK
 
/ CODE 22 PROCESSOR: .IODEV REQUEST.
 
CODE22	SPA		/IF BIT0=1, REQUEST IS .IODEV ALL.
	JMP .+3
	JMS IODEV.	/REQUEST ONLY THIS .DATB SLOT.
	JMP BUFCHK
 
/ .IODEV ALL REQUESTS ALL POSITIVE .DATB SLOTS WITH NON-0 CONTENTS.
 
	DZM TEMP5
NEXPOS	IDX TEMP5		/UPDATE SLOT #.
	LAC TEMP5
	TAD DATB		/ADDRESS OF .DATB+0 .
	DAC TEMP4		/ADDRESS OF NEXT .DATB SLOT.
	SAD* DATB		/.DATB+0 CONTAINS POINTER TO .DATND .
	JMP BUFCHK
	LAC* TEMP4	/GET .DATB SLOT CONTENTS.
	SNA
	JMP NEXPOS	/IGNORE. CONTENTS=0.
	LAC TEMP5		/PICKUP SLOT #.
	JMS IODEV.	/PROCESS .IODEV REQUEST.
	JMP NEXPOS
 
/ CODE 23 PROCESSOR: END OF PROGRAM UNIT (PROGRAM START ADDRESS).
 
CODE23	DZM BLKFLG	/TURN OFF BLOCKDATA SUBPROGRAM FLAG
			/IN CASE IT WAS ON.
	TAD RELRUN	/ADD RUN-TIME RELOCATION FACTOR TO THE
	AND (77777	/PROGRAM START ADDRESS.
	JMP* LDPROG	/PROGRAM UNIT HAS BEEN LOADED. RETURN.
 
	.EJECT
/ UNRESOLVED GLOBALS. PRINT THE NAMES OF THE UNREOLVED GLOBALS
/ IN THE MEMORY MAP WITH A LOAD ADDRESS OF ZERO.
 
GLBERR	JMS UNGLOB
	JMS IOGLOB	/ANY UNDEFINED GLOBALS?
	SKP
	JMP NOMORE
	DZM* SYMWD1	/YES. KILL THE ENTRY IN THE SYMBOL TABLE
			/TO AVOID SEEING IT AGAIN.
	DZM RELRUN	/SET LOAD ADDRESS TO 0 FOR PRINTOUT.
	JMS NEXSYM	/PICKUP THE GLOBAL'S NAME.
	DAC SYM1
	JMS NEXSYM
	DAC SYM2
	LAC (107		/ASCII FOR G.
	JMS MEMMAP	/PRINT IN MEMORY MAP.
	JMP GLBERR	/CONTINUE UNTIL THEY'RE ALL DONE.
 
NOMORE	CAL 775		/WAIT FOR LAST MESSAGE TO FINISH.
	12
 
	JMP ERR110	/MISSING GLOBAL(S).
 
	.EJECT
/ SUBROUTINE IODEV.: CALLED WITH THE DATB SLOT # IN THE AC. SEVERAL CHECKS
/ ON THE REQUEST FOR AN I/O HANDLER ARE MADE IN ORDER TO PROTECT THE
/ FOREGROUND JOB. IF THE HANDLER'S ALREADY IN CORE, SET THE SLOT TO POINT
/ TO IT. IF NOT, MAKE A VIRTUAL GLOBAL ENTRY IN THE SYMBOL TABLE.
 
/ TEST THE LEGALITY OF THE .DATB SLOT.
 
IODEV.	0
	AND PLIT1		/(777 MASK AC TO DAT SLOT #.
	SNA
	JMP ERR111	/DAT SLOT 0 IS ILLEGAL.
	DAC TEMP1
	AND (400
	SZA		/TEST IF NEGATIVE DAT SLOT.
	LAW -1000		/YES.
	XOR TEMP1
	TAD DATB
	DAC SLOT		/SAVE SLOT ADDRESS.
	JMS TWOS
	TAD* DATB		/EXAMINE .DATB 0 FOR PTR TO .DATND .
	SNA!SPA		/IS SLOT ADDRESS TOO HIGH?
	JMP ERR111	/YES.
	LAC* DATB		/EXAMINE .DATND FOR PTR TO .DATBG .
	JMS EXAMIN
	JMS TWOS
	TAD SLOT
	SPA
	JMP ERR111	/SLOT ADDRESS IS TOO LOW.
 
/ CHECK CONTENTS OF .DATB SLOT.
 
	LAC* SLOT		/EXAMINE REQUESTED DAT SLOT.
	DAC RQUEST	/SAVE SLOT REQUEST.
	SPA
	JMP* IODEV.	/SLOT IS ALREADY SETUP.
	SNA
	JMP ERR112	/CONTENTS 0 ILLEGAL.
 
	.EJECT
/ SLOT REQUEST O.K. SO FAR. SEARCH THRU THE .IOIN TABLE TO SEE IF
/ THE HANDLER IS ALREADY THERE. NO ENTRIES WERE MADE FOR THE LINK
/ LOADER'S HANDLERS.
 
CKIOIN	LAC* (.SCOM+13
	DAC IOINPTR	/POINTER TO .IOIN, CONTAINING ENTRY COUNT.
	TAD (1
	DAC IOINMAX	/POINTER TO .IOIN+1, CONTAINING MAX. COUNT.
	DZM HANDLR	/HANDLER ADDRESS; 0=NOT IN THE TABLE.
	LAC* IOINPTR
	DAC IOINCT	/C(.IOIN)=ENTRY COUNT (2'S COMP).
	LAC IOINMAX
	DAC TEMP1
	IDX TEMP1
NXIOIN	IDX TEMP1		/MATCH 1ST WORD OF NEXT .IOIN ENTRY
	LAC* TEMP1	/AGAINST .DATB SLOT REQUEST.
	IDX TEMP1		/POINT TO 2ND ENTRY WORD.
	XOR RQUEST
	DAC IOINWD
	SNA
	JMP EXACT		/EXACT MATCH.
	AND (217600	/CHECK FOR DEVICE MATCH.
	SZA
	JMP DIFDVC	/IGNORE. DIFFERENT DEVICE.
 
/ DEVICES MATCH. IF LT19 BIT IS SET, THE HANDLER IS FOUND.
 
	LAC RQUEST	/C(.DAT SLOT).
	RAL
	SPA
	JMP GOTHND	/LT19 HANDLER.
	LAC IOINWD	/CHECK FOR OTHER HANDLER MATCH.
	AND PLIT16	/(177
	SZA
	JMP ERR113	/SAME DEVICE - DIFFERENT HANDLERS.
 
/ FOUND DEVICE AND HANDLER MATCH. SAVE A POINTER TO THE SECOND
/ WORD IN THIS .IOIN ENTRY.
 
GOTHND	LAC TEMP1
	DAC HANDLR
DIFDVC	ISZ IOINCT	/ANYMORE ENTRIES?
	JMP NXIOIN	/YES.
	LAC HANDLR	/WAS HANDLER FOUND?
	SNA
	JMP NOTIN		/NO.
 
	.EJECT
/ THE HANDLER'S IN THE TABLE (NOT NECESSARILY IN CORE YET), BUT A
/ NEW UNIT HAS BEEN REQUESTED. THE NON-RESIDENT MONITOR HAS MADE SURE
/ THAT IF BGD REQUESTS THE SAME DEVICE AS FGD, THE MULTIUNIT (SHAREABLE)
/ HANDLER IS IN CORE.
 
	JMS IONTRY	/PREPARE TO MAKE .IOIN ENTRY.
IOENTR	LAC RQUEST
	JMS STORE		/C(.DAT SLOT) IS 1ST ENTRY WORD.
	LAC* HANDLR	/IF BIT0=0 IN THE HANDLER'S DEFINITION,
	SPA		/IT'S PART OF A VIRTUAL GLOBAL CHAIN.
	JMP IN
	JMS CHNEND	/FIND END OF CHAIN.
	XOR* HANDLR
	XOR TEMP1
	DAC* HANDLR	/MAKE IT POINT TO NEW END OF CHAIN.
	LAC TEMP1		/2ND WORD OF NEW ENTRY (END OF CHAIN)
	DAC HANDLR
IN	DAC* TEMP1	/POINTS TO ITSELF.
	JMP SETDAT	/SETUP THE .DAT SLOT.
 
/ THE HANDLER IS NEITHER IN CORE NOR IN .IOIN. ENTER VIRTUAL GLOBAL
/ SYMBOL REFERENCE INTO THE SYMBOL TABLE AND .IOIN TABLE.
 
NOTIN	LAC RQUEST
	AND PLIT16	/(177 GET HANDLER CODE.
	SNA
	JMP ERR114	/CODE 0 IS ILLEGAL.
	TAD IOCPTR	/POINTER TO TOP REGISTER IN IOC TABLE,
	TAD* IOCPTR	/CONTAINING ENTRY COUNT (2'S COMP).
	TAD MINUS1
	JMS EXAMIN	/GET HANDLER NAME (1ST 3 CHARS).
	DAC SYM1
	LAC (127400	/RADIX 50 FOR PERIOD.
	DAC SYM2
	LAC TEMP1		/POINTER TO HANDLER NAME IN TABLE.
	JMS TWOS
	TAD IOCPTR	/POINTER TO LAST WORD IN TABLE.
	SPA!SNA
	JMP ERR114	/HANDLER CODE TOO HIGH.
	JMS IONTRY	/PREPARE TO MAKE .IOIN ENTRY.
	TAD (1
	DAC HANDLR	/POINTER TO 1ST FREE .IOIN ENTRY (2ND WORD).
	DAC* HANDLR	/MAKE IT POINT TO ITSELF.
	XOR PLIT7		/(100000 - VIRTUAL GLOBAL CODE.
	DAC SYMDEF
	JMS DEFSYM	/MAKE SYMTAB ENTRY.
	JMP IOENTR	/MAKE .IOIN ENTRY.
 
	.EJECT
/ CONTENTS OF THE .DAT SLOT EXACTLY MATCHES THE .IOIN ENTRY. THE NON-
/ RESIDENT MONITOR ALREADY MADE SURE THIS ISN'T A BGD/FGD CONFLICT.
 
EXACT	LAC TEMP1		/GET POINTER TO ENTRY WORD 2.
	DAC HANDLR
 
/ SETUP THE .DAT SLOT. IF THE HANDLER IS NOT IN CORE, LINK THE SLOT IN
/ THE VIRTUAL GLOBAL CHAIN.
 
SETDAT	LAC* HANDLR
	SPA
	JMP SETUP		/BIT0=1 MEANS DEFINED.
	JMS CHNEND	/FIND END OF CHAIN.
	XOR* HANDLR	/SAVE UNIT #.
	XOR SLOT		/MAKE IT POINT AT THE .DAT SLOT.
	DAC* HANDLR
	LAW
	AND RQUEST	/SAVE UNIT #.
	XOR (600000	/ADD "DEFINED" BIT AND LT19 BIT SO
			/REDUNDANT .IODEV W/B IGNORED AND RESMON
			/WON'T CALL NON-EXISTENT HANDLER TO STOP I/O.
	XOR SLOT		/MAKE SLOT POINT AT ITSELF
	JMP DACIT		/TO TERMINATE THE CHAIN.
SETUP	LAC RQUEST	/LT19 OR NOT?
	RAL
	SMA!RAR		/SKIP IF LT19.
	AND PLIT8		/(760000 SAVE UNIT #.
	XOR* HANDLR	/ADD DEFINITION.
DACIT	DAC* SLOT
 
/ IF THE HANDLER'S IN THE .MUD TABLE, REQUEST ANOTHER EXTERNAL BUFFER.
 
	LAC* (.SCOM+14	/POINTER TO .MUD TABLE.
	JMS EXAMIN
	DAC MUDCNT	/ENTRY COUNT (2'S COMP).
NEXMUD	IDX TEMP1
	LAC* TEMP1	/GET WORD 1 OF ENTRY,
	RTR		/SHIFT HANDLER CODE TO
	RTR		/MATCH AGAINST CODE
	RTR		/FROM THE .DAT SLOT.
	AND PLIT16	/(177
	SAD (1		/1=HANDLER CODE FOR TTA. .
	JMP NOPE		/TTA. NEEDS NO EXT. BUFFERS.
	XOR RQUEST	/C(.DAT SLOT) BEFORE SETUP.
	AND PLIT16	/(177
	SNA
	JMP GOTMUD
NOPE	IDX TEMP1		/NO MATCH YET.
	ISZ MUDCNT
	JMP NEXMUD
	JMP* IODEV.	/NON-MUD HANDLER; NO BUFFERS NEEDED.
 
	.EJECT
GOTMUD	LAC* TEMP1	/BIT0=1 IN WORD 1 OF .MUD ENTRY
	SPA		/IF USER ISSUED $FILES COMMAND.
	JMP* IODEV.
	AND (77
	DAC TEMP2		/CURRENT $FILES COUNT.
	LAC TEMP1
	DAC TEMP3
	IDX TEMP3
	LAC* TEMP3	/GET MAX. $FILES COUNT.
	AND (77
	SAD TEMP2		/OLD $FILES COUNT = MAX. $FILES?
	JMP ERR104	/YES. COUNT OVERFLOW.
	IDX* TEMP1	/ADD 1 TO $FILES COUNT.
	JMP* IODEV.
 
/ SUBROUTINE IONTRY: GET POINTER TO FREE ENTRY IN .IOIN TABLE.
 
IONTRY	0
 
	LAC* IOINPTR
	SAD* IOINMAX
	JMP ERR103	/NO MORE ROOM IN .IOIN .
	TAD MINUS1
	DAC* IOINPTR	/ADD 1 TO ENTRY COUNT (2'S COMP).
	JMS TWOS
	RCL
	TAD IOINMAX
	DAC TEMP1		/POINTER TO 1ST WORD OF FREE ENTRY.
	JMP* IONTRY
 
/ SUBROUTINE CHNEND: FIND END OF VIRTUAL GLOBAL CHAIN.
 
CHNEND	0
 
	LAC* HANDLR
	AND (17777
	SAD HANDLR
	JMP* CHNEND
	DAC HANDLR
	JMP .-5
 
	.EJECT
/ SUBROUTINE IOGLOB: STARTING AT THE BEGINNING OF THE SYMBOL TABLE, SEARCH
/ FOR ANY UNRESOLVED I/O GLOBALS. IF NOT FOUND, SKIP ON RETURN. IF FOUND,
/ DOUBLE SKIP ON RETURN.
 
IOGLOB	0
 
	STL		/SET LINK FOR I/O GLOBAL.
	JMS FNDGLB
	IDX IOGLOB	/FOUND.
	IDX IOGLOB	/NOT FOUND.
	JMP* IOGLOB
 
/ SUBROUTINE UNGLOB: STARTING AT THE BEGINNING OF THE SYMBOL TABLE, SEARCH
/ FOR ANY UNRESOLVED NON-I/O GLOBALS. IF FOUND, SKIP ON RETURN.
 
UNGLOB	0
 
	CLL		/CLEAR LINK FOR NON-I/O GLOBAL.
	JMS FNDGLB
	IDX UNGLOB
	JMP* UNGLOB	/FOUND ONE; SKIP ON RETURN.
 
/ SUBROUTINE FNDGLB: SEARCH FOR A VIRTUAL GLOBAL IN SYMBOL TABLE.
 
FNDGLB	0
 
	JMS BEGSYM	/START AT BEG OF SYMTAB.
	JMS FINDCOD	/SEARCH FOR
	100000		/VIRTUAL GLOBAL ENTRY.
	IDX FNDGLB	/RETURN HERE IF NONE FOUND.
	JMP* FNDGLB	/HERE IF FOUND.
 
	.EJECT
/ 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. IF SEARCH CODE IS 100000,
/ (VIRTUAL GLOBAL), LINK=0 ASKS FOR NON-I/O VIRTUAL GLOBAL; LINK=1 ASKS
/ FOR I/O VIRTUAL.
 
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 PLIT6		/(700000 MASK TO CODE BITS.
	SAD* FINDCOD	/MATCH?
	JMP .+3		/YES.
 
NOMATCH	JMS NXNTRY	/MOVE POINTER TO THE NEXT ENTRY.
	JMP NEXCOD
 
	SAD PLIT7		/(100000 VIRTUAL GLOBAL CODE?
	JMP WHICH1	/YES. WHICH ONE - I/O OR NON-I/O?
 
FOUND	IDX FINDCOD
NOFIND	IDX FINDCOD
	JMP* FINDCOD
 
WHICH1	XOR* SYMWD1	/WHERE IN CORE DOES GLOBAL POINT?
	CMA!CLL
	TAD* (.SCOM+25	/CONTAINS: REGISTER ABOVE THE FOREGROUND JOB.
 
/ IF THE LINK=0, MEANING THE GLOBAL POINTS TO A REGISTER ABOVE THE
/ FOREGROUND JOB, IT IS NOT AN I/O GLOBAL.
 
	RAR		/GET LINK INTO AC0.
	XOR FINDCOD	/COMPARE TO LINK AS IT WAS ON ENTRY TO
	SPA		/THIS SUBROUTINE. SKIP IF CORRECT TYPE.
	JMP NOMATCH
	JMP FOUND
 
	.EJECT
/ SUBROUTINE FIT: THIS IS THE GENERAL SUBROUTINE THAT ASSIGNS CORE SPACE
/ FOR ALL PROGRAMS, COMMON BLOCKS, I/O HANDLERS, AND I/O HANDLER BUFFERS.
/ IT CHECKS BLKFLG, COMFLG, IOFLAG, AND BUFFLG IN ORDER TO MAKE THE
/ RELEVANT TESTS AND TO DETERMINE WHERE TO SET THE LOAD ADDRESS AND THE
/ RELOCATION FACTORS (LOAD-TIME AND RUN-TIME).
 
FIT	0
 
	DZM IOLOW		/0 MEANS THAT IF AN I/O HANDLER IS
			/BEING LOADED IT WILL BE LOADED HIGH NOW
			/(ABOVE AS OPPOSED TO BELOW THE LOADER).
	LAC BUFFLG	/ARE HANDLER BUFFERS  BEING ASSIGNED SPACE NOW?
	SZA
	JMP IOFIT		/YES.
	LAC IOFLAG	/ARE I/O HANDLERS BEING LOADED NOW?
	SNA
	JMP LOADHI	/NO.
 
/ IS THERE ANY ROOM BELOW THE LOADER TO LOAD THIS HANDLER IN NOW? IF SO,
/ COMPUTE HOW MUCH ROOM WILL REMAIN; THEN SET IOLOW TO INDICATE THAT
/ THE HANDLER IS LOADING LOW.
 
	LAC HIHAND	/HANDLER MUST LOAD AT AN ADDRESS EVENLY
	AND (3		/DIVISIBLE BY 4. ADJUST BOTH HIHAND
	SNA!CMA		/AND LOROOM ACCORDINGLY.
	JMP LOWTST
	TAD (5
	DAC TEMP1
	TAD HIHAND
	DAC HIHAND
	LAC TEMP1
	JMS TWOS
	TAD LOROOM
	DAC LOROOM
	SPA
	DZM LOROOM
LOWTST	LAC LOROOM
	TAD SIZE
	SPA		/ENOUGH ROOM BELOW THE LOADER?
	JMP LOADHI	/NO.
	DAC LOROOM	/SAVE HOW MUCH IS LEFT.
	SET IOLOW		/FLAG NON-0 MEANS LOAD HANDLER
	JMP IOFIT		/BELOW THE LINK LOADER NOW.
 
	.EJECT
LOADHI	LAC BANKS		/(BANK0+4
	DAC TEMP1
 
NXBANK	LAC TEMP1		/IS THIS THE LOWEST BANK?
	SAD PBANK0	/(BANK0 .
	JMP ERR100	/YES. NO MORE TO LOOK AT. NO FIT.
NXBNK1	TAD MINUS1
	DAC TEMP2
	JMS EXAMIN	/NO. LOOK AT NEXT LOWER BANK.
	SNA		/ANY ROOM IN IT?
	JMP NXBANK	/NO. TRY NEXT LOWER BANK.
	TAD (1		/YES. SUBTRACT PROGRAM SIZE
	TAD SIZE		/AND SAVE AS THE
	DAC RELLOD	/LOAD-TIME RELOCATION FACTOR,
	DAC RELRUN	/RUN-TIME RELOCATION FACTOR,
	DAC LOADADR	/AND THE PROGRAM'S LOADING ADDRESS.
 
	LAC BLKFLG	/IS THIS A BLOCKDATA SUBPROGRAM, I/O HANDLER,
	TAD COMFLG	/OR ARE COMMON BLOCKS BEING ASSIGNED?
	TAD IOFLAG
	SNA
	JMP NONCOM	/NO.
 
BNKLOOP	LAC LOADADR	/YES. IS LOAD ADDRESS IN THIS BANK?
	XOR* TEMP1
	AND PLIT8		/(760000
	SNA
	JMP ZLOOP		/YES.
 
	LAC TEMP1		/ARE THERE ANY BANKS BELOW THE PRESENT ONE?
	SAD PBANK0	/(BANK0 .
	JMP ERR100	/NO.
 
	TAD MINUS1	/YES. IS THE NEXT LOWER BANK UNUSED, I.E. IS
	JMS EXAMIN	/ITS HIGHEST FREE ADDRESS=17777(MOD 13)?
	AND (17777
	SAD (17777
	JMP BNKLOOP	/YES.
	LAC TEMP2		/NO. START AGAIN WITH NEXT LOWER BANK.
	JMP NXBNK1
 
ZLOOP	LAC TEMP2		/ZERO ALL HIGHER BANK POINTERS
ZLOOP1	SAD TEMP1		/TO INDICATE THAT THOSE BANKS
	JMP NUBPTR	/ARE COMPLETELY USED UP.
	DZM* TEMP2
	TAD MINUS1
	DAC TEMP2
	JMP ZLOOP1
 
	.EJECT
NONCOM=.
PLIT13	LAW -20		/THE PROGRAM MAY NOT LOAD INTO REGISTERS
	TAD LOADADR	/0 THRU 17 OF ANY MEMORY BANK AND MAY
	XOR* TEMP1	/NOT OVERLAP MEMORY BANKS.
	AND PLIT8		/(760000
	SZA		/DOES IT FIT IN THIS BANK?
	JMP NXBANK	/NO.
NUBPTR	LAW -1
	TAD LOADADR	/YES. SET THE HIGHEST FREE ADDRESS IN THIS
	DAC* TEMP1	/BANK TO JUST BELOW THE LOAD ADDRESS OF
	DAC TEMP7		/THIS PROGRAM.
	SPA
	JMP ERR100	/MEMORY UNDERLAP.
	AND (17777	/IS THE CURRENT BANK USED UP?
	SAD (17777
	DZM* TEMP1	/YES. 0 THE POINTER TO INDICATE NO ROOM.
 
	LAC COMFLG	/ARE COMMON BLOCKS BEING ASSIGNED NOW?
	SZA
	JMP USERLOW	/YES.
 
	LAC LOADADR
	JMS TWOS
	TAD SYMEND	/DOES THIS PROGRAM OVERLAP THE SYMBOL TABLE?
	SMA
	JMP ERR101	/YES. NO FIT.
	JMS LOWER		/SKIP ON RETURN.
HISYM	0		/HIGHEST REGISTER AVAILABLE TO SYMTAB.
 
/ IS THIS PROGRAM AN I/O HANDLER OR NOT? IF NOT, RECOMPUTE THE HIGHEST
/ FREE ADDRESS BELOW THE USER'S PROGRAMS.
 
	LAC IOFLAG	/IS THIS AN I/O HANDLER BEING LOADED?
	SZA
	JMP IOFIT		/YES. MORE TO BE DONE.
 
USERLOW	JMS LOWER		/SKIP ON RETURN.
HIFREE	0		/HIGHEST FREE REGISTER BELOW USER PROGS.
 
/ FOR PROGRAM SEGMENTS WITH EXECUTABLE CODE, RECOMPUTE THE HIGHEST
/ FREE REGISTER BELOW EXECUTABLE CODE. NEEDED LATER ON TO CHECK
/ AGAINST HARDWARE MEMORY PROTECT BOUND.
 
	LAC COMFLG
	TAD BLKFLG
	SZA
	JMP* FIT		/NOT EXECUTABLE CODE.
	JMS LOWER		/SKIP ON RETURN.
XCTBND	0		/REGISTER BELOW EXECUTABLE CODE.
	JMP* FIT
 
	.EJECT
/ SUBROUTINE LOWER: IF C(TEMP7) IS LESS THAN C(ARGUMENT),
/ REPLACE LATTER WITH THE FORMER.
 
LOWER	0
 
	LAC TEMP7
	CMA!CLL
	TAD* LOWER
	LAC TEMP7
	SZL
	DAC* LOWER
	IDX LOWER
	JMP* LOWER
 
/ ASSIGN RUN-TIME SPACE FOR I/O HANDLER OR HANDLER BUFFER.
 
IOFIT	LAC BANKS		/(CORE0-1 .
	DAC TEMP1
 
NXCORE	IDX TEMP1		/POINT TO NEXT HIGHER BANK.
NXCOR1	LAC TEMP1
	DAC TEMP7
	SAD CORES		/(CORE0+4
	JMP ERR100	/NO MORE BANKS. NO FIT.
 
	LAC* TEMP1
	SNA		/ANY ROOM IN THIS BANK?
	JMP NXCORE	/NO. TRY NEXT HIGHER ONE.
	DAC RELRUN	/SAVE 1ST FREE BANK ADDRESS AS THE
			/RUN-TIME RELOCATION FACTOR.
	LAC BUFFLG
	SZA
	JMP NOCHNG
	LAC RELRUN	/ADJUST RUN-TIME LOAD ADDRESS FOR I/O
	AND (3		/HANDLER TO START AT A LOCATION
	SNA!CMA		/EVENLY DIVISIBLE BY 4.
	JMP NOCHNG
	TAD (5
	TAD RELRUN
	DAC RELRUN
NOCHNG	LAC SIZE		/ADD SIZE TO DETERMINE THE LAST
	CMA		/REGISTER IN THE HANDLER OR BUFFER.
	TAD RELRUN
	DAC TEMP2		/SAVE LAST ADDRESS.
	XOR RELRUN	/IS LAST ADDRESS IN SAME BANK AS THE 1ST?
	AND PLIT8		/(760000
	SNA!CLA
	JMP CHKLOW	/YES.
 
	.EJECT
	SAD BUFFLG	/NO. ARE I/O BUFFERS NOW BEING ASSIGNED?
	JMP NXCORE
 
	IDX TEMP1		/YES. LOOK AT NEXT HIGHER BANK.
	LAC TEMP1
	SAD CORES		/ARE THERE ANY MORE BANKS?
	JMP ERR100	/NO.
 
	LAC* TEMP1	/IS NEXT BANK UNUSED, I.E. IS 1ST FREE
	AND (17777	/REGISTER IN THAT BANK=20(MOD 13)?
	SAD (20
	SKP
	JMP NXCOR1	/NO. BUFFER CAN'T OVERLAP INTO THIS BANK.
 
	DZM* TEMP7	/0 PRESENT BANK POINTER; ROOM IN IT USED UP.
	LAC TEMP2		/IS THE LAST ADDRESS OF THE BUFFER
	AND (17777	/(WHICH FALLS IN THE NEXT HIGHER BANK)
	TAD PLIT13	/(-20
	SPA		/LOWER THAN 20 (ADDRESS MOD 13)?
	JMP UPHIHN	/YES.
	JMP UPDBPT
 
CHKLOW	SAD IOLOW		/IS HANDLER LOADING NOW BELOW LOADER?
	JMP UPDBPT	/NO.
	LAC RELRUN	/YES. CHANGE THE LOAD ADDRESS
	DAC LOADADR	/AND LOAD-TIME RELOCATION FACTOR.
	DAC RELLOD
 
UPDBPT	LAC TEMP2		/UPDATE POINTER TO 1ST FREE LOCATION
	DAC* TEMP1	/IN THIS BANK.
	IDX* TEMP1
 
UPHIHN	LAC HIHAND	/HIGHEST FREE REGISTER ABOVE THE HANDLERS
	CMA!CLL		/AND HANDLER BUFFERS AT RUN-TIME.
	TAD* TEMP1	/POSSIBLE NEW VALUE IF HIGHER THAN OLD ONE.
			/OVERFLOW GOES TO THE LINK.
	LAC* TEMP1
	SZL		/IS NEW VALUE HIGHER?
	DAC HIHAND	/YES. REPLACE THE OLD ONE.
	AND PLIT6		/(700000
	SZA		/HAVE WE OVERLAPPED ALL OF MEMORY?
	JMP ERR100	/YES.
	LAC* TEMP1	/0 THE POINTER IF BANK SPACE USED UP.
	AND (17777
	SNA
	DZM* TEMP1
 
	.EJECT
	LAC BUFFLG	/ARE BUFFERS BEING ASSIGNED NOW OR
	TAD IOLOW		/IS HANDLER LOADING NOW BELOW LOADER?
	SZA
	JMP* FIT		/YES.
 
/ HANDLER IS LOADING ABOVE THE LOADER. SINCE IT MIGHT BE ASSIGNED TO
/ SPACE CURRENTLY FREE BELOW THE LOADER, RECOMPUTE LOROOM.
 
	LAW -FIRST	/ 2'S COMPLEMENT OF LOADER'S 1ST ADDRESS.
	TAD RELRUN	/DOES THIS HANDLER RUN BELOW THE CURRENT POSITION
	SMA		/OF THE LOADER?
	JMP IOSYM		/NO.
 
	LAC LOROOM	/YES. SUBTRACT HANDLER SIZE FROM LOROOM.
	TAD SIZE
	SPA
	CLA
	DAC LOROOM
 
/ MAKE AN ENTRY IN THE SYMBOL TABLE USING CODE 0: WORD 1: 000000 +
/ PRESENT STARTING LOCATION OF THE HANDLER. WORD 2: 400000 + PRESENT
/ LAST LOCATION OF THE HANDLER. WORD 3: RUN-TIME LOCATION OF HANDLER.
 
IOSYM	LAC LOADADR
	JMS ENTSYM	/ENTER: 000000 + PRESENT 1ST LOCATION.
	LAC SIZE
	CMA
	TAD LOADADR
	XOR (400000
	JMS ENTSYM	/ENTER: 400000 + PRESENT LAST ADDRESS.
	LAC RELRUN
	JMS ENTSYM	/ENTER: RUN-TIME 1ST ADDRESS.
	JMP* FIT
 
	.EJECT
/ SUBROUTINE ABSOFF:
 
ABSOFF	0
 
	LAC ABSFLG	/NON-0 IF ABS LOADING ALLOWED.
	SNA
	JMP* ABSOFF	/FLAG ALREADY TURNED OFF.
	LAC HIFREE	/HIGHEST FREE REGISTER BELOW USER PROGS.
	DAC XCTBND	/REGISTER BELOW EXECUTABLE CODE.
	RTL
	RTL
	RTL
	AND (3		/GET BANK BITS.
	TAD PBANK0	/(BANK0
	DAC TEMP1		/POINTER TO POINTER TO HIGHEST FREE BANK.
	LAC HIFREE
	JMS STORE		/SAVE HIGHEST FREE LOCATION.
	LAC TEMP1		/ANY HIGHER BANKS?
	SAD BANKS
	JMP .+3		/NO.
	CLA		/YES. ZERO HIGHER BANK POINTERS.
	JMP .-5
	DZM ABSFLG	/DISALLOW FURTHER ABS PROGRAM LOADING.
	JMP* ABSOFF
 
	.EJECT
/ SUBROUTINE MOD13: ADD, TO THE ADDRESS PART OF THE RELOCATABLE
/ INSTRUCTION IN THE AC, THE RUN-TIME RELOCATION FACTOR (MODULO 13).
 
MOD13	0
 
	DAC TEMP1
	LAC RELRUN
	AND (17777
	TAD TEMP1
	JMP* MOD13
 
/ 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
 
	IDX SYMEND	/INDEX END-OF-SYMTAB POINTER.
	LAC HISYM		/HIGHEST REGISTER AVAILABLE TO SYMTAB.
	CMA
	ADD SYMEND
	SPA		/OVERFLOW?
	JMP* UPSYM	/NO.
	JMP ERR101
 
	.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.
	IDX SYMPTR
	IDX SYMPTR
 
	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.
	IDX SYMPTR	/COMMON BLOCK ENTRY IS 2 WORDS LONGER
	IDX SYMPTR	/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
 
	IDX SYMPTR
	LAC* SYMPTR
	JMP* NEXSYM
 
/ SUBROUTINE TWOS:
 
TWOS	0
 
	CMA
	TAD (1
	JMP* TWOS
 
/ SUBROUTINE BEGSYM:
 
BEGSYM	0
 
	LAC SYMBEG
	DAC SYMWD1
	DAC SYMPTR
	JMP* BEGSYM
 
	.EJECT
/ SUBROUTINE SYMSCAN: SEARCH FROM THE BEGINNING OF THE SYMBOL TABLE
/ FOR A GLOBAL OR A COMMON ENTRY (3 OR 7 = COMMON; 1 OR 5 = GLOBAL)
/ WHOSE NAME MATCHES SYM1 AND SYM2. RETURN 0 IF NOT FOUND. RETURN
/ 15-BIT DEFINITION OF THE ENTRY IF FOUND.
 
SYMSCAN	0
 
	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.
	JMP* SYMSCAN
 
/ SUBROUTINE SCAN: SCAN SYMBOL TABLE TO SEE IF ENTRY HAS ALREADY BEEN MADE.
 
SCAN	0
 
	DAC SYMDEF	/SAVE SYMBOL DEFINITION WITH CODE BITS.
	JMS SYMSCAN	/SEARCH SYMTAB FOR CODE AND NAME MATCH.
	SNA		/0 RETURNED IN AC IF NOT FOUND.
	IDX SCAN		/NOT FOUND.
	JMP* SCAN		/FOUND.
 
	.EJECT
/ SUBROUTINE DEFCOM: GO THROUGH THE COMMON BLOCK CHAIN AND DEFINE
/ EACH MEMBER (IF ANY) OF THE COMMON BLOCK.
 
DEFCOM	0
 
	LAC* COMCHN	/GET STARTING ADDRESS OF THE CHAIN.
	DZM* COMCHN	/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 COMCHN	/SET POINTER TO NEXT CHAIN ENTRY.
	TAD (1		/SET POINTER TO WORD2 OF CHAIN ENTRY
	DAC COM.TV	/(WHICH POINTS AT A TRANSFER VECTOR).
	LAC* COM.TV
	DAC COM.TV	/SAVE ADDRESS OF THE TRANSFER VECTOR.
	LAC* COM.TV	/GET CONTENTS OF THE VECTOR: THE ADDRESS
			/OF THIS COMMON ENTRY RELATIVE TO THE
			/BEGINNING OF THE COMMON BLOCK.
	TAD* COMDEF	/ADD THE COMMON BLOCK BASE ADDRESS.
	DAC* COM.TV	/STORE TRUE ADDRESS IN THE TRANSFER VECTOR.
 
	LAC* COMCHN	/GET POINTER TO NEXT CHAIN ENTRY.
	AND (77777	/MASK OFF THE CODE BITS.
	JMP DEFLOOP
 
/ SUBROUTINE EXAMIN:
 
EXAMIN	0
 
	DAC TEMP1
	LAC* TEMP1
	JMP* EXAMIN
 
/ SUBROUTINE STORE:
 
STORE	0
 
	DAC* TEMP1
	IDX TEMP1
	JMP* STORE
 
	.EJECT
/ SUBROUTINE MEMMAP: PRINT THE PROGRAM NAME, THE GLOBAL SYMBOL, OR
/ THE COMMON BLOCK AND DEFINITION IN THE MEMORY MAP.
 
MEMMAP	0
 
	DAC TEMP1		/SAVE DESCRIPTOR CHARACTER (C,G, OR SPACE).
 
	CAL 775		/.WAIT FOR ANY PREVIOUS TYPEOUT TO FINISH.
	12
 
	LAC TEMP1
	DAC CHAR1
	LAC (SYMBOL	/SETUP POINTER FOR STORING CHARACTERS
	DAC TEMP1		/IN THE WRITE BUFFER.
	LAC SYM1		/GET 1ST HALF OF SYMBOL.
	AND (377777	/MASK OFF THE CODE BIT.
	JMS CONVERT	/UNPACK RADIX 50, CONVERT TO ASCII,
			/AND STORE IN THE WRITE BUFFER.
	LAC SYM1		/BIT0=0 MEANS THERE'S NO SYM2.
	SPA!CLA		/IF SO, INSERT 3 SPACES.
	LAC SYM2
	JMS CONVERT
	IDX TEMP1		/SKIP OVER THE SPACE CHARACTER.
 
/ CONVERT THE LOAD ADDRESS TO OCTAL ASCII AND STORE IN WRITE BUFFER.
 
	LAW -5		/SETUP 5-DIGIT COUNT.
	DAC TEMP2
	LAC RELRUN	/RUN-TIME LOAD ADDRESS.
	RTL
	RTL
NXDGIT	RTL
	RAL
	DAC TEMP3		/SAVE REMAINDER.
	AND (7
	TAD (60		/CONVERT TO ASCII.
	JMS STORE		/STORE DIGIT IN WRITE BUFFER.
	LAC TEMP3
	ISZ TEMP2
	JMP NXDGIT
 
/ WRITE LINE IN THE MEMORY MAP.
 
	CAL 3775		/.WRITE IMAGE ALPHA ON TTY.
	11
	MEMBUF
PLIT23	33
 
	JMP* MEMMAP
 
	.EJECT
/ MEMORY MAP LINE BUFFER (IMAGE ALPHA).
 
MEMBUF	11000
PLIT24	34
 
CHAR1	XX		/DESCRIPTOR CHARACTER (C,G, OR P).
	40
SYMBOL	.BLOCK 6		/PROGRAM, GLOBAL, OR COMMON BLOCK NAME.
SPACE	40
	.BLOCK 5		/5-DIGIT OCTAL LOAD ADDRESS.
PLIT14	15		/CAR. RET.
PLIT15	12		/LINE FEED.
 
/ SUBROUTINE CONVERT: UNPACK CHARACTERS FROM RADIX 50 WORD IN THE AC.
/ CHANGE TO ASCII AND STORE SEQUENTIALLY IN THE MEMORY MAP BUFFER.
 
CONVERT	0
 
	JMS DIVIDE
	-3100		/50 X 50 OCTAL.
	JMS DIVIDE
	-50
	JMS DIVIDE
	-1
	JMP* CONVERT
 
/ SUBROUTINE DIVIDE: DIVIDEND IN THE AC; DIVISOR (2'S COMPLEMENT)
/ FOLLOWS THE JMS DIVIDE. STORE QUOTIENT IN WRITE BUFFER.
 
DIVIDE	0
 
	DZM TEMP3		/THE QUOTIENT.
 
DIVLOOP	DAC TEMP4		/SAVE REMAINDER.
	TAD* DIVIDE	/SUBTRACT DIVISOR.
	SPA
	JMP .+3		/DONE.
	IDX TEMP3
	JMP DIVLOOP
 
	.EJECT
/ CONVERT RADIX 50 OCTAL TO ASCII.
 
	LAC TEMP3		/QUOTIENT=RADIX 50 CHARACTER.
	SNA		/SPACE?
	LAW -40
	SAD PLIT23	/(33 % ?
PLIT17	LAW -33
	SAD PLIT24	/(34 . ?
	LAC PLIT23	/(33
	SAD (47		/ # ?
	LAW -35
	TAD PLIT17
	SPA
	TAD (55		/A - Z
	TAD (56		/0 - 9
	JMS STORE
	LAC TEMP4		/PICKUP REMAINDER.
	IDX DIVIDE
	JMP* DIVIDE
 
/ SUBROUTINE BUILDX: IF THERE'S ROOM TO DO SO, MAKE A 3-WORD ENTRY AT
/ THE FRONT OF THE .EXIT LIST.
 
BUILDX	0
 
	LAW -3		/ROOM FOR ENTRY?
	TAD HISYM
	DAC TEMP1
	IDX TEMP1
	DAC HISYM
	CMA
	ADD SYMEND
	SMA
	JMP ERR117	/NO. .EXIT LIST RAN INTO SYMTAB.
	LAC* SYMPTR	/YES. PICKUP 3 WORD ENTRY; PUT IN .EXIT LIST.
	JMS STORE
	JMS NEXSYM
	AND (77777
	JMS STORE
	JMS NEXSYM
	DAC* TEMP1
	JMP* BUILDX
 
	.EJECT
/ EXIT TO THE MONITOR WITH THE CODE FOR THE ERROR MESSAGE TO BE PRINTED.
 
ERR117	IDX ERRXIT	/.EXIT LIST OVERLAP.
	IDX ERRXIT
ERR115	IDX ERRXIT	/ABSOLUTE PROGRAM ERROR.
ERR114	IDX ERRXIT	/ILLEGAL HANDLER CODE.
ERR113	IDX ERRXIT	/SAME DEVICE - DIFFERENT HANDLERS.
ERR112	IDX ERRXIT	/.DAT CONTENTS = 0.
ERR111	IDX ERRXIT	/ILLEGAL .DAT NUMBER.
ERR110	IDX ERRXIT	/MISSING GLOBAL(S).
ERR107	IDX ERRXIT	/COMMON BLOCK SIZE ERROR.
ERR106	IDX ERRXIT	/ILLEGAL LOADER CODE.
ERR105	IDX ERRXIT	/PARITY, CHECKSUM, OR BUFFER OVERFLOW.
ERR104	IDX ERRXIT	/$FILES OVERFLOW.
ERR103	IDX ERRXIT	/.IOIN OVERFLOW.
ERR102	IDX ERRXIT	/.BFTAB OVERFLOW.
ERR101	IDX ERRXIT	/PROGRAM AND SYMBOL TABLE OVERLAP.
 
ERR100	CAL 775		/.INIT -3 TO STOP .READ, TO
	1		/DISABLE ^P, AND TO PRINT
	0		/CAR. RET. LINE FEED.
	0
 
/ CAL 6XXX = BGD TERMINAL ERROR.
 
ERRXIT	CAL 6100		/NO ROOM.
	16		/ERROR EXIT CODE.
 
/ TELETYPE MESSAGES:
 
MSG1=.-2
	.ASCII /BGLOAD V1A/<15>
	.LOC .-1
MSG2=.-2
	.ASCII />/<175>
	.LOC .-1
MSG3=.-2
	.ASCII /^P/<175>
PLIT12=.-1		/(500000
 
	.EJECT
/ COUNTS:
 
SIZE	0		/2'S COMPLEMENT OF PROGRAM SIZE.
WRDCNT	0		/IOPS BINARY BLOCK WORD COUNT.
CDWCNT	0		/CODE WORD BLOCK COUNTER.
LOROOM	0		/FREE ROOM BELOW THE LOADER FOR
			/LOADING I/O HANDLERS AT LOAD-TIME.
XITCNT	0		/# OF 3-WORD .EXIT LIST ENTRIES.
 
/ DATA:
 
MAPFUNC	0		/MEMORY MAP FUNCTION BITS; 0=NO MAP WHILE
			/DDT IS LOADING.
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
DATA3	0
PLIT11	17
PLIT16	177
PLIT20	7777
TEMP2	0
 
/ DIRECTORIES:
 
USRLIB	.SIXBT /.LIBR@BIN/
F4LIB	.SIXBT /.F4LIBBIN/
IOLIB	.SIXBT /.IOLIBBIN/
BIN=.-1
 
	.EJECT
/ POINTERS:
 
BCTL.P	0		/TO BGD ^P REGISTER IN RESMON.
BCTL.T	0		/TO BGD ^T REGISTER IN RESMON.
SET.T	0		/0=NO DDT;IF DDT, CONTAINS ^T RETURN ADDRESS.
DIRPTR	0		/TO BEG OF PROGRAM DIRECTORIES TABLE.
IOCPTR	0		/TO I/O HANDLER CONVERSION TABLE.
IOINPTR	0		/TO .IOIN: CONTAINS ENTRY COUNT (2'S COMP).
IOINMAX	0		/TO .IOIN+1: CONTAINS MAX. ENTRY COUNT (2'S).
SYMBEG	0		/TO BEG OF SYMBOL TABLE.
SYMEND	0		/TO LAST SYMTAB REGISTER + 1.
SYMWD1	0		/TO 1ST WORD OF A SYMTAB ENTRY.
SYMPTR	0		/TO SOMEWHERE WITHIN A SYMTAB ENTRY.
UPRLIM	0		/HIGHEST ALLOWABLE ABS LOAD ADDRESS.
HIHAND	0		/TO LAST HANDLER/BUFFER REGISTER + 1 (RUN-TIME).
LOFREE	0		/TO 1ST HANDLER/BUFFER REGISTER (RUN-TIME).
LOADADR	0		/PROGRAM'S LOAD ADDRESS.
RELLOD	0		/LOAD-TIME RELOCATION FACTOR.
RELRUN	0		/RUN-TIME RELOCATION FACTOR.
BUFPTR	0		/TO LINE BUFFER #1 OR #2.
DATB	.SCOM+17		/INITIALLY TO .SCOM+17, WHICH POINTS AT .DATB.
			/THEN .DATB IS STORED HERE.
BANK0	17777		/HIGHEST FREE REGISTER FOR EACH OF 4
BANK1	37777		/POSSIBLE MEMORY BANKS.
BANK2	57777
BANK3	77777
BANKS	.		/(BANK0+4 AND (CORE0-1 .
CORE0	20		/LOWEST FREE REGISTER FOR EACH OF 4
CORE1	20020		/POSSIBLE MEMORY BANKS.
CORE2	40020
CORE3	60020
CORES	.
PBANK0	BANK0		/USED AS A LITERAL.
PDATA1	DATA1		/USED AS A LITERAL.
 
/ FLAGS:
 
SCOM6	0		/BITS 0-2 FROM .SCOM+6 (TYPE-OF-LOAD CODE).
DDTFLG	0		/SAME AS ABOVE. BIT 0 IS TURNED OFF AFTER
			/DDT HAS BEEN LOADED.
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.
IOFLAG	0		/SET NON-0 WHEN LOADING IN I/O HANDLERS.
IOLOW	0		/SET NON-0 WHEN I/O HANDLER LOADS BELOW
			/THE LOADER AT LOAD-TIME.
COMFLG	0		/SET NON-0 WHEN DEFINING NON-BLOCKDATA COMMON.
BUFFLG	0		/SET NON-0 WHEN ASSIGNING I/O BUFFERS.
ABSFLG	0		/NON-0 MEANS ABS PROGRAMS MAY BE LOADED.
			/LOWEST REGISTER LOADED IS STORED IN THE FLAG.
 
	.END BFLOAD
