/ 
/ 
/                   FIRST PRINTING, FEBRUARY 1974
/ 
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO 
/ CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED
/ AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPON-
/ SIBILITY FOR ANY ERRORS THAT MAY APPEAR IN THIS
/ DOCUMENT.
/ 
/ THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FUR-
/ NISHED TO THE PURCHASER UNDER A LICENSE FOR USE ON
/ A SINGLE COMPUTER SYSTEM AND CAN BE COPIED (WITH
/ INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR 
/ USE IN SUCH SYSTEM, EXCEPT AS MAY OTHERWISE BE PRO-
/ VIDED IN WRITING BY DIGITAL.
/ 
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/ FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIP-
/ MENT THAT IS NOT SUPPLIED BY DIGITAL.
/ 
/ COPYRIGHT (C) 1974, BY DIGITAL EQUIPMENT CORPORATION
/ 
/ 
        .EJECT
/ EDIT #14
/
/ COPYRIGHT 1970,1971 DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/
/ TDV FUNCTION -- REQUEST FOR BATCH	7 MAR 72	R. MCLEAN
/					FEB 1 74	M. HEBENSTREIT
/
/ TASK NAME  "REQ..."   TO REQUEST A TASK WITH OPTIONAL
/ RUN PRIORITY SPECIFICATION.
/
/ THE FIRST LINE OF THE COMMAND INPUT FOR ANY MCR
/ FUNCTION IS READ BY THE RESIDENT MCR TASK ("...MCR").
/ FOR THE "REQUEST" FUNCTION, THERE IS ONLY ONE LINE OF
/ COMMAND INPUT, AND IT'S SYNTAX IS AS FOLLOWS:
/
/	SYNTAX = 'REQ'$<NBC><BREAK CHARACTER><TASK NAME>
/		(<BREAK CHAR><PRIORITY>/NUL)(<CR>/<AM>)
/	<BREAK CHAR> = " "/","
/	<TASK NAME> = 1-6 ALPHANUMERIC CHARACTERS
/	<PRIORITY> = <DV>
/	<DV> = DECIMAL VALUE 1-512
/	<CR> = CAR RTN
/	<AM> = ALTMODE
/	<NBC> = NON BREAK CHARACTER
/	$ -- " ANY NUMBER OF "INCLUDING ZERO ""
/	NUL -- " THE EMPTY SET"
/
/	THE RESIDENT MCR READS A LINE, FETCHES THE
/	FIRST THREE CHARACTERS TO FORM THE MCR FUNCTION TASK
/	NAME ("...REQ"), FLUSHES CHARACTERS THRU THE FIRST
/	BREAK CHARACTER, REQUESTS "...REQ", AND EXITS
/	THE TASK "...REQ " PROCESSES THE REMAINDER OF THE LINE
/	AND IF THE REQUEST IS VALID, ISSUES AN APPROPRIATE " REQUEST"
/	DIRECTIVE.
/
 .TITLE *** MCR FUNCTION 'REQUEST'
/
X10=10
IDX=ISZ
/
REQ	LAW	-7	/SET UP TO FETCH TASK NAME AND STORE
	DAC	CNT	/SIX CHARACTERS (ZERO RIGHT FILL) IN
	CAL	RDTDV	/READ FROM TDV
	LAC	EV	/CHECK EVENT VARIABLE
	SPA
	JMP	ERR2	/TDV ERROR
	LAC	(REQCPB+1)	/REQUEST CAL PARAMETER BLOCK
	DAC*	(X10)
REQN5	JMS	FAC
	SAD	(040	/SPACE?
	JMP	REQN1	/SPACE FOUND CONTINUE
	SAD	(015)	/CR FOUND ERROR
	JMP	ERR1
	SAD	(175)	/AM FOUND ERROR
	JMP	ERR1
	JMP	REQN5
/
REQN1	JMS	FAC	/FETCH A CHARACTER
	SAD	(054)	/ IS IT A COMMA?
	JMP	GETPRI	/YES -- GET A PRIORITY
	SAD	(040)	/NO -- BLANK?
	JMP	GETPRI	/YES -- GET A PRIORITY
	SAD	(015)	/NO -- CAR RTN?
	JMP	ENDCRA	/YES-- END OF REQUEST
	SAD	(175)	/NO -- ALTMODE?
	JMP	ENDCRA	/YES-- END OF REQUEST
	DAC*	X10	/NO -- STORE CHARACTER
	ISZ	CNT	/LAST CHARACTER OF TASK NAME?
	JMP	REQN1	/NO -- GET NEXT CHARACTER
ERR1	JMS	TYPE	/PRINT MESSAGE FOR SYNTAX ERROR
	MES2
	JMP	EXT2	/EXIT AND CALL MCR
ERR2	JMS	TYPE	/PRINT TDV ERROR
	MES7
	JMP	EXT2
GETPRI	LAW	-7	/WAS A NAME TYPED?
	SAD	CNT
	JMP	ERR1	/NO -- ERROR
	JMS	NUMBER	/YES -- GET A PRIORITY
	JMP	CHKBRK	/NO NO. WAS GIVEN. WAS BREAK A TERM?
	SKP		/A PRIO WAS GIVEN
	JMS	FAC
	SAD	(15
	SKP
	SAD	(175
	SKP
	JMP	.-5
	DAC	BREAK
	LACQ
	DAC	PRIO
	JMP	REQN2
CHKBRK	SAD	(15
	JMP	ENDCRA
	SAD	(175
	JMP	ENDCRA
	JMP	ERR1
ENDCRA=.
	DAC	BREAK	/SAVE THE BREAK CHAR.
REQN2	DZM*	X10	/FILL REMAINING CHARACTERS WITH ZERO
	ISZ	CNT
	JMP	REQN2
/
	LAC	REQCPB+4	/FORM FIRST HALF OF TASK NAME
	DZM	REQCPB+4	/CLEAR PRIORITY TO ZERO
	LRS	6
	LAC	REQCPB+3
	LRS	6
	LAC	REQCPB+2
	SNA		/IS THIS A NULL NAME?
	JMP	ERR1	/YES EXIT WITH ERROR
	LLS	14
	DAC	REQCPB+2	/STORE FIRST HALF OF WORD IN REQCPB
	LAC	REQCPB+7	/FORM SECOND HALF OF TASK NAME
	LRS	6
	LAC	REQCPB+6
	LRS	6
	LAC	REQCPB+5
	LLS	14
	DAC	REQCPB+3
	LAC	PRIO	/WAS A PRIO GIVEN?
	SZA
	JMP	SETPRI	/YES -- PREPARE TO SET IT UP
	.DEC
	LAC	(400	/NO -- SET PRIO TO 400
	.OCT
	DAC	REQCPB+4
	JMP	EXT1
SETPRI	DAC	REQCPB+4
	SAD	(1000
	SKP
	IAC
	DAC	REQTDC+4
EXT1	CAL	REQCPB	/ISSUE REQUEST DIRECTIVE
	CAL	WAITEV
	LAC	EV	/GET EVENT VARIABLE
	SMA		/JUMP IF REJECTED
	JMP	EXT1A	/OK NO ERRORS
	SAD	(-201)	/TASK NOT IN SYSTEM ERROR
	JMP	MESA
	SAD	(-202)	/TASK ACTIVE
	JMP	MESB
	SAD	(-204)	/TASK DISABLED
	JMP	MESC
	SAD	(-212	/PARTITION LOST?
	JMP	MESD
	JMS	TYPE	/POOL EMPTY
	MES6
	JMP	EXT2
MESA	JMS	TYPE
	MES3
	JMP	EXT2
MESB	JMS	TYPE
	MES4
	JMP	EXT2
MESC	JMS	TYPE
	MES5
	JMP	EXT2
MESD	JMS	TYPE
	MES8
	JMP	EXT2
EXT1A=.
	LAC	BREAK
	SAD	(15
EXT2	CAL	REQTDC	/REQUEST TDV TASK
	CAL	(10)	/RETURN
/
REQTDC	1		/CALL TDC DIRECTIVE
	0
	.SIXBT	'TDC'
	.SIXBT	"@@@"
	.DEC
	401
	.OCT
REQCPB	1	/FUNCTION CODE
	EV	/EVENT VARIABLE ADR
	0	/TASK NAME (FIRST HALF)
	0	/TASK NAME (SECOND HALF)
	0
B1	0
B2	0
CMPBF	0
	0
BREAK	0
PRIO	0
NUMT	0
NUMFLG	0
CHAR	0
COUNT	0
NUM	0
/
/ SUBROUTINE NUMBER -- READ A DECIMAL NUMBER OF UP TO 4 DIGITS
/			OFF THE MCR TTY.
/ 
/ ALTERED REGISTERS: AC AND MQ
/ 
/ CALLING SEQUENCE:
/		JMS	NUMBER
/		JMP	???	/RETURN HERE IF 1ST CHARACTER
/				/AFTER A BUNCH OF SPACES IS NOT
/				/A DECIMAL DIGIT WITH THE CHARACTER
/				/IN THE AC.
/		???	???	/RETURN HERE IF 1ST CHARACTER
/				/AFTER A BUNCH OF SPACES IS A DECIMAL
/				/DIGIT WITH THE BREAK CHARACTER IN THE
/				/AC AND THE NUMBER IN THE MQ.
/ 
NUMBER	0
	LAW	-4		/SET DIGIT COUNTER
	DAC	COUNT
	DZM	NUM		/ZERO PREVIOUS RESULTS
	CLC			/SET A FLAG TO INDICATE THAT SPACES
	DAC	NUMFLG		/ARE NOT BREAK CHARACTERS YET.
NUM1	JMS	FAC		/GET A CHARACTER
	SAD	(40		/WAS THE CHARACTER A SPACE?
	JMP	NUMSPC		/YES
	DZM	NUMFLG		/NO -- CLEAR FLAG TO INDICATE THAT ANY
				/SPACES ENCOUNTERED SHOULD BE USED AS
				/BREAK CHARACTERS.
	DAC	NUMT		/SAVE IT TEMPORARILY
	AAC	-60		/IS IT A DIGIT?
	SPA
	JMP	NUM2		/NO -- EITHER A BREAK OR AN ERROR
	DAC	CHAR		/SAVE THE POTENTIAL DIGIT
	AAC	-12
	SMA
	JMP	NUM2		/NO -- EITHER A BREAK OR AN ERROR
	LAC	NUM		/YES -- PICK UP THE REAL NUMBER
				/THAT HAS ALREADY BEEN CONSTRUCTED
	CLL
	MUL			/MULTIPLY IT BY 10 DECIMAL
	12
	LACQ			/GET RESULT INTO AC
	TAD	CHAR		/ADD THE DIGIT JUST READ
	DAC	NUM		/SAVE THE RESULTING DECIMAL NUMBER
	ISZ	COUNT		/HAVE 4 DIGITS BEEN READ?
	JMP	NUM1		/NO -- READ SOME MORE
	JMS	FAC		/YES -- READ A BREAK CHARACTER
NUM3	DAC	CHAR		/SAVE THE CHARACTER TEMPORARILY
	IDX	NUMBER		/PREPARE TO RETURN AT JMS+2
	LAC	NUM		/PICK UP THE DECIMAL NUMBER
	LMQ			/STORE IT IN THE MQ
	LAC	CHAR		/GET THE BREAK CHAR INTO THE AC
	JMP*	NUMBER		/RETURN AT JMS+2
NUM2	LAW	-3		/CHARACTER IS EITHER A BREAK OR ERROR
	SAD	COUNT		/IF THIS WAS THE 1ST CHARACTER READ
				/ITS AN ERROR. OTHERWIZE ITS A BREAK.
	JMP	NUMERR		/ERROR
	LAC	NUMT		/BREAK -- GET THE CHARACTER INTO AC
	JMP	NUM3
NUMERR	LAC	NUMT		/ERROR SO GET CHARACTER INTO AC
	JMP*	NUMBER		/AND RETURN AT JMS+1
NUMSPC	LAC	NUMFLG		/CHAR. WAS A SPACE -- IS IT A BREAK CHAR.?
	SZA
	JMP	NUM1		/NO -- THE SPACE SHOULD BE IGNORED
	LAC	(40		/YES -- TREAT THE SPACE AS A BREAK CHAR.
	DAC	NUMT
	JMP	NUM2
/
/	FAC -- SUBROUTINE TO FETCH A CHARACTER FROM 5/7 ASCII LINE BUFFER 'FACLB'.
/	CHARACTERS ARE NOT FETCHED BEYOND TERMINAL CHARACTERS
/
FAC	0
	LAC*	FACCBX	/FETCH NEXT UNPACKED CHARACTER FROM 'FACCB'
	SMA		/WAS CHARACTER BUFFER (FACCB) EMPTY?
	JMP	FAC2	/NO -- TEST FOR TERMINAL CHARACTER
	LAC	(FACCB-1)	/YES -- REFIL 'FACCB'
	DAC	FACCBX
	LAC*	FACLBX	/(FIRST HALF OF WORD PAIR)
	ISZ	FACLBX
	LMQ
	CLA!CLL
	JMS	FACUPS	/(FIRST CHAR)
	JMS	FACUPS	/(SECOND CHARACTER
	JMS	FACUPS	/(FIRST FOUR BITS OF THIRD CHARACTER)
	LAC*	FACLBX	/(SECOND HALF OF WORD PAIR)
	ISZ	FACLBX
	LRS	17	/(LAST THREE BITS OF THIRD CHAR)
	XOR*	FACCBX
	DAC*	FACCBX
	CLA
	JMS	FACUPS	/(FORTH CHAR)
	JMS	FACUPS	/(FIFTH CHAR)
	LAC	(FACCB)	/RESET CHAR BUF INDEX
	DAC	FACCBX
	LAC*	FACCBX	/FETCH FIRST CHAR FROM BUFFER
FAC2	SAD	(015)	/IF TERMINAL CHARACTER, (CR OR AM)
	JMP*	FAC	/RETURN WITH CHAR IN AC BUT DO NOT
	SAD	(175)	/AUGMENT CHAR BUF INDEX (REPEATED CHAR)
	JMP*	FAC	/OF FAC WILL RETURN THE TERMINAL CHARACTER)
/
	ISZ	FACCBX	/NON-TERMINAL CHARACTER -- AUGMENT CHARACTER
	JMP*	FAC	/BUFFER INDEX AND RETURN WITH CHAR IN AC
/
FACUPS	0		/UNPACKING SUBROUTINE -- AC & LINK MUST BE
	LLS	7	/CLEARED, NEXT CHAR MUST BE IN HIGH ORDER
	ISZ	FACCBX	/MQ, 'FACCBX' MUST POINT TO WORD PRECEEDING
	DAC*	FACCBX	/CHAR TO BE STORED.
	CLA		/CHAR IS SHIFTED INTO AC (LOW ORDER BITS
	JMP*	FACUPS	/OF THIRD CHAR ARE ZERO BECAUSE LINK IS
		/ZERO), STORED, 'FACCBX' IS LEFT POINTING TO 
		/CHAR, AND AC IS CLEARED (LINK IS ALSO LEFT CLEARED
FACLBX	FACLB+2	/LINE BUFFER INDEX
FACCBX	FACCB+5	/CHARACTER BUFFER INDEX
FACCB	.BLOCK	5	/CHARACTER BUFFER (5 IMAGE ALPHA CHARS)
	-1		/END OF 'FACCB' INDICATOR
/
FACLB	.BLOCK	22	/BUFFER FOR ASCII LINE
	.ASCII	<15>	/TERMINATOR IN CASE OF TRUNCATED LONG LINE
/
/	TYPE -- SUBROUTINE TO TYPE THE MESSAGE WHOSE ADDRESS FOLLOWS THE JMS
/
TYPE	0
	LAC*	TYPE
	DAC	TYPCPB+4
	ISZ	TYPE
/
	CAL	TYPCPB	/MAKE TYPE CPB REQUEST
/
	CAL	WAITEV	/WAIT FOR TTY TO FINISH
	JMP*	TYPE	/RETURN
/
WAITEV	20	/WAITFOR
	EV	/EVENT VARIABLE ADDRESS
/
TYPCPB	2700
	EV
	15
	2
	XX
EV	0
RDTDV	37	/READ TDV
	EV
	FACLB	/LINE BUFFER
	22	/SIZE OF BUFFER
/
MES2	MES3-MES2/2*1000
	0
	.ASCII "REQ-SYNTAX ERR"<15>
MES3	MES4-MES3/2*1000
	0
	.ASCII "REQ-TASK NOT IN SYSTEM"<15>
MES4	MES5-MES4/2*1000
	0
	.ASCII "REQ-TASK ALREADY ACTIVE"<15>
MES5	MES6-MES5/2*1000
	0
	.ASCII "REQ-TASK DISABLED"<15>
MES6	MES7-MES6/2*1000
	0
	.ASCII "REQ-POOL EMPTY"<15>
MES7	MES8-MES7/2*1000+2
	0
	.ASCII	"REQ-TDV ERR"<15>
MES8	MES9-MES8/2*1000
	0
	.ASCII "REQ-PART LOST"<15>
MES9=.
/
/	ENDCRA	SAVE LINE TERMINATOR
/
CNT	0
	.END	REQ
