	.TITLE	UIC.NN
/
/  16 DEC 76 (016; PDH) ENSURE UFD EXISTS ON MOUNTED DISK
/   5 OCT 76 (011; PDH) CHANGE TO EXEC MODE TASK
/   5 OCT 76 (010; PDH) REMOVE DEBUGGING AIDS
/   4 OCT 76 - PAUL HENDERSON
/
	.DEC
/NN=00		/ TO ASSEMBLE FOR TTY N, THE SYMBOL 'NN' MUST BE DEFINED
TTY=30+NN		/ TERMINAL NUMBER FOR THIS TERMINAL
DK1=40+NN
DK2=50+NN
	.OCT
/
/  ROUTINE TO ALLOW EACH TERMINAL USER TO 'LOGIN IN' HIS
/  UIC SO THAT HIS TERMINAL EDITOR LOOKS AT THE CORRECT UFD.
/  THIS ROUTINE FOLLOWS THE CONVENTION THAT TERMINAL 'NN'
/  USES LUN'S 40+NN AND 50+NN FOR DISK I/O.  THIS ROUTINE
/  IS INVOKED VIA THE TERMINAL DISPATCHER BY TYPING 'UIC',
/  AND EXPECTS THE FOLLOWING EXCHANGE:
/
/  COMPUTER:-	LOGIN
/		<
/      USER:-	 UIC
/  COMPUTER:-	    >
/		 XXX
/
/  NOTE THAT THE INTERCHANGE IS CARRIED OUT ON TWO LINES ONLY, AND
/  SERVES TO BLANK OUT THE UIC AFTER ENTRY.
/
UIC.NN	CAL	MARK		/ DELAY 1/4 SECOND TO ALLOW POSSIBLE TTY
	JMS	WTFOR		/ I/O TO ABORT.
	CAL	TSKNAM		/ GET NAME OF THIS TASK
	JMS	WTFOR
	LAC	TSKNAM+3	/ WE WANT ONLY THE '.NN' PART
	DAC	REQTSR+3	/ TO REQUEST THE CORRECT TERMINAL ROUTINE
	LAC	(DK1-1
	TAD*	(304		/ POINTER TO LUN-UFD TABLE
	DAC	LUFD1		/ POINTER TO 1ST DISK ENTRY IN LUN-UFD TABLE
	LAC	(DK2-1
	TAD*	(304
	DAC	LUFD2		/ POINTER TO SECOND ENTRY
	LAC*	LUFD1
	SNA
	JMP	NOMNT		/ 1ST DISK NOT MOUNTED
	LAC*	LUFD2
	SZA
	JMP	MNTED
/
	.EJECT
NOMNT	CAL	MNTERR		/ 'USER DISK NOT MOUNTED'
	JMP	ERRXIT
/
MNTED	CAL	WLOGIN		/ OUTPUT FIRST PART OF EXCHANGE
	JMS	WTFOR
	CAL	READIN		/ READ THE 3 CHARACTER UIC
	JMS	WTFOR
	LAC	ILINE+2		/ GET 1ST CHARACTER
	LMQ			/ LEADING BIT WILL BE SHIFTED OUT
	LLSS	6		/ LEAVE ROOM FOR NEXT CHARACTER
	LAC	ILINE+3
	AND	(77		/ TRIM TO 6 BITS
	LMQ\10000		/ AC!MQ -> MQ
	LLSS	6
	LAC	ILINE+4		/ 3RD CHARACTER
	AND	(77		/ 6 BITS
	OMQ
	SNA
	JMP	NOUFD		/ NULL UIC IS ILLEGAL
	SAD	(-1
	JMP	NOUFD		/ <???> IS ALSO ILLEGAL
	DAC	UIC		/ SAVE UIC SUPPLIED BY USER
	LAC	(DK1		/ MAKE SURE WE HAVE A DISK
	JMS	CK4DK		/ AND A UFD
	LAC	(DK2		/ DO IT FOR BOTH DISK LUNS
	JMS	CK4DK
	LAC	UIC		/ IT ALL CHECKS OUT.  GET UIC AND
	DAC*	LUFD1		/ CHANGE UIC FOR DISK LUNS
	DAC*	LUFD2
	CAL	SMUDGE		/ BLANK OUT UIC
EXIT	CAL	WAITFR
	CAL	REQTSR		/ REQUEST 'OUR' TERMINAL DISPATCHER
	CAL	WAITFR		/ WAIT FOR SYSTEM RESPONSE
	CAL	(10		/ EXIT WHEN ALL FINISHED
/
	.EJECT
/  SUBROUTINE TO WAIT FOR EVENT VARIABLE, AND ANNOUNCE
/  ERROR IF EVENT VARIABLE IS NEGATIVE.
/
WTFOR	XX
	CAL	WAITFR		/ WAIT FOR THE EVENT VARIABLE
	LAC	EV
	SMA!TCA
	JMP*	WTFOR		/ EVENT VARIABLE OK.  RETURN.
	SAD	(13		/ IGNORE 'FILE NOT FOUND' ERROR
	JMP*	WTFOR
	CLQ!LRS	11		/ STORE IN MQ
	LAC	(6		/ ASCII CONVERSION
	LLSS	3		/ PACK BAD EVENT VARIABLE
	ALSS	4		/ MAKE ROOM FOR NEXT CONVERSION
	XOR	(6
	LLSS	3
	ALSS	4
	XOR	(6		/ CONVERSION FOR 3RD CHARACTER
	DAC	ERB		/ STORE IN MESSAGE
	LACQ
	XOR	(32		/ APPEND CARRIAGE RETURN
	DAC	ERB+1		/ ALSO STORE IN MESSAGE
	CAL	WRERR		/ OUTPUT ERROR MESSAGE
	JMP	ERRXIT		/ THEN BLANK OUT UIC
/
/  THIS SUBROUTINE CHECK TO SEE IF WE HAVE A DISK WHERE WE EXPECT
/  ONE, AND IF THE SPECIFIED UIC HAS A CORRESPONDING UFD.
/  FATAL ERRORS ARE ANNOUNCED WHERE REQUIRED.
/
CK4DK	XX
	DAC	HINF+2		/ MUST HINF CORRECT LUN
	CAL	HINF
	JMS	WTFOR
	LAC	EV
	ALSS	11		/ FROM THE INFORMATION RETURNED BY HINF,
	AND	(700000		/ EXTRACT THE PHYSICAL UNIT NUMBER
	DAC	UNIT
	LAC	EV
	AND	(77		/ EXTRACT DEVICE TYPE
	DAC	DKTYPE		/ PUT IT IN 'GET' CPB
	SAD	(2
	JMP	RK		/ RF
	SAD	(3
	JMP	RP		/ RP
	SAD	(24
	JMP	RK		/ RK
/
	.EJECT
NODK	CAL	WRNODK		/ 'DEVICE ON DISK LUN IS NOT A DISK'
ERRXIT	CAL	WAITFR
	CAL	WRIGNR		/ 'ENTRY IGNORED'
	JMP	EXIT
/
RP	LAC	(47040		/ START BLOCK OF MFD ON RP DISK
	SKP
RK	LAC	(1777		/ START BLOCK ON RF & RK
GETMFD	JMS	BLK2PL		/ CONVERT BLOCK NUMBERS TO PLATTER, ETC
	LAC	(374		/ AND FETCH IT INTO CORE
	PAL			/ DON'T SEARCH PAST END OF BLOCK
	CLX
MFD1	LAC	BUFFER,X	/ SEARCH MFD FOR DESIRED UFD ENTRY
	SAD	UIC
	JMP	UICFND
	AXS	4		/ INDEX TO NEXT MFD ENTRY
	JMP	MFD1
	LAC	ENDBLK		/ END OF MFD BLOCK - UIC NOT FOUND
	SMA			/ IS THERE ANOTHER MFD BLOCK?
	JMP	GETMFD		/ YES.  FETCH IT AND CONTINUE SEARCH
/
NOUFD	CAL	WRNUFD		/ 'ILLEGAL UIC'
	JMP	ERRXIT
/
UICFND	LAC	BUFFER+1,X	/ POINT TO UFD START BLOCK
	SPA
	JMP	NOUFD		/ NO UFD, ALTHOUGH ENTRY IS IN MFD
	JMP*	CK4DK		/ LEAVE IF DISK & UIC ARE OK.
/
/  SUBROUTINE TO CONVERT BLOCK NUMBERS TO PLATTER NUMBERS AND
/  READ THE BLOCK INTO CORE
/
BLK2PL	XX
	LMQ
	LLSS	1010
	XOR	UNIT		/ MUST INCLUDE PHYSICAL UNIT NUMBER
	DAC	CTRLTB		/ PUT UNIT & PLATTER # IN CONTROL TABLE
	LACQ
	DAC	DKADDR		/ PUT DISK ADDRESS IN CONTROL TABLE
	CAL	GETDK		/ FETCH THE BLOCK
	JMS	WTFOR
	JMP*	BLK2PL
/
	.EJECT
MARK	13;	EV; 17; 1	/ 15 TICKS = 1/4 SECOND
WLOGIN	2700;	EV; TTY; 3; MSG1
WRERR	2700;	ER; TTY; 2; MSG2
SMUDGE	2700;	EV; TTY; 3; MSG4
READIN	2600;	EV; TTY; 3; ILINE; 5
WAITFR	20;	EV
TSKNAM	25;	EV
LUFD1;LUFD2		/ DOUBLE USE OF THESE WORDS USED BY 'TSKNAM'
REQTSR	1;	EV
	.SIXBT	'TTY.NN'
	302			/ PRIORITY 194 (10), AS PER TTY.NN
ILINE;	.LOC	ILINE
BUFFER	.BLOCK	377
ENDBLK
/
	.EJECT
MNTERR	2700;	EV;	TTY; 2; MSG5
HINF	3600;	EV;	XX
GETDK	13000;	EV;	1; CTRLTB;DKTYPE
CTRLTB;DKADDR;	BUFFER;	400
WRNUFD	2700;	EV;	TTY; 2; MSG7
MSG7	M7-.*400+2;UNIT
	.ASCII	'> ILLEGAL UIC'<15> ;M7=.
WRNODK	2700;	EV;	TTY; 2; MSG6
WRIGNR	2700;	EV;	TTY; 2; MSG3
MSG5	M5-.*400+2; 0
	.ASCII	'USER DISK NOT MOUNTED'<15> ;M5=.
MSG6	M6-.*400+2; 0
	.ASCII	'  DEVICE ON DISK LUN IS NOT A DISK'<15> ;M6=.
MSG3	M3-.*400+2; 0
	.ASCII	'ENTRY IGNORED'<15> ;M3=.
MSG1	6003;EV
/		 L    O	   G	I    N		 <
	15; 12; 114; 117; 107; 111; 116; 15; 12; 74
MSG2	M2-.*400+2;ER
	.ASCII	'  "UIC" ERR '
ERB	.BLOCK	2
	.ASCII	<175> ;M2=.
MSG4	15003;UIC
	76; 15;	40; 115; 115; 115; 15
		40; 127; 127; 127; 15
		40; 132; 132; 132; 15
		74;  40;  40;  40; 76; 15; 12 / FINAL FLOURISH FOR CRT'S
	.END	UIC.NN
