	.TITLE	INSTALL TASK (...INS)
/
/  29 SEP 76 - PAUL HENDERSON; CHANGE TO LUN 18
/
/ COPYRIGHT (C) 1975
/ DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
/
/ THIS SOFTWARE IS FURNISHED UNDER A LICENSE FOR USE ONLY
/ ON A SINGLE COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH
/ THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS
/ SOFTWARE, OR ANY OTHER COPIES THEREOF, MAY NOT BE PRO-
/ VIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON
/ EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO
/ THESE LICENSE TERMS.  TITLE TO AND OWNERSHIP OF THE
/ SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.
/
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE
/ WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COM-
/ MITMENT BY DIGITAL EQUIPMENT CORPORATION.
/
/ DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY
/ OF ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY
/ DEC.
/
	.EJECT
/ EDIT #12
/  
/   
/ DATE OF LAST EDIT: OCT 15 75  D. MCMILLAN
/                               M. HEBENSTREIT
/				S. ROOT
/				M. HEBENSTREIT
/  
/
/WRITTEN TO HANDLE BLOCK MODE (400 WORDS/BLOCK) MASS STORAGE DEVICES
/SUCH AS THE RP15 THAT WILL NOT HANDLE WORD ADDRESSABILITY. HOWEVER,
/IT WILL STILL WORK ON A WORD ADDRESSABLE DEVICE (SUCH AS RF15)
/
/THE ALLOCATION SIZE FOR THE TASK WAS IN A SPECIAL AREA JUST BEFORE THE
/ACTUAL TASK. THIS AREA WAS 10(8) WORDS LONG DUE TO THE FACT THAT THE
/LOW 3 BITS STILL HAD TO CONTAIN THE UNIT NUMBER. THE ALLOCATION WAS
/EXTENDED FOR 10(8) WORDS, AND THE STL NODE DISK ADDRESS WAS SET UP
/AS 10(8) MORE THAN IT WOULD HAVE BEEN. DUE TO THE FACT THAT ALL DISK
/TRANSFERS IN BLOCK MODE MUST START ON A SECTOR(BLOCK) BOUNDARY, THIS
/HAS NOW BEEN EXTENDED TO 400(8) WORDS. PERHAPS SOME USEFUL FUNCTION
/CAN BE DEVISED TO KEEP SOME MORE INFORMATION IN THE NOW WASTED 377(8)
/WORDS.
/ EDIT #3 S. ROOT. WORDS 2-4 NAME, NAME, BASE . FOR RECONFIGURATION.
/(THE REMOVE TASK HAS BEEN MODIFIED TO LOOK IN THE RIGHT PLACE.)
/
/
ILUN=22			/ 'TSK' INPUT VIA LUN 18
X10=10
X11=11
X15=15
	.IFUND	TKNAM
R1=101
R2=102
NADD=107	/NODE ADDITION
PENP=115	/PICK EMPTY NODE FROM POOL
SNAM=123	/SCAN DEQUE FOR NAME
MCRRI=171	/MCR REQUEST INHIBIT FLAG
IFAC=172	/INITIALIZE 'FAC'
FAC=174		/FETCH A CHARACTER (FROM THE COMMAND LINE)
STKL=242	/SYSTEM TASK LIST
PBDL=250	/PARTITION BLOCK DESCRIPTOR LIST
SCDL=254	/SYSTEM COMMON BLOCKS DESCRIPTION LIST
	.ENDC
RELHWE=235	/CONTAINS A SKIP IF RELOCATE ON MACHINE
FPHDW=236	/CONTAINS A SKIP IF FP15 ON MACHINE
/
INSTAL=.	/BEGINNING OF INSTALL ROUTINE
I.BLOK=.	/(MJH-11) ***** WARNING 1ST 400(8) LOCATIONS OVERLAYED ***
	.IFDEF	TKNAM
I.TSKN=TKNAM	/IF ASSEMBLED WITH SCF, THEN THIS IS A SUBROUTINE
	0	/THIS IS ITS ENTRY POINT
	.ENDC
	DZM	I.DSKA	/DISK AREA NOT ASSIGNED YET
	DZM	I.DFPR	/NO DEFAULT PRIORITY YET
	.IFUND	TKNAM
/STANDARD INSTALL TASK - A LINE MUST BE DECODED
	LAW	-2	/SET UP THE COMMA COUNT
	DAC	I.BCNT	/FOR PARTITION NAME SCAN
	JMS	I.GTNM	/CREATE A SIXBIT NAME BLOCK FROM THE LINE
	I.TSKN		/PLACE IT HERE
	JMP	I.ER01	/GO HERE ON AN ERROR
	JMS	I.TER	/WAS THE DELIMITING CHARACTER A DELIMITER?
	JMP	I.NOD	/YES, NO PRIORITY SPECIFIED
	SKP		/OVER THE FIRST CHARACTER FETCH
I.MPRL	JMS*	(FAC)	/NO, SEE IF THERE IS A PRIORITY SPECIFIED
	SAD	(40	/SPACE?
	JMP	I.MPRL	/YES, KEEP LOOKING
	JMS	I.TER	/TERMINATOR?
	JMP	I.NOD	/YES, NO PRIORITY GIVEN
	SAD	(54)	/COMMA?
	JMP	I.PRCK	/YES, IS IT THE SECOND?
I.MPRI	LMQ	/A CHARACTER, IS IT A NUMBER?
	AAC	-60	/SHOULD STILL BE POSITIVE
	SPA		/SKIP IF SO
	JMP	I.ER01	/SYNTAX ERROR
	AAC	-12	/SHOULD GO NEGATIVE
	SMA		/YES?
	JMP	I.ER01	/NO
	LACQ		/BRING IT BACK
	TAD	(AAC-60)	/CREAT AN AAC N INSTRUCTION
	DAC	I.AACN	/SAVE IT
	LAC	I.DFPR	/PICK UP THE DEFAULT PRIORITY
	673122		/CLL!MUL
	12		/TIMES 10
	LACQ		/BRING THE LOW ORDER PART OUT
I.AACN	XX		/ADD IN WHAT WE HAVE
	DAC	I.DFPR	/SAVE THIS
	TAD	(-1000)	/IS IT TOO LARGE?
	SMA!SZA		/SKIP IF NOT
	JMP	I.ER01	/YES, SYNTAX ERROR
	JMS*	(FAC)	/NEXT CHARACTER
	SAD	(40)	/SPACE?
	JMP	I.PART	/YES, SCAN TO SEE IF THE PARTITION IS SPECIFIED
	SAD	(54)	/COMMA?
	JMP	I.PART	/YES
	JMS	I.TER	/TERMINATOR?
	JMP	I.NOD	/YES, PROCEED
	JMP	I.MPRI	/NO, CONTINUE WITH NUMBER BUILDING
I.PRCK	ISZ	I.BCNT	/IS THIS THE SECOND COMMA (OMMITTING PRIORITY)?
	JMP	I.MPRL	/NO, CONTINUE SCAN
I.PART	JMS	I.GTNM	/MAKE ANOTHER NAME
	I.PTNM		/AT THIS ADDRESS
	JMP	I.PERR	/POSSIBLE ERROR, CHECK IT OUT
	JMP	.+3	/NAME SPECIFIED, DON'T ZERO IT
I.NOD	DZM	I.PTNM	/CLEAR PARTITION NAME SPECIFICATION
	JMS*	(FAC)	/NOW SCAN FOR A TERMINATOR
	SAD	(40)	/SPACE?
	JMP	.-2	/YES, KEEP SCANNING
	JMS	I.TER	/TERMINAL CHARACTER?
	JMP	I.INST	/YES, START THE REAL WORK OF INSTALLING
I.ER01	LAC	(I.ME01	/ERROR IN SYNTAX, SHOW IT
	JMP	I.ERRR	/
/
/ROUTINE TO CREATE A NAME. THE TERMINATING CHARACTER IS LEFT IN THE
/AC UPON EXIT. IT CAN ONLY BE A TERMINATOR, SPACE, OR A COMMA.
/
I.GTNM	XX		/ENTRY/ARG/ERROR EXIT/NORMAL EXIT
	LAW	-2	/ALLOWED TWO TRIES FOR TWO WORDS
	DAC	I.ACNT	/SET THE COUNT
	LAC*	I.GTNM	/PICK UP THE ADDRESS OF THE BLOCK
	DAC	I.WRK	/SAVE IT
	ISZ	I.GTNM	/UP TO NORMAL RETURN
I.GTLP	DZM*	I.WRK	/CLEAR THE CHARACTER WORD
	JMS	I.GTC6	/GET A SIXBIT CHARACTER
	ALSS	14	/PUT IT IN IT'S PROPER PLACE
	DAC*	I.WRK
	JMS	I.GTC6	/SECOND
	ALSS	6	/PUT IT WHERE IT BELONGS
	XOR*	I.WRK
	DAC*	I.WRK
	JMS	I.GTC6	/LAST CHAR
	XOR*	I.WRK
	DAC*	I.WRK	/SIXBIT IS BUILT UP
	ISZ	I.WRK	/UP TO NEXT WORD
	ISZ	I.ACNT	/IF ALLOWED TO GO FOR MORE
	JMP	I.GTLP	/YES, CONTINUE
	JMS	I.GTFC	/NO, DONE, GET NEXT CHARACTER
	ISZ	I.GTNM	/TERMINATOR, LEAVE WITH IT IN THE AC AND A SKIP RETURN
	JMP*	I.GTNM	/RETURN TO INDICATE DONE
I.GTFC	XX	/SUB TO FETCH A CHARACTER AND SKIP IF ","," ", OR TERM
	JMS*	(FAC)	/PICKUP CHAR
	SAD	(40)	/TERMINATOR CHAR?
	JMP*	I.GTFC	/YES
	SAD	(54)	/?
	JMP*	I.GTFC	/YES
	JMS	I.TER	/?
	JMP*	I.GTFC	/YES
	ISZ	I.GTFC	/NO, SKIP RETURN
	JMP*	I.GTFC
I.GTC6	XX	/SUB TO GET THE NEXT CHARACTER AND RETURN IT AS SIXBIT
	JMS	I.GTFC	/FETCH CHARACTER, SKIP IF NORMAL
	JMP	I.GTQQ	/NOT NORMAL CHAR, WHAT IS HAPPENING?
	LMQ		/SAVE THE CHARACTER
	AAC	-40	/IS IT IN THE SIXBIT SET?
	SPA		/SKIP IF POSSIBLY
	JMP	I.GTCE	/NO, ERROR
	AAC	-100	/STILL IN THERE?
	SMA!SZA		/SKIP IF SO
	JMP	I.GTCE	/NO, ERROR
	SAD	(-40)	/WAS IT THE CHARACTER "@"?
	JMP	I.GTCE	/YES, ERROR
	LACQ		/SEEMS TO BE OK
	AND	(77)	/TRIM IT DOWN
	JMP*	I.GTC6	/AND LEAVE
I.GTCE	LACQ		/ERROR
	JMP*	I.GTNM	/LEAVE WITH TERMINAL CHARACTER IN AC AT ERROR EXIT
I.GTQQ	LMQ		/SAVE TERMINAL CHARACTER
	LAC*	I.WRK	/IS THIS THE FIRST OF THE THREE?
	SNA		/SKIP IF NOT
	JMP	I.GTQR	/YES, SEE IF THIS IS THE FIRST OF ALL
I.GTOK	LACQ		/ALL IS WELL, RETURN THE TERMINATING CHARACTER IN
	ISZ	I.GTNM	/IN THE AC WITH A SKIP RETURN
	ISZ	I.WRK	/SET UP FOR POSSIBLE CLEARING OF SECOND WORD
	ISZ	I.ACNT	/SKIP IF NOW WORKING ON SECOND WORD
	DZM*	I.WRK	/CLEAR SECOND WORD IF IT HASN'T BEEN CLEARED
	JMP*	I.GTNM
I.GTQR	LAW	-2	/CHECK TO SEE
	SAD	I.ACNT	/IF THE COUNT IS AT -2
	SKP		/IT IS, CHECK THE CHARACTER
	JMP	I.GTOK	/IT IS NOT, LEAVE WITH TERMINATING CHARACTER IN AC
	LACQ		/IS THIS CHARACTER A SPACE?
	SAD	(40)	/SKIP IF NOT
	JMP	I.GTC6+1	/IT IS, IGNORE LEADING SPACES
	JMP*	I.GTNM	/IT IS NOT, ERROR EXIT WITH CHAR IN AC
/
/ROUTINE TO CHECK TO SEE IF THE 'ERROR' IN CREATING THE PARTITION
/NAME IS REALLY THE LACK OF ANY CHARACTERS FOR THE NAME.
/
I.PERR	JMS	I.TER	/IS THE TERMINAL CHARACTER A TERMINATOR?
	JMP	I.NOD	/YES, NO PARTITION NAME GIVEN
	JMP	I.ER01	/NO, SYNTAX ERROR
/
I.TER	XX	/ROUTINE TO SKIP IF NOT CR OR ALTMODE
	SAD	(15)	/CR?
	JMP*	I.TER	/YES
	SAD	(175)	/ALTMODE?
	JMP*	I.TER	/YES
	ISZ	I.TER	/NEITHER,
	JMP*	I.TER	/SKIP RETURN
/
I.INST=.	/REAL WORK STARTS HERE
	.ENDC
/
/SCAN THE STL TO SEE IF THE TASK EXISTS ALREADY
/
	LAC	(STKL)
	DAC*	(R1)
	LAC	(I.TSKN)	/ADDRESS OF THE NAME
	DAC*	(R2)
	JMS*	(SNAM)	/GO LOOK (ALMOST ALL REGISTERS WIPED OUT)
	SKP		/NOT FOUND, ALL IS WELL
	JMP	I.ER02	/FOUND, ERROR
/
/CODE TO DO THE INSTALL WORK:
/
/NOTE: ALL DISK ADDRESS CARRIED AROUND DURING PROCESSING, AND PASSED ON
/TO THE RSX EXECUTE PROGRAM VIA THE LINK TABLE ARE OF THE FORM
/ BLOCK NUMBER * 400 + UNIT NUMBER. THE 'ADD' INSTRUCTION INSTEAD OF THE
/'TAD' INSTRUCTION IS USED TO CALCULATE DISK ADDRESSES, AS THIS WILL
/INCREMENT THE UNIT NUMBER IF AN OVERFLOW OCCURS.
/
/
	.IFUND	TKNAM
	CAL	ATTACH	/ATTACH THE LUN-18 DEVICE
	CAL	I.WAIT	/WAIT FOR THE EV
	LAC	I.EV	/ALL OK?
	SMA		/SKIP IF NOT
	JMP	I.OVRY	/YES, CONTINUE
	SAD	(-6)	/NO ATTACH ALLOWED?
	SKP		/TRUE, SO CONTINUE
	JMP	I.ER13	/TREAT THIS AS A FILE NOT FOUND SITUATION
I.OVRY=.
	.ENDC
/
	JMS	SEEK	/SEEK THE FILE
	LAC	(377777)	/FIND LINK #377777 FOR INFO
	DAC	I.LKNM	/
	DZM	I.ACNT	/COUNTING THE LINKS ON THE WAY
	JMS	I.FLNK	/GO DO IT
	LAC	INBUF+4	/BASE OF BLANK COMMON
	DAC	I.BCBS	/SAVED FOR PATCHING
/
	LAC	I.ACNT	/THE COUNT OF EXTERNAL LINKS+1 FOR THE ALLOCATION
	ALSS	10	/MULTIPLY BY 400
	TAD	INBUF+5	/NOW WE HAVE THE NUMBER OF BLOCKS *400
	AAC	377	/NEEDED TO HOLD THE IMAGE
	AND	(-400)	/ON THE DISK, WITH EACH OVERLAY
	DAC	I.ALSZ	/STARTING ON A BLOCK BOUNDARY
/
	LAC	INBUF+7	/SAVE THE BASE ADDRESS OF THE LINK TABLE
	DAC	I.LTBS
/
	LAC	INBUF+6	/AND THE SIZE OF THE RESIDENT IMAGE
	DAC	I.RISZ
/
	LAC	INBUF+11	/SAVE THE
	DAC	I.ENTR	/ENTRY POINT FOR THE TASK
	SMA		/IS FP15 REQUIRED?
	JMP	.+3	/NO
	XCT*	(FPHDW)	/SKIP IF FP IS THERE
	JMP	I.ER15	/NO, BUT IT IS NEEDED - ERROR
	DZM	I.XM	/(MJH-11) CLEAR XVM MODE BITS
	LAC	I.ENTR	/(MJH-11) IS THIS TASK EXEC MODE?
	RTL		/(MJH-11)
	SMA		/(MJH-11)
	JMP	I.OVXM	/(MJH-11) YES -- LEAVE XM BITS CLEARED
	LAC	INBUF+16	/(MJH-11) NO -- GET XM BITS
	DZM	INBUF+16	/(MJH-11) CLEAR GARBAGE OUT OF INBUF+16
	PAL		/(MJH-11) SAVE XM BITS TEMPORARILY
	AND	(1	/(MJH-11) IS TASK IN XVM MODE?
	SNA		/(MJH-11)
	JMP	.+4	/(MJH-11) NO
	LAC	I.XM	/(MJH-11) YES -- SET UP XVM MODE BITS
	XOR	(000140	/(MJH-11)
	DAC	I.XM	/(MJH-11)
	PLA		/(MJH-11) RETRIEVE FORMER CONTENTS OF INBUF+16
	AND	(2	/(MJH-11) IS TASK IN IOT MODE?
	SNA		/(MJH-11)
	JMP	.+4	/(MJH-11) NO
	LAC	I.XM	/(MJH-11) YES -- SET UP IOT MODE BIT
	XOR	(20	/(MJH-11)
	DAC	I.XM	/(MJH-11)
I.OVXM=.
/
	.IFUND	TKNAM
	LAC	I.PTNM	/WAS THE PARTITION NAME SPECIFIED IN THE COMMAND?
	SZA		/SKIP IF NOT
	JMP	.+5	/OVER THIS IF SO
	.ENDC
	LAC	INBUF+12	/MOVE THE PARTITION NAME IN
	DAC	I.PTNM
	LAC	INBUF+13
	DAC	I.PTNM+1
/
	LAC	INBUF+14	/SAVE THE BASE
	DAC	I.CORB	/ADDRESS OF THE PARTITION ACCORDING TO TKB
	DAC	I.LCOR	/SAVE THIS FOR LINK TABLE EXPANSION (&LINK #0)
/
	LAC	INBUF+15	/GET THE MAXIMUM TASK REGISTER
	AAC	377	/FORCE IT TO 400 WORD INCREMENTS
	AND	(-400)
	DAC	I.MXTR	/SAVE IT
	LAC	INBUF+15	/IF SIZE IS 401,1001, ETC. ADD 400
	AND	(-400		/TO MAX TASK REG.
	SAD	INBUF+15
	SKP
	JMP	.+4
	LAC	I.MXTR
	TAD	(400
	DAC	I.MXTR
	LAC	I.ENTR	/NOW WE SEE IF THAT WAS A MISTAKE AND THIS IS
	RTL		/REALLY AN EXEC MODE TASK
	SPA		/SKIP ON MISTAKE
	JMP	I.OVRX	/NO, WE DID GOOD, WELL DIDN'T WE????
	LAC	INBUF+14	/PICK UP THE PARTITION BASE ADDRESS
	TCA		/NEGATE
	TAD	INBUF+15	/NOW WE HAVE THE SIZE -1 OF THE TASK
	IAC		/SO FIX IT UP
	DAC	I.MXTR	/AND REPLACE OUR ERROR
/
I.OVRX	LAC	(PBDL)	/NOW WE SCAN THE PARTITION BLOCK DESCRIPTOR LIST
	DAC*	(R1)	/FOR THIS PARTITION
	LAC	(I.PTNM)	/NAME
	DAC*	(R2)	/
	JMS*	(SNAM)	/GO DO IT
	JMP	I.ER03	/NOT FOUND, WE HAVE TROUBLE HERE
	DAC	I.PBAD	/FOUND, SAVE THE ADDRESS FOR LATER
	AAC	4	/AND UP TO THE ADDRESS OF
	DAC	I.WRK	/THE PARTITION BASE ADDRESS
/
	LAC	I.ENTR	/PICK UP THE TASK ENTRY POINT AGAIN
	RTL		/AC0 IS THE PROTECTION INDICATOR
	SPA		/SKIP IF NOT PROTECTED
	JMP	I.RELT	/RELOCATED TASK, CHECK IT OUT
	LAC*	I.WRK	/NOT RELOCATED - WAS THE PARTITION BASE SPECIFIED
	SAD	INBUF+14	/CORRECTLY TO TKB?
	JMP	I.PARC	/YES , GO CHECK THE PARTITION
	JMP	I.ER04	/NO, ERROR
I.RELM	LAC	I.DFPR	/PRIORITY REQUESTED?
	SZA		/SKIP IF NOT
	JMP	I.CBCK	/IF SO, USE IT - NOW CHECK COMMON BLOCKS
	LAC	INBUF+10	/WAS A PRIORITY SPECIFIED TO TKB?
	SNA		/SKIP IF SO
	JMP	I.ER12	/NO, NO PRIORITY AT ALL - ERROR
	DAC	I.DFPR	/YES, SAVE THIS
I.CBCK	LAC	(INBUF+15)	/SET UP TO SCAN THE COMMON BLOCKS
	DAC*	(X15)	/ADDRESS OF LIST
	LAC*	X15	/PICK IT UP
	SNA		/ANYTHING THERE?
	JMP	I.ALLD	/NO, ALLOCATE THE DISK SPACE
	LAC*	(X15)	/YES, SET UP TO SCAN
	DAC*	(R2)	/THE SYSTEM COMMON BLOCK LIST
	LAC	(SCDL)	/FOR THIS COMMON BLOCK
	DAC*	(R1)	/NAME
	JMS*	(SNAM)	/GO DO IT - FOUND?
	JMP	I.ER09	/NO, ERROR
	AAC	4	/YES, SET UP TO COMPARE
	DAC*	(X10)	/THE BASE AND SIZE
	LAC*	X15	/SCAN OVER THE NAME SECOND HALF
	LAC*	X15	/ARE THE BASES THE SAME?
	SAD*	X10	/SKIP IF SO
	SKP
	JMP	I.ER09	/NO, ERROR
	LAC*	X15	/ONCE MORE
	SAD*	X10	/FOR THE SIZES
	JMP	I.CBCK+2	/ALL OK, KEEP LOOKING
	JMP	I.ER09	/NO, ERROR
/
I.RELT	XCT*	(RELHWE)	/DO WE HAVE RELOCATION HARDWARE?
	JMP	I.ER14	/NO, SHOW THE ERROR
I.PARC	ISZ	I.WRK	/YES, CHECK THE SIZE OF THE PARTITION
	LAC*	I.WRK	/TO SEE IF THIS WILL FIT
	TCA		/NEGATE
	TAD	I.MXTR	/AND ADD THE HIGHEST TASK REGISTER IN
	SMA!SZA		/WILL IT FIT? SKIP IF SO
	JMP	I.ER04	/NO, TASK IS TOO LARGE - ERROR
	JMP	I.RELM	/YES IT WILL FIT, CARRY ON WITH OTHER THINGS
/
I.ALLD	CAL	I.ACPB	/ALLOCATE THE DISK SPACE NEEDED
	CAL	I.WAIT	/WAIT UNTIL COMPLETION
	LAC	I.EV	/PICK UP THE EV
	.IFDEF	TKNAM
	SAD	(-777)	/OUT OF POOL?
	JMP	SCF999	/YES - STOP SYSTEM CONFIG
	.ENDC
	SPA		/ALLOCATION OK? - SKIP IF SO
	JMP	I.ER06	/NO - ERROR
	ISZ	I.DSKA	/YES, SHOW THAT WE HAVE ALLOCATED DISK SPACE
	LAC	I.ALSZ+1	/MOVE THE ADDRESS INTO THE
	DAC	I.PCPB	/PUT CPB
	LAC	I.ALSZ+2
	DAC	I.PCPB+1
	LAC	(I.BLOK-1)	/CLEAR THE DISK I/O BLOCK
	DAC*	(X10)	/TO ZEROS
	LAW	-400
	DAC	I.WRK
	DZM*	X10
	ISZ	I.WRK
	JMP	.-2
	LAC	I.ALSZ	/NOW CLEAR ALL OF THE ALLOCATED DISK AREA TO
	DAC	I.WRK	/ZEROS
	CAL	I.PUTC	/PUT THE ZEROS OUT
	JMS	I.WFEV	/WAIT UNTIL DONE
	LAC	I.PCPB+1	/UP THE ADDRESS
	CLL
	TAD	(400	/TO THE NEXT BLOCK
	DAC	I.PCPB+1
	SZL		/IF OVERFLOW
	ISZ	I.PCPB	/UP THE HIGH-ORDER WORD ALSO
	LAW	-400	/COUNT DOWN
	TAD	I.WRK	/TO ZERO
	SMA!SZA		/DONE?
	JMP	.-14	/NO, KEEP ON
/
/THE DISK SPACE HAS BEEN ALOCATED, AND ALL OF IT IS ZEROED. NOW TO
/BRING THE CODE IN.
/
	LAC	I.ALSZ	/PICK UP THE SIZE OF THE ALLOCATION
	DAC	I.BLOK	/SET THIS IN AS WORD ZERO OF THE BLOCK
/
/  EDIT #3 CHANGE
/
	LAC	I.PTNM	/NAME
	DAC	I.BLOK+1
	LAC	I.PTNM+1
	DAC	I.BLOK+2
	LAC	I.CORB	/BASE
	DAC	I.BLOK+3
/
/  END EDIT #3 CHANGE
/
	LAC	I.ALSZ+2	/SET UP THE DISK GET/PUT CONTROL TABLE
	DAC	I.PCPB+1	/SO THE FIRST WRITE WILL SEND OUT
	LAC	I.ALSZ+1	/THE BLOCK WITH THE ALLOCATION SIZE IN IT
	DAC	I.PCPB
	XOR	I.ALSZ+2	/SET THIS BLOCK (IN CORE) AS BEING THE
	DAC	I.THIS	/FIRST ONE
	ADD	(400)	/NOW UP TO THE BLOCKS TO BE USED
	DAC	I.DSKB	/SAVE AS BASE OF LINK ZERO
	DAC	I.LBSE	/SET THIS ALSO AS THE BASE FOR THE FIRST LINK
	LAW	-1	/SHOW THAT CURRENT BLOCK HAS BEEN MODIFIED
	DAC	I.WRIT	/SO IT WILL BE WRITTEN OUT
/
/EXPAND THE LINK TABLE IF IT EXISTS
/
	JMS	I.EXPL	/DO IT
	.IFUND	TKNAM
	CAL	CLOSE	/CLOSE THE FILE
	.ENDC
	JMS	SEEK	/RE-SEEK THE FILE
	DZM	I.LKNM	/FIND LINK #0
	JMS	I.FLNK	/
I.LOOP	JMS	I.EXPL	/EXPAND THIS LINK
	LAC	I.MXDK	/PICK UP THE MAXIMUM DISK BLOCK USED
	SZA
	JMP	.+3
	LAC	I.THIS
	DAC	I.MXDK
	ADD	(400)	/UP TO THE NEXT ONE
	DAC	I.WRK	/SAVE THIS AS THE BASE FOR THE NEXT LINK
	LAC	INBUF+3	/LAST LINK?
	SAD	(377777)	/SKIP IF NOT
	JMP	I.DEXP	/YES, DONE EXPANDING THE TSK FILE
	JMS	I.LKTB	/NO, SET UP THE LINK TABLE FOR THE NEXT LINK
	JMP	I.LOOP	/ AND GO FOR MORE
/
/SUBROUTINE TO READ THROUGH UNTIL A CERTAIN LINK IS FOUND
/
I.FLNK	XX		/LINK NUMBER IS IN I.LKNM
	JMS	READ	/READ A RECORD
	LAC	INBUF+2	/IS THIS A TYPE ONE RECORD?
	AND	(IOT)
	SAD	(JMS)	/SKIP IF NOT
	JMP	I.OVRP	/IT IS, IS IT THE ONE WE WANT?
	SNA		/IT ISN'T - ERROR VIA TYPE 0 RECORD?
	JMP	I.ER10	/YES, LEAVE
	JMP	I.FLNK+1	/CYCLE ON FOR MORE
I.OVRP	LAC	INBUF+3	/TYPE ONE RECORD FOUND, IS IT THE ONE WE WANT?
	SAD	I.LKNM	/SKIP IF NOT
	JMP*	I.FLNK	/IT IS, LEAVE
	ISZ	I.ACNT	/IT IS NOT, COUNT THE LINKS FOUND
	NOP		/ANYWAY
	JMP	I.FLNK+1	/AND GO FOR MORE
/
/
/SUBROUTINE TO EXPAND A LINK. THE TYPE ONE RECORD HAS BEEN READ. UPON
/EXIT, A TYPE ONE RECORD WILL BE IN 'INBUF'.
/
I.EXPL	XX
	DZM	I.MXDK	/CLEAR OUT THE HIGHEST DISK ADDRESS USED
/
/I.LBSE SHOULD CONTAIN THE BASE DISK ADDRESS FOR THIS LINK
/I.LCOR SHOULD CONTAIN THE BASE CORE ADDRESS THAT CORESPONDS TO I.LBSE
/
I.EXLP	LAC	(INBUF+2)
	DAC	I.PNTR	/SET UP FOR 'GETW' ROUTINE
	JMS	READ	/READ A RECORD
	LAC	INBUF+2	/IS IT A TYPE TWO RECORD?
	AND	(IOT)
	SAD	(LAC)	/SKIP IF NOT
	JMP	I.TYP2	/IT IS, PROCESS IT
	SAD	(ADD)	/TYPE THREE?
	JMP	I.TYP3	/YES, PROCESS IT
	SAD	(JMS)	/TYPE ONE?
	JMP*	I.EXPL	/YES, LEAVE
	LAC	INBUF+2	/IS THIS THE EOF ON LINK EXPANSION?
	SZA		/MAYBE
	JMP	I.ER10	/NO, READ ERROR
	LAC	I.LKNM	/CHECK TO SEE IF THIS IS LINK 377777
	SAD	(377777)	/SKIP IF NOT
	JMP*	I.EXPL	/IT IS, LEAVE
	JMP	I.ER10	/IT ISN'T - READ ERROR
I.TYP2	JMS	I.GETW	/PICK UP THE COUNT
	SAD	(-1)	/SKIP IF NOT THE END OF THE RECORD
	JMP	I.EXLP	/IT IS, GO FOR MORE RECORDS
	AND	(077777)	/SINGLE IT OUT
	TCA		/NEGATE IT
	DAC	I.ACNT	/SAVE IT
	JMS	I.GETW
	JMS	I.GETA	/PICK UP AN ADDRESS AND READ THAT BLOCK INTO CORE
I.T2LP	JMS	I.GETW	/PICK UP A WORD
	JMS	I.PUTW	/SET IT DOWN
	ISZ	I.ACNT	/SKIP WHEN DONE
	JMP	I.T2LP	/UNTIL THEN
	JMP	I.TYP2	/GO UNTIL DONE
/
/SUBROUTINE TO PICK UP ONE WORD FROM THE BUFFER
/
I.GETW	XX
	LAC*	I.PNTR	/PICK IT UP
	ISZ	I.PNTR	/INCREMENT IT
	JMP*	I.GETW	/AND LEAVE
/
/SUBROUTINE TO PUT ONE WORD INTO THE DISK BLOCK
/(A CALL TO I.GETA SHOULD BE DONE FIRST TO SET UP THE PARAMETERS)
/
I.PUTW	XX
	DAC*	I.DPNT	/SET IT IN
	LAW	-1	/SHOW THAT THE BLOCK
	DAC	I.WRIT	/HAS BEEN MODIFIED
	ISZ	I.DPNT	/INCREMENT THE POINTER
	ISZ	I.BCNT	/SEE IF THE END OF THE BLOCK HAS BEEN REACHED
	JMP*	I.PUTW	/IT HASN'T, LEAVE
	LAC	I.THIS	/GO TO THE NEXT BLOCK
	ADD	(400)	/FOR THE CONTINUATION OF THIS ESCAPADE
	JMS	I.XDSK	/PICK UP THE BLOCK 
	LAC	(I.BLOK)	/AND RESET THE
	DAC	I.DPNT	/POINTERS
	LAW	-400	/TO THE DISK
	DAC	I.BCNT	/BLOCK
	JMP*	I.PUTW	/LEAVE
/
/SUBROUTINE TO SEE THAT THE DISK BLOCK THAT WILL CONTAIN A CERTAIN ADDRESS
/IS IN CORE, AND TO SET UP POINTERS FOR I.PUTW
/CALL WITH THE DESIRED CORE ADDRESS IN THE AC - IT WON'T BE THERE ON RETURN
/
I.GETA	XX
	AND	(77777)
	TCA	/NEGATE
	TAD	I.LCOR	/ADD IN THE BASE
	TCA		/POP BACK TO POSITIVE
	DAC	I.DPNT	/SAVE
	AND	(-400)	/FIND OUT WHICH RELATIVE BLOCK
	ADD	I.LBSE	/FIND OUT WHICH ACTUAL BLOCK
	JMS	I.XDSK	/BRING THAT ONE INTO CORE
	LAC	(377)	/NOW WE PICK UP
	AND	I.DPNT	/THE OFFSET INTO THE DISK BLOCK
	AAC	-400	/CREAT THE NUMBER OF WORDS LEFT IN THE BLOCK
	DAC	I.BCNT	/SAVE THIS AS A COUNTER FOR I.PUTW
	TAD	(I.BLOK+400)	/UP TO THE CORE ADDRESS IN REAL CORE
	DAC	I.DPNT	/WHERE THE WORD IS
	JMP*	I.GETA	/LEAVE
/
/SUBROUTINE TO MAKE CERTAIN THAT THE CORRECT BLOCK IS IN CORE. THE
/ONE CURRENTLY IN CORE IS WRITTEN OUT, IF IT HAS BEEN MODIFIED (I.WRIT=-1)
/
I.XDSK	XX		/ENTRY
	DAC	I.BCNT	/SAVE THIS
	XOR	I.THIS	/IS THE BLOCK THE ONE THAT IS IN CORE?
	SNA		/SKIP IF NOT
	JMP*	I.XDSK	/IT IS, LEAVE
	XOR	I.THIS	/RESORE THE ORIGINAL AC CONTENTS
	LMQ		/FIND OUT IF THE BLOCK JUST ABOUT TO BE READ IN
	LLS	12	/IS HIGHER NUMBERED THAN THE ONE SHOWN IN I.MXDK
	DAC	I.GETW	/SAVE THIS
	LAC	I.MXDK	/PICK UP THE CURRENT MAXIMUM
	LMQ
	LLS	12	/CREATE A PROPER COMPARISON NUMBER
	TCA		/NEGATE
	TAD	I.GETW	/ADD IN THE ONE WE ARE ABOUT TO GET
	RAL		/SAVE THE SIGN
	LAC	I.BCNT	/PICK UP THE ONE WE WANT
	SNL		/SKIP IF IT IS LOWER
	DAC	I.MXDK	/IF HIGHER OR EQUAL, RESET I.MXDK
	ISZ	I.WRIT	/HAS THE CURRENT RECORD BEEN MODIFIED?
	JMP	.+3	/NO, SO JUST READ THE NEW ONE IN
	CAL	I.PUTC	/PUT OUT THE CURRENT BLOCK
	JMS	I.WFEV	/WAIT UNTIL DONE
	DZM	I.WRIT	/CLEAR THE 'THE BLOCK HAS BEEN MODIFIED' FLAG
	LAW	777400	/PICK UP THE
	AND	I.BCNT	/BLOCK NUMBER
	DAC	I.PCPB+1	/AND SET IT IN THE DISK CONTROL TABLE
	XOR	I.BCNT	/PICK UP THE UNIT NUMBER
	DAC	I.PCPB	/AND SET IT IN ALSO
	XOR	I.PCPB+1	/NOW SET THE CURRENT BLOCK POINTER
	DAC	I.THIS	/TO POINT TO WHERE WE ARE NOW
	CAL	I.GETC	/GET THE NEW BLOCK
	JMS	I.WFEV	/WAIT
	JMP*	I.XDSK	/AND LEAVE
/
/
I.TYP3	XOR	INBUF+2	/PICK UP THE TOTAL NUMBER OF PATCHES
	SPA!SNA		/SKIP IF THERE ARE ANY
	JMP	I.EXLP	/NO, LOOK FOR SOMETHING ELSE TO DO
	DAC	I.TOTP	/SAVE THIS
I.T3LP	ISZ	I.PNTR	/FIND OUT HOW MANY
	JMS	I.GETW	/PATCHES ON THIS RECORD
	SPA!SNA!TCA	/SKIP IF THERE ARE ANY
	JMP	I.EXLP	/NO, CARRY ON WITH THE NEXT RECORD
	DAC	I.CCNT	/YES, SAVE THE COUNT
	TAD	I.TOTP	/AND SUBTRACT THIS FROM THE TOTAL
	DAC	I.TOTP
I.T3LQ	LAC*	I.PNTR	/PICK UP THE ADDRESS
	AND	(077777)	/WHERE THE PATCH GOES
	JMS	I.GETA	/MAKE SURE THAT IT IS IN CORE
	JMS	I.GETW	/FIND OUT WHAT THE FUNCTION IS
	AND	(IOT)
	SAD	(JMS)	/IS IT ADDRESS FIELD MODIFICATION?
	JMP	I.T3AD	/YES, DO IT
	SAD	(LAC)	/IS IT BLANK COMMON OFFSET?
	JMP	I.T3CO	/YES
	SZA		/IS IT SIMPLE REPLACEMENT?
	JMP	I.ER10	/NO, MUST BE A READ ERROR
	JMS	I.GETW	/PICK UP THE WORD
I.T3BK	DAC*	I.DPNT	/SET IT IN THE DISK BLOCK
	LAW	-1	/SET THE 'MODIFIED BLOCK' FLAG
	DAC	I.WRIT	/TO SHOW THAT WE CHANGED THE BLOCK
	ISZ	I.CCNT	/COUNT THE PATCHES
	JMP	I.T3LQ	/NOT YET DONE, GO FOR MORE
	LAC	I.TOTP	/ARE WE COMPLETELY DONE?
	SPA!SNA		/SKIP IF NOT
	JMP	I.EXLP	/YES, READ A TYPE ONE RECORD
	JMS	READ	/NO, RESET FOR THE NEXT PATCH RECORD
	LAC	(INBUF+2)
	DAC	I.PNTR	/SET UP FOR 'GETW'
	LAC	INBUF+2	/MAKE CERTAIN THAT THIS IS
	AND	(IOT)	/A TYPE THREE RECORD
	SAD	(ADD)	/SKIP IF NOT
	JMP	I.T3LP	/IT IS, FINISH UP
	JMP	I.EXLP+3	/IT ISN'T, WHAT HAPPENED???
I.T3AD	LAC	I.ENTR	/PICK UP THE TASK ENTRY POINT
	RAL		/BANK/PAGE BIT TO AC0
	SMA!CLA
	LAC	(010000)	/PAGE MODE, MUST KEEP THE INDEX BIT
	XOR	(760000)	/CREATE A MASK
	PAL		/SAVE THIS
	AND*	I.DPNT	/PICK UP THE INSTRUCTION FIELD ONLY
	LMQ		/SAVE THIS
	PLA		/BRING THE MASK BACK
	CMA		/FLIP IT OVER
	AND*	I.PNTR	/BRING IN THE NEW ADDRESS FIELD
	OMQ		/AND BRING THE INSTRUCTION OUT
	ISZ	I.PNTR	/UP THE POINTER
	JMP	I.T3BK	/AND PUT THIS AWAY
I.T3CO	JMS	I.GETW	/PICK UP THE WORD
	TAD	I.BCBS	/ADD IN THE BASE OF BLANK COMMON
	JMP	I.T3BK	/AND PUT THE WORD AWAY
/
/
/SUBROUTINE TO SET UP THE LINK TABLE FOR THE LINK ABOUT TO BE PROCESSED
/
I.LKTB	XX
	LAC	I.CORB	/SET UP TO ACCESS ON LINK 0 LEVEL
	DAC	I.LCOR	/AS THIS IS LINK TABLE MODIFICATION
	LAC	I.DSKB
	DAC	I.LBSE
	LAC	I.LTBS	/PICK UP THE BASE ADDRESS OF THE LINK TABLE
	IAC		/PLUS ONE
I.LKLP	DAC	I.PNTR	/SAVE THIS
	JMS	I.GETA	/BRING THIS INTO CORE
	LAC*	I.DPNT	/IS THIS THE END OF THE LINK TABLE?
	SAD	I.LTBS	/SKIP IF NOT
	JMP	I.LKUP	/IT IS, SET UP FOR THE NEXT LINK
	LAC	I.PNTR	/PICK UP THE
	AAC	7	/LINK NUMBER WORD
	JMS	I.GETA	/
	LAC*	I.DPNT	/IS THIS THE LINK WE ARE WORKING ON NOW?
	SAD	INBUF+3	/SKIP IF NOT
	JMP	I.LKBS	/IT IS, SET UP THE DISK ADDRESS ON THIS ONE
I.LKMR	LAC	I.PNTR	/IT ISN'T, UP TO THE NEXT ONE
	AAC	13	/IN THE TABLE
	JMP	I.LKLP
/
/NOTE: EARLIER VERSIONS USED THE MINIMUM ADDRESS WORD TO FLAG THE LINKS
/THAT HAD BEEN UPDATED. HOWEVER, WITH THE LOW END OF THE DISK ALLOCATED
/TO THE SYSTEM IMAGE, IT IS VERY UNLIKELY THAT THE LINK NUMBERS WILL
/REACH THE SAME MAGNITUDE AS THE DISK ADDRESS THAT REPLACES IT.
/THEREFORE, THE SAD SHOULD BE ENOUGH.
/
I.LKBS	LAC	I.WRK	/SET THE BASE ADDRESS OF THIS LINK
	JMS	I.PUTW	/IN THE LINK TABLE
	LAC*	I.DPNT	/AND SET THE MINIMUM ADDRESS OF THE LINK
	DAC	I.TMP	/IN A SAFE PLACE FOR SETTIN I.LCOR WHEN DONE
	JMP	I.LKMR	/NOW LOOK AT THE NEXT LINK
/
I.LKUP	LAC	I.TMP	/SET THE CORE BASE ADDRESS FOR THIS LINK
	DAC	I.LCOR	/IN FOR DISK ADDRESS ADJUSTING
	LAC	I.WRK	/SET THE DISK BASE ADDRESS CORRESPONDING TO
	DAC	I.LBSE	/I.LCOR IN ALSO
	JMP*	I.LKTB	/AND LEAVE
/
/
/THE WHOLE THING IS DONE, NOW TO MAKE THE STL ENTRY FOR THIS TASK
/AND LEAVE THIS BLOODY MESS.
/
I.DEXP=.
	.IFUND	TKNAM
	CAL	CLOSE	/CLOSE THE FILE
	CAL	DETACH	/AND DETACH THE DEVICE
	CAL	I.WAIT
	.ENDC
	ISZ	I.WRIT	/DOES THE DISK BLOCK NEED RE-WRITING?
	JMP	I.DOVR	/NO, GO CLEAN UP
	CAL	I.PUTC	/YES, WRITE IT OUT
	JMS	I.WFEV	/AND WAIT FOR IT
I.DOVR	JMS*	(PENP)	/PICK AN EMPTY BEER CAN FROM THE POOL
	JMP	I.ER05	/AND SHOW AN ERROR IF NO LITTER IS AROUND
	DAC*	(R2)	/OTHERWISE, IF ONE IS FOUND, MAKE IT LOOK RESPECTABLE
	IAC		/BY CLEVERLY DISGUISING IS AS AN STL NODE FOR
	DAC*	(X11)	/THIS NEW TASK IN THE SYSTEM
	LAC	I.XM	/(MJH-11) SET XVM MODE BITS INTO STL NODE
	XOR	I.MXTR	/(MJH-11)
	DAC	I.MXTR	/(MJH-11)
	.IFUND	TKNAM
	LAC	(I.TSKN-1)	/SET THE
	DAC*	(X10)	/TASK INFO IN THE
	LAW	-10	/STL NODE
	.ENDC
	.IFDEF	TKNAM
	LAC	TKNAM
	DAC*	X11
	LAC	TKNAM+1
	DAC*	X11
	LAC	(I.DFPR-1)
	DAC*	(X10)
	LAW	-6
	.ENDC
	DAC	I.ACNT	/BY MOVING IT FROM THE NEAT BLOCK IT IS IN
	LAC*	X10	/FRESHLY PICKED
	DAC*	X11	/NODE
	ISZ	I.ACNT
	JMP	.-3
/
	LAC	(STKL)	/NOW ADD THIS TO
	DAC*	(R1)	/THE STL (R2 IS SET FROM ABOVE) (THANK GOD)
	JMS*	(NADD)
	.IFPNZ	-1	/DON'T ASSEMBLE THIS CODE
/
/AT THIS POINT, WE ARE DONE. NOW IT IS POSSIBLE THAT WE HAVE OVER-ALLOCATED
/THE DISK. A CHECK IS MADE TO SEE IF THE ENTIRE ALLOCATION WAS USED.
/IF NOT, THE UNUSED PART IS GIVEN BACK.
/
	LAC	I.ALSZ	/PICK UP THE SIZE OF THE ALLOCATION
	CLL		/MAKE CERTAIN THAT THE LINK IS CLEAR
	LRS	10	/SHIFT OVER TO BLOCK COUNT
	DAC	I.BCNT	/SAVE THIS
	LAC	I.ALSZ+2	/PICK UP THE WORD ADDRESS
	LMQ
	LAC	I.ALSZ	/NOW THE 'UNIT' NUMBER
	LLS	12	/NOW AC=FIRST 'BLOCK' NUMBER OF ALLOCATION
	TAD	I.BCNT	/NOW AC=FIRST BLOCK AFTER ALLOCATION
	DAC	I.BCNT	/SAVE
	LAC	I.WRK	/PICK UP THE FIRST UNUSED BLOCK NUMBER IN PACKED
	LMQ		/FORM AND UNPACK IT
	LLS	12	/DONE
	TCA		/NEGATE IT
	TAD	I.BCNT	/SUBTRACT IT FROM THE FIRST UNALLOCATED BLOCK
	SPA!SNA		/SKIP IF ANY ARE LEFT OVER
	JMP	I.DDED	/NO, LEAVE
	ALSS	10	/YES - NOW BACK TO WORD FORMAT
	DAC	I.ALSZ	/SAVE THIS AS THE SIZE TO DE-ALLOCATE
	LAW	-400
	AND	I.WRK	/PICK UP THE LOW ORDER 'WORD' ADDRESS
	DAC	I.ALSZ+2	/OF THE FIRRST UNUSED BLOCK
	XOR	I.WRK	/PICK UP THE 'UNIT' NUMBER
	DAC	I.ALSZ+1	/SET IT IN FOR DE-ALLOC.
	CAL	I.DCPB	/DE-ALLOCATE THE SPACE
	CAL	I.WAIT	/WAIT UNTIL DONE
I.DDED=.
/*****
/AT THIS POINT THE ALLOCATION PARAMETER IN BLOCK 0-1 OF THE TASK SHOULD
/ALSO BE CHANGED
	.ENDC	/END OF NON-ASSEMBLY
/
	.IFDEF	TKNAM
	JMP*	INSTAL	/DONE, LEAVE IF SCF SUBROUTINE
	.ENDC
	.IFUND	TKNAM
	CAL	DETACH	/DETACH DEVICE ON LUN 18
	CAL	I.WAIT
	JMS*	(FAC)	/PICK UP THE TERMINATING CHARACTER AGAIN
	SAD	(015)	/CR TERMINATED COMMAND STRING?
LEAVE	CAL	REQMCR	/YES, REQUEST THE MCR ROUTINE
	DZM*	(MCRRI)	/CLEAR THE ^C INHIBIT
	CAL	(10)	/AND EXIT
/
REQMCR	1	/CPB TO REQUEST '...MCR' KEYBOARD LISTENER
	0	/NO EV
	.SIXBT	'...MCR'
	0	/DEFAULT PRIORITY
/
/
/SEEK SUBORUTINE
/
SEEK	XX
	LAC	I.TSKN	/PICK UP THE
	DAC	DTSEEK+3
	LAC	I.TSKN+1
	DAC	DTSEEK+4	/TASK NAME AND PUT IT IN THE CPB
	CAL	DTSEEK	/SEEK THE FILE
	CAL	I.WAIT	/WAIT FOR THE EV
	LAC	I.EV	/WAS THIS ALL OK?
	SMA		/SKIP IF NOT
	JMP*	SEEK
	SAD	(-6)	/ONLY THAT THE FUNCTION IS NOT HONOURED?
	JMP*	SEEK	/YES
I.ER13	LAC	(I.ME13)	/NO, FILE NOT FOUND
	JMP	I.ERRR	/SHOW IT
/
/READ SUBROUTINE
/
READ	XX
	CAL	DTREAD	/READ A LINE
	CAL	I.WAIT	/WAIT FOR IT
	LAC	I.EV	/WHAT DOES THE ALL-KNOWING EV HAVE TO SAY?
	SPA		/SKIP IF IT SAYS ALL OK
	JMP	I.ER10	/JUMP FOR ERROR IF NOT
	LAC	INBUF	/SO FAR SO GOOD - NOW WHAT DOES THE HEADER SAY?
	AND	(77)	/SINGLE OUT THE GOODIE BITS
	SNA		/UH-OH - WE ARE SKIPPING IF SOME BITS ARE ON
	JMP*	READ	/NO SKIP - ALL OK
	ALS	14	/BRING THE CHECKSUM BIT TO AC0
	SPA!RAL		/SKIP IF NOT CHECKSUM
	JMP	I.ER07	/IT IS A CHECKSUM ERROR
	SPA		/SKIP IF NOT PARITY ERROR
	JMP	I.ER08	/PARITY ERROR, SHOW IT
	DZM	INBUF+2	/CLEAR THE RECORD TYPE, JUST IN CASE
	LAC	INBUF
	SAD	(1005)	/EOF?
	JMP*	READ	/YES, QUIT
	SAD	(1006)	/EOM?
	JMP*	READ	/YES, FORGET IT
I.ER10	LAC	(I.ME10)	/DECTAPE ERROR - (EOF OR EOM?) SAY SOMETHING
	JMP	I.ERRR
/
/CPBS FOR MCR FUNCTION
/
ATTACH	2400	/ATTACH LUN 18
	I.EV	/FOR INPUT
	ILUN
/
DTSEEK	3200	/SEEK THE FILE
	I.EV
	ILUN
	.SIXBT	'@@@@@@TSK'
/
DTREAD	2600	/READ A LINE
	I.EV
	ILUN
	0	/IN IOPS BINARY
	INBUF
	42
/
CLOSE	3400	/CLOSE THE FILE
	0
	ILUN
/
DETACH	2500	/DETACH LUN 18
	I.EV
	ILUN
/
TTMESG	2700	/WRITE AN ERROR MESSAGE TO THE MCR OPERATOR
	I.EV
	3
	2
TTMESA	XX
	42
/
I.ERRR	DAC	TTMESA
	CAL	TTMESG	/WRITE THE MESSAGE
	CAL	I.WAIT	/WAIT FOR THE EV
	LAC	I.EV	/PICK IT UP
	SMA		/SKIP IF ERROR
	JMP	ERRXIT	/DE-ALLOCATE THE DISK SPACE AND LEAVE
	SAD	(-777)	/OUT OF POOL?
	JMP	.-5	/YES, TRY UNTIL WE CAN DO IT
ERRXIT	LAC	I.DSKA	/HAS DISK SPACE BEEN ALLOCATED?
	SNA		/SKIP IF SO
	JMP	.+3	/OVER IF NOT
	CAL	I.DCPB	/DEALLOCATE IT IF SO
	CAL	I.WAIT
	CAL	DETACH	/DETACH LUN 18 - IT CAN'T HURT (CAN IT?)
	CAL	I.WAIT
	JMP	LEAVE	/REQUEST THE MCR LISTENER AND LEAVE
/
	.ENDC
	.IFDEF	TKNAM
I.ERRR	DAC	I.ERRA	/SET THE ADDRESS OF THE MESSAGE TO PRINT
	JMS*	(TYPE)	/START PRINTING
	MES900		/THEE ERROR
	LAC	(SCFIB+1)	/NOW TO CREATE THE TASK NAME IN
	DAC*	(X10)	/IMAGE MODE
	LAC	TKNAM
	JMS	EREXS1	/FIRST THREE
	LAC	TKNAM+1
	JMS	EREXS1	/LAST THREE
	CAL	SCFTIB	/WRITE IT OUT
	CAL	WFCPB	/WAIT
	JMS*	(TYPE)	/NOW FINISH THE 'TASK XXXXXX NOT INSTALLED'
	MES901
	JMS*	(TYPE)	/PUT OUT THE REASON
I.ERRA	XX
	LAC	I.DSKA	/DISK SPACE ALLOCATED?
	SNA		/SKIP IF SO
	JMP	.+3	/OVER IF NOT
	CAL	I.DCPB	/DEALLOCATE IT IF SO
	CAL	I.WAIT
	JMP*	INSTAL	/AND LEAVE
/
EREXS1	XX
	LMQ
	JMS	EREXS2
	JMS	EREXS2
	JMS	EREXS2
	JMP*	EREXS1
/
EREXS2	XX
	LLS	6
	AND	(77)
	SNA
	AAC	177
	XOR	(40)
	TAD	(40)
	DAC*	X10
	JMP*	EREXS2
/
	.DEFIN	ABUF,TEXT,?B
	B-./2*1000+2 ; 0
	.ASCII	\@TEXT@\<15>
B=.
	.ENDM
	.ENDC
/
	.IFUND	TKNAM
	.DEFIN	ABUF,TEXT,?B
	B-./2*1000+2 ; 0
	.ASCII	\ @TEXT@\<15>
B=.
	.ENDM
	.ENDC
I.ER02	LAC	(I.ME02)
	JMP	I.ERRR
I.ER03	LAC	(I.ME03)
	JMP	I.ERRR	/ERROR ROUTINES - PICK UP THE MESSAGE ADDRESS
I.ER04	LAC	(I.ME04)	/AND GO OFF TO DO THE WORK
	JMP	I.ERRR
I.ER05	LAC	(I.ME05)
	JMP	I.ERRR
I.ER06	LAC	(I.ME06)
	JMP	I.ERRR
I.ER07	LAC	(I.ME07)
	JMP	I.ERRR
I.ER08	LAC	(I.ME08)
	JMP	I.ERRR
I.ER09	LAC	(I.ME09)
	JMP	I.ERRR
	.IFDEF	TKNAM
I.ER10	LAC	(I.ME10)
	JMP	I.ERRR
	.ENDC
I.ER12	LAC	(I.ME12)
	JMP	I.ERRR
I.ER14	LAC	(I.ME14)
	JMP	I.ERRR
I.ER15	LAC	(I.ME15)
	JMP	I.ERRR
/
/ERROR MESSAGES:
/
I.ME01	ABUF	<SYNTAX ERROR>
I.ME02	ABUF	<TASK ALREADY IN SYSTEM>
I.ME03	ABUF	<PARTITION NOT IN SYSTEM>
I.ME04	ABUF	<TASK WOULD OVERFLOW PARTITION>
I.ME05	ABUF	<OUT OF POOL>
I.ME06	ABUF	<OUT OF DISK>
I.ME07	ABUF	<INPUT CHECKSUM ERR>
I.ME08	ABUF	<INPUT PAR ERR>
I.ME09	ABUF	<SYS COM BLK ERR>
I.ME10	ABUF	<READ ERR ON LUN 18>
I.ME11	ABUF	<DISK ERR>
I.ME12	ABUF	<NO DEFAULT PRIORITY>
I.ME13	ABUF	<FILE NOT FOUND ON LUN 18>
I.ME14	ABUF	<RELOCATION HARDWARE NOT AVA>
I.ME15	ABUF	<FLOATING POINT UNIT NOT AVA>
/
/SUBROUTINE TO WAIT FOR I.EV AND ANNOUNCE A DISK ERROR IF NEGATIVE WHEN
/COMPLETE.
/
I.WFEV	XX
	CAL	I.WAIT	/WAIT
	LAC	I.EV
	SMA		/ERRORS?
	JMP*	I.WFEV	/NO, LEAVE
I.ER11	LAC	(I.ME11)	/DISK ERROR
	JMP	I.ERRR	/ANNOUNCE IT AND CLEAN UP
/
/
/VARIABLES, CONSTANTS, AND CPBS WITH BUFFERS AS A SIDELINE
/
I.XM	0	/(MJH-11) XVM MODE BITS
I.ACNT	0	/SCRATCH LOCATIONS
I.TMP	0
I.BCNT	0
I.CCNT	0
I.WRK	0
I.DPNT	0	/POINTER USED PRIMARILY BY I.PUTW
I.MXDK	0	/MAXIMUM DISK BLOCK USED BY THE CURRENT LINK
I.THIS	0	/DISK ADDRESS OF CURRENT BLOCK IN CORE
I.WRIT	0	/-1 WHEN CURRENT BLOCK HAS BEEN MODIFIED, 0 IF NOT
I.DSKA	0	/INDICATOR THAT THE DISK AREA HAS BEEN ALLOCATED (0 IF NOT)
I.LBSE	0	/DISK BASE ADDRESS FOR CURRENT LINK
I.LCOR	0	/CORE ADDRESS CORRESPONDING TO I.LBSE
I.LKNM	0	/NUMBER OF LINK BEING SOUGHT BY I.FLNK
I.PTNM	0 ; 0   /PARTITION NAME
I.TOTP	0	/COUNTER FOR PATCH RECORDS
I.LTBS	0	/LINK TABLE BASE ADDRESS
/THE FOLLOWING ARE NEEDED FOR STL NODE BUILDING:
	.IFUND	TKNAM
I.TSKN	0 ; 0   /NAME OF TASK
	.ENDC
I.DFPR	0	/PRIORITY OF TASK
I.PBAD	0	/PARTITION DESCRIPTOR BLOCK ADDRESS
I.DSKB	0	/DISK BASE ADDRESS
I.RISZ	0	/RESIDENT IMAGE SIZE
I.MXTR	0	/MAXIMUM TASK REGISTER (CHANGED TO SIZE FOR STL NODE)
I.ENTR	0	/TASK ENTRY PC (WITH BANK/PAGE AND EXEC/NORM MODE BITS)
/
I.BCBS	0	/BASE OF BLANK COMMON FOR PATCHING
I.PNTR	0	/POINTER USED BY I.GETW
I.CORB	0	/CORE BASE ADDRESS (CORRESPONDING TO I.DSKB)
/
I.WAIT	20	/CPB FOR WAITING
	I.EV		/FOR THE EV
/
I.EV	0	/GENERAL PURPOSE EV
/
I.ACPB	1500	/ALLOCATE DISK SPACE CPB
	I.EV
	1	/ALLOCATE ON DISK - LUN 1
	I.ALSZ	/ADDRESS OF ALLOCATE/DEALLOCATE DISK CONTROL TABLE
/
I.DCPB	1600	/DEALOCATE DISK SPACE CPB (IN CASE OF ERRORS)
	I.EV
	1
	I.ALSZ	/OTHERWISE, SAME AS I.ACPB
/
I.ALSZ	0	/ALLOCATE/DEALLOCATE CONTROL TABLE
	0 ; 0
/
I.GETC	3000	/GET (DISK) CPB
	I.EV
	1
	I.PCPB	/GET/PUT CONTROL TABLE
/
I.PUTC	3100	/PUT (DISK) CPB
	I.EV
	1
	I.PCPB	/SAME AS I.GETC
/
I.PCPB	0	/GET/PUT CONTROL TABLE
	0	/DISK ADDRESS IS PUT HERE
	I.BLOK	/ALL I/O TO/FROM DISK IS DONE THROUGH THE I.BLOK BUFFER
	400	/AND IS EXACTLY ONE BLOCK LONG
/
/
INBUF	.BLOCK	42	/INPUT BUFFER
	.IFDEF	TKNAM
TCX	0
	SAD	(015)	/SUBROUTINE TO SKIP IF AC DOES NOT
	JMP*	TCX	/CONTAIN A TERMINATOR
	SAD	(175)
	JMP*	TCX
	ISZ	TCX
	JMP*	TCX
ERR10=I.ER10	/TO ALLOW LABEL REFERENCING
	.ENDC
	.END	INSTAL
	.ENDC
