	.SYSID <	.TITLE EXECUTE >,< 000>
/
/  EDIT#003	NS.DG	7-APR-74
/	004	SK	22-OCT-74	ENABLE BANK MODE OPERATION
/	005	SK	30-OCT-74	PERMIT EXTRA 4K
/					REMOVE RESTRICTION ON MAXM. # OF LINKS
/					REMOVE ILLEGAL PDP-9 INST.
/	006	SK	1-NOV-74	BOSS15 SETUP FOR TTY I/O
/	007	EAG	6-JAN-75	CHANGE HELLO MESSAGE TO V3B000
/	008	EAG	25-JUN-75	CHANGE CLEAR SUBROUTINE	/EAG:008
/					SO IT WON'T CLOBBER	/EAG:008
/					BOOTSTRAP WITH X4K	/EAG:008
/ 100	24-JUL-75 (RCHM)	CHANGE TO EXECUT AND MAKE XVM CHANGES.
/				SAVE AND RESTORE MQ, AC, AND SC AFTER OVERLAYS.
/ 101	04-AUG-75 (RCHM)	FIX MISUNDERSTANDING ABOUT .XVMON AND .XVM OFF.
/ 102	04-AUG-75 (RCHM)	USE NEW BIT IN ENVIRONMENT WORD FOR UPWARD
/				COMPATABILITY BETWEEN CHAINS.
/ 103	06-AUG-75 (RCHM)	NEW WORD IN RESIDENT LINK RECORD. WORD 20 IS NOW
/				THE WORD CONTAINING THE INFORMATION ON EXTENDED MEMORY
/				BOUNDS.
/ 103	15-OCT-75 (RCHM)	MAKE SURE HELLO DOES NOT APPEAR ON TTY
/				DURING BOSS PROCESSING.
/
/
/
/
/
/ GENERAL REMARKS:
/
/	THE SYSTEM LOADER ENTERS AT 'EXECUT'.
/	THE USER LINK TABLE ENTRY ENTERS AT 'LKOVLA'.
/
/	AC, LR, AUTO INDEX 10,11 ARE SAVED & RESTORED.
/
/	**** THE INPUT HANDLER MUST SUPPORT .TRAN & .FSTAT ***
/
/
/	THE PROGAM USES 1 BUFFER FROM THE BUFFER POOL DURING ITS OVERLAY
/	PROCESSING.  BEFORE ENTERING THE USER PROGRAM IT IS RELEASED.
/	NO BUFFERS ARE REQUIRED BY EXECUTE DURING USER PROGRAM
/	EXECUTION.
//
/
/ IF NO OVERLAYS:
/
/	THE MAIN PROGRAM IS LOADED IF IT CAN FIT & THEN EXECUT
/	FREES ITS BUFFER AND ITS CORE AREA.  CONTROL THEN GOES
/	TO THE USER PROGRAM'S MAIN ENTRY POINT.
/
/
/ IF OVERLAYS:
/
/	IF THE OVERLAY SYSTEM CAN FIT, EXECUT LOADS THE LINK TABLE,
/	RESIDENT CODE, & THEN EACH LINK & THEREBY BUILDS A RESIDENT
/	LINK POINTER TABLE (LPT).
/
/	THE LPT IS USED DURING OVERLAYS FOR DIRECT ACCESS OF THE LINKS
/	VIA TABLE LOOK-UP.
/
/	FOR STORAGE EFFICIENCY, THE LPT OVERWRITES THE SETUP CODE.
/
/
/	AFTER ESTABLISHING THE LPT, CONTROL IS PASSED TO THE USER
/	PROGRAM'S MAIN ENTRY POINT.
/
//
/
/
/
/ ERROR MESSAGES:
/
/
/	IOPS13...		FILE NOT FOUND
/	CAN'T FIT...		NOT ENOUGH CORE
/	TOO MANY LINKS...	LINK POINTER TABLE TOO SMALL
/	IOPS55...		NOT ENOUGH BUFFERS IN THE BUFFER POOL
/
/	CAN'T RUN...		WRONG SYSTEM MODE(PAGE/BANK)
/	WRONG MODE		MODE DIFFERS BETWEEN LOAD AN CURRENT ENVIRONMENT.
/	WRONG BOOT		WRONG BOOT ADDRESS.
/
///////////////
/
MASK1	0			/(RCHM-100) ADDRESS MASK.
MASK2	0			/(RCHM-100) OP CODE MASK.
/
/
//////////////////
/
/
/ SYSTEM PARAMETERS
/
/
/
/
.SCOM=100			/MONITOR COMMUNICATION TABLE.
SC.MOD=.SCOM+4			/(RCHM-101)
SC.FRH=.SCOM+76			/(RCHM-100) BASE OF EXTEND MEMORY POINTERS.
SC.NMF=.SCOM+42			/(RCHM-100) NON RESIDENT MONITOR AVAILABILITY FLAGS.
SBA=707761			/(RCHM-100) SKIP IF BANK ADDRESSING.
ECLA=641000			/(RCHM-100)
OSC=640001			/(RCHM-100)
X10=10				/(RCHM-100)PTR TO AR 10.
X11=11				/(RCHM-100) SAME FOR AR11.
TO=-3				/OUTPUT DEVICE. (CONSOLE)
IN=-4				/INPUT DEVICE. (DISK)
/
/
/
/////////////////////////
/
/	CODE ENTERED FOR LINK FETCH
/
//////////////////////////
/
LKOVLA	.DSA	LKOVLA		/LINK TABLE ENTRY ADDRESS AFTER SETUP
/
/ SAVE VOLATILE REGISTERS
/
	DAC ACSAVE		/(RCHM-100) SAVE AC.
	LACQ			/(RCHM-100) SAVE MQ.
	ECLA!OSC		/(RCHM-100) SAVE STEP COUNTER.
	CMA!IAC			/(RCHM-100)
	AND (77)		/(RCHM)-100)
	XOR (NORM)		/(RCHM-100)
	DAC SCSAVE		/(RCHM-100)
/			/EXECUT ENTRY ADDRESS DURING SETUP PASS
	RAR			/SAVE LINK.
	DAC	LNKBIT
	LAC* (X10)			/SAVE AUTO-INDEXES 10 AND 11.
	DAC	XR10
	LAC* (X11)	
	DAC	XR11
/
	LAW	-1		/POINT TO LINK ENTRY TO BE FIXED.
	TAD	LKOVLA
	AND	(77777)		/DESTROY LINK BIT.
	DAC	LKOVLA		/POINTS TO JMS* LKOVLA
	AAC 5			/(RCHM-100) POINT TO LINK NUMBER FIELD -1.
	DAC* (X10)	
	LAC* X10		/FETCH LINK NUMBER.
	DAC	T1		/SAVE FOR TRAN.
	LAC* X10		/POINT TO BOTTOM OF AREA.
	DAC	BOTTOM
	LAC* X10		/POINT TO TOP OF AREA.
	DAC	TOP
	JMS	CLEAR		/CLEAR THE AREA.
/
/	SCAN THE LINK TABLE ENTRIES... UPDATE STATUS
/
	LAC	LNKBAS		/PROCESS THE LINK TABLE.
	DAC	TBLENT		/POINTER TO TABLE ENTRY.
LNKSCN	LAC	TBLENT		/POINT TO NEW ENTRY.
	SAD	LNKTOP		/IS THIS THE END...
	JMP	EXUOUT		/YES. END OF TABLE PROCESSING.
	AAC 2			/(RCHM-100) POINT TO JMS FIELD.
	DAC	JMSFLD
	AAC 5			/(RCHM-100) POINT TO LINK NUMBER FIELD -1.
	DAC* (X10)	
	AAC 4			/(RCHM-100) POINT TO NEXT ENTRY.
	DAC	TBLENT
/
	LAC* X10		/GET LINK NUMBER.
	SAD	T1		/SAME AS THIS OVERLAY...
	JMP	SAMLNK		/YES. GO PROCESS.
	LAC	TOP		/WAS THIS PROGRAM OVERLAYED...
	CMA!IAC			/(RCHM-100)
	TAD* X10		/BEGINNING OF ENTRY'S CODE.
	SMA!SZA
	JMP	LNKSCN		/OUR TOP < HIS BOTTOM; HE'S OK.
	LAC* X10		/END OF ENTRY'S CODE.
	CMA!IAC			/(RCHM-100)
	TAD	BOTTOM		/OUR BOTTOM.
	SMA!SZA
	JMP	LNKSCN		/OUR BOTTOM > HIS TOP; HE'S OK.
/
	LAC	JMS		/LINK IS BEING OVERLAID.
	DAC*	JMSFLD		/CHANGE TO CAUSE JMS* LKOVLA.
	JMP	LNKSCN		/TRY NEXT LINK.
/
SAMLNK	LAW	-2		/THIS ROUTINE IN NEW LINK.
	TAD	JMSFLD		/ENTRY POINT-2.
	AND	MASK1		 /(RCHM-100) BUILD LAC .-2 AT ENTRY+2.
	XOR	(LAC)		/(RCHM-100)
	DAC*	JMSFLD		/STORE IT.
	JMP	LNKSCN		/THIS ENTRY NOW LOADED.
/
/ LINK TABLE PROCESSING DONE
/ LOAD THE LINK
/
EXUOUT	LAC	T1	/GET LINK NO.
	RCL		/ X 2
	TAD	LPTPT	/POINT TO DATA IN LPT POSITION -1
	DAC* (X11		/SET AUTO INCREMENT
	LAC* X11		/GET DISK BLOCK ADDRESS OF LINK
/
	DAC	TRAN+3	/SETUP FOR I/O
	JMS	GETBUF	/GET A BUFFER FROM THE BUFFER POOL
	JMS	TRAN	/GET THE 1ST BLOCK OF LINK
	LAC* X11		/GET THE LOG. REC. POINTER
	TAD	TRAN+4	/ADD BUFFER BASE
	DAC	BPTR	/SETUP FOR LOAD
	JMS	LOAD		/LOAD IT.
	JMS	GIVBUF	/RETURN BUFFER TO BUFFER POOL
/
	LAC	XR10		/RESTORE AUTO-INDEXES.
	DAC* (X10)	
	LAC	XR11
	DAC* (X11)	
	LAC	LNKBIT		/RESTORE LINK BIT.
	RAL
	LAC (400000)		/(RCHM-100) RESTORE STEP COUNTER.
SCSAVE	XX			/(RCHM-100)
	LAC MQSAVE		/(RCHM-100)
	LMQ			/(RCHM-100)
	LAC ACSAVE		/(RCHM-100)
	JMP*	LKOVLA		/ENTER USER PROGRAM.
/
/	SUBROUTINE LOAD -- LOAD A LINK.
/
/	WE ALWAYS SKIP THE FIRST LOGICAL RECORD (SINCE IT IS A TYPE 1
/	& THEREFORE IS ONLY AN ID RECORD & IS NOT SUBSTANTIVE).
/
LOAD	.DSA	0
READ	JMS	NEXT		/GET THE NEXT LOGICAL RECORD.
	LAC* X10		/START SUBRECORD.
	DAC	T1	       /SAVE SUBRECORD HEADER.
	AND	(700000)	/ISOLATE TYPE.
	SAD	(300000)	/PATCH RECORD...
	JMP	TYPE3		/YES.
	LAC	T1		/NO. ASSUME TYPE TWO RECORD.
	SKP
/
/	TYPE 2 RECORD... FIXED FORMAT
/	STRING OF RELOCATED BINARY RECORDS
/
TYPE2	LAC* X10		/PICK UP SUBRECORD HEADER.
	SPA			/IF -1, END OF TYPE TWO THIS LRECORD.
	JMP	READ		/READ A NEW LOGICAL RECORD.
	AND	(77777)		/ISOLATE WORD COUNT FIELD.
	CMA!IAC			/(RCHM-100) SAVE COUNT.
	DAC	LCTRL
	LAW	-1		/COMPUTE DATA-1 ADDRESS.
	TAD* X10
	AND	(77777)
	DAC* (X11)			/"TO" FIELD FOR MOVE.
/
WDLOOP	LAC* X10		/MOVE DATA WORDS.
	DAC* X11	
	ISZ	LCTRL	/LOOP CONTROL
	JMP	WDLOOP
	JMP	TYPE2		/RETURN FOR MORE TYPE TWO DATA.
/
/	TYPE 3 RECORDS... HEADER PAIR+STRING OF SUBRECORDS
/	SUBRECORDS OF 3 FORMATS POSSIBLE
/	CONTAINING FORWARD REFERENCE PATCHES & COMMON BLOCK ADDRESS
/	RELOCATIONS.
/
TYPE3	LAC	T1		/PICK UP RECORD HEADER.
	AND	(77777)		/ISOLATE COUNT.
	SNA			/COUNT IS TOTAL NUMBER OF PATCHES.
	JMP*	LOAD		/END OF LINK PROCESSING.
	CMA!IAC			/(RCHM-100) NON-ZERO COUNT.
	DAC	T1		/SAVE PATCH COUNT.
	JMP	.+3		/SKIP OVER READ.
/
TYP3RD	JMS	NEXT		/READ A RECORD OF PATCHES.
	LAC* X10		/IGNORE HEADER WORD.
	LAC* X10		/COUNT OF PATCHES THIS RECORD.
	CMA!IAC			/(RCHM-100) SET UP LOOP CONTROL.
	DAC	LCTRL
NEXTPT	LAC* X10		/PATCH HEADER WORD.
	LMQ			/(RCHM-100) SAVE FOR A MINUTE.
	AND (77777)		/(RCHM-100) EXTRACT ADDRESS FIELD.
	DAC	ADDR
	LACQ			/(RCHM-100) FETCH WORD AGAIN.
	AND	(700000)	/ISOLATE TYPE.
	SNA
	JMP	PATCH0		/TYPE ZERO -- PUT WORD 2 IN WORD 1 ADDRESS.
	SAD	(100000)
	JMP	PATCH1		/TYPE ONE -- ADDRESS FIE3D  OF WD 2 IN WD 1
/
PATCH2	LAC* X10		/TYPE TWO -- ADDRESS IN COMMON.
	TAD	COMMON		/BASE ADDRESS OF COMMON.
	JMP	PATOUT
/
PATCH1	LAC* X10		/GET DATA.
	AND	MASK1		/(RCHM-100) ISOLATE ADDRESS BITS
	DAC	T2	       /SAVE.
	LAC*	ADDR		/PICK UP USER DATA WORD.
	AND	MASK2		/(RCHM-100) SAVE ONLY OP,INDIRECT.
	XOR	T2		/INSERT ADDRESS.
	SKP
/
PATCH0	LAC* X10		/MOVE WHOLE DATA WORD.
PATOUT	DAC*	ADDR		/PLACE IN ADDRESS SUPPLIED.
	ISZ	T1		/TOTAL PATCH COUNT.
	SKP
	JMP*	LOAD		/END OF LOAD.
	ISZ	LCTRL	/LOOP CONTROL
	JMP	NEXTPT		/MORE PATCHES -- GET THEM.
	JMP	TYP3RD		/ANOTHER PATCH RECORD.
/
/
/	SUBROUTINE TRAN -- INPUT A BLOCK VIA TRAN
/	SETUP FOR THE NEXT BLOCK
/	REINIT THE BUFFER POINTER
/
/
TRAN	.DSA	0		/READ ONE BLOCK.
	.TRAN	IN,0,0,0,256 /READ ONE BLOCK.
	LAC	TRAN+3	/SAVE CURRENT BLOCK NO.
	DAC	XCUBLK
	LAC	TRAN+4		/POINT TO FIRST WORD.
	DAC	BPTR		/POINTER TO FIRST LRHWP
	AAC 1			/(RCHM-100) POINTER TO FIRST DATA -1.
	DAC* (X10)			/POINTER USED TO EXTRACT DATA.
	.WAIT	IN
	LAC*	 BUF377	       /GET FORWARD LINK.
	DAC	TRAN+3		/SAVE IT.
	JMP*	TRAN		/RETURN TO CALLER.
/
/	SUBROUTINE NEXT -- GET NEXT LOGICAL RECORD FROM FILE
/	WE FIRST UPDATE THE BUFFER POINTER TO THE NEXT LOGICAL
/	RECORD HEADER WORD PAIR.
/	NOTE THAT IOPS BINARY WON'T ALLOW LOGICAL RECORDS TO SPAN
/	DISK BLOCKS.!!!!
/
/
NEXT	.DSA	0		/GET NEXT RECORD.
	LAC*	BPTR		/PICK UP LRHWP POINTER.
	CLL
	LRS	11		/GET WORD PAIR COUNT.
	CLL!RAL			/CONVERT TO WORD COUNT.
	TAD	BPTR		/POINT TO BEGINNING OF NEXT RECORD.
	SAD	BUF376	    /POINTER TO END OF PHYSICAL DATA...
	JMP	MUSTRD		/READ A NEW RECORD.
	DAC	BPTR
	AAC 1			/(RCHM-100) POINTER TO FIRST DATA -1.
	DAC* (X10)			/PLACE IN AUTO-INDEX.
	LAC*	BPTR		/PICK UP HEADER.
	SZA			/IF ZERO, END OF DATA THIS BLOCK.
	JMP*	NEXT		/RETURN TO CALLER.
/
MUSTRD	JMS	TRAN		/READ A RECORD.
	JMP*	NEXT		/RETURN TO CALLER.
/
/	SUBROUTINE CLEAR -- CLEAR CORE FOR INCOMING LINK.
/
CLEAR	.DSA	0
	LAC BOTTOM		/ POINT LCTRL TO BOTTOM OF	/EAG:008
	DAC LCTRL		/ AREA TO BE CLEARED		/EAG:008
CLRLUP	LAC LCTRL		/ FETCH ADDRESS OF NEXT WORD	/EAG:008
	SAD TOP			/ IS IT LAST WORD?		/EAG:008
	JMP* CLEAR		/ IF SO DONE, SO EXIT		/EAG:008
	DZM* LCTRL		/ IF NOT, CLEAR IT!		/EAG:008
	SAD* (.SCOM+0)		/ ARE WE ABOUT TO CLEAR		/EAG:008
				/ BOOTSTRAP?			/EAG:008
	JMP CLRBOO		/ YES -- GO SKIP AROUND IT	/EAG:008
	ISZ LCTRL		/ NO -- ADVANCE TO NEXT WORD	/EAG:008
	JMP CLRLUP		/ AND GO CLEAR IT		/EAG:008
								/EAG:008
								/EAG:008
/ COME HERE WHEN WE REACH THE BOOTSTRAP, IN ORDER TO SKIP	/EAG:008
/ AROUND IT.							/EAG:008
								/EAG:008
CLRBOO	TAD (7777)		/ ROUND UP TO NEXT PAGE		/EAG:008
	AND (770000)		/ BOUNDARY			/(RCHM-100)
	JMP CLRLUP-1		/ AND CONTINUE LOOP		/EAG:008
/
/
/	SUBROUTINE GETBUF... OBTAIN A BUFFER FROM THE BUFFER POOL
/
/
GETBUF	0		/RETURN ADDRESS
	.GTBUF		/GET THE BUFFER
	SPA		/SKIPS IF SUCCESSFUL
	JMP	NOBUF	/ERROR CONDITION
	DAC	GIVBUF+3	/SETS UP DE-ALLOCATION CODE
	DAC	TRAN+4	/TRAN NEEDS THE BUFFER ADDRESS
	AAC 376			/(RCHM-100) NEXT TO LAST BUFFER WORD.
	DAC	BUF376	/POINTER
	AAC 1			/(RCHM-100) LAST BUFFER WORD.
	DAC	BUF377	/POINTER
	JMP*	GETBUF	/DONE
/
NOBUF	.FSTAT	IN,NAME /ISSUES AN IOPS 55 (NO BUFFERS)
/
/
/	SUBROUTINE GIVBUF... DE-ALLOCATE A BUFFER TO THE BUFFER POOL
/
/
GIVBUF	0		/RETURN ADDRESS
	.GVBUF		/GIVE BACK BUFFER
	JMP*	GIVBUF	/DONE
/
/
/	BUILD THE LINK POINTER TABLE & ENTER USER CODE
/
/
LPTBLD	JMS	NEXT	/GET NEXT LOG. REC.
	LAC*	BPTR	/GET LRHWP OF TYPE 1 RECORD
	SAD	EOF	/CHECK FOR SOFTWARE END OF FILE
	JMP	FIN1	/ALL DONE... ENTER USER CODE
	LAC	XCUBLK	/GET CURRENT DISK BLOCK
	DAC*	LPTPTR	/STORE IN LPT
	ISZ	LPTPTR	/BUMP POINTER
	LAC	TRAN+4	/GET BUFFER ADDRESS
	CMA!IAC			/(RCHM-100) FOR RELATIVE POINTER CALCULATION.
	TAD	BPTR	/GET POINTER TO LRHWP OF TYPE 1 REC.
	DAC*	LPTPTR	/STORE IN LPT
	ISZ	LPTPTR	/BUMP POINTER
	JMS	LOAD	/LOAD THE LINK
	LAC	LPTPTR	/WATCH OUT FOR TOO MANY LINKS
	SAD	BOTTOM	/HIT BOTTOM OF OVERLAY SYSTEM?
	SKP		/YES. REPORT CANT FIT
	JMP	LPTBLD	/NEXT LINK
	.WRITE	TO,2,MSG1,0	/LPT OVERFLOW
/
EXIT	.CLOSE	TO	/WAIT FOR TTY.
	.EXIT		/LEAVE... LOAD NON RESIDENT MONITOR
/
FIN0	.CLOSE	IN	/CLEAN UP SYS SOFTWARE XCT DEVICE STATUS
FIN1	JMS	GIVBUF	/RELEASE THE BUFFER
	JMP*	ENTRY	/ENTER USER CODE
/
/
/
/
/
//////////////////////
/
/	STORAGE AND CONSTANTS & OVERWRITABLE CODE
/			NON-OVERWRITABLE STORAGE FIRST.
/
//////////////////
/
ACSAVE	XX			/(RCHM-100)
MQSAVE	XX			/(RCHM-100)
BOTTOM	.DSA	0		/BOTTOM OF INCOMING LINK.
TOP	.DSA	0		/TOP OF INCOMING LINK.
ENTRY	.DSA	0		/ENTRY POINT OF MAIN PROGRAM.
COMMON	.DSA	0		/BASE OF BLANK COMMON.
LNKBAS	.DSA	0		/BASE OF LINK TABLE.
LNKTOP	.DSA	0		/TOP OF LINK TABLE.
BPTR	.DSA	0		/POINTER TO NEXT LRHWP IN BUFFER.
JMS	JMS*	0		/JMS FOR LINK TABLE USE.
LNKBIT	0		/SAVED REGISTERS
XR10	0		/ "
XR11	0		/ "
T1	0		/TEMPORARIES
T2	0		/ "
ADDR	0		/TYPE 3 REC. PATCH ADDRESS
TBLENT	0		/LINK TABLE ENTRY ADDRESS
JMSFLD	0		/LINK TABLE JMS FIELD
/
/ ENVIRONMENT WORD.
/
/ BIT 17 -- RESERVED (CURRENTLY UNUSED).
/ BIT 16 -- BANK/PAGE
/ BIT 15 -- XVM ON/XVM OFF
/ BIT 14 -- BOOT 32K/BOOT 24K
/ BIT 13 -- XVM/DOS/NON-XVM/DOS
/
/ FIRST PART IS IF BIT IS ON, SECOND PART IF BIT IS OFF.
/
CEV.IN=LCTRL			/(RCHM-100) TEMP USED IN SETUP.
LCTRL	0		/LOOP CONTROL
/
EOF	1005		/SOFTWARE END OF FILE
LPTPT	LPT-3		/BASE TO CALC LPT POSITION -1
BUF376=GETBUF+3		/NEXT TO LAST BUFFER LOCATION POINTER
/			/USES THE FREE WORD IN .GTBUF
BUF377	0		/LAST BUFFER LOCATION POINTER
XCUBLK	0		/CURRENT DISK BLOCK ADDRESS
LPTPTR	LPT		/POINTER TO LPT
MSG1	4*1000; 0
	.ASCII	"TOO MANY LINKS"<15>
/
	.LTORG		/LITERALS SHOULD NOT BE OVERWRITTEN
/
/
LPT=.			/THE LINK POINTER TABLE WILL START HERE.
/			/ALL FOLLOWING CODE IS OVERWRITABLE.
/
/
/
/
/
/
///////////////////
/
/	THE LINK POINTER TABLE IS CONSTRUCTED IF NEEDED.
/	IT OVERWRITES THE SETUP CODE.
/
/ AN ENTRY IN THE LPT CONSISTS OF 2 WORDS ...
/	1.THE DISK BLOCK ADDRESS OF THE BEGINNING OF THE LINK
/	2.THE RELATIVE BUFFER LOCATION OF THE LOGICAL RECORD HEADER WORD
/		PAIR OF THE TYPE 1 RECORD FOR THE LINK.
/
/ EACH LINK HAS 1 ENTRY IN THE LPT
/
/////////////////////
/
/
/
/
////////////////////////////////
/
/
/	SYSTEM LOADER ENTERS HERE
/
///////////////////////////
/
/
EXECUT	LAW 0			/(RCHM-100) SET UP ADDRESS MASKS.
	SBA			/(RCHM-100) BANK MODE?
	LAW 10000		/(RCHM-100) NO, FETCH PAGE MODE MASK.
	DAC MASK2		/(RCHM-100) SET UP OPCODE MASK.
	CMA			/(RCHM-100) SET UP OP CODE MASK.
	DAC MASK1		/(RCHM-100) SET UP ADDRESS MASK
	.INIT TO,1,EXIT		/(RCHM-100) OPEN TTY (THE NON-RESIDENT MONITOR
/	SETUP FOR BOSS15
	LAC*	(.SCOM+52	/SET I/O TO TTY BIT
	SPA			/(RCHM-104) IS BOSS RUNNING?
	JMP EXEC10		/(RCHM-104) YES.
	.WRITE	TO,2,MSG0,6	/IDENTIFY PROGRAM
EXEC10	JMS	INIT		/(RCHM-104) INIT THE XCT DEVICE
	LAC*	SCOM3	    /COMPUTE END OF CORE.
	AND (70000)		/(RCHM-100)
	XOR (7777)		/(RCHM-100) CALCULATE TOP OF EXECUTABLE CORE BANK.
	DAC	T1	       /SAVE FOR FUTURE USE.
	LAC* (SC.FRH+1)		/(RCHM-100) FETCH HIGH BOUND OF EXTENDED MEMORY.
	SMA			/(RCHM-100) ANY HIGH MEMORY THERE?
	DAC T1			/(RCHM-100) YES, SET UP FOR COMPARISON.
	LAC*	NAME		/PICK UP FILE NAME.
	DAC	NAME
	LAC*	NAME+1
	DAC	NAME+1
	JMS	FSTAT	/GET XCU STARTING BLOCK IN AC
/			/BUFFER IS OBTAINED THRU HANDLER
	DAC	XCUSAV	/SAVE
	LAC	NAME+3	/SET UP FOR XCT FILE
	DAC	NAME+2
	JMS	FSTAT		/FIND "XCT" FILE.
	JMS	INIT	/RETURN BUFFER OBTAINED THRU HANDLER
	JMS	GETBUF	/GET A BUFFER FROM THE BUFFER POOL
	JMS	TRAN		/READ ONE BLOCK.
/
	LAC	TRAN+4	/GET BUFFER ADDRESS
	AAC 3			/ PUT COMMON BASE POINTER -1 IN AR10.
	DAC* (X10		/AUTO-INCREMENT 10
	AAC 15			/(RCHM-103) POINT TO POSSIBLE HIGH BOUNDS WORD.
	DAC XR10		/(RCHM-103) USE XR10 TEMPORARILY.
/
	LAC* X10		     /GET COMMON BASE.
	DAC	COMMON
	LAC* X10		     /MAIN PROGRAM ENTRY.
	DAC	ENTRY
	LAC* X10		     /LINK TABLE BASE.
	DAC	LNKBAS
	LAC* X10		     /LINK TABLE TOP.
	DAC	LNKTOP
/
	LAC* X10	/BOTTOM OF USER PROGRAM
	DAC	BOTTOM
	CMA!IAC			/(RCHM-100) CHECK FOR ROOM.
	TAD*	SCOM2	/FIRST FREE ADDRESS
	SMA!SZA		/SKIP IF OK
	JMP	NOGO
	LAC* X10	/TOP OF USER PROGRAM
	DAC	TOP
	CMA!IAC			/(RCHM-100) CHECK FOR ENOUGH CORE.
	TAD	T1	/ADDRESS OF END OF HIGHEST BANK
	SPA		/SKIP IF OK
	JMP	NOGO	/WHOOPS
/
	LAC* X10	/CHECK FOR PROPER SYSTEM MODE:PAGE/BANK
	DAC CEV.IND		/(RCHM-100) SAVE CHAINS ENVIRONMENT INDICATOR.
	RTR		/SYSTEM MODE OF XCU FILE SAVED IN BIT 16 OFWORD 12 IN LTB
	SBA			/(RCHM-100) PAGE OR BANK MODE.
	SNL!CML		/(RCHM-100) LINK = 1 => BANK ADDRESSING. 0 LINK MAPS TO 1 LINK.
	SNL			/(RCHM-100) LINK = 1 => BANK ADDRESSING OR GOOD PAGE ADDRESSING.
	JMP CNTRUN		/(RCHM-100) ERROR.
/+
/ CHECK FOR COMPATABILITY MODE, BIT 13 OF ENV WORD WILL BE ON IF XVM.
/-
	ALS 17		/(RCHM-102) CHECK BIT 13 (SHIFTED RIGHT 2.)
	SMA			/(RCHM-102) XVM/DOS SYSTEM?
	JMP BOODON		/(RCHM-102) NO.
/+
/ BANK AND PAGE MODE HAVE BEEN CHECKED, CHECK XVM ON OR OFF AND TURN THEM ON.
/ IF ON THEN EXECUT WILL RUN IN WIDE MODE THROUGHOUT. IF OFF THEN
/ THE ASSUMPTION IS MADE THAT ONLY 32K MAX IS USED FOR THIS OVERLAY.
/-
	LAC* (SC.MOD)		/(RCHM-101) FETCH CURRENT MODE BITS.
	RAR			/(RCHM-101) PUT XVM ON INTO LINK.
	LAC CEV.IND		/(RCHM-101) FETCH ENVIRONMENT BITS.
	ALS 17			/(RCHM-101) STICK REQUEST INTO SIGN BIT.
	SPA!SZL!CMA!CML		/(RCHM-101) BOTH OFF?
	SMA!SNL			/(RCHM-101) BOTH ON?
	SKP!CMA!CML		/(RCHM-101) YES.
	JMP NOX			/(RCHM-101) NO.
	SNL			/(RCHM-101) TURN XVM ON?
	JMP XVDONE		/(RCHM-101) NO.
	.XVMON			/(RCHM-101) YES.
/
/ XVM MODE HAS BEEN ENABLED, DISABLED, OR VERIFIED AS NOT NEEDED. CHECK FOR
/ CORRECT LOCATION OF THE BOOTSTRAP.
/
XVDONE	LAC* (.SCOM)		/(RCHM-100) FETCH BOOT ADDRESS.
	ALS 4	 		/(RCHM-100) MOVE BIT TO SIGN OF AC
				/(RCHM-100) THIS IS USED TO DETERMINE THE DIFFERENCE
				/(RCHM-100) BETWEEN 7XXXX AND 5XXXX BOOT ADDRESSES.
	RAL			/(RCHM-100) PUT AC IN LINK. 0=> 24K 1=> 32K.
	LAC CEV.IND		/(RCHM-100) SET UP AC SIGN BIT WITH CHAIN EXP BOOT.
	ALS 16			/(RCHM-100) PUT IN SIGN BIT.
	SPA!SZL!CMA!CML		/(RCHM-100) BOTH OFF?
	SMA!SNL			/(RCHM-100) EITHER ON?
	SKP			/(RCHM-100) NO, BOT OFF.
	JMP WRONGB		/(RCHM-101) ERROR, BOOTS DON'T MATCH.
/
/ ALL PARAMETERS HAVE BEEN CHECKED.
/ XVM IS EITHER AVAILABLE AND OFF OR ON AS REQUIRED OR NOT AVAILABLE AND NOT
/ RETUIRED.
/ BOOT ADDRESS IS EITHER 24 OR 32K AND CHECKED.
/ ENOUGH MEMORY EXISTS TO RUN THE PROGRAM.
/ THE ONLY REMAINING THING TO DO IS TO SET UP THE HIGH MEMORY BOUNDS.
/
	LAC* XR10		/(RCHM-103) FETCH BOUNDARY.
	SNA			/(RCHM-103) ARE WE TO ALTER BOUNDS?
	JMP BOODON		/(RCHM-103) NO.
	SPA!CLL!CML		/(RCHM-103) CHECK FOR HIGH VERSUS LOW BOUND.
	CMA!IAC!CLL		/(RCHM-103) MAKE ADDRESS RIGHT AND INDICATE LOW MEMORY BOUND.
	DAC XR10		/(RCHM-103) SAVE POSITIVE VALUE OF CORE BOUND.
	LAC* (SC.FRH)		/(RCHM-1039 CHECK FOR HIGH MEMORY. I'M NOT SURE
				/(RCHM-103) IF THIS IS STRICTLY NECESSARY BUT
				/(RCHM-103) CHAIN DOESN'T DIFFERENTIATE THE 24K BOOT
				/(RCHM-103) AND THE 32K MEMSIZE FROM REAL HIGH CORE.
	SPA			/(RCHM-103) ANY HIGH MEMORY?
	JMP BOODON		/(RCHM-103) NO.
	LAC (SC.FRH)		/(RCHM-103) FETCH POINTER TO MEMORY BOUND.
	SZL			/(RCHM-103) ALTER LOW BOUND?
	AAC 1			/(RCHM-103) NO, ALTER HIGH BOUND.
	DAC XR11		/(RCHM-103) SAVE BOUNDS POINTER.
	LAC XR10		/(RCHM-103) FETCH BOUNDARY.
	DAC* XR11		/(RCHM-103) SET UP POINTER.
BOODON	LAW	-1		/FITS CORE. ADJUST POINTERS.
	TAD	BOTTOM
	DAC*	SCOM3	/SET LAST FREE ADDRESS POINTER
	JMS	CLEAR		/CLEAR AREA FOR MAIN LOAD.
/
	LAC	LNKTOP	/TOP OF LINK TABLE
	SAD	LNKBAS		/IS THERE A TABLE...
	JMP	NOVLY		/NO OVERLAYS. LOAD MAIN ONLY.
/
	JMS	LOAD		/LOAD THE TABLE.
	LAC	LKOVLA		/ADDRESS OF EXECUTE PROCESSOR.
	DAC*	LNKTOP
	LAC	LNKTOP		/BUILD A JMS.
	AND	MASK1		/(RCHM-100) GET ADDRESS BITS
	XOR	JMS		/INSERT "JMS* 0".
	DAC	JMS		/SAVE FOR FUTURE USE.
	JMP	MAIN	/LOAD THE RESIDENT CODE
NOVLY	LAC*	SCOM1	    /ONLY MAIN PROGRAM. FREE EXECUTE'S CORE.
	DAC*	SCOM2
	.IFDEF %DEBUG
	.WAIT TO
	HLT
	.ENDC
/
MAIN	LAC	XCUSAV	/SETUP FOR TRAN
	DAC	TRAN+3
	JMS	TRAN		/READ IN ONE RECORD.
	JMS	LOAD		/LOAD MAIN ONLY.
	.IFDEF %DEBUG
	HLT
	.ENDC
	LAC	LNKBAS		/MAIN ONLY...
	SAD	LNKTOP
	JMP	FIN0		/YES. ENTER USER CODE.
	JMP	LPTBLD	/BUILD THE LPT
/
NOGO	.WRITE	TO,2,MSG2,0	/CAN'T FIT IN CORE.
	JMP	EXIT	/READY TO CLEAN UP
/
CNTRUN	.WRITE	TO,2,MSG3,0	/CAN'T RUN IN CURRENT SYSTEM MODE(PAGE/BANK)
	JMP	EXIT
/
NOX	.WRITE TO,2,MSG4,0	/(RCHM-101) NO XVM HARDWARE AVAILABLE.
	JMP EXIT		/(RCHM-101) ALL DONE.
/
WRONGB	.WRITE TO,2,MSG5,0	/(RCHM-101) BOOT AT WRONG ADDRESS.
	JMP EXIT		/(RCHM-101) ALL DONE.
/
/
/	SUBROUTINES FOR SETUP PHASE
/
/
/
/
/
/	SUBROUTINE INIT... INITIALIZES THE XCT DEVICE
/
/
INIT	0		/RETURN ADDRESS
	.INIT	IN,0,0
	JMP*	INIT	/DONE
/
/
/	SUBROUTINE FSTAT -- LOCATE A FILE BY FSTAT
/			& SETUP THE TRAN ROUTINE.
/			A BUFFER IS OBTAINED FROM THE BUFFER POOL
/			BY THE XCT DEVICE HANDLER.
/
FSTAT	.DSA	0		/LOCATE A FILE.
	.FSTAT	IN,NAME		/CHECK PRESENCE OF FILE.
	SNA			/IF ZERO, NOT FOUND.
	JMP	MISS		/MISSING FILE.
	DAC	TRAN+3		/STORE FIRST BLOCK NUMBER.
	JMP*	FSTAT		/NORMAL EXIT.
/
/ FILE IS MISSING
/
MISS	.WAIT	TO		/GIVE THE TTY TIME TO FINISH
	.SEEK   IN,NAME	   /CAUSE AN IOPS 13 WITH FILE NAME.
/
/
///////////////////////////
/
/
/	MISCELLANEOUS STORAGE FOR SETUP PHASE
/
/
/
NAME	.DSA	.SCOM+7		/POINTER TO NAME, OVERLAID BY NAME.
	.DSA	.SCOM+10
	.SIXBT	"XCU"	/MASTER FILE EXTENSION
	.SIXBT	"XCT"		/SECONDARY FILE EXTENSION.
/
MSG0=.-2			/(RCHM-101)
	.SYSID <	.ASCII *EXECUTE >,<000*<15>>	/(RCHM-103)
MSG2=.-2
	.ASCII	"CAN'T FIT"<15>
/
MSG3=.-2			/(RCHM-101)
	.ASCII	"CAN'T RUN"<15>
/
MSG4=.-2			/(RCHM-101)
	.ASCII 'WRONG MODE'<15>	/(RCHM-101)
MSG5=.-2			/(RCHM-101)
	.ASCII 'WRONG BOOT'<15>	/(RCHM-101)
/
/
XCUSAV	0		/RESIDENT CODE STARTING BLOCK ADDRESS
SCOM1	.SCOM+1		/1ST LOC. AFTER RESIDENT MONITOR
SCOM2	.SCOM+2		/1ST FREE LOC.
SCOM3	.SCOM+3		/HIGHEST FREE LOC.
/
/
/
	.END	EXECUT
