	.TITLE *** REASSIGN MCR FUNCTION ***
/
/ 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 #35
/
/
/ MCR FUNCTION -- REASSIGN	13 JAN 72	R. MCLEAN
/				8 MAY 1972	W. DESIMONE, S. DELLER
/				30 AUG 1974	M.HEBENSTREIT
/				27 JAN 1975	M.HEBENSTREIT
/				27 JUNE 75	M. HEBENSTREIT
/
/ TASK NAME "...REA" TO REASSIGN A LOGICAL UNIT NUMBER
/
/ THE FIRST LINE OF THE COMMAND INPUT FOR ANY MCR
/ FUNCTION IS READ BY THE RESIDENT MCR TASK ("...MCR").
/ FOR THE "REASSIGN" FUNCTION, THERE IS ONLY ONE LINE OF
/ COMMAND INPUT, AND IT'S SYNTAX IS AS FOLLOWS:
/
/	SYNTAX = 'REA'$<NBC><BREAK CHARACTER>
/		$<NDEV><LUN><BREAK CHAR><ODEV><LUN></ OR NULL>
/		(<CR>/<AM>)
/	<BREAK CHAR> = " "/","
/	<TASK NAME> = 1-6 ALPHANUMERIC CHARACTERS
/	<NDEV> = NEW DEVICE TO BE ASSIGNED
/	<ODEV> = OLD DEVICE TO BE REMOVED
/	<LUN> = LUN NUMBER TO BE USED
/	<CR> = CAR RTN
/	<AM> = ALTMODE
/	<NBC> = NON BREAK CHARACTER
/	<NULL> =" THE EMPTY SET"
/	$ -- " ANY NUMBER OF "INCLUDING ZERO "
/
/	THE RESIDENT MCR READS A LINE, FETCHES THE
/	FIRST THREE CHARACTERS TO FORM THE MCR FUNCTION TASK
/	NAME ("...REA"), FLUSHES CHARACTERS THRU THE FIRST
/	BREAK CHARACTER, REQUESTS "...REA", AND EXITS
/	THE TASK "...REA " PROCESSES THE REMAINDER OF THE LINE
/	AND IF THE REQUEST IS VALID, EXECUTES THE APPROPRIATE "REASSIGN"
/	REQUEST.
/
/	IF THE COMMAND INPUT LINE IS TERMINATED BY A CAR RTN,
/	THE RESIDENT MCR TASK IS REQUESTED, AND THE FUNCTION TASK
/	EXITS.
/
/	IF THE COMMAND INPUT LINE IS TERMINATED BY AN ALTMODE, THE
/	FUNCTION TASK EXITS WITHOUT REQUESTING "...MCR". A ^C TYPEIN
/	IS THEN NECESSARY TO RE-ESTABLISH MCR DIALOGUE.
/
/	IF THE NEW DEVICE IS A DISK, THEN OPTIONALLY THE USER
/	MAY SPECIFY A UFD TO BE ASSOCIATED WITH THE DISK/LUN PAIR.
/	E.G. MCR>REA 5 RP0 <ABC> DT2. IF NO UFD IS SPECIFIED THEN
/	REA WILL TRY TO OBTAIN A DEFAULT UFD NAME FROM THE 
/	DISK-UFD TABLE.
 .TITLE *** MCR FUNCTION 'REASSIGN'
/
MCRRI=171
CURTSK=135
TTMCTT=200
TTDVTT=201
ECLA=641000
.INH=705522
.ENB=705521
LUN1=142
LUN2=143
LUFD1=304
DUFD1=306
AFTP1=144
FAC=174
IDX=ISZ
PENP=115
R1=101
R2=102
SPRI=126
X10=10
PDVL=252
/
REA	LAC*	(LUN1)	/PICK UP LUN POINTER
	DAC	LUNPTR
	TCA		/DETERMINE THE SIZE OF THE LUN TABLE
	TAD*	(LUN2)
	DAC	LUNMAX
	DZM	MCRCNT	/MCR CONTROL TTY CHANGED INDICATOR
	DZM	TDVCNT	/TDV CONTROL TTY CHANGED INDICATOR
	DZM	UFDNAM	/ZERO UFD NAME IN CASE NEW DEV IS A DISK.
	DZM	SVSLS	/CLEAR SLASH FLAG
	LAW	-1
	DAC	TTCNTS	/SET UP THE CONTROL TTY CHANGED FALG
	DAC	TTCNTD	/SET UP THE TDV TTY CHANGED FLAG
	LAC	(LUNTAB-1)
	DAC*	(X10)	/STORE POINTER TO BEGINNING OF LUNTABLE
	AND	(070000)	/MASK OFF PAGE BITS
	DAC	MXADJ	/SAVE COMPLEMENT OF XADJ
	TCA
	DAC	XADJ	/SAVE INDEX REGISTER ADJUSTMENT
	DZM	UNTTMP	/CLEAR TEMP STORAGE
/
/ GET THE LUN NUMBERS
/
REAN2	LAW	-4	/MAX LUN NUMBER IS 999
	DAC	CNT
	DZM	LUNTMP
	DZM	ONCEFL	/SET UP FILES FLAG
	LAC	(MES9-2)
	DAC	MESSET	/RESET MESSAGE
REAN1	JMS*	(FAC)	/PICK UP A CHARACTER
	SAD	(040)	/IS IT A BLANK?
	JMP	NEWDEV	/YES GO LOOK AT THE REST OF THE LINE .
	SAD	(054)	/IS IT A COMMA?
	JMP	NXTLUN	/YES PICK UP NEXT LUN NUMBER TO BE SAVED
	AAC	-57	/CHECK TO SEE IF LUN NUMBER IS OCTAL
	SPA		/IS IT LESS THAN 60?
	JMP	ERR1	/YES SYNTAX ERROR
	AAC	-13	/IS IT GREATER THAN 71?
	SMA	
	JMP	ERR1	/YES SYNTAX ERROR
	AAC	12
	TAD	LUNTMP	/FORM LUN NUMBER
	DAC	LUN
	CLL
	MUL	/LUN NUMBERS IN OCTAL
	12
	LACQ
	DAC	LUNTMP	/SAVE INCASE THIS IS NOT ALL THE NUMBER
	ISZ	CNT	/IS LUN NUMBER TOO LARGE?
	JMP	REAN1
	JMP	ERR1	/SYNTAX ERROR LUN TOO LARGE A NUMBER
NXTLUN	LAC	LUN
	TAD	LUNPTR
	AAC	-1
	DAC*	X10	/STORE LUN NUMBER IN LUN POINTER TABLE
	LAC	LUN
	SAD	(1)	/CHECK FOR LUN 1 (ILLEGAL TO REASSIGN)
	JMP	ERR1	/SYNTAX ERROR
	SAD	(2)	/IS IT MCR CONTROL TTY?
	ISZ	MCRCNT	/YES SET UP TO CHANGE CONTROL
	SAD	(14)	/IS IT MCR CONTROL TTY?
	ISZ	TDVCNT	/YES SET UP TO CHANGE CONTROL
	TCA
	IAC
	TAD	LUNMAX	/IS LUN NUMBER GREATER THAN TABLE END?
	SPA
	JMP	ERR1	/YES SYNTAX ERROR
	JMP	REAN2	/NO PICK UP NEXT LUN
/
/ CHECK FOR LEGAL LUNS
/
NEWDEV	LAC	LUN
	TAD	LUNPTR	/SAVE LAST LUN FOUND IN TABLE
	AAC	-1
	DAC*	X10
	LAC	LUN
	SAD	(1)	/IS IT LUN-1
	JMP	ERR1	/YES SYNTAX ERROR
	SAD	(2)	/IS IT MCR CONTROL TTY?
	ISZ	MCRCNT	/YES SETUP TO CHANGE CONTROL
	SAD	(14)	/IS IT MCR CONTROL TTY?
	ISZ	TDVCNT	/YES SET UP TO CHANGE CONTROL
	TCA
	IAC
	TAD	LUNMAX	/DETERMINE IF LUN TOO LARGE
	SPA
	JMP	ERR1	/YES SYNTAX ERROR
/
/ GET NEW DEVICE
/
	CLA		/INDICATE NO CHAR IN AC
	JMS	GETDEV	/PICK UP DEVICE NAME AND UNIT NUMBER
	AAC	56	/ADD A .
	DAC	REQNAM
	LAC	MCRCNT	/ARE WE REASSIGNING THE MCR TTY?
	SNA
	JMP	MCROK	/NO -- PROCEED NORMALLY
	LAC	REQNAM	/YES -- IS NEW DEVICE A TTY?
	SAD	(242456	/(242456)=(TT.) IN SIXBT
	SKP		/YES -- OK
	JMP	ERR2	/NO -- DECLARE AN ERROR
MCROK	PLA		/GET UNIT NUMBER
	DAC	NEWUNT	/SAVE IT
/
/ CHECK FOR A DISK, AND IF SO LOOK FOR A UFD NAME
/
	LAC	REQNAM	/IS NEW DEV A DISK?
	SAD	(222056	/RP?
	JMP	RP	/YES
	SAD	(220656	/NO -- RF?
	JMP	RF	/YES
	SAD	(221356	/NO -- RK?
	SKP
	JMP	NOTDSK	/NO
	LAC	(24	/YES -- SAVE DEVICE CODE
	SKP
RP	LAC	(3
	SKP
RF	LAC	(2
	DAC	DEVICE	/SAVE CODE
	PLA		/STORE UNIT NUMBER
	DAC	UNIT
DSK1	JMS*	(FAC	/READ A CHAR
	SAD	(40	/SPACE?
	JMP	DSK1	/YES -- IGNORE
	SAD	(74	/<?
	SKP
	JMP	DSK2	/NO
	JMS	UFD	/YES -- GET 1ST CHAR OF UFD NAME
	ALS	14
	DAC	UFDNAM	/SAVE CHAR
	JMS	UFD	/GET 2ND CHAR
	ALS	6
	TAD	UFDNAM	/STORE IT
	DAC	UFDNAM
	JMS	UFD	/GET LAST CHAR OF UFD
	TAD	UFDNAM	/STORE IT
	DAC	UFDNAM
	JMS*	(FAC	/GET NEXT CHAR
	SAD	(76	/>?
	SKP
	JMP	ERR1	/NO -- FORMAT ERROR
	JMS*	(FAC	/YES -- GET NEXT CHAR
	SAD	(40	/CHECK FOR BREAK CHAR (SPACE OR COMMA)
	JMP	NOTDSK
	SAD	(54
	JMP	NOTDSK
	JMP	ERR1	/NOT A BREAK -- ERROR
DSK2	DAC	TEMP	/SAVE CHAR
	LAC	DEVICE	/TRY TO GET UFD NAME FROM DSIK-UFD TABLE
	SAD	(2
	JMP	RF1
	SAD	(3
	JMP	RP1
	LAC	(10	/RK
	SKP
RP1	CLA
	SKP
RF1	LAC	(20
	TAD	UNIT	/ADD UNIT NUMBER TO OFFSET
	TAD*	(DUFD1	/ADD BASE OF TABLE
	JMS	SETXR	/PREPARE TO GET DEFAULT UFD NAME
	LAC	0,X	/GET NAME
	SNA		/IS DISK MOUNTED?
	JMP	ERR20	/NO -- ERROR
	DAC	UFDNAM	/YES -- SAVE DEFAULT UFD NAME
	LAC	TEMP	/RESTORE CHAR IN AC
	SKP
/
/ GET OLD DEVICE
/
NOTDSK	CLA		/INDICATE NO CHAR IN AC
OLDLUN	JMS	GETDEV	/PICK UP OLD LUN NAME
	DAC	OLDNAM
	LAC*	(X10)	/SAVE POINTER TO LAST LUN POINTER IN TABLE
	DAC	LASTUN
	PLA		/PICK UP UNIT NUMBER
	DAC	OLDUNT
	LAC	(LUNTAB)	/PICK UP LUN TABLE POINTER
	DAC	LUNADR
	LAC*	LUNADR	/PICK UP THE POINTER TO THE PDVL
	DAC	CNT
	LAC*	CNT
	SZA		/CHECK FOR NONE
	JMP	NOTNON	/NO MUST BE OK
	SAD	OLDNAM
	JMP	LUNCK
	JMP	ERR2
NOTNON	AAC	2
	DAC	DEVNAM	/POINTER TO THE DEVICE NAME
	AAC	3
	DAC	DEVUNT	/POINTER TO THE DEVICE UNIT NUMBER
	AAC 3
	DAC	DEVTEV	/POINTER TO PDVL TRIGGER EV ADDRESS
	LAC*	DEVNAM	/PICK UP THE DEVICE NAME
	SAD	OLDNAM	/IS IT CORRECT?
	SKP		/YES
	JMP	ERR2	/INCORRECT NAME ERROR
	LAC*	DEVUNT	/IS THE UNIT NUMBER CORRECT
	SAD	OLDUNT
	SKP		/YES
	JMP	ERR3	/OLD UNIT NUMBER INCORRECT ERROR
	LAC*	DEVTEV
	SZA	/IS THE HANDLER INITIALIZED?
	JMP	LUNCK	/YES
	LAC	DEVTEV	/SEE IF REA. INHIBIT IS ON.
	IAC
	DAC	TMPA
	LAC*	TMPA
	SPA
	JMP	ERR7	/YES -- REA. INHIBITED
	JMP	ERR13	/NO -- HANDLER NOT INITIALIZED
LUNCK	LAC*	LASTUN	/PICK UP THE POINTER TO THE LUN SLOT
	DAC	TMPB	/SAVE IT
LUNCKK	LAC*	LUNADR	
	DAC	TMPA	/SAVE POINTER TO LUN SLOT
	LAC*	TMPA	/LOOK AT THE ADDRESSES OF THE PDVL NODES
	SAD*	TMPB	/TO SEE IF THEY ARE THE SAME
	SKP		/SAME PDVL?
	JMP	ERR4	/NO INCORRECT ASSIGNMENT
	LAC	LUNADR
	ISZ	LUNADR
	SAD	LASTUN	/ARE WE AT THE END OF THE TABLE?
	SKP
	JMP	LUNCKK	/NO CHECK NEXT LUN
	LAC	REQNAM	/CHECK FOR NONE
	AAC	-56	/SUBTRACT .
	SNA
	JMP	STORNO	/YES DON'T REQUEST NONE
REQTSK	LAC*	(PDVL)
PVDLSR	TAD	XADJ
	PAX
	LAC	2,X
	AAC	56	/ADD A .
	SAD	REQNAM
	JMP	FNDNAM
NOTUNT	LAC	0,X	/PICK UP NEXT POINTER TO PVDL TABLE
	SAD	(PDVL)
	JMP	ERR2
	JMP	PVDLSR	/SEARCH NEXT NODE
FNDNAM	PXA		/SAVE NEW PVDL POINTER FOR LUN TABLE
	DAC	NEWPVD
	LAC	5,X	/PICK UP UNIT NUMBER
	SAD	NEWUNT	/IS IT THE CORRECT ONE?
	SKP
	JMP	NOTUNT	/NO TRY AGAIN
	LAC	2,X	/CHECK FOR NAMES OF TTA OR DSK
	SAD	TTA	/IS THIS THE TELETYPE
	JMP	UPDLUN
	SAD	DSK	/IS THIS THE DISK?
	JMP	UPDLUN	/YES DON'T REQUEST (NO STL NODE)
	LAC	11,X	/IS REASSIGN INHIBITED?
	SPA
	JMP	ERR7	/YES ISSUE ERROR MESSAGE
	LAC	UFDNAM	/IS A DISK THE NEW DEVICE?
	SZA
	JMS	MFD	/YES -- GO CHECK THE MFD FOR UFD
	CAL	REQCPB	/REQUEST DEVICE TASK
	LAC	EV	/PICK UP REQUEST EVENT VARIABLE
	SMA		/WAS REQUEST OK?
	JMP	UPDLUN	/YES GO SET UP LUN TABLE
	SAD	(-201)	/IS TASK IN SYSTEM?
	JMP	ERR6	/NO TASK NOT IN SYSTEM ERROR
	SAD	(-777)	/EMPTY POOL?
	JMP	ERR5
UPDLUN	LAC	MCRCNT	/CHECK FOR CONTROL TTY CHANGED
	SNA
	JMP	UPDLUA	/NO DON'T CHANGE CONTROL
	LAC	NEWPVD	/PICK UP PDVL POINTER
	PAX
	LAC	2,X
	SAD	TTA	/IS IT A TTY?
	SKP		/YES OK
	JMP	UPDLUA	/NO DON'T CHANGE CONTROL
	LAC*	(TTMCTT)	/SAVE THE CONTROL TTY NUMBER
	DAC	TTCNTS	/INCASE OF ATTACH
	LAC	5,X
	DAC*	(TTMCTT) /YES CHANGE CONTROL TTY
UPDLUA	LAC	TDVCNT	/CHECK FOR TDV CONTROL TTY CHANGED
	SNA
	JMP	UPDLUB	/NO DON'T CHANGE CONTROL
	LAC	NEWPVD	/PICK UP PDVL POINTER
	PAX
	LAC	2,X
	SAD	TTA	/IS IT TTY?
	SKP		/YES OK
	JMP	UPDLUB	/NO DON'T CHANGE CONTROL
	LAC*	(TTDVTT)	/SAVE THE CONTROL TTY NUMBER
	DAC	TTCNTD	/INCASE OF ATTACH
	LAC	5,X
	DAC*	(TTDVTT)	/YES CHANGE CONTROL OF TDV
UPDLUB	LAC	NEWPVD	/GET PDVL POINTER
	TAD	MXADJ	/SUBTRACT THE  PAGE BITS
STORNO	PAL
	LAC	(LUNTAB) /SET UP TO INSERT NODE POINTER
	DAC	LUNADR
SETUP	LAC*	LUNADR	/PICK UP THE LUNT TABLE POINTER
	DAC	TMPA
	LAC*	(LUN1)
	TCA
	DAC	TEMP
	TAD*	LUNADR	/DETERMINE THIS LUN NUMBER
	TAD*	(AFTP1)	/FIND THE  AFT TABLE POINTER
	DAC	TMPB
	LAC	TEMP	/FIND LUN-UFD POINTER
	TAD*	LUNADR
	TAD*	(LUFD1
	DAC	TMPC
	PLA		/SAVE LIMIT REGISTER
	DAC	UNTTMP
	LAC*	LUNADR
	DAC	CNT
	LAC*	CNT	/POINT TO ASSING INHIBIT FALG
	AAC	11
	DAC	CNT
	.INH		/INHIBIT INTERRUPTS TO PREVENT ATTACH
	LAC	ONCEFL	/ONLY DONE ONCE
	SZA
	JMP	NODKCK	/DONE IGNORE
	ISZ	ONCEFL	/UPDATE FLAG
	LAC*	CNT	/PICK UP FILES FLAG
	RAL
	SMA		/SET?
	JMP	NODKCK	/NO FORGET IT
	.ENB		/YES PRINT MESSAGE
	LAC	(MES12-2)
	DAC	MESSET	/SET UP MESSAGE
ASKGN	CAL	ATTCH	/ATTACH TO TTY
	CAL	ATTCH2
	CAL	MES9CP
	CAL	WFTEV
	CAL	DETCH
	CAL	DETCH2
	CAL	TYINCP	/REQUEST ANSWER
	CAL	WFTEV
	LAC	TTYEV
	SPA
	JMP	ATTFL
	SAD	(1)	/EV OK
	CAL	CRTN	/RETURN  CARRAGE
	LAC	UNTTMP
	PAL		/RESTORE LR
	LAC	INPAR+2	/CHECK MESSAGE
	AND	(774000)
	SAD	YES	/YES?
	JMP	NODKCK	/YES CONTINUE
	SAD	NO	/NO?
	JMP	ATTFL	/NO TRY NEXT
	CAL	WHAT	/TRY AGAIN
	JMP	ASKGN
NODKCK	LAC	(MES9-2)
	DAC	MESSET	/RESET MESSAGE
	.INH
	LAC*	TMPB	/PICK UP THE DEVICE ATTACHED FLAG
	SNA
	JMP	NOTATT	/NOT ATTACHED TO THE DEVICE OK
	.ENB		/ATTACHED GO ASK WHAT TO DO
ASKREA	CAL	ATTCH	/ATTACH TO CONSOLE TTY
	CAL	ATTCH2
ASKAGN	CAL	MES9CP
	CAL	WFTEV
	CAL	TYINCP	/REQUEST ANSWER
	CAL	WFTEV
	LAC	TTYEV	/CHECK EVENT VARIABLE
	SPA		/IS IT POSITIVE?
	JMP	ATTFL	/NO -SOME ERROR DON'T REASSIGN
	SAD	(1)	/RETURN CARRAGE ON ALTMODE
	CAL	CRTN
	LAC	INPAR+2	/PICK UP THE MESSAGE
	AND	(774000)
	SAD	YES	/IS IT A YES?
	JMP	DET	/GO DETACH THE DEVICE
	SAD	NO	/IS IT A NO ANSWER
	JMP	ATTFL	/YES CLEAN UP
	CAL	WHAT	/? TRY AGAIN
	JMP	ASKAGN
DET	CAL	DETCH
	CAL	DETCH2	/DETACH THE TTY'S
	LAC	UNTTMP	/RESTORE LR
	PAL
	LAC*	LUNADR	/PICK UP THE PDVL NODE ADDRESS
	DAC	UNTTMP
	.INH		/INHIBIT INTERRUPTS TO PREVENT INTERRUPTS THAT MAY CAUSE REASSIGNMENT
	LAC*	TMPB	/DECREMENT TRANSFERS PENDING COUNT
	SNA		/MAKE SURE DEVICE IS STILL ATTACHED
	JMP	NOTATT	/DEVICE HAS BEEN DETACHED
	TAD	XADJ
	PAX
	LAC	5,X	/FIND THE PARTITION BLOCK ADDRESS
	TAD	XADJ
	PAX
	LAC	7,X	/DECEMENT COUNT
	SZA
	AAC	-1
	DAC	7,X
	DZM*	TMPB	/CLEAR THE LUN ATTACH
	LAC*	UNTTMP
	TAD	XADJ
	PAX
	DZM	4,X	/CLEAR THE DEVICE ATTACH
NOTATT	PLA		/PICK UP NEW ASSIGNMENT
	DAC*	TMPA	/PUT IT IN THE TABLE
	LAC	UFDNAM	/ENTER UFD NAME IN LUN-UFD TABLE
	.ENB
	DAC*	TMPC
	LAC	LUNADR
	SAD	LASTUN
	JMP	REQOK	/YES SEARCH FOR CARRTN
	ISZ	LUNADR	/NO CHECK NEXT LUN IN TABLE
	JMP	SETUP	/NO LOOK UNTIL ARE SET
REQOK	LAC	OLDNAM	/IS THE FILE NAME NONE?
	SNA
	JMP	FLUSH	/YES GO UPDATE LUN SLOTS
	ISZ	DEVUNT	/IS THERE A QUEUE
	LAC*	DEVUNT
	SAD	DEVUNT
	SKP
	JMS	REQACT	/INSERT NODES STILL IN QUEUE MESSAGE
	LAC*	(LUN1)	/PICK UP LUN POINTER
	SKP
NXTNOD	IAC	/CHECK NEXT LUN
	TAD	XADJ	/SET UP XR TO LOOK AT LUN SLOTS
	PAX
	LAC	0,X	/LOOK AT A LUN POINTER
	AAC	2	/POINT TO PDVL NAME
	DAC	CNT
	LAC	OLDNAM	/LOOK FOR A NAME MATCH
	SAD*	CNT
	JMP	FLUSH	/ASSIGNMENT FOUND DON'T REQUEST HANDLER TO EXIT
	PXA		/CHECK FOR THE END OF THE TABLE
	TAD	MXADJ	/SUBTRACT PAGE BITS
	SAD*	(LUN2)	/ARE WE AT THE END OF THE TABLE ?
	SKP
	JMP	NXTNOD	/NO TRY ANOTHER ENTRY
	LAC	(400004)	/RAISE TO LEVEL 5 TO PREVENT HANDLER
	ISA		/FROM EXITING BEFORE ALL NODES HAVE BEEN FOUND
	LAC*	(PDVL)
	TAD	XADJ	/ADD PAGE BITS
	PAX		/SAVE IT IN XR
NXTND	LAC	2,X	/PICK UP THE DEVICE NAME
	SAD	OLDNAM	/IS IT THE OLD NAME?
	SKP		/YES SET ASSIGN INHIBIT FLAG
	JMP	NOASGN	/NO DON'T FLAG IT
	PXL		/SAVE LAST NODE ADDRESS
	LAC	11,X	/SET REASSIGN INHIBIT FLAG
	AND	(377777)
	XOR	(400000)
	DAC	11,X	/RESTORE WORD
	LAC	10,X	/SAVE TRIGGER EVENT VARIABLE ADDRESS
	DAC	TRGGR
	DZM	10,X	/CLEAR THE TRIGGER EVENT VARIABLE ADDRESS
NOASGN	LAC	0,X	/IS THIS THE END OF THE TABLE?
	SAD	(PDVL)
	JMP	EXNOD	/YES EXIT
	TAD	XADJ	/ADD PAGE BITS
	PAX
	JMP	NXTND	/SEARCH NEXT NODE
EXNOD	JMS*	(PENP)	/PICK UP A NODE FOR 777 REQUEST
	JMP	ERR5	/EMPTY POOL ERROR
	DAC*	(R2)	/SAVE NODE ADDRESS FOR SPRI
	TAD	XADJ
	PAX
	LAC*	(CURTSK)
	AAC	6	/FIND A GOOD STL NODE ADDRESS
	DAC	CNT
	LAC*	CNT
	DAC	2,X
	DZM	3,X	/CLEAR UNUSED WORDS
	DZM	7,X
	DZM	10,X
	DZM	11,X
	LAC	(1002)	/SET PRIORITY TO 514
	DAC	4,X
	AAC	-3
	DAC	5,X	/SET REQUEST TYPE TO 777
	DZM	6,X	/CLEAR EVENT VARIABLE ADDRESS
	PLA		/PICK UP LAST NODE FOUND FOR 777 REQUEST
	TAD	MXADJ	/SUBTRACT PAGE BITS
	AAC	6	/POINT TO THE QUEUE
	DAC*	(R1)
	JMS*	(SPRI)	/PUT NODE IN REQUEST QUEUE
	DBK		/DEBREAK FORM LEVEL 5
	LAC	(401000)	/SET SIGNIFICANT EVENT
	ISA
	.INH		/INHIBIT INTERRUPTS
	LAC*	TRGGR	/LOOK AT TRIGGER
	AND	(377776)	/MASK OFF BITS
	XOR	(400001)	/SET Q I/O
	.ENB		/ENABLE INTERRUPTS
	DAC*	TRGGR
FLUSH	LAC	SVSLS	/PICK UP LAST CHARACTER READ
	SKP		/CHECK IT TO SEE IF IT IS A SLASH
FLUSHA	JMS*	(FAC)	/PICK UP A CHARACTER
	SAD	(057)	/IS THERE A SLASH TO REQUEST ANOTHER REA REQUEST
	JMP	REA	/YES PICK UP NEXT SEQUENCE
	SAD	(015)	/FLUSH FOR CAR RTN OR ALTMODE
	JMP	REQM
	SAD	(175)	
	JMP	ALTEXT
	JMP	FLUSHA
ALTEXT	DZM*	(MCRRI)	/SET MCR REQUEST OK FLAGE
	CAL	(10)	/EXIT
REQM	CAL	REQMCR	/REQUEST MCR
	CAL	(10)	/EXIT
/
/  ATTFL  FLUSHES THE HANDLER IF NECESSARY WHEN THE OPERATOR
/       REFUSES TO REMOVE AN ATTACH REQUEST
/
ATTFL	CAL	DETCH
	CAL	DETCH2	/DETACH THE TTY'S
	LAC	REQNAM	/PICK UP THE HANDLER NAME
	AAC	-56	/REMOVE THE .
	SNA		/IS THIS A REQUEST FOR NONE?
	JMP	FLUSH	/YES DON'T FLUSH HANDLER
	DAC	OLDNAM	/SET UP TO CHECK FOR OTHER ASSIGNMENTS
	LAC	TTCNTS	/IS THE CONTROL TTY CHANGED?
	SMA
	DAC*	(TTMCTT)	/YES -- RESTORE IT TO ORIGIONAL CONDITION
	LAC	TTCNTD	/IS THE TDV CONTROL CHANGED?
	SNA
	DAC*	(TTDVTT)	/YES RESTORE IT
	LAC*	(LUN1)	/PICK UP LUN POINTER
	AAC	-1
	JMP	NXTNOD	/GO CHECK THE HANDLER FOR REMOVAL
/
/ REQACT - SUBROUTINE TO PACK THE DEVICE NAME
/  AND UNIT NUMBER INTO THE QUEUE STILL ACTIVE MESSAGE
/
REQACT	0
	LAC	OLDNAM	/PICK UP THE NAME OF THE HANDLER
	LMQ		/CONVERT THE NAME TO 5/7 ASCII
	ECLA!LLS	6
	AAC	100
	CLL!RAL
	LLS	6
	AAC	100
	CLL!RTL
	RTL
	AAC	4	/STORE IT IN THE
	DAC	MES8A	/NON EMPTY QUEUE MESSAGE
	CAL	MES8CP
	CAL	WFTEV
	JMP*	REQACT	/RETURN AFTER TYPING IS FINISHED
/
/	GETDEV - PICKS UP THE DEVICE AND UNIT NUMBER
/		THE DEVICE NAME IS RETURNED IN AC AND THE
/		UNIT NUMBER IS IN THE LIMIT REGISTER
/
GETDEV	0
	DAC	TEMP	/SAVE AC --- THERE MAY BE A CHAR IN IT
	CLLR		/CLEAR LIMIT REGISTER TO ZERO DEVICE UNIT
	LAW	-2	/MAXIMUM OF TWO CHARACTERS
	DAC	CNT
	DZM	UNTTMP
	DZM	DEV	/CLEAR TEMPORARY STORAGE
	LAC	TEMP	/IS THER A CHAR IN AC?
	SNA		/SKIP IF SO
LETLP	JMS*	(FAC)	/PICK UP A LETTER
	AAC	-100
	SPA!CLL		/IS IT LEGAL?
	JMP	ERR1	/NO SYNTAX ERROR
	XOR	DEV	/ADD TO LAST LETTER FOUND
	ALS	6
	DAC	DEV	/SAVE IT
	ISZ	CNT	/TWO CHARACTERS FOUND?
	JMP	LETLP	/NO PICK UP ANOTHER
	JMS*	(FAC)	/PICK UP A NUMBER
	SAD	(116)	/IS IT AN N?
	JMP	NONE
	SKP		/DON'T CHECK FOR AN N TWICE
UNITLP	JMS*	(FAC)	/PICK UP A NUMBER
	AAC	-57	/CHECK FOR OCTAL NUMBER
	SPA!SNA
	JMP	NONXA	/NOT A NUMBER THEREFORE EXIT
	AAC	-13
	SMA
	JMP	NONXB	/NOT A NUMBER THEREFORE EXIT
	AAC	12	/MAKE OCTAL
	AND	(17)	/MASK TO FOUR BITS
	TAD	UNTTMP	/ADD ON PREVIOUS VALUES
	PAL		/SAVE VALUE IN LIMIT REGISTER
	CLL
	MUL
	12
	LACQ		/MULTIPLY BY 10
	DAC	UNTTMP
	JMP	UNITLP
NONXB	AAC	13	/RESTORE CHARACTER
NONXA	AAC	57
	SKP		/DON'T READ A CHARACTER
NONXIT	JMS*	(FAC)	/PICK UP ANOTHER CHARACTER
	SAD	(040)	/IS IT A BLANK?
	JMP	GETXIT
	SAD	(054)	/NO IS IT A COMMA?
	JMP	GETXIT	/YES EXIT
	SAD	(015)	/IS IT CAR RTN?
	JMP	GETXIT	/YES EXIT
	SAD	(175)	/IS IT ALTMODE?
	JMP	GETXIT	/YES EXIT
	SAD	(057)	/IS IT A SLASH?
	JMP	SLSH	/YES SAVE IT
GETXIT	LAC	DEV	/PICK UP DEVICE NAME
	JMP*	GETDEV	/OK RETURN
NONE	JMS*	(FAC)	/PICK UP ANOTHER CHARACTER
	SAD	(105)	/IS IT AN E?
	SKP!CLA
	JMP	ERR1	/NO ERROR
	DZM	DEV
	JMP	NONXIT
/
SLSH	DAC	SVSLS	/SAVE SLASH INDICATOR
	JMP	GETXIT
/ 
/ SUBROUTINE MFD -- MAKE SURE AN MFD ENTRY EXISTS FOR A UFD AND THAT
/                   THE UFD IS PROPERLY INITIALIZED.
/
/ ENTER WITH AC CONTAINING SIXBT NAME OF UFD AND 
/ UNIT CONTAINING THE UNIT NUMBER AND
/ DEVICE CONTAINING THE DEVICE CODE.
/
/ RETURN AT JMS+1 UNLESS AN ERROR IS DETECTED
/
/ ALL REGISTERS ARE MODIFIED
/
MFD	0
	DAC	MFDNAM		/SAVE THE NAME OF THE UFD
	JMS	MFDSCN		/SCAN THE MFD FOR THE UFD
	JMP	MFDFND		/RETURN HERE IF FOUND
MFD1	CLA			/RETURN HERE IF NOT -- LOOK FOR FREE ENTRY
	JMS	MFDSCN		/WAS A FREE MFD ENTRY FOUND?
	SKP
	JMP	MFD2		/NO -- GO CREATE ONE
	DAC	MFDT0		/YES -- SAVE MFD BLK WITH FREE ENTRY
	LAW	-1		/SET STATING UFD BLK TO -1 FOR FREE ENT
	DAC	1,X
	LAC	MFDT0		/GET THE MFD BLK NO.
	JMP	MFDFND		/GO ENTER NEW UFD
MFD2	JMS	MFDNEW		/ALLOCATE A BLK AND INIT BUFFER
	DAC	MFDT1		/SAVE NO. OF NEW BLOCK
	LAC	MFDT0		/GET NO. OF LAST MFD BLK
	DAC	BUFF+376	/ENTER NO. AS BACK PTR FOR NEW MFD BLK
	LAC	MFDT1		/WRITE OUT NEW MFD BLK
	JMS	MFDPUT
	LAC	MFDT0		/GET NO. OF OLD MFD BLK
	JMS	MFDGET		/READ IT INTO BUFFER
	LAC	MFDT1		/SET UP FWD PTR
	DAC	BUFF+377
	JMS	MFDPUT		/WRITE OUT OLD, MODIFIED MFD BLK
	LAC	(BUFF		/SET XR TO POINT AT BUFFER
	JMS	SETXR
	LAW	-1		/SET -1 INTO UFD ST. BLK
	DAC	1,X
	LAC	MFDT1		/GET BLK OF MFD WITH FREE ENTRY
MFDFND	DAC	MFDT0		/SAVE BLK NO. OF MFD BLK
	LAC	1,X		/IS UFD ST. BLK DEFINED?
	SAD	(-1
	SKP
	JMP*	MFD		/YES -- RETURN
	PXA			/NO -- SAVE XR
	DAC	MFDT1
	JMS	MFDNEW		/ALLO A BLK AND INIT BUFFER
	DAC	MFDT2		/SAVE NEW UFD BLK NO.
	JMS	MFDPUT		/WRITE OUT NEW UFD BLK
	LAC	MFDT0		/GET MFD BLK
	JMS	MFDGET
	LAC	MFDT1		/RESTORE XR
	PAX
	LAC	MFDNAM		/ENTER NAME OF UFD INTO MFD
	DAC	0,X
	LAC	MFDT2		/ENTER START OF UFD INTO MFD
	DAC	1,X
	LAC	(400010		/ENTER PC AND NO. WDS / UFD ENTRY
	DAC	2,X
	LAC	MFDT0		/WRITE OUT MODIFIED MFD BLK
	JMS	MFDPUT
	JMP*	MFD		/RETURN
/
MFDT0	0
MFDT1	0
MFDT2	0
MFDNAM	0
/
/ SUBROUTINE MFDSCN -- SCAN MFD FOR A UFD NAME
/
/ ENTER WITH AC CONTAINING UFD NAME AND
/ UNIT CONTAINING UNIT NUMBER AND
/ DEVICE CONTAINING DEVICE CODE
/
/ RETURN AT JMS+1 IF FOUND WITH AC=MFD BLK NO. AND XR POINTING
/ AT ENTRY (XR IS CORRECTED)
/ RETURN AT JMS+2 IF NOT FOUND WITH AC=LAST MFD BLK
/
/ ALL REGISTERS ARE MODIFIED
/
MFDSCN	0
	DAC	MFDST1		/SAVE UFD NAME
	LAC	DEVICE		/IS DEVICE THE RP?
	SAD	(3
	JMP	MFDS1		/YES
	LAC	(1777		/NO -- RK OR RF , GET MFD ST. BLK
	SKP
MFDS1	LAC	(47040
MFDS4	DAC	MFDST2		/SAVE MFD BLK NO.
	JMS	MFDGET		/READ IN MFD BLK
	LAC	(BUFF		/INIT PTR TO BUFFER
	DAC	MFDST0
MFDS2	LAC*	MFDST0		/GET THIS UFD NAME
	SAD	MFDST1		/DOES IT MATCH THE ONE WANTED?
	JMP	MFDS5		/YES
	LAC	MFDST0		/NO -- END OF MFD BLK?
	SAD	(BUFF+370
	JMP	MFDS3		/YES
	AAC	4		/NO -- PREPARE TO EXAMINE NEXT ENTRY
	DAC	MFDST0
	JMP	MFDS2		/GO LOOK AT NEXT MFD ENTRY
MFDS3	LAC	BUFF+377	/GET NO. OF NEXT MFD BLK
	SAD	(-1		/END OF MFD?
	SKP
	JMP	MFDS4		/NO -- PREPARE TO READIN NEXT BLK
	IDX	MFDSCN		/YES -- PREPARE TO RET. AT JMS+2
MFDS6	LAC	MFDST2		/GET MFD BLK INTO AC
	JMP*	MFDSCN		/RETURN
MFDS5	LAC	MFDST0		/GET THE POINTER TO MFD ENTRY
	JMS	SETXR		/ADJUST XR
	JMP	MFDS6		/PREPARE TO RETURN AT JMS+1
/
MFDST0	0
MFDST1	0
MFDST2	0
/
/ SUBROUTINE MFDNEW -- ALLOCATE A BLK AND INIT BUFFER
/
/ ENTER WITH DEVICE AND UNIT SET UP
/
/ RETURN AT JMS+1 WITH AC CONTAING BLK NO.
/
/ ALL REGISTERS ARE MODIFIED
/
MFDNEW	0
	LAC	DEVICE		/SET UP DEVICE AND UNIT NO.
	DAC	ALLO+4
	LAC	UNIT
	CLL
	ALS	17
	DAC	ACTA+1
	CAL	ALLO		/ALLOCATE A DISK BLOCK
	CAL	WAIT
	LAC	EV		/WHERE THERE ANY ERROR?
	SPA
	JMP	ERR21		/YES
	LAC	ACTA+2		/NO -- DETERMINE BLK NO.
	LMQ
	LAC	ACTA+1
	AND	(7777
	LRSS	10
	LAC	(BUFF-1		/INIT BUFFER
	DAC*	(X10
	LAW	-376		/INIT COUNTER
	DAC	MFDTMP
	DZM*	X10		/ZERO WDS 0-376
	ISZ	MFDTMP
	JMP	.-2
	LAW	-1		/SET -1 INTO BLK PTRS
	DAC	BUFF+376
	DAC	BUFF+377
	LACQ			/GET BLK NO. INTO AC
	JMP*	MFDNEW		/RETURN
/
MFDTMP	0
/
/ SUBROUTINE CONVRT -- CONVERT BLK NO. INTO PLATTER AND ADDR
/
/ ENTER WITH BLK NO. IN AC
/
/ RETURN AT JMS+1 UNCOND.
/
/ AC IS MODIFIED
/
CONVRT	0
	LMQ			/PUT BLK INTO MQ
	CLL
	LLSS!ECLA  10
	DAC	GPCTA+0		/ENTER PLATTER INTO CTA
	LACQ
	DAC	GPCTA+1		/ENTER ADDR INTO CTA
	LAC	UNIT		/ENTER UNIT NO.
	CLL
	ALS	17
	TAD	GPCTA+0
	DAC	GPCTA+0
	JMP*	CONVRT		/RETURN
/
/ SUBROUTINE MFDGET -- GET A DISK BLOCK
/
/ ENTER WITH BLK NO IN AC
/
/ RETURN AT JMS+1 WITH AC UNCHANGED
/
/ ALL OHTER REG. ARE MOD
/
MFDGET	0
	DAC	MFDTMP		/SAVE AC
	JMS	CONVRT		/CONVERT BLK NO INTO PLATTER + ADDR
	LAC	DEVICE		/ENTER DEVICE INOT CPB
	DAC	GET+4
	CAL	GET		/GET THE DISK BLK
	CAL	WAIT
	LAC	EV		/ANY ERROR?
	SPA
	JMP	ERR22		/YES
	LAC	MFDTMP		/NO -- RESTORE AC
	JMP*	MFDGET
/
/ SUBROUTINE MFDPUT -- WRITE OUT A DISK BLK
/
/ ENTER WITH BLK NO. IN AC
/
/ RETURN AT JMS+1 WITH AC UNCHANGED
/
/ ALL OTHER REG ARE MOD.
/
MFDPUT	0
	DAC	MFDTMP		/SAVE AC
	JMS	CONVRT		/ENTER PLATTER AND ADDR INTO CTA
	LAC	DEVICE		/SET UP DEVICE CODE
	DAC	PUT+4
	CAL	PUT		/WRITE OUT BLK
	CAL	WAIT
	LAC	EV		/ANY ERROR?
	SPA
	JMP	ERR23		/YES
	LAC	MFDTMP		/NO -- RESTORE AC
	JMP*	MFDPUT		/RETURN
/ SUBROUTINE UFD -- READ A CHAR AND CHECK FOR A LINE TERM
/
UFD	0
	JMS*	(FAC	/READ A CHAR
	SAD	(15	/IS IT A CR?
	JMP	ERR1	/YES -- ERROR
	SAD	(175	/NO -- ALTMODE?
	JMP	ERR1	/YES -- ERROR
	AND	(77
	JMP*	UFD	/NO -- RETURN
/
/ SUBROUTINE SETXR -- ADJUST THE XR
/
SETXR	0
	TAD	XADJ
	PAX
	JMP*	SETXR
/
REQMCR	1
	EV
	.SIXBT	"...MCR"
	0
/
REQCPB	1
	EV
REQNAM	0
	.SIXBT	"..."
	0
/
MES8CP	2700
	TTYEV
	3
	2
	MES8-2
MES9CP	2700
	TTYEV
	3
	2
MESSET	MES9-2
WHAT	2700
	0
	3
	3
	MES10
TYINCP	2600
	TTYEV
	2
	2
	INPAR
	4
CRTN	2700
	0
	3
	2
	MES11
ATTCH	2400
	0
	3
ATTCH2	2400
	0
	2
DETCH	2500
	0
	3
DETCH2	2500
	0
	2
/
PUT	13100
	EV
	1
	GPCTA
	XX
GET	13000
	EV
	1
	GPCTA
	XX
GPCTA	0
	0
	BUFF
	400
ALLO	11500
	EV
	1
	ACTA
	XX
ACTA	400
	XX
	XX
WAIT	20
	EV
/
TYPCPB	2700
	TTYEV
	3
	2
	MES1-2
/
WFTEV	20
	TTYEV
/
TTYEV	0
EV	0
/
TYPMSG	DAC	TYPCPB+4
	CAL	TYPCPB
	CAL	WFTEV
	JMP	REQM	/PRINT ERROR  MESSAGE AND REQ MCR
ERR1	LAC	(MES1-2)
	JMP	TYPMSG
ERR2	LAC	(MES2-2)
	JMP	TYPMSG	/TYPE ERROR MESSAGE
ERR3	LAC	(MES3-2)
	JMP	TYPMSG
ERR4	LAC	(MES4-2)
	JMP	TYPMSG
ERR5	LAC	(MES5-2)
	JMP	TYPMSG
ERR6	LAC	(MES6-2)
	JMP	TYPMSG
ERR7	LAC	(MES7-2)
	JMP	TYPMSG
ERR13	LAC	(MES13-2)
	JMP	TYPMSG
ERR20	LAC	(MES20
	JMP	TYPMSG
ERR21	LAC	(MES21
	JMP	TYPMSG
ERR22	LAC	(MES22
	JMP	TYPMSG
ERR23	LAC	(MES23
	JMP	TYPMSG
INPAR	.BLOCK	4
XADJ	0
MXADJ	0
TMPA	0
TMPB	0
SVSLS	0
DEV	0
CNT	0
UNTTMP	0
DEVNAM	0
DEVUNT	0
DEVTEV	0
LASTUN	0
LUN	0
LUNADR	0
LUNMAX	0
LUNPTR	0
NEWPVD	0
LUNTMP	0
NEWUNT	0
OLDNAM	0
MCRCNT	0
TDVCNT	0
TRGGR	0
OLDUNT	0
TTCNTS	0	/CONTROL TTY SAVE
TTCNTD	0	/TDV CONTROL SAV
UFDNAM	0
UNIT	0
DEVICE	0
TMPC	0
TEMP	0
NON	.SIXBT	"NON"
TTA	.SIXBT	"TT"
DSK	.SIXBT	"DK@"
LUNTAB	.BLOCK	20
/
	MES2-MES1-2/2*1000+2
	0
MES1	.ASCII	"REA-SYNTAX ERR"<15>
	MES3-MES2-2/2*1000+2
	0
MES2	.ASCII	"REA-INCORRECT DEV"<15>
	MES4-MES3-2/2*1000+2
	0
MES3	.ASCII	"REA-INCORRECT UNIT"<15>
	MES5-MES4-2/2*1000+2
	0
MES4	.ASCII	"REA-INCORRECT LUN"<15>
	MES6-MES5-2/2*1000+2
	0
MES5	.ASCII	"REA-EMPTY POOL"<15>
	MES7-MES6-2/2*1000+2
	0
MES6	.ASCII	"REA-HANDLER TASK NOT IN SYSTEM"<15>
	MES8-MES7-2/2*1000+2
	0
MES7	.ASCII	"REA-REASSIGN INHIBITED"<15>
	MES9-MES8-2/2*1000+2
	0
MES8	.ASCII	"REA-I/O REQUEST QUEUE NOT EMPTY ON "
MES8A	.ASCII	"DV "<15>
	MES10-MES9/2*1000+2
	0
MES9	.ASCII	"REA-DEVICE ATTACHED, DO YOU WISH TO DETACH? "<175>
MES10	YES-MES10/2*1000+2
	0
	277
	175
YES	544000
MES11	NO-MES11/2*1000+2
	0
	064000
NO	470000
	15002
	0
MES12	.ASCII	'REA-FILES OPEN ON DEVICE -- DO YOU STILL WISH TO REASSIGN?'<175>
	ONCEFL-MES13/2*1000+2
	0
MES13	.ASCII	"REA-OLD DEV NOT YET IN CORE"<15>
ONCEFL	0
MES20	MES21-MES20/2*1000
	0
	.ASCII "REA-NO DEFAULT UFD AVAIL"<15>
MES21	MES22-MES21/2*1000
	0
	.ASCII "REA-ALLOCATE ERROR"<15>
MES22	MES23-MES22/2*1000
	0
	.ASCII "REA-DISK GET ERROR"<15>
MES23	BUFF-MES23/2*1000
	0
	.ASCII "REA-DISK PUT ERROR"<15>
BUFF	.BLOCK 400
	.END	REA
