/ 
/ 
/                   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
/	QUEUE SYSTEM FUNCTION
/	QUEUES JOBS TO THE BATCH PROCESSOR
/
/	COPYRIGHT 1974 DIGITAL EQUIPMENT CORPORATION
/	GARY M. COLE  NOVEMBER 1973
/
/
/
	.TITLE QUEUE  -- SUBMIT A JOB TO THE BATCH PROCESSOR
/
/	QUE FUNCTION TASK FOR MCR,TDV,OPR,STACKR, AND TSR USE
/	EDIT #1  1/30/74  G. COLE
/
/
/	ASSEMBLE INTO ONE OF THREE VERSIONS
/
/	TDV VERSION, GETS COMMAND STRING FROM XFRCMD, REQUESTS TDV ON EXIT
/
/	MCR VERSION, GETS COMMAND STRING FROM FAC, REQUESTS MCR ON EXIT
/
/	TERMINAL VERSION, REQUESTS COMMAND STRING FROM USER,
/		USING LUN SPECIFIED WITH  TTYLUN  PARAMETER
/		EXITS NORMALLY.
/
/
/
/	ASSEMBLY PARAMETERS ARE
/
/	TDV=0  FOR TDV VERSION
/	MCR=0	FOR MCR VERSION
/	TTYLUN=0 FOR TERMINAL VERSION
	.IFUND	TDV
	.IFUND	MCR
	.IFUND	TTYLUN
	.END  -- NO VERSION (TDV,MCR,TTYLUN) PARAMETER SPECIFIED
	.ENDC
	.ENDC
	.ENDC
/
	.IFDEF	TTYLUN
	.IFUND	CMDLUN
CMDLUN=TTYLUN
	.ENDC
	.ENDC
	.IFUND	DEFCLS	/DEFAULT JOB CLASS
DEFCLS=0
	.ENDC
/THIS FEATURE ALLOWS YOU TO RUN QUEUE FROM ONE PACE
/AND READ QUEUE COMMANDS FROM ANOTHER. IT WOULD ALLOW YOU TO QUEUE
/CARD DECKS ON A PUSH BUTTON COMMAND OR A SINGL CNTL/X.
/THE QUEUE PARAMETERS WOULD BE ON CMDLUN AND ALL PRINTOUT WOULD BE
/ON TTYLUN.......
	.GLOBL	SET57,FAC57
	.IFUND	STKLUN
STKLUN=77
	.ENDC		/DEFAULT SETTING OF STKLUN=LUN10
/
/DEFINE PRINT MACRO:
	.DEFIN	PRINT,ZLUN,ZA,ZB,ZC,ZD,ZE,ZF
	CAL	.+3	/PRINT LINE
	CAL	.+10	/WAIT FOR IT
ZTMP2=.
	HLT		/REPLACED WITH JMP
	2700		/WRITE CAL
	.+4
	ZLUN		/LUN
	2 		/ASCII
	.+4		/BUFFER
	0	/EV
	20		/WAITFR CPB
	.-2
ZTMP=.
	0		/LINE BUFFER
	0
	.ASCII	"ZA ZB ZC ZD ZE ZF"<015>
ZTMP1=.
	.LOC	ZTMP
	ZTMP1-ZTMP/2*1000+2
	.LOC	ZTMP2
	JMP	ZTMP1	/JMP AROUND CPBS AN BUFFER
	.LOC	ZTMP1
	.ENDM
START	NOP
	.EJECT
	/INITIALIZE VARIABLES
	DZM	NFO		/DECLARE IT FILE ORIENTED INITIALLY (0)
	LAC	(21)		/SET DEFAULT FOR LUN NUMBER
	DAC	LUNN
	DZM	SPNFLG	/DEFAULT IS NO SPAWNING
	DZM	HLDFLG	/DEFAULT IS TO RUN
	DZM	OPRFLG		/DEFAULT IS NO OPERATOR COVERAGE
	DZM	NCKFLG		/DEFAULT IS TO CHECK FILE
	DZM	DELFLG		/DEFAULT IS NOT TO DELETE FILE
	DZM	SEQFLG		/DEFAULT IS NOT TO SEQUENCE JOB
	DZM	MEMSIZ	/DEFAULT IS CURRENT SIZE
	DZM	USRNUM		/DEFAULT IS NON-USER ORIENTED
	LAC	(3)		/DEFAULT IS
	DAC	TIMLIM		/3 MINUTE TIME LIMIT
	LAC	(DEFCLS)
	DAC	CLASS		/DEFAULT IS JOB  DEFCLS PARAMETER
/
/
/	NOW GET THE INPUT LINE AND UNPACK IT INTO THE INBUF AREA
/
	JMS	GETLIN		/GETLIN SUB DEPENDS ON ASSEMBLY
	LAC	(FL-1)	/SETUP X11 TO STORE LIST OF FILE NAME CHARS
	DAC*	(11)	/
	.IFDEF	TDV	/ONLY NEED THIS CODE FOR TDV SCAN
SCNSP	JMS	GETC	/GET CHARS, SCAN FOR SPACE TO TERMINATE 
			/NAME OF FUNCTION
	JMP	FMTERR	/FORMAT ERROR IF END HERE
	SAD	(40)	/TEST FOR SPACE
	SKP
	JMP	SCNSP		/LOOP UNTIL SPACE FOUND
	.ENDC
SCNCHR	JMS	GETC		/PASS SPACES TO CHAR
	JMP	FMTERR	/ERROR AGAIN 
	SAD	(40)
	JMP	SCNCHR	/LOOP
 
	JMS	TDIG		/TEST CHAR IN AC FOR DIGIT
				/IF SO, LEAVE VALUE IN AC, ELSE
				/RETURN WITH CHAR IN AC
	JMP	FILN		/NOT A DIGIT, FIRST CHAR OF THE FILE
				/NAME
	ISZ	NFO		/SET "NON FILE ORIENTED" FLAG
LUNIN	DAC	DIGIT
	DZM	VALUE
LUNINL	LAC	VALUE
	MUL; 12		/MULTIPLY BY 10
	LACQ
	TAD	DIGIT
	DAC	VALUE
	JMS	GETC
	JMP	OKLUN
	JMS	TDIG	/TEST IT FOR DIGIT
	JMP	NONDGL	/NOT A DIGIT IN LUN NUMBER
	DAC	DIGIT
	JMP	LUNINL
NONDGL	SAD	(40)	/IS IT A SPACE?
	JMP	OKLUN2	/YES
	SAD	(54)	/IS IT A COMMA?
	JMP	OKLUN2	/YES
	JMP	FMTERR	/NO, MUST BE A FORMAT ERROR
			/NO TERMINATOR AFTER VALUE OF LUN
OKLUN	LAC	VALUE
	DAC	LUNN	/SAVE VALUE IN LUN
	JMP	OK
 
OKLUN2	LAC	VALUE
	DAC	LUNN
	JMP	EOLUN
	.EJECT
FILN	DAC*	11	/SAVE FIRST CHARACTER OF FILE NAME
	JMS	GETC
	JMP	OK
	SAD	(40)
	JMP	EOFN	/DELIMITER FOR END OF FILE NAME
	SAD	(54)
	JMP	EOFN	/SAME FOR COMMA
	JMP	FILN	/LOOP FOR MORE
 
EOFN	JMS	GETC
	JMP	OK
	DAC	CHAR	/SAVE IN CASE WE HAVE NO LUN SPECIFIED
	SAD	(40)
	JMP	EOFN
	SAD	(54)
	JMP	EOFN	/SCAN OFF TRAILING DELIMITERS
	JMS	TDIG	/TEST FOR DIGIT(LUN NUMBER)
	JMP	NODIG
	JMP	LUNIN	/SCAN FOR LUN
 
NODIG	LAC	(21)	/DEFAULT LUN IF FILE IS SPECIFIED BUT LUN NOT
	DAC	LUNN
	JMP	KEYW	/PROCESS THE CHAR THAT WE KNOW IS NOT A DIGIT
 
EOLUN	JMS	GETC	/PROCESS JOB SPECIFIERS
	JMP	OK	/IF END
	SAD	(40)	/TEST FOR SPACE
	JMP	EOLUN	/SCAN OFF
	SAD	(54)
	JMP	EOLUN	/SCAN OFF COMMAS TOO
	DAC	CHAR	/SAVE FIRST CHARACTER
	JMS	TDIG	/TEST FOR DIGIT HERE(ERROR)
	SKP		/SKIP IF NOT DIGIT AFTER LUN
	JMP	FMTERR
KEYW	LAC	CHAR	/TEST FOR THE CASES WHICH HAVE NO 
			/ASSOCIATED NUMERICAL VALUE
	SAD	(123)
	JMP	SPFL	/SET SPN OR STK OR SEQ FLAG
	SAD	(117)
	JMP	OPRFL		/SET OPR (OPERATOR REQUIRED) FLAG
	SAD	(104)		/SET DELETE FILE FLAG
	JMP	DELFL
	SAD	(116)		/SET NOCHECK FLAG
	JMP	NCKFL
	SAD	(110)
	JMP	HLDFL	/TEST FOR AN "H" HOLDING
	JMP	GETVAL	/GET ASSOCIATE VALUE (T=XXX ETC)
OPRFL	ISZ	OPRFLG
	JMP	RUNOFF
HLDFL	ISZ	HLDFLG	/SET HOLDING FLAG
	JMP	RUNOFF
DELFL	ISZ	DELFLG
	JMP	RUNOFF
NCKFL	ISZ	NCKFLG
	JMP	RUNOFF
SPFL	JMS	GETC	/MUST DIFFERENTIATE BETWEEN
				/SPN AND SEQ
	JMP	FMTERR	/FORMAT ERROR IF NO MORE CHAR
	SAD	(120)	/TEST FOR P
	JMP	SPNXXX
	SAD	(105)	/TEST FOR E
	JMP	SEQXXX
	SAD	(124)	/TEST FOR T
	JMP	STKXXX
	JMP	FMTERR	/IF NOT SP OR SE
SPNXXX	ISZ	SPNFLG
	JMP	RUNOFF
SEQXXX	ISZ	SEQFLG
	JMP	RUNOFF
STKXXX	ISZ	STKFLG
	ISZ	DELFLG	/NOTE, STACKING IMPLIES DELETION
			/THIS IS DONE TO PREVENT CLUTTER
			/ON THE STKLUN UFD, IF YOU DISLIKE THIS
			/ASSUMPTION, REMOVE THIS INSTRUCTION
	JMP	RUNOFF
	JMP	RUNOFF
 
 
	.EJECT
RUNOFF	JMS	GETC	/SCAN TO NEXT BLANK
	JMP	OK
	SAD	(40)
	JMP	EOLUN
	SAD	(54)
	JMP	EOLUN
	JMP	RUNOFF	/LOOP UNTIL SPACE, COMMA, OF EOL
 
GETVAL	DZM	VALUE
	JMS	GETC
	JMP	FMTERR	/ERROR IF ENDS HERE
	JMS	TDIG	/TEST FOR START OF VALUE FIELD
	JMP	GETVAL	/LOOP UNTIL DIGIT
VLOP	DAC	DIGIT
	LAC	VALUE
	MUL ; 12	/MULTIPLY BY 10
	LACQ
	TAD	DIGIT
	DAC	VALUE
	JMS	GETC	/GET NEXT CHAR
	JMP	OKVL
	JMS	TDIG
	JMP	NOTDIG
	JMP	VLOP
 
NOTDIG	ISZ	CONTFG	/SET CONTINUATION FLAG
 
OKVL	LAC	CHAR
	SAD	(115)	/TEST FOR M=XXX MEMORY SIZE SPECIFICATION
	JMP	STRMEM
 
	SAD	(124)	/TEST FOR TIME LIMIT SPECIFICATION
	JMP	STRTIM
 
	SAD	(103)	/TEST FOR CLASS SPECIFICATION
	JMP	STRCLS
 
	SAD	(125)	/TEST FOR USER SPECIFICATION
	JMP	STRUSR
 
	JMP	FMTERR	/ILLEGAL SPECIFIER NOT (U,M,T,S,O,C)
 
LSTVL	LAC	CONTFG	/TEST FOR MORE SPECIFIERS
	DZM	CONTFG
	SNA
	JMP	OK	/PROCESS REQUEST
	JMP	EOLUN	/TRY FOR MORE SPECIFIERS
 
STRMEM	LAC	VALUE
	DAC	MEMSIZ
	JMP	LSTVL
 
STRTIM	LAC	VALUE
	DAC	TIMLIM
	JMP	LSTVL
 
STRUSR	LAC	VALUE
	DAC	USRNUM
	JMP	LSTVL
 
STRCLS	LAC	VALUE
	DAC	CLASS
	JMP	LSTVL
	.EJECT
/
/	BEGIN ASSEMBLY OF THE QJOB CAL ENTRIES
/
OK	DZM	JINFO	/CLEAR JINFO WORD
	LAC	DELFLG		/TEST AND SET DELETE FILE BIT (0)
	SNA
	JMP	OK1
	LAC	(400000)
	DAC	JINFO
 
OK1	LAC	OPRFLG		/TEST AND SET OPERATOR REQUIRED FLAG
	SNA
	JMP	OK2
	LAC	JINFO
	TAD	(200000)
	DAC	JINFO
 
OK2	LAC	SEQFLG		/TEST AND SET  THE SEQUENCING FLAG
	SNA
	JMP	OK3
	LAC	JINFO
	TAD	(40000)
	DAC	JINFO
 
OK3	LAC	SPNFLG	/INSERT SPAWNING FLAG
	SNA
	JMP	OK4
	LAC	JINFO	/SET BIT 04
	TAD	(20000)
	DAC	JINFO
 
OK4	LAC	HLDFLG
	SNA
	JMP	OK5
	LAC	JINFO	/INSERT THE HOLD BIT
	TAD	(10000)
	DAC	JINFO
 
 
OK5	LAC	TIMLIM	/TEST AND INSERT TIME LIMIT
	AND	(776000)
	SZA	/SKIP IF OK
	JMP	VALERR
	LAC	TIMLIM
	AND	(1777)
	TAD	JINFO
	DAC	JINFO	/JINFO IS COMPLETED EXCEPT FOR POSSIBLE
			/UPDATE OF THE TIME LIMIT FROM THE
			/FILE CHECK
	.EJECT
/
/	CONTINUE TO ASSEMBLE THE SP1 WORD
/		THIS CONTAINS THE JOB SPAWNING FLAG
/		THE USER NUMBER, AND THE MEMORY SIZE.
/
/
/
OK6	LAC	CLASS	/INSERT CLASS INTO BITS 0-2 OF SP1 WORD
	AND	(777770)	/CHECK FOR RESONABLE VALUE
	SZA
	JMP	VALERR	/ERROR IF GTR 7 OR NEG
 
	LAC	CLASS
	RTR!CLL; RTR	/ROTATE INTO BITS 0,1,2
	DAC	SP1	/FIRST PARAMETER IN SP1
 
OK7	LAC	USRNUM	/TEST AND SET USER NUMBER
	AND	(777400)
	SZA
	JMP	VALERR		/IF NUMBER GT 255
	LAC	USRNUM
	LLS	7	/SHIFT INTO BITS 3-10
	AND	(077600)	/REMOVES STRAY MQ BITS
	TAD	SP1		/ADD USER NUMBER TO SP1 WORD
	DAC	SP1
 
OK8	LAC	MEMSIZ		/TEST AND INSERT MEMSIZE*4
	AAC	-201		/TEST FOR GTR 128
	SMA			/SKIP IF OK
	JMP	VALERR
	LAC	MEMSIZ
	SZA
	AAC	-1		/LEAVE 0=0, ELSE SUB 1(=1024 WORDS)
				/0 IMPLIES CURRENT TDV PARTITION SIZE
	AND	(177)
	TAD	SP1
	DAC	SP1
/
/	SP1 IS NOW COMPLETED
/
	.EJECT
OK10	LAC	FL	/CONVERT FILE NAME TO TWO SIXBT WORDS
	JMS	SIXBTC
	DAC	FL
	LAC	FL+1
	JMS	SIXBTC
	DAC	FL+1
	LAC	FL+2
	JMS	SIXBTC
	DAC	FL+2
	LAC	FL+3
	JMS	SIXBTC
	DAC	FL+3
	LAC	FL+4
	JMS	SIXBTC
	DAC	FL+4
	LAC	FL+5
	JMS	SIXBTC
	DAC	FL+5	/ALL CAHR ARE NOW SIXBT FORMAT
 
	LAC	FL	/PACK INTO TWO WORDS
	CLL!RTL; RTL; RTL
	TAD	FL+1
	RTL; RTL; RTL
	TAD	FL+2
	DAC	JOBFL1	/PUT INTO CAL
	LAC	FL+3
	CLL!RTL; RTL; RTL
	TAD	FL+4
	RTL; RTL; RTL
	TAD	FL+5
	DAC	JOBFL2	/PUT SECOND HALF OF FILENAME INTO CAL
/
/
	LAC	LUNN	/PUT LUN NUMBER INTO CAL
	SAD	(1)	/TEST FOR LUN 1
	JMP	SRCERR	/CANNOT INPUT FROM DISK DRIVER
	SWHA
	DAC	JOBLUN
 
	.EJECT
TES1	LAC	NCKFLG	/IS FILE CHECKING REQUIRED?
	SZA		/YES
	JMP	QJOB	/NO, INITIATE THE JOB
 
	LAC	LUNN	/SETUP CALS
	DAC	HINLUN
	DAC	OPNLUN
	DAC	CLSLUN
 
	CAL	HINF	/ASK CHARACTERISTICS OF DEVICE
	CAL	WAIT
 
	LAC	EV	/GET DESCRIPTION
	AND	(200000)
	SNA	/CAN IT DO INPUT?
	JMP	SRCERR	/NO!, CANT RUN A JOB FROM THE LPT!!
 
	LAC	EV
	AND	(77)
	SAD	(21)	/IS IT THE BATCH PROCESSOR?
	JMP	SRCERR	/YES!!, MUST NOT DO THIS
 
	LAC	EV
	AND	(40000)	/IS IT A FILE STRUCTURED DEVICE?
	SNA
	JMP	NONFS	/NO, CANNOT READ UNLESS STACKING FILE
 
	LAC	JOBFL1	/GET FILE NAME
	SNA		/IS IT REASONABLE
	JMP	FNERR	/NO!
	DAC	CLSFL1	/
	DAC	OPNFL1
	LAC	JOBFL2
	DAC	OPNFL2
	DAC	CLSFL2
 
	CAL	OPN	/OPEN THE FILE
	CAL	WAIT
	LAC	EV	/TEST FOR ERRORS
	SMA
	JMP	READJ	/FILE OPEN
	SAD	(-13)
	JMP	FILNOT	/FILE NOT FOUND
	JMP	FILERR	/FILE ERROR
	.EJECT
READJ	LAC	LUNN
	DAC	REDLUN	/SETUP LUN FOR READ
	CAL	READF	/READ FIRST LINE OF THE JOB
			/MUST BE $JOB CARD
	CAL	WAIT
 
	LAC	EV
	SPA
	JMP	FILERR	/FILE ERROR
 
	LAC	BUF1	/GET FIRST WORD OF LINE
	SAD	DJOB1	/COMPARE WITH "$JOB"
	JMP	ROK1
	JMP	NJOBER	/NOT A $JOB FILE
 
ROK1	LAC	BUF2
	SAD	DJOB2
	JMP	ROK2
	JMP	NJOBER	/NOT A $JOB LINE
 
ROK2	JMS*	SET57
	BUF1 
 
	JMS	GETCX
	JMP	JFERR	/$JOB FORMAT ERROR
 
	JMS	GETCX
	JMP	JFERR	/SAME
 
	JMS	GETCX	/SCANNING OFF TO TIME LIMIT
	JMP	JFERR
 
	JMS	GETCX
	JMP	JFERR
	JMS	TDIG
	JMP	JFERR	/NO A DIGIT IN TIME LIMIT FIELD
	DAC	VALUE
 
	JMS	GETCX
	JMP	JFERR	/EXTRACT SECOND AND THIRD DIGITS FROM TIME 
	JMS	TDIG
	JMP	JFERR
	DAC	DIGIT
	LAC	VALUE
	MUL;	12
	LACQ
	TAD	DIGIT
	DAC	VALUE	/STORE RUNNING VALUE
 
	JMS	GETCX
	JMP	JFERR
	JMS	TDIG
	JMP	JFERR
	DAC	DIGIT
	LAC	VALUE
	MUL;	12
	LACQ
	TAD	DIGIT
 
	DAC	TIMLIM	/THIS THE REAL TIME LIMIT FOR THE JOB
 
	LAC	JINFO
	AND	(776000)
	TAD	TIMLIM
	DAC	JINFO
	JMP	STKCK	/GO CHECK FOR STACKING
	.EJECT
NONFS	ISZ	NFO	/INDICATE THAT IT IS NON FILE STRUCTURED
	LAC	STKFLG	/TEST FOR STACKING
	SZA		/SKIP IF NOT
	JMP	READJ	/JUP IF SO AND READ FIRST LINE
	JMP	QJOB	/QUEUE THE JOB IF ALL DONE NOW
 
 
/NOW THE JOB QUEUE DATA IS COMPLETE
/
/IF WE ARE TO STACK THE FILE WE NOW MUST COPY IT TO
/THE DISK , IF NOT WE CLOSE THE FILE AND QUEUE THE JOB.
 
STKCK	LAC	STKFLG	/TEST FOR STACKING
	SNA		/SKIP IF SO
	JMP	STKSX		/ELSE  MIGHT BE SCANNING--GO CHECK AND RETURN IF SO
	/	JOB STACKING LOGIC
	/ALSO USED FOR JOB SCANNING
	/
	/TWO FUNCTIONS ARE AS FOLLOWS:
	/
	/SCANNING: DONE IF STACKING NOT SET BUT DEVICE IS
	/FILE ORIENTED. READS THE FILE AND SENSES SPECIAL CARDS.
	/
	/STACKING: DONE IF STK INDICATED, CREATES NEW FILE AND COPIES ORIGIN
	/JOB INTO IT, FREEING ORIG JOB FILE OR DEVICE.
	/
	/
	/
	/
/
/	THE FUNCTION HERE IS TO COPY THE JOB DECK
/	FROM WHERE IT NOW IS TO A PRESPECIFIED
/	DISK LUN AND QUEUE IT FROM THERE.
/
/	TO DO THIS IT IS NECESSARY TO HAVE A FILE NAME
/	WHICH WE DERIVE FROM THE TIME OF DAY, CHECKING TO 
/	BE SURE THAT THIS HAS NOT ALREADY BEEN USED.
/
/	IF THE DELETE PARAMETER HAS BEEN SPECIFIED, THE BATCH
/	PROCESSOR WILL AUTOMATICALLY DELETE THE JOB FILE
/	AFTER IT HAS BEEN RUN.
/
/	WHILE WE COPY THE FILE FROM DEVICE TO DISK,
/	WE DETECT $MSG,$PAU CARDS WHICH WOULD REQUIRE
/	OPERATOR ASSISTANCE AT RUN TIME AND SET THE OPR
/	REQUIRED INDICATOR. WE ALSO DETECT THE $SPN
/	CONTROL CARD AND SET THE SPAWNING FLAG.
/
/	STACKING TERMINATES WHEN WE SEE A PHYSICAL END OF FILE,
/	A $END RECORD, OR A $QUIT RECORD. NOTICE IT IS NOT
/	POSSIBLE TO STACK MORE THAN ONE JOB INTO A FILE IF
/	$END RECORDS SEPERATE THE JOBS.
/
	.EJECT
	CAL	SPYSSM	/GET TIME IN SEC SINCE MIDNIGHT
 
CPTFN	LAC	TIMEV	/GET TO AC
	LMQ		/TO MQ FOR SHIFTING
	LLS	6	/IGNORE UPPER 6 BITS
	CLA!CLL
	LLS	4	/GET FIRST CHAR IN SIXBT
	IAC
	RTL		/SLIDE IN TWO ZERO BITS
	LLS	4
	IAC
	RTL
	LLS	4
	IAC
	DAC	SEKFLN	/FILE NAME HAS BEEN CREATED IN SIXBT
	DAC	ENTFLN
	DAC	CLSFLN
	DAC	DELFLN
	DAC	JOBFL2
	LAC	ENTFLN-1
	DAC	JOBFL1		/SETUP JOB FILE NAME
	LAC	(STKLUN*1000)
	DAC	JOBLUN		/DEFINE THIS LUN FOR EXECUTION
			/IT IS OF THE FORM SK.ZZZ JOB
/
/	IS THE FILE ALREADY THERE(USUAL PROBLEM WITH HASH CODED
/	VECTORS!!
/
	CAL	SEKSTK	/SEEK THE FILE
	CAL	WAIT	/
	LAC	EV
	SAD	(-13)	/TEST FOR FILE NOT FOUND
	JMP	MAKFL	/GOOD!, WE CAN USE OUR NAME
	SPA		/WAS OPERATION SUCESSFUL?
	JMP	STKERR	/NO, DECLARE ERROR
	ISZ	TIMEV	/YES, TRY NEW NAME
	JMP	CPTFN	/TRY,TRY AGAIN
	JMP	STKERR	/CANNOT HAPPEN,EVER!!!
			/IMPLIES ALL 4096 JOBS ARE STACKED!
 
MAKFL	CAL	ENTSTK	/ENTER THE NEW FILE
	CAL	WAIT
	LAC	EV
	SPA
	JMP	STKERR	/UNLIKELY TO HAPPEN UNLESS MEDIA FULL
			/OR STACKING ON DECTAPE AND DIRECTORY FULL
	.EJECT
/
/COPY THE JOB FILE FROM THE INPUT DEVICE TO THE QUEUE AREA
/
STKW	LAC	STKFLG	/ARE WE STACKING OR SCANNING
	SNA	/SKIP IF STACKING
	JMP	STKEW	/JMP IF SCANNING
	CAL	WRISTK	/WRITE OUT THE LINE TO THE NEW FILE
				/THIS MUST BE THE JOB LINE WHICH
				/IS AREADY IN CORE.
	CAL	WAIT
	LAC	EV
	SPA
	JMP	STKERR
 
STKEW	LAC	ENDSTK		/TEST IF LAST LINE ALREADY READ
	SZA
	JMP	STKDON		/IF SO,CLOSE FILE AND CONTINUE
 
	CAL	READF	/ELSE READ THE NEXT LINE
	CAL	WAIT
	LAC	EV
	SPA
	JMP	STKERR		/CLOSE AND DEL THE NEW FILE
	LAC	BUFL		/TEST HEADER
	AND	(7)
	SAD	(5)		/TEST FOR EOF ON INPUT
	JMP	STKDON		/CLOSE FILES AND CONTINUE
 
/NOT AN ERROR OR A PHYSICAL END OF FILE
/TEST FOR SPECIAL CONTROL CARDS
 
	JMS	CMP2
	ENDQ
	JMP	SETEND		/IF END LINE SEEN
 
	JMS	CMP2
	QUITQ
	JMP	SETEND		/IF $QUIT SEEN
 
	JMS	CMP2
	MSGQ
	JMP	SETOPR		/IF $MSG SEEN
 
	JMS	CMP2
	PAUQ
	JMP	SETOPR		/IF $P^AUSE SEEN
 
	JMS	CMP2
	SPNQ
	JMP	SETSPN		/IF $SPN SEEN
 
	JMP	STKW		/IF ANYTHING ELSE, WRITE IT OUT
	.EJECT
SETOPR	LAC	JINFO
	AND	(577777)
	TAD	(200000)
	DAC	JINFO
	JMP	STKW
 
SETSPN	LAC	JINFO
	AND	(757777)
	TAD	(20000)
	DAC	JINFO
	JMP	STKW
 
SETEND	ISZ	ENDSTK
	JMP	STKW	/SET FLAG AND WRITE LAST LINE
ENDSTK	0
/	
/	
STKSX	LAC	NFO	/TEST FOR FILEORIENTED DEVICE
	SZA
	JMP	QJOB	/NO SCANNING TO BE DONE, QUE THE JOB
	JMP	STKW	/BEGIN TO SCAN THE JOB
/
/
/
 
STKDON	LAC	STKFLG	/TEST FOR STACKING
	SNA	/SKIP IF SO
	JMP	CLOSX	/ELSE WE ARE DONE, GO CLOSE THE FILE AND QUEUE THE JOB
	CAL	CLSSTK	/CLOSE THE OUTPUT FILE
	CAL	WAIT
	LAC	EV
	SPA
	JMP	STKERR
	JMP	CLOSX
 
STKERR	LAC	STKFLG	/TEST
	SNA
	JMP	STKERM	/MESSAGE ONLY
	CAL	CLSSTK	/CLOSE THE OUTPUT FILE
	CAL	DELSTK	/CLOSE AND DELETE THE NEW F
STKERM	PRINT	TTLUN,STACKING,ERROR
	JMP	EXERR	/EXIT WITH ERROR
/
/DEFINE SPECIAL CARDS TO BE FOUND 
MSGQ	.ASCII	/$MSG/
PAUQ	.ASCII	/$PAU/
ENDQ	.ASCII	/$END/
QUITQ	.ASCII	/$QUI/
SPNQ	.ASCII	/$SPN/
/
/DEFINE CPBS
/
SPYSSM	31	/
	EV
	160	/SCOM CELL OF SECONDS SINCE MIDNIGHT
TIMEV	0	/VALUE RETURNED
 
SEKSTK	3200
	EV
	STKLUN
	.SIXBT	/SK./
SEKFLN	0
	.SIXBT	/JOB/
 
ENTSTK	3300
	EV
	STKLUN
	.SIXBT	/SK./
ENTFLN	0
	.SIXBT	/JOB/
 
WRISTK	2700
	EV
	STKLUN
	2
	BUFL
 
CLSSTK	3400
	EV
	STKLUN
	.SIXBT	/SK./
CLSFLN	0
	.SIXBT	/JOB/
 
DELSTK	3500
	EV
	STKLUN
	.SIXBT	/SK./
DELFLN	0
	.SIXBT	/JOB/
 
	.EJECT
/
/CMP2	COMMON SUBROUTINE TO COMPARE
/	THE TWO WORDS AT THE ADDRESS SPECIFIED IN THE 
/	ARGUMENT WITH THE WORDS BUF1 AND BUF2
/	THE LAST 8 BITS OF THE SECOND WORD ARE IGNORED
/	I.E. A 4 CHARACTER TEST IS MADE
/
CMP2	0
	LAC*	CMP2	/GET ARG
	DAC	CMPT1
	ISZ	CMP2	/PREPARE TO RETURN IF OK
	LAC	BUF2	/GET RID OF LAST CHAR
	AND	(777400)
	DAC	CMPT2
	LAC	BUF1	/COMPARE FIRST 2.5 CHAR
	SAD*	CMPT1	/WITH ARGUMENT STRING
	SKP		/SKIP IF OK
	JMP	CMPX	/EXIT TO CALL+3 IF ERROR
	ISZ	CMPT1
	LAC*	CMPT1	/GET CHAR 3 + 4
	AND	(777400)
	SAD	CMPT2	/TEST
	JMP*	CMP2	/RETURN TO CALL +2 IF OK
CMPX	ISZ	CMP2
	JMP*	CMP2	/RETURN TO CALL+3 IF DIFFERENT
 
CMPT1	0	/HOLDS ADDRESS OF ARG STRING
CMPT2	0	/HOLDS BUF2**777400
 
	.EJECT
 
CLOSX	LAC	NFO
	SZA		/TEST FOR FILE OPEN(FOD)
	JMP	QJOB
	CAL	CLS
	CAL	WAIT
	.EJECT
QJOB	CAL	QUEJB	/TELL THE WORLD!!!!!!
	.IFDEF	DEBUG
	.LOC	.-1
	HLT
	.ENDC
	CAL	WAIT
	LAC	EV
	SMA		/QUEUEING ERRORS?---- RARE
	JMP	QOK
	JMP	QUEERR
 
QOK	LAC	(005003)	/PRINTOUT JOB ID
	DAC	LINBF	/SETUP HEADER
	DZM	LINBF+1
	LAC	(6)	/SETUP LOOP
	PAL
	CLX
	LAC	EV	/EVENT VARIABLE CONTAINS ID
	LMQ
QIDPL	CLA!CLL
	LLS	3	/MOVE OCTAL DIGIT TO AC
	AAC	60	/CONVERT TO ASCII OCTAL
	DAC	LINBF+2,X	/STORE
	AXS	1	/TEST AND LOOP
	JMP	QIDPL
	LAC	(12)	/LINEFEED
	DAC	LINBF+2,X	/STORE
	LAC	(15)	/CARRIAGE RTN
	DAC	LINBF+3,X
	CAL	WRIQID		/PRINT ID
	CAL	WAIT
	JMP	EXIT	/ALL DONE!!
	.EJECT
WRIQID	2700
	EV
	TTLUN
	3
	LINBF	/CPB FOR PRINTING IDENT
/
/
/TDIG SUBROUTINE:
/
TDIG	0
	DAC	TDIG0	/SAVE ORIGINAL CHAR
	AAC	-60	/SUB 60 FROM DIGIT
	DAC	TDIG1
	SPA		/IS IT OK?
	JMP	TDIX	/NO,RETURN TO CALL+1
	AAC	-12	/SUB 10 MORE
	SMA		/IS IT STILL OK
	JMP	TDIX	/NO
	ISZ	TDIG
	LAC	TDIG1	/CHAR IS GOOD
	JMP*	TDIG	/RETURN TO CALL + 2
TDIX	LAC	TDIG0	/RESTORE AC
	JMP*	TDIG
TDIG0	0
TDIG1	0		/TEMPORARY
/
/SIXBTC SUBROUTINE
/
SIXBTC	0
	AND	(77)
	JMP*	SIXBTC
 
/	GENERAL VARIABLE DEFINITIONS
/
LUNN	0	/HOLDS LUN NUMBER
SEQFLG	0	/SET TO INDICATE SEQUENCING
HLDFLG	0	/SET TO INDICATE HOLDING
SPNFLG	0	/SET TO INDICATE SPAWNNING
NCKFLG	0	/SET TO BYPASS CHECKING OF JOB FILE
DELFLG	0	/SET TO INDICATE DELETE AFTER RUN 
MEMSIZ	0	/SET TO CORE SIZE IN K
USRNUM	0	/SET TO USER CODE
TIMLIM	0	/SET TO TIME LIMIT (MINUTES)
CLASS	0	/SET TO CLASS
VALUE	0	/TEMPORARY
DIGIT	0	/TEMPORARY
STKFLG	0	/SET TO INDICATE STACKING
OPRFLG	0	/SET TO INDICATE OPERATOR REQUIRED
NFO	0	/SET TO INDICATE NON FILE ORIENTED
CHAR	0	/TEMP
CONTFG	0	/TEMP, CONTINUATION FLAG ON PARAMETER SCAN
/
/
DJOB1=.
DJOB2=.+1
	.ASCII	/$JOB /
/
/
/NECESSARY CPB'S
/
QUEJB	33	/QUEUE JOB DIRECTIVE
	EV
JOBFL1	0
JOBFL2	0
JOBLUN	0
JINFO	0
SP1	0
SP2	0
/
/
WAIT	20
	EV
EV	0
OPN	3200	/OPEN THE JOB FILE
	EV
OPNLUN	0
OPNFL1	0
OPNFL2	0
	.SIXBT	'JOB'
/
/
CLS	3400	/CLOSE THE JOB FILE
	EV
CLSLUN	0
CLSFL1	0
CLSFL2	0
	.SIXBT	'JOB'
/
/
READF	2600
	EV
REDLUN	0
	2
	BUFL
	60
/
/
HINF	3600	/TEST DEVICE CHAR
	EV
HINLUN	0
/
/WORKING BUFFERS
/
BUFL	0
	0	/SPACE FOR HEADER, LINE FOLLOWS NEXT
BUF1	0
BUF2	0
BUF3	.BLOCK	56
FL	.BLOCK	20	/FILE NAME
	.EJECT
/	PRINT MESSAGES FOR VARIOUS ERRORS 
FMTERR	PRINT	TTLUN,FORMAT,ERROR,IN,COMMAND
	JMP	EXERR	/ERROR OUT
/
VALERR	PRINT	TTLUN,ILLEGAL,VALUE,FOR,ARGUMENT
	JMP	EXERR	/ERROR OUT
/
SRCERR	PRINT	TTLUN,CANNOT,INPUT,FROM,DEVICE,SPECIFIED
	JMP	EXERR	/ERROR OUT
/
FNERR	PRINT	TTLUN,NEED,FILE,NAME,FOR,THIS,DEVICE
	JMP	EXERR	/ERROR OUT
FILNOT=.
/
FILERR	PRINT	TTLUN,FILE,NOT,FOUND
	JMP	EXERR	/ERROR OUT
/
NJOBER	PRINT	TTLUN,JOB,RECORD,MUST,BE,FIRST,LINE
	JMP	EXERR	/ERROR OUT
/
JFERR	PRINT	TTLUN,INCORRECT,JOB,LINE
	JMP	EXERR	/ERROR OUT
/
QUEERR	PRINT	TTLUN,IMPOSSIBLE,TO,QUEUE,JOB
	JMP	EXERR	/ERROR OUT
	.EJECT
	.IFDEF	TTYLUN
/
/CONDITIONAL CODING FOR USER TERMINAL VERSION
/
/	WHEN RUN, PRINT * AND WAIT FOR COMMAND LINE
/	PROCESS AS USUAL RETURNING ERRORS TO TTYLUN
/
TTLUN=TTYLUN
GETLIN	0
	CAL	PROMPT	/PROMPT USER WITH *
	CAL	RCMDL	/READ LINE
	CAL	WAITLL
	LAC	EVL
	SPA
	JMP	CMDERR
	JMS*	SET57	/DEFINE BUFFER
	LINBF
	JMP*	GETLIN
EXERR	CAL	(10)	/ON AN ERROR
EXIT	CAL	(10)	/IF OK
GETCX=.
GETC	0
	JMS*	FAC57	/GET NEXT CHAR
	SAD	(015)
	JMP*	GETC
	SAD	(175)
	JMP*	GETC
	ISZ	GETC
	JMP*	GETC	/RETURN TO CALL+1 ON END,+2 ON DATA
CMDERR	CAL	(10)	/EXIT ON INITIAL ERROR
/
PROMPT	2700
	0	/NO EV, WILL WAIT ON THE READ THAT FOLOWS
	CMDLUN
	3
	.+1
	003003
	0
	0
	15	/NULL,CR,NULL,AND *
	0
	52
WAITLL	20
	EVL
EVL	0
RCMDL	2600
	EVL
	CMDLUN	/READ FROM COMMAND DEVICE
	2
	LINBF
	60
LINBF	.BLOCK	60
	.ENDC
	.IFDEF	TDV
/	DEFINE TDV VERSION OF QUEUE
/
/	READ COMMAND LINE FROM TDV, OUTPUT TO LUN 13
/
TTLUN=15
GETLIN	0
	CAL	XFCMD
	LAC	EVL
	SPA
	JMP	TDVERR
	JMS*	SET57
	LINBF		/DEFINE BUFFER
	JMP*	GETLIN
EXIT	CAL	REQTDV
	CAL	(10)
EXERR	CAL	REQTDV
	CAL	(10)
REQTDV	1
	0
	.SIXBT	/TDV.../
	0
XFCMD	37
	EVL
	LINBF
	60
LINBF	.BLOCK	60
EVL	0
GETCX=.
GETC	0	/FETCH CHAR ROUTINE
	JMS*	FAC57
	SAD	(15)
	JMP*	GETC
	SAD	(175)
	JMP*	GETC
	ISZ	GETC
	JMP*	GETC
/
TDVERR	PRINT	TTLUN,TDV,COMMAND,TRANSFER,ERROR
	JMP	EXERR
	.ENDC
	.IFDEF	MCR
GETLIN	0
	JMP*	GETLIN	/NO SETUP REQUIRED
TTLUN=3
EXERR=.
EXIT	DZM*	(171)	/RESET MCRRI
	LAC	MCRLST	/GET LAST CHAR SEEN
	SAD	(175)	/WAS LINE TERMINATED BY ALTMODE
	CAL	(10)	/YES
	CAL	REQMCR
	CAL	(10)
REQMCR	1
	0
	.SIXBT	/...MCR/
	0
GETCX	0
	LAC	GETCX
	DAC	GETC
	JMS*	FAC57
	JMP	GETC+3	/GET CHAR FROM JOBLINE BUFFER, NOT MCR!!
GETC	0
	JMS*	(174)	/FAC SUBROUTINE IN EXEC
	DAC	MCRLST
	SAD	(15)
	JMP*	GETC
	SAD	(175)
	JMP*	GETC
	ISZ	GETC
	JMP*	GETC
MCRLST	0
LINBF	.BLOCK	60
	.ENDC
	.END	START
