	.TITLE	INSTALL TASK (...INS)

/

/ COPYRIGHT (C) 1976

/ 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 #13 SAVE-REMOVE-INSTALL	M. HEBENSTREIT	4/6/76

/ EDIT #23	MAY-12-76 (SCR) MODIFY SAVE-REMOVE-INSTALL FIX
/ EDIT #24	MAY-13-76 (SCR) FURTHER CLEANUP
/ EDIT #25	MAY-17-76 (SCR) POINTER OFF BY INSSZ
/  

/

/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.)

/

/

X10=10

X11=11

X15=15

	.IFUND	TKNAM

R1=101

R2=102

REMBLK=311		/1ST BLK IN SAVE-INSTALL-REMOVE CHAIN

P.N1=2			/PBDL OFFSET TO PARTITION NAME 1ST 1/2

P.N2=3			/PBDL OFFSET TO PARTITION NAME 2ND 1/2

P.BS=4			/PBDL OFFSET TO PARTITON BASE

ECLA=641000		/CLEAR AC WITH EAE

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

	LAC	(I.ALSZ	/(027) START CORRECTLY

	DAC	I.ACPB+3

	AND	(70000					/(MJH-13)

	TCA						/(MJH-13)

	DAC	XRADJ					/(MJH-13)

	.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-5 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=.

	.TITLE	SAVE-REMOVE-INSTALL BLOCK CHAIN UPDATE

/

/ (THE CODE FOUND BETWEEN THE "*****" WAS ENTERED BY MJH 4/6/76 EDIT #13

/  AND SCR EDIT #23)
/ *********************

/

/

/ THE FOLLOWING CODE IS USED TO UPDATE THE INSTALL/REMOVE

/ CHAIN OF BLOCKS IN ORDER TO FIX THE SAVE-REMOVE-INSTALL

/ GLITCH. THE IDEA IS THAT EACH TIME THE STL IN CORE IS CHANGED,

/ THIS CHAIN OF DISK BLOCKS MUST ALSO CHANGE. WHENEVER A TASK IS

/ REMOVED, THE TASKS NAME IS ENTERED INTO THE CHAIN. WHENEVER A

/ TASK IS INSTALLED,  A COPY OF ITS STL NODE (LESS POINTERS) IS

/ ENTERED INTO THE CHAIN ALONG WITH THE TASKS PBDL DATA.

/ WHEN THE SYSTEM IS BOOTSTAPPED THE COPY OF SAVE WHICH IS

/ IN CORE READS THE CHAIN OF BLOCKS AND RECONSTRUCTS THE

/ STL FROM THE DATA FOUND IN THE BLOCKS.

/ WHENEVER A SAVE IS DONE (STL IN CORE MATCHES STL ON DISK)

/ THIS CHAIN OF BLOCKS IS PURGED.

/

/ THE STRUCTURE OF EACH BLOCK IS:

/

/	WORDS 0-375 USED FOR DATA ENTRIES

/	WORD 376 IS A POINTER TO 1ST FREE WORD IN BLOCK

/	WORD 377 IS A POINTER TO NEXT BLOCK OR -1

/

/ THE STRUCTURE OF A REMOVE ENTRY IS:

/

/	NTRY+0 -1 (FLAG SAYING THIS ENTRY IS A REMOVE)

/	NTRY+1 TASK NAME IN SIXBT 1ST HALF

/	NTRY+2 TASK NAME IN SIXBT 2ND HALF

/

/ THE STRUCTURE OF AN INSTALL ENTRY IS:

/

/	NTRY+0 +1 (FLAG SAYING THIS ENTRY IS AN INSTALL)

/	NTRY+1 TASK NAME IN SIXBT 1ST HALF

/	NTRY+2 TASK NAME IN SIXBT 2ND HALF

/	NTRY+3 STL NODE WORD 4

/	NTRY+4 STL NODE WORD 5

/	NTRY+5 STL NODE WORD 6

/	NTRY+6 STL NODE WORD 7

/	NTRY+7 STL NODE WORD 10

/	NTRY+10 STL NODE WORD 11

/	NTRY+11 PARTITION NAME IN SIXBT 1ST HALF

/	NTRY+12 PARTITION NAME IN SIXBT 2ND HALF

/	NTRY+13 PARTITION BASE ADDRESS

/

/ NOTE THAT IT IS EXTREMELY IMPORTANT TO FILL UP DATA

/ ENTRIES IN THE REMOVE CHAIN IN THE ORDER THAT EACH

/ STL MODIFICATION WAS MADE.

/

/ NOTE ALSO THAT ALL TASKS WHICH ACCESS THIS CHAIN OF 

/ BLOCKS MUST RESIDE IN THE SAME PARTITION.

/ THOSE TASKS ARE: SAVE,TDV REM, MCR REM, TDV INS, MCR INS,

/ FININS, AND AUTORM.

/

	.EJECT

/

/ START TO PROCESS THE REMOVE CHAIN OF BLOCKS

/

INSSZ=14				/SIZE OF AN INSTALL ENTRY

REMSZ=2					/SIZE OF A REMOVE ENTRY

BEGIN	DZM	REMFLG		/NOT AT END, ZERO FLAG

	LAC*	(REMBLK		/GET THE 1ST BLOCK IN THE CHAIN

	SKP			/JOIN UP TO PLACE BLOCK

/

/ READ IN A BLOCK IN THE CHAIN

/

REM0	LAC	I.BLOK+377	/GET NEXT BLOCK

	DAC	CURBLK		/SAVE CURRENT BLOCK NUMBER

	JMS	CONVRT		/CONVERT TO PLATTER AND ADDR
	CAL	I.GETC		/READ BLOCK
	CAL	I.WAIT
	LAC	I.EV		/ANY ERRORS ON READ?
	SPA
	JMP	I.ER11		/YES --
				/NO --

/

REM1	LAC	REMFLG		/NOP UNLESS LAST BLOCK, 

	SMA			/LAST, FORCE -1

	LAC	I.BLOK+376	/DATA, LAST BLOCK MISSES THIS

	SMA			/SKIP IF LAST BLOCK

	JMP	REM0		/NO, FETCH ANOTHER

	AAC	377-INSSZ	/CAN INSTALL ENTRY FIT

	SPA			/SKIP IF YES

	JMP	GETSOM		/NO, ANOTHER BLOCK NEEDED

	AAC	-377		/UPDATE POINTER

	DAC	I.BLOK+376

	CMA			/SET UP X10 TO PLACE DATA
	TAD	(I.BLOK-1-INSSZ	/(025)SETUP X10 TO POINT AT NTRY-1

	DAC*	(X10		/SAVE BLOCK ENTRY POINTER

	CLA!IAC			/SET UP FLAG WORD ENTRY

	DAC*	X10		/IF FLAG IS +1 THIS IS AN INSTALL NTRY

	LAC	(I.TSKN-1	/PREPARE TO ENTER STL DATA

	DAC*	(X11		/USER X11 AS A POINTER TO STL DATA

	LAW	-10		/TRANSFER WORDS 2-11 OF STL NODE

	DAC	I.TMP		/INTO BLOCK NTRY

	LAC*	X11

	DAC*	X10

	ISZ	I.TMP

	JMP	.-3

	LAC	I.PBAD		/PREPARE TO ENTER PBDL DATA

	JMS	SETXR

	LAC	P.N1,X		/GET PART NAME

	DAC*	X10

	LAC	P.N2,X

	DAC*	X10

	LAC	P.BS,X		/GET BASE

	DAC*	X10

/

/ UPDATE THE BLOCK DATA ITEM POINTER, WRITE OUT BLOCK, AND QUIT

/

	JMS	PUTBLK		/WRITE OUT THE DISK BLOCK

	JMP	REMNOD		/ALL DONE WITH THIS PHASE

/

/ PREPARE TO GET NEXT BLOCK IN CHAIN OR ALLOCATE A NEW BLOCK

/

GETSOM	LAC	I.BLOK+376	/NO LONGER EOF, MAKE IT +

	CMA

	DAC	I.BLOK+376	/

	LAW	-1		/SET REMFLG TO SHOW END

	DAC	REMFLG

	SAD	I.BLOK+377	/ANOTHER BLOCK ALREADY IN CHAIN

	JMP	ALLBLK		/(027) GO TO ALLOCATE A NEW BLOCK

	JMS	PUTBLK		/(027) OLD BLOCK OUT WITH + POINTER

	JMP	REM0		/NO -- PREPARE TO READ IN ANOTHER

				/YES --

/

/ ALLOCATE A NEW BLOCK FOR THE REM CHAIN

/

ALLBLK	LAC	(ALLCTA		/ENTER SAV-REM-INS ALLOCATE CTA 

	DAC	I.ACPB+3	/INTO ALLOCATE CPB

	CAL	I.ACPB		/ALLOCATE A BLOCK

	CAL	I.WAIT

	LAC	I.EV		/ANY ERRORS?

	SPA

	JMP	I.ER06		/YES

	LAC	ALLCTA+2	/NO -- GET THE BLK NUMBER

	LMQ			/CONVERT PLATTER AND ADDR

	LAC	ALLCTA+1	/TO A DISK BLOCK NUMBER

	AND	(7777

	LRSS	10

	LACQ

	DAC	NEWBLK		/SAVE THE BLK NUMBER

/

/  CAN WE WRITE ON THE NEW BLOCK, TRY IT. IF FAILS,

/ THE PREVIOUS BLOCK DOESN'T POINT AT IT.

/

	JMS	CONVRT		/CHANGE TO PLATTER AND ADDR

	JMS	PUTBLK		/WRITE OUT THE NEW BLOCK

/

/ OK, SO WRITE OUT THE CURRENT DISK BLOCK

/

	LAC	CURBLK		/GET CURRENT BLOCK NUMBER

	JMS	CONVRT		/PREPARE TO WRITE IT OUT

	LAC	NEWBLK		/SET UP BLK FORWARD PTR

	DAC	I.BLOK+377

	JMS	PUTBLK		/WRITE OUT THE OLD BLOCK

/

/ INIT THE NEW DATA BLOCK BUFFER

/

	LAC	NEWBLK		/SET NEWLY ALLO'D BLK TO CURRENT BLK

	DAC	CURBLK

	JMS	CONVRT		/PREP TO WRITE OUT THIS BLOCK

	LAW	-1		/NO BLOCK POINTER ON NEW BLOCK

	DAC	I.BLOK+377

	JMP	REM1		/GO PROCESS ZEROD BLK

/

REMFLG	0			/0 UNTIL LAST FOUND, THEN -1

REMNOD=.

/ ********************

	.EJECT

	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 5

	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

	.EJECT

/

/ SUBROUTINE SETXR -- SETUP XRADJUSTMENT

/

SETXR	0					/(MJH-12)

	TAD	XRADJ				/(MJH-12)

	PAX					/(MJH-12)

	JMP*	SETXR				/(MJH-12)

/

/ SUBROUTINE CONVRT -- CHANGE BLK NUMBER IN AC TO PLAT AND ADDR

/

CONVRT	0					/(MJH-12)

	LMQ					/(MJH-12)

	LLSS!ECLA 10				/(MJH-12)

	DAC	I.PCPB				/(MJH-12)

	LACQ					/(MJH-12)

	DAC	I.PCPB+1			/(MJH-12)

	JMP*	CONVRT				/(MJH-12)

/

/ SUBROUTINE PUTBLK -- WRITE OUT A DISK BLOCK

/

PUTBLK	0					/(MJH-12)

	CAL	I.PUTC				/(MJH-12)

	JMS	I.WFEV				/(MJH-12)

	JMP*	PUTBLK				/(MJH-12)

	.EJECT

/

/CPBS FOR MCR FUNCTION

/

ATTACH	2400	/ATTACH LUN 5

	I.EV	/FOR INPUT

	5

/

DTSEEK	3200	/SEEK THE FILE

	I.EV

	5

	.SIXBT	'@@@@@@TSK'

/

DTREAD	2600	/READ A LINE

	I.EV

	5

	0	/IN IOPS BINARY

	INBUF

	42

/

CLOSE	3400	/CLOSE THE FILE

	0

	5

/

DETACH	2500	/DETACH LUN 5

	I.EV

	5

/

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 5 - 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 5>

I.ME11	ABUF	<DISK ERR>

I.ME12	ABUF	<NO DEFAULT PRIORITY>

I.ME13	ABUF	<FILE NOT FOUND ON LUN 5>

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

CURBLK	0	/CURRENT BLK IN REM-INS-SAV CHAIN (MJH-12)

NEWBLK	0	/NEWLY ALLO'D BLK FOR CHAIN (MJH-12)

OLDPTR	0	/OLD BLKS FREE WD PTR		(MJH-12)

XRADJ	0	/XR ADJUSTMENT FACTOR		(MJH-12)

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

/

ALLCTA	400	/ALLO/DEAL CT FOR SAV-REM-INS CHAIN (MJH-12)

	XX					/(MJH-12)

	XX					/(MJH-12)

/

/

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
