Google
 

Trailing-Edge - PDP-10 Archives - BB-H137A-BM - uetp/lib/uetp.mac
There is 1 other file named uetp.mac in the archive. Click here to see a list.
;<UETP.LIB>UETP.MAC.51, 12-Jun-78 09:52:40, Edit by ENGEL
;GET RID OF VERSION NUMBER PRINTING
;<UETP.LIB>UETP.MAC.30, 25-Apr-78 09:24:15, Edit by ENGEL
;update help text
TITLE UETP



;COPYRIGHT (C) 1977 BY
;DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
;
;
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
;ONLY  IN  ACCORDANCE  WITH  THE  TERMS  OF  SUCH LICENSE AND WITH THE
;INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR ANY  OTHER
;COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
;OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF THE  SOFTWARE  IS  HEREBY
;TRANSFERRED.
;
;
;THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT  NOTICE
;AND  SHOULD  NOT  BE  CONSTRUED  AS A COMMITMENT BY DIGITAL EQUIPMENT
;CORPORATION.
;
;DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY  OF  ITS
;SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.
	SEARCH MONSYM, MACSYM
	.REQUIRE SYS:MACREL
	SALL

; ACCUMULATOR DEFINITIONS

	T1=1		;TEMPORARY
	T2=2		;TEMPORARY
	T3=3		;TEMPORARY
	T4=4		;TEMPORARY
	Q1=5		;PRESERVED
	Q2=6		;PRESERVED
	Q3=7		;PRESERVED
	P1=10		;PRESERVED
	P2=11		;PRESERVED
	P3=12		;PRESERVED
	P4=13		;PRESERVED
	P5=14		;PRESERVED
	P6=15		;PRESERVED (CAUTION, USED BY SOME MACROS IN MACSYM)
	CX=16		;RESERVED FOR SUPPORT CODE
	P=17		;PUSH-DOWN POINTER

; VERSION NUMBER DEFINITIONS

VMAJOR==1		;MAJOR VERSION OF UETP
VMINOR==0		;MINOR VERSION NUMBER
VEDIT==16		;EDIT NUMBER
VWHO==0			;GROUP WHO LAST EDITED PROGRAM (0=DEC DEVELOPMENT)

VUETP== <VWHO>B2+<VMAJOR>B11+<VMINOR>B17+VEDIT

NCHPW==5		;NUMBER OF ASCII CHARACTERS PER WORD
BUFSIZ==1000		;SIZE OF INPUT TEXT BUFFER
ATMSIZ==BUFSIZ		;SIZE OF ATOM BUFFER FOR COMND JSYS
GJFSIZ==.GJRTY+2	;SIZE OF GTJFN BLOCK USED BY COMND JSYS
FDBSIZ==.CMDEF+2	;SIZE OF FUNCTION DESCRIPTOR BLOCK
NAMSIZ==200		;ALLOW UP TO 200 (OCTAL) TESTS
WRKSIZ==200		;SIZE OF GENERAL PURPOSE BUFFER
PDLEN==150		;PUSH-DOWN STACK LENGTH
CORSIZ==200000		;SIZE IN WORDS OF CORE TABLE
		SUBTTL		FLAG AND SYMBOL DEFENITIONS

DELETE=1		;DELETE AN ENABLED TEST FROM TABLE (SCHED)
CREATE=2		;ADD AN ENTRY TO THE TABLE (SCHED)
MODIFY=3		;CHANGE A VALUE OF AN ENTRY IN A TABLE (SCHED)
STARTM=4		;START (SUBMIT) ALL ENABLED JOBS
READ=5			;READ AN ENTRY OFF ENABLED TABLE (SCHED)
STRMSG=6		;START MESSAGE FOR ENABLED TEST RCV'D (SCHED)
ENDMSG=7		;END   MESSAGE FOR ENABLED TEST RCV'D (SCHED)
ERRMSG=10		;ERROR MESSAGE FOR ENABLED TEST RCV'D (SCHED)
ABORT=11		;ABORT THE SPECIFIED JOB

;  LOCAL FLAGS

SC%EOT=400000			;FLAG FROM SCHED - END OF ENABLED TABLE REACHED
NT%QUE=200000,,0		;SCHED FLAG - TEST IS QUEUED IN GALAXY
NT%RUN=100000,,0		;SCHED FLAG - TEST RUNNING
NT%END=40000,,0		;SCHED FLAG - TEST ENDED
NT%ABR=20000,,0		;SCHED FLAG - TEST WAS ABORTED
NT%ENA=10000,,0		;SCHED FLAG - TEST ENABLED
NT%ERR=4000,,0		;SCHED FLAG - ERRORS IN THIS RUN OF TEST
NT%SUP=400000		;FLAG INDICATING A SUPERFICIAL DEPTH
NT%INT=200000		;FLAG INDICATING AN INTERMEDIATE DEPTH
NT%MAX=100000		;FLAG INDICATING AN INTERMEDIATE DEPTH
NT%CON=40000		;FLAG TO SHOW /CYCLE IS CONTINUOUS
NT%NUM=20000		;FLAG TO SHOW /CYCLE IS A REPETITION COUNT
NT%TYM=10000		;FLAG TO SHOW /CYCLE IS TIME VALUE
PR%ALL=400000		;PARSE SWITCH INDICATING USER TYPED "ALL"
PR%ONE=200000		;PARSE SWITCH INDICATING USER WANTED 1 OPTION
				SUBTTL  LOCAL MACRO'S

;   TXT MACRO - TAKES ARGUMENT AND CREATES A POINTER TO IT AS AN ASCIZ STRING
;
DEFINE TXT(TEXT) <POINT 7,[ASCIZ\TEXT\]>
;
; RITMSG - MACRO TO CALL SNDMSG, WHICH PRINTS OUT THE MSG ON TTY AND/OR TAKE
;		LOG FILE.
;
	DEFINE	RITMSG(STR)<
	HRROI	T1,[ASCIZ\STR\]		;POINT TO STRING
	CALL	SNDMSG			;GO TYPE THE MSG
>
;
; ERRSND - MACRO TO CALL SNDERR, WHICH PRINTS THE ERROR MSG ON TTY AND/OR TAKE
;		LOG FILE.
;
	DEFINE	ERRSND(MSG)<
	HRROI	T1,[ASCIZ\MSG\]		;POINT TO STRING
	CALL	SNDERR			;GO TYPE THE MSG
>
; THIS MACRO IS USED TO CREATE TBLUK JSYS TYPE ENTRIES
DEFINE TB(RTN,TXT)
<	[ASCIZ/TXT/] ,, RTN
>
; THIS MACRO SAVES THE ACS 1-4 IN STACK FROM P
;
	DEFINE	SAVE<
	PUSH	P,T1
	PUSH	P,T2
	PUSH	P,T3
	PUSH	P,T4>
;
; THIS MACRO RESTORES TOP FOUR ITEMS ON P STACK
;
	DEFINE	RESTOR<
	POP	P,T4
	POP	P,T3
	POP	P,T2
	POP	P,T1>
;THE W,X,Y,Z ARE CALCULATED BY THE MACRO LIKE THIS:

;W - THE NUMBERICAL VALUE OF VMAJOR
;
;X - THE LETTER CORRESPONDING TO THE VALUE OF VMINOR.  @=0, A=1...
;
;Y - THE NUMERICAL VALUE OF VEDIT
;
;Z - THE NUMERICAL VALUE OF VWHO

	DEFINE	.CLNAM<
	  DEFINE  .CLNM(LETTER,WHO)<
	    IRPC LETTER,<
	      IFE "A"-"'LETTER'"+VMINOR-1,<
		STOPI
		IFIDN <LETTER><@>,<
		  IFE VWHO,< .NAME(\VMAJOR,,\VEDIT,)>
		  IFN VWHO,< .NAME(\VMAJOR,,\VEDIT,-WHO)>>
		IFDIF <LETTER><@>,<
		  IFE VWHO,< .NAME(\VMAJOR,LETTER,\VEDIT,)>
		  IFN VWHO,< .NAME(\VMAJOR,LETTER,\VEDIT,-WHO)>>>>>
	IFGE VMINOR-^D26,< VMINOR==0
	  PRINTX %MINOR VERSION TOO LARGE - IGNORED>
	IFGE VWHO-7,< VMINOR== 
	  PRINTX %VWHO IS TOO LARGE - IGNORED>
	.CLNM(@ABCDEFGHIJKLMNOPQRSTUVWXYZ,\VWHO)
>

;DEFINE A .NAME MACRO TO GEN THE TEXT STRING

	DEFINE	.NAME(V,M,E,W)<
ASCIZ /V'M'('E')'W/>

VTXT:	.CLNAM			;GENERATE VERSION STRING
SUBTTL	MAIN ENTRY POINT AND INITIALIZATION

START:	RESET			;RESET THE UNIVERSE
	MOVE P,[IOWD PDLEN,PDL]	;SET UP STACK
	SETZM TAKFLG		;MARK THAT TAKE FILE NOT BEING PROCESSED
	MOVE	T1,[POINT 7,WRKBUF]	;POINT TO WHERE DATE AND TIME WILL GO
	MOVEI	T3,"["			;BRACKET THE TIME AND DATE
	IDPB	T3,T1
	MOVX	T3,OT%SCL		;AVOID LEADING SPACES
	HRROI	T2,-1			;CURRENT DATE AND TIME
	ODTIM
	SETZ	T3,
	HRROI	T2,[ASCIZ/      User Environment Test Package /]
	SOUT
;	HRROI	T2,VTXT		;NOW PUT VERSION NUMBER IN
;	SOUT
	HRROI	T2,[ASCIZ/]


/]
	SOUT
	HRROI	T1,WRKBUF	;POINT TO HEADER
	CALL	SNDMSG		;WRITE IT OUT
; ACTIVATE THE CHANNELS
	MOVEI	T1,.FHSLF	;ACTIVATE OUR CHANNELS
	MOVE	T2,[LEVTAB,,CHNTAB]	;CHANNEL TABLES
	SIR			;TELL SYSTEM ABOUT THEM
	EIR			;ENABLE THE CHANNEL SYSTEM
	CALL	ENAALL		;GO ENABLE ALL
	CALL	STSWCH		;START IPCF HANDLER FORK
	HALTF
	CALL	STPTYI		;GO START PTY I/O HANDLER
	JRST	 [HALTF
		 JRST	START]
	CALL	TSTBLD			;GO BUILD TABLE OF POSSIBLE TESTS
	JRST	[RITMSG<
?ERROR INITIALIZING THE TESTS
>
		HALTF]			;AND STOP
	CALL	ENWAKE			;TURN ON CTL/C TRAPPING
	JFCL
	CALL	ABRTIM			;GO START ABORT TIMER
	;..
SUBTTL	COMMAND PARSER AND DISPATCH

	;..

	HRROI T1,PROMPT		;GET POINTER TO PROMPT STRING
	MOVEM T1,CMDBLK+.CMRTY	;PUT RE-TYPE PROMPT POINTER IN STATE BLOCK
	HRROI T1,BUFFER		;GET POINTER TO INPUT TEXT BUFFER
	MOVEM T1,CMDBLK+.CMPTR	;SAVE POINTER TO COMMAND STRING
	MOVEM T1,CMDBLK+.CMBFP	;SAVE POINTER TO START-OF-BUFFER
	MOVE T1,[.PRIIN,,.PRIOU] ;GET PRIMARY INPUT,, OUTPUT JFN'S
	MOVEM T1,CMDBLK+.CMIOJ	;SAVE PRIMARY JFN'S
	MOVEI T1,PARSE1		;GET RE-PARSE ADDRESS
	MOVEM T1,CMDBLK+.CMFLG	;SAVE RE-PARSE ADDRESS
	SETZM CMDBLK+.CMINC	;INITIALIZE # OF CHARACTERS AFTER POINTER
	MOVEI T1,BUFSIZ*NCHPW	;GET # OF CHARACTERS IN BUFFER AREA
	MOVEM T1,CMDBLK+.CMCNT	;SAVE INITIAL # OF FREE CHARACTER POSITIONS
	HRROI T1,ATMBFR		;GET POINTER TO ATOM BUFFER
	MOVEM T1,CMDBLK+.CMABP	;SAVE POINTER TO LAST ATOM INPUT
	MOVEI T1,ATMSIZ*NCHPW	;GET # OF CHARACTERS IN ATOM BUFFER
	MOVEM T1,CMDBLK+.CMABC	;SAVE COUNT OF SPACE LEFT IN ATOM BUFFER
PARSE:	SKIPE	TAKFLG		;COMMANDS COMING FROM FILE?
	JRST	[HRRZ	T1,OUTJFN	;FIND OUT IF IT'S  DISK (THEN NO OUTPUT)
		 DVCHR
		 LDB	T2,[POINTR (2,DV%TYP)]	;ISOLATE DEVICE TYPE BITS
		 CAIN	T2,.DVTTY		;SKIP IF NOT TTY - I.E. DUPLICATE MSG
		 JRST	.+1			;NO NEED TO DUPLICATE
		 CALL	TSTCOL			;NOT EOF - SEE IF CR/LF NEEDED
		 HRROI	T1,PROMPT		;PUT PROMPT TO TERMINAL
		 PSOUT
		 JRST	.+1]			;RETURN TO MAIN LINE CODE
	HRROI T1,PROMPT		;GET POINTER TO PROGRAM'S PROMPT STRING
	CALL CMDINI		;OUTPUT THE PROMPT

PARSE1:	MOVE P,[IOWD PDLEN,PDL]	;SET UP STACK AGAIN
	MOVE	T1,[CZ%NIF+CZ%NSF+CZ%NCL+.FHSLF]	;CLEAR THIS
	CLZFF			; PPOCESSES EXTRA JFN'S
	ERJMP	.+1		;IGNORE CLZFF FAILERES
	CALL CLRGJF		;GO CLEAR GTJFN BLOCK

	MOVEI T1,GJFBLK		;GET ADDRESS OF GTJFN BLOCK
	MOVEM T1,CMDBLK+.CMGJB	;STORE POINTER TO GTJFN BLOCK
	MOVEI T1,CMDBLK		;GET POINTER TO COMMAND STATE BLOCK
	MOVEI T2,[FLDDB. (.CMKEY,,CMDTAB)] ;GET FUNCTION BLOCK
	COMND			;DO INITIAL PARSE
	 ERJMP [HRROI	T1,[ASCIZ/COMND JSYS ERRORS AT PARSE1:/]
		 JRST	CMDERR]		;error, go check for eof on take file
	TXNN T1,CM%NOP		;VALID COMMAND ENTERED ?
	JRST PARSE5		;YES, GO DISPATCH TO PROCESSING ROUTINE
	HRROI	T1,BUFFER	;GET READY TO PRINT COMMAND IF TAKING
	SKIPE	TAKFLG		;SKIP IF NOT TAKING
	CALL	SNDMSG		;TAKING - TYPE OUT COMMAND
	CALL TSTCOL		;TEST COLUMN POSITION, NEW LINE IF NEEDED
	RITMSG <? UETP: No such UETP command as ">
	MOVE T1,CMDBLK+.CMABP	;GET POINTER TO ATOM BUFFER
	CALL	SNDMSG		;OUTPUT STRING ENTERED BY USER
	RITMSG <"
>				;OUTPUT END-OF-MESSAGE
	JRST PARSE		;GO TRY TO GET A COMMAND AGAIN

PARSE5:	HRRZ T1,(T2)		;GET DISPATCH ADDRESS
	CALL (T1)		;PERFORM REQUESTED FUNCTION
	JRST PARSE		;GO PARSE NEXT COMMAND
			SUBTTL  ABORT (TEST) NAME/ALL /DEPTH:SUP/INT/MAX

.ABORT:	STKVAR	<ABRHLD>		;WHERE TO SAVE NAME OF TEST
	HRROI	T2,[ASCIZ/TEST/]	;TEST NAME
	CALL	SKPNOI			;PARSE THE NOISE
	RET
	CALL	ENABLD			;GO BUILD KEYWORD TABLE OF ENABLED TESTS
	MOVEI	T1,ENATBL		;TELL PARSKY WHERE KEYWORDS ARE
	CALL	PARSKY			;GO PARSE KEYWORDS
	RET				;ERROR RETURN - RETURN
	MOVE	P3,T2			;MOVE THE "ALL" OR KEYWORD INDICATOR
	MOVEM	T1,ABRHLD		;SAVE THE POINTER TO THE NAME
	MOVEI	T1,SWDEP		;PARSE /DEPTH ONLY
	CALL	PARSSW			;GET THE DEPTH TO ABORT
	RET
	HRRZ	T3,(T1)			;ADDRESS OF /CYCLE: VALUE
	HRRZ	T4,(T2)			;WHERE /DEPTH: VALUE IS STORED
	MOVE	T4,(T4)			;DEPTH VALUE
	MOVE	T2,ABRHLD		;NOW TO ABORT THE JOB
	MOVEI	P4,ENATBL		;POINT TO TABLE OF NAMES
	HLRZ	P5,(P4)			;LENGTH OF TABLE
	DMOVE	Q1,T1			;SAVE THE FIRST FOUR AC'S
	DMOVE	Q3,T3
	TXNE	P3,PR%ALL		;ARE WE DOING THIS FOR ALL THE TESTS
	SETOM	PRTOFF			;TURN OFF PRINTIN WHILE IN ABORT ALL
	TXNE	P3,PR%ALL		;ARE WE DOING THIS FOR ALL THE TESTS
	SETOM	ABRALL			;FLAG - WE LOOP THROUGH ALL TWICE (RACE
					; CONDITIONS.
	TXNE	P3,PR%ALL		;ARE WE DOING THIS FOR ALL THE TESTS
ABRNAM:	JRST	[CALL	ALLNMS		;YES - GO GET A NAME
		 JRST	[SKIPN	ABRALL	;SKIP IF FIRST TIME THRU
			 JRST	ABRRET	;NO MORE NAMES
			 SETZM	ABRALL	;CLEAR LOOP FLAG
			 MOVEI	T2,ENATBL	;START FROM SCRATCH
			 HLRZ	P5,0(P4)
			 JRST	ABRNAM]
		 MOVEM	Q1,T1		;RESTORE THE FIRST AC
		 DMOVEM	Q3,T3
		 JRST	.+1]		;GO DO THE SCHED ACTION
	TXNN	P3,PR%ALL		;SKIP IF  DOING AN ALL KEYWORD
	JRST	ABRGO			;GO DO THE DISABLE
	DMOVE	T3,Q3			;GET SWITCH VALUES
	MOVEI	T1,READ			;GO GET HIS TCB
	CALL	SCHED
	RET
	MOVE	T1,TCBSTA(T2)		;GET THE STATUS BITS
	DMOVE	T3,Q3			;GET SWITCH VALUES
	TXNE	T1,NT%END		;DON'T GET RID OF THESE
	JRST	ABRNAM			;DON'T DO THE DISABLE
ABRGO:	MOVEI	T1,ABORT		;FUNCTION CODE FOR SCHED
	CALL	SCHED			;GO ADD ENTRY TO TABLE
	JRST	ABRRET			;GO RETURN
	DMOVE	T1,Q1			;GET THE FIRST FOUR AC'S
	DMOVE	T3,Q3
	TXNE	P3,PR%ALL		;DID USER WANT 'ALL' EVENTS?
	JRST	ABRNAM			;YES
ABRRET:	CALL	TSTCOL			;PUT OUT CR/LF IF NEEDED
	SETZM	PRTOFF			;ALLOW PRINTING
	HRROI	T1,[ASCIZ/ABORT COMPLETED/]
	CALL	CONMSG			;GO SEND CONFIRMATION
	RET	
			SUBTTL BEGIN (UETP RUN AFTER) <HH:MM>
.BEGIN:	HRROI	T2,[ASCIZ/UETP RUN AFTER/]
	CALL	SKPNOI			;PARSE THE NOISE
	RET
	CALL	PARSTM			;GO PARSE TIME
	RET
	EXCH	T2,T1			;MOVE TIME TO PARAM REG
	JUMPN	T1,BEGTYP		;JUMP IF WE DIDN'T GET A TIME VALUE
	CALL	ENDCOM			;GO GET CONFIRMATION
	RET
BEGTYP:	MOVEI	T1,STARTM		;FUNCTION CODE TO START JOBS
	SETZM	BEGFLG			;ZERO JOBS STARTED FLAG
	CALL	SCHED			;GO START THE JOBS
	RET				;ERROR RETURN
	CALL	TSTCOL			;PUT OUT CR/LF IF NEEDED
	SKIPN	BEGFLG			;SKIP IF JOBS STARTED
	JRST	NOSTR			;NO JOBS STARTED
	HRROI	T1,[ASCIZ/BEGIN COMPLETED/]
	CALL	CONMSG			;GO SEND CONFIRMATION
	RET
NOSTR:	RITMSG <
%NO JOBS STARTED.
>
	RET
		SUBTTL		DEFAULTS - SET SWITCH DEFAULTS
.DEFAU:	HRROI	T2,[ASCIZ/VALUES FOR SWITCHES/]	;NOISE FIELD
	CALL	SKPNOI			;PARSE IT
	RET
	MOVEI	Q2,DEFCYC		;POINT TO DEFAULT CYCLE VALUE
	MOVEI	Q3,DEFDEP		;POINT TO DEFAULT DEPTH VALUE
	SETOM	CURENT			;TURN ON ALL BITS IN CURRENT JOB PTR
	MOVEI	T1,SWBOTH		;PARSE /CYCLE AND /DEPTH 
	CALL	PARSSW			;GO PARSE SWITCHES (/CYCLE,/DEPTH)
	RET				;ERROR - RETURN
	MOVE	T3,DEFCYC		;POINT TO DEFAULT VALUE POINTER
	EXCH	T3,(T1)			;EXCHANGE WITH NEW ONE (OR ITSELF)
	EXCH	T3,DEFCYC		;EXCHANGE AGAIN - FOR  NEW DEFAULT
	MOVE	T3,DEFDEP		;NOW DO THE SAME FOR DEPTH VALUE
	EXCH	T3,(T2)			;Q2&Q3 POINT TO DEFCYC,DEFDEP,TDEFCY, OR
	EXCH	T3,DEFDEP		; TDEFDP. THEREBY SWITCHING WITH BACK UP 
	RET
			SUBTTL  DISABLE (TEST) NAME /DEPTH:
.DISAB:	STKVAR	<SAVNAM>
	HRROI	T2,[ASCIZ/TEST/]	;NOISE FIELD
	CALL	SKPNOI			;PARSE IT
	RET
	CALL	ENABLD			;GO BUILD TABLE OF ENABLED TESTS
	MOVEI	T1,ENATBL		;TELL PARSKY WHERE KEYWORDS ARE
	CALL	PARSKY			;GO PARSE THE TEST TYPE
	RET
	MOVE	P3,T2			;MOVE THE "ALL" OR KEYWORD INDICATOR
	MOVEM	T1,SAVNAM		;SAVE THEN NAME
	MOVEI	T1,SWDEP		;PARSE /DEPTH ONLY
	CALL	PARSSW			;GO PARSE SWITCHES (,/DEPTH)
	RET				;ERROR - RETURN
	HRRZ	T3,(T1)			;ADDRESS OF /CYCLE: VALUE
	HRRZ	T4,(T2)			;WHERE /DEPTH: VALUE IS STORED
	MOVE	T4,(T4)			;DEPTH VALUE
	MOVE	T2,SAVNAM		;GET NAME OF TEST
	MOVEI	P4,ENATBL		;POINT TO TABLE OF NAMES
	HLRZ	P5,(P4)			;LENGTH OF TABLE
	DMOVE	Q1,T1			;SAVE THE FIRST FOUR AC'S
	DMOVE	Q3,T3
	TXNE	P3,PR%ALL		;ARE WE DOING THIS FOR ALL THE TESTS
DISNAM:	JRST	[CALL	ALLNMS		;YES - GO GET A NAME
		 JRST	DISRET		;NO MORE NAMES
		 MOVEM	Q1,T1		;RESTORE THE FIRST AC
		 DMOVEM	Q3,T3
		 JRST	.+1]		;GO DO THE SCHED ACTION
	TXNN	P3,PR%ALL		;SKIP IF  DOING AN ALL KEYWORD
	JRST	DISGO			;GO DO THE DISABLE
	DMOVE	T3,Q3			;GET SWITCH VALUES
	MOVEI	T1,READ			;GO GET HIS TCB
	CALL	SCHED
	RET
	MOVE	T1,TCBSTA(T2)		;GET THE STATUS BITS
	DMOVE	T3,Q3			;GET SWITCH VALUES
	TXNN	T1,NT%END+NT%ABR+NT%ENA	;GET RID OF THESE
	JRST	DISNAM			;DON'T DO THE DISABLE
DISGO:	MOVEI	T1,DELETE		;TELL SCHED IT'S A DELETE
	CALL	SCHED			;GO DELETE ENTRY TO TABLE
	RET
	DMOVE	T1,Q1			;GET THE FIRST FOUR AC'S
	DMOVE	T3,Q3
	TXNE	P3,PR%ALL		;DID USER WANT 'ALL' EVENTS?
	JRST	DISNAM			;YES
DISRET:	CALL	TSTCOL			;PUT OUT CR/LF IF NEEDED
	HRROI	T1,[ASCIZ/DISABLE COMPLETED/]
	CALL	CONMSG			;GO SEND CONFIRMATION
	RET	
			SUBTTL  ENABLE (TEST) NAME /CYCLE:/DEPTH:
.ENABL:	STKVAR	<HLDNAM>
	HRROI	T2,[ASCIZ/TEST/]	;NOISE FIELD
	CALL	SKPNOI			;PARSE IT
	RET
	MOVEI	T1,TSTTBL		;TELL PARSKY WHERE KEYWORDS ARE
	CALL	PARSKY			;GO PARSE THE TEST TYPE
	RET				;ERROR - RETURN
	MOVE	P3,T2			;MOVE THE "ALL" OR KEYWORD INDICATOR
	MOVEM	T1,HLDNAM		;SAVE THEN NAME
	MOVEI	T1,SWBOTH		;PARSE /CYCLE AND /DEPTH 
	CALL	PARSSW			;GO PARSE SWITCHES (/CYCLE,/DEPTH)
	RET				;ERROR - RETURN
	HRRZ	T3,(T1)			;ADDRESS OF /CYCLE: VALUE
	HRRZ	T4,(T2)			;WHERE /DEPTH: VALUE IS STORED
	MOVE	T4,(T4)			;DEPTH VALUE
	MOVE	T2,HLDNAM		;GET NAME OF TEST
	MOVEI	T1,CREATE		;TELL SCHED IT'S A CREATE
	MOVEI	P4,TSTTBL		;POINT TO TABLE OF NAMES
	HLRZ	P5,(P4)			;LENGTH OF TABLE
	DMOVE	Q1,T1			;SAVE THE FIRST FOUR AC'S
	DMOVE	Q3,T3
	TXNE	P3,PR%ALL		;ARE WE DOING THIS FOR ALL THE TESTS
MORNAM:	JRST	[CALL	ALLNMS		;YES - GO GET A NAME
		 JRST	ENARET		;NO MORE NAMES
		 MOVEM	Q1,T1		;RESTORE FIRST  AC
		 DMOVE	Q3,T3		;RESTORE T3 AND T4
		 JRST	.+1]		;GO DO THE SCHED ACTION
	CALL	SCHED			;GO ADD ENTRY TO TABLE
	JRST	[TXNN	P3,PR%ALL	;ARE WE DOING THIS FOR ALL THE TESTS
		 RET			;RETURN ON ERRORS IF ONLY NOT 'ALL'
		 JRST	.+1]		;GO DO THE SCHED ACTION
	DMOVE	T1,Q1			;GET THE FIRST FOUR AC'S
	DMOVE	T3,Q3
	TXNE	P3,PR%ALL		;DID USER WANT 'ALL' EVENTS?
	JRST	MORNAM			;YES
ENARET:	CALL	TSTCOL			;PUT OUT CR/LF IF NEEDED
	HRROI	T1,[ASCIZ/ENABLE COMPLETED/]
	CALL	CONMSG			;GO SEND CONFIRMATION
	RET	
			SUBTTL  EXIT (TO MONITOR)

.EXIT:	HRROI T2,[ASCIZ/TO MONITOR/] ;GET NOISE PHRASE
	CALL SKPNOI		;GO PARSE NOISE FIELD
	 RET			;FAILED, RETURN FAILURE
	CALL ENDCOM		;GO PARSE END OF COMMAND
	 RET			;BAD CONFIRMATION, RETURN

;FIRST SEE IF ANYTHING IS RUNNING
	HRROI	T2,-1			;TELL SCHED WE WANT HIS FIRST NAME
EXTLOP:	MOVEI	T1,READ			;WE WANT TO READ THE TABLE
	CALL	SCHED			;GO GET NEXT ENABLED NAME
	JRST	DOEXIT			;GO TAKE ERROR EXIT
	TXNE	T3,SC%EOT		;ARE WE AT END OF TABLE
	JRST	DOEXIT			;GO TAKE NORMAL EXIT
	MOVE	T2,T1			;PLACE IN BASE FOR FUTURE USE
	MOVE	T3,TCBSTA(T2)		;GET THE STATUS VECTOR
	TXNN	T3,NT%RUN+NT%QUE	;IS THIS TEST ACTIVE
	JRST	EXTLOP			;NO - THEN KEEP LOOKING
	RITMSG <
%YOU STILL HAVE TESTS RUNNING. "ABORT ALL" BEFORE EXITING.
>
	RET				;GO PARSE COMMANDS
DOEXIT:	CALL	EXIT		;GO EXIT
	HALTF
	JRST	START
SUBTTL	HELP  COMMANDS

; HELP COMMAND

.HELP:	HRROI T2,[ASCIZ/WITH UETP/] ;GET NOISE WORDS
	CALL SKPNOI		;GO PARSE NOISE FIELD
	 RET			;FAILED, RETURN FAILURE
	CALL ENDCOM		;GO PARSE END OF COMMAND
	 RET			;BAD CONFIRMATION, RETURN
	HRROI T1,HLPMSG		;GET POINTER TO HELP MESSAGE
	CALL	SNDMSG		;OUTPUT HELP MESSAGE
	RET			;GO PARSE NEXT COMMAND
			SUBTTL  MODIFY (TEST) NAME /DEPTH: (TO) /DEPTH;/CYCLE:
.MODIF:	STKVAR <MODSAV>
	HRROI	T2,[ASCIZ/TEST/]	;NOISE FIELD
	CALL	SKPNOI			;PARSE IT
	RET
	CALL	ENABLD			;GO BUILD TABLE OF POSSIBLE TESTS
	MOVEI	T1,ENATBL		;TELL PARSKY WHERE KEYWORDS ARE
	CALL	PARSKY			;GO PARSE THE TEST TYPE
	RET
	MOVE	P3,T2			;MOVE THE "ALL" OR KEYWORD INDICATOR
	MOVEM	T1,MODSAV		;SAVE THEN NAME
	HRROI	T1,SWDEP		;GO GET DEPTH TO CHANGE
	CALL	PARSSW			;PARSE THE /DEPTH SWITCH
	RET
	HRRZ	P2,(T2)			;WHERE /DEPTH: VALUE IS STORED
	MOVE	P2,(P2)			;DEPTH VALUE
	HRROI	T2,[ASCIZ/TO/]		;NOISE FIELD
	CALL	SKPNOI
	RET
	MOVEI	Q1,DEFCYC		;NEED TO KNOW WHAT VALUES WERE ENTERED
	MOVEI	Q2,DEFDEP		;WHERE /DEPTH: VALUE IS STORED
	MOVEI	T1,SWBOTH		;PARSE /DEPTH OR /CYCLE
	CALL	PARSSW			;GO PARSE SWITCHES (/CYCLE,/DEPTH)
	RET				;ERROR - RETURN
	HRRZ	T3,(T1)			;GET NEW /CYCLE VALUE
	CAMN	T1,Q1			;SKIP IF NEW VALUE ENTERED
	SETZM	T3			;NO NEW VALUE - DON'T CHANGE CYCLE
	MOVE	Q1,T3			;SET THE SWITCH VALUE
	HRRZ	T3,(T2)			;WHERE /DEPTH: VALUE IS STORED
	MOVE	T3,(T3)			;GET THE DEPTH VALUE
	CAMN	T2,Q2			;SKIP IF NEW VALUE ENTERED
	SETZM	T3			;NO NEW VALUE - DON'T CHANGE DEPTH
	MOVE	Q2,T3			;SET THE SWITCH VALUE
	MOVEI	P4,ENATBL		;POINT TO TABLE OF NAMES
	HLRZ	P5,(P4)			;LENGTH OF TABLE
	; ...
	;...
MODLOP:	TXNE	P3,PR%ALL		;ARE WE MODIFYING ALL TESTS
	JRST	[MOVE	T4,P2		;GET THE DEPTH VALUE
		 CALL	ALLNMS		;GO GET NEXT NAME
		 JRST	MODRET		;ALL DONE - RETURN
		 MOVEM	T2,MODSAV	;SET-UP THE NEW NAME
		 JUMPE	Q2,.+1		;JUMP IF DEPTH NOT CHANGING
		 TLNN	T2,(Q2)		;IS NEW DEPTH LEGAL?
		 JRST	MODLOP		;NO - KEEP LOOKING
		 JRST	.+1]
	DMOVE	T3,Q1			;GET SWITCH VALUES
	MOVE	T2,MODSAV		;GO SEE IF DEPTH IS ENABLED
	MOVEI	T1,READ			;GO GET HIS TCB
	CALL	SCHED
	RET
	TDNE	P2,TCBSTA(T2)		;SEE IF HE IS ENABLED FOR GIVEN DEPTH
	JRST	GOMOD			;YES - THEN GO MODIFY HIM
	TXNE	P3,PR%ALL		;SKIP IF NOT DOING AN ALL KEYWORD
	JRST	MODLOP			;KEEP MODIFYING ALL THE ENTRIES
	RITMSG <
?TEST NOT ENABLED FOR SPECIFIED DEPTH.
>
	RET
GOMOD:	DMOVE	T3,Q1			;MOVE PARMS INTO PARM REGS
	MOVE	T2,MODSAV		;GET NAME OF TEST
	MOVEI	T1,MODIFY		;TELL SCHED IT'S A MODIFY
	CALL	SCHED			;GO ADD ENTRY TO TABLE
	RET				;ERROR RETURN
MODCON:	TXNE	P3,PR%ALL		;SKIP IF NOT DOING AN ALL KEYWORD
	JRST	MODLOP			;KEEP MODIFYING ALL THE ENTRIES
MODRET:	CALL	TSTCOL			;PUT OUT CR/LF IF NEEDED
	HRROI	T1,[ASCIZ/MODIFY COMPLETED/]
	CALL	CONMSG			;GO SEND CONFIRMATION
	RET
;ROUTINE TO PUSH DOWN TO A LOWER EXEC

.PUSH:	HRROI	T2,[ASCIZ/TO EXEC LEVEL/]
	CALL	SKPNOI		;PARSE THE NOISE FIELD
	 RET
	CALL	ENDCOM		;GO PARSE CONFIRMATION
	 RET
	MOVSI	T1,(1B2!1B17)	;GET A JFN FOR THE EXEC
	HRROI	T2,[ASCIZ/SYSTEM:EXEC.EXE/]
	GTJFN
	  JRST	NOEXEC		;NO EXEC FOUND
	PUSH	P,T1
	MOVSI	T1,(1B1)	;CREATE A LOWER FORK FOR EXEC
	CFORK
	  JRST	NOFORK
	HRLZS	T1
	HRR	T1,0(P)
	GET			;NOW GET THE EXEC INTO THE LOWER FORK
	HLRZS	T1
	PUSH	P,T1		;SAVE LOWER FORK NUMBER
	MOVEI	T1,.FHSLF	;DONT ALLOW LOWER FORK TO LOG OUT
	RPCAP
	TXZ	T2,SC%LOG
	SETZ	T3,		;NO PRIVS ENABLED
	MOVE	T1,0(P)		;GET LOWER FORK HANDLE
	EPCAP			;SET ITS CAPABILITIES
	SETO	T1,		;REMEMBER OUR NAME TO RESTORE IT LATER
	MOVE	T2,[-2,,NAMES]	;GET BOTH NAMES	
	MOVEI	T3,.JISNM
	GETJI
	  JFCL
	MOVEI	T1,.FHSLF	;TURN OFF PANIC CHANNEL
	MOVX	T2,1B<ICHIFT-ICH000>
	DIC
	POP	P,T1		;GET BACK FORK NUMBER
	SETZ	T2,
	SETOM	PUSHF		;MARK THAT WE ARE PUSHED DOWN
	SETOM	PRTOFF		;NO PRINTING WHILE IN EXEC
	SFRKV			;START THE EXEC
	WFORK			;AND WAIT FOR IT TO HALT
	SETZM	PRTOFF		;CONTINUE PRINTING
	SETZM	PUSHF		;OUT OF EXEC
	KFORK			;KILL THE LOWER FORK
	MOVEI	T1,.FHSLF	;TURN OFF PANIC CHANNEL
	MOVX	T2,1B<ICHIFT-ICH000>
	AIC
PUSHE1:	DMOVE	T1,NAMES
	SETSN			;RESTORE NAME OF PROGRAM
	  JFCL
	POP	P,T1			;GET BACK JFN OF EXEC
	RLJFN			;RELEASE JFN
	  JFCL
	RET
NOEXEC:	RITMSG <
?NO EXEC - CAN'T DO A PUSH FOR YOU.
>
	RET

NOFORK:	RITMSG<
?NO LOWER FORKS AVAILABLE.
>
	RET
			SUBTTL  STATUS (INFORMATION)

.STATU:	HRROI	T2,[ASCIZ/INFORMATION/]
	CALL	SKPNOI			;GO PARSE NOISE
	RET				;ERROR - RETURN
	CALL	ENDCOM			;PARSE CR/LF
	RET				;ERROR - RETURN 
	CALL	STATUS			;GO DO STATUS STUFF
	RET
	RET
SUBTTL	TAKE (COMMANDS FROM) FILE-SPEC (LOGGING OUTPUT ON) FILE-SPEC

.TAKE:	HRROI T2,[ASCIZ/COMMANDS FROM/] ;GET NOISE TEXT
	CALL SKPNOI		;GO PARSE NOISE FIELD
	 RET			;FAILED, RETURN FAILURE
	CALL CLRGJF		;GO CLEAR GTJFN BLOCK
	MOVX T1,GJ%OLD		;GET EXISTING FILE FLAG
	MOVEM T1,GJFBLK+.GJGEN	;STORE GTJFN FLAGS
	HRROI T1,[ASCIZ/CMD/]	;GET DEFAULT FILE TYPE FIELD
	MOVEM T1,GJFBLK+.GJEXT	;STORE DEFAULT EXTENSION
	MOVEI T1,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI T2,[FLDDB. (.CMFIL)] ;GET FUNCTION DESCRIPTOR BLOCK ADDRESS
	COMND			;PARSE INPUT FILE SPEC
	 ERJMP [HRROI	T1,[ASCIZ/COMND JSYS ERRORS AT TAKE10:/]
		 JRST	CMDERR]		;error, go check for eof on take file
	TXNN T1,CM%NOP		;PARSED FILE-SPEC OK ?
	JRST TAKE10		;YES, GO ON AND SAVE INPUT JFN
	HRROI	T1,BUFFER	;GET READY TO PRINT COMMAND IF TAKING
	SKIPE	TAKFLG		;SKIP IF NOT TAKING
	CALL	SNDMSG		;TAKING - TYPE OUT COMMAND
	CALL TSTCOL		;ISSUE NEW LINE IF NEEDED
	RITMSG <? UETP: Invalid file specification, >
	CALLRET PUTERR		;OUTPUT ERROR STRING TO TERMINAL

; HERE ON A GOOD INPUT FILE SPEC

TAKE10:	MOVEM T2,INJFN		;SAVE INPUT JFN FOR COMMANDS
	HRROI T2,[ASCIZ/LOGGING OUTPUT ON/] ;GET NOISE TEXT
	CALL SKPNOI		;GO PARSE NOISE FIELD
	 RET			;FAILED, RETURN FAILURE
	CALL CLRGJF		;GO CLEAR GTJFN BLOCK USED BY COMND JSYS
	MOVX T1,GJ%FOU		;GET FLAG SAYING FILEIS FOR OUTPUT USE
	MOVEM T1,GJFBLK+.GJGEN	;SAVE GTJFN FLAGS
	SETZM NAMBUF		;INITIALIZE FILENAME BUFFER
	HRROI T1,NAMBUF		;GET POINTER TO WHERE FILENAME IS TO GO
	MOVE T2,INJFN		;GET INPUT JFN
	MOVX T3,<FLD(.JSAOF,JS%NAM)> ;GET FLAG BITS SAYING OUTPUT NAME ONLY
	JFNS			;GET FILE NAME OF INPUT FILE
	SKIPE NAMBUF		;ANY FILENAME ?
	HRROI T1,NAMBUF		;YES, GET A POINTER TO THE FILE NAME FOR INPUT
	MOVEM T1,GJFBLK+.GJNAM	;STORE DEFAULT NAME OF OUTPUT FILE
	HRROI T1,[ASCIZ/LOG/]	;GET DEFAULT FILE TYPE OF OUTPUT FILE
	MOVEM T1,GJFBLK+.GJEXT	;STORE DEFAULT EXTENSION
	MOVEI T1,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI T2,[FLDDB. (.CMFIL)] ;GET FILE-SPEC FUNCTION BLOCK ADDRESS
	COMND			;PARSE OUTPUT FILE SPEC
	 ERJMP [HRROI	T1,[ASCIZ/COMND JSYS ERRORS AT TAKE20:/]
		 JRST	CMDERR]		;error, go check for eof on take file
	TXNN T1,CM%NOP		;FILE SPEC PARSED OK ?
	JRST TAKE20		;YES, GO ON TO SAVE JFN
	; ...
	;...
	HRROI	T1,BUFFER	;GET READY TO PRINT COMMAND IF TAKING
	SKIPE	TAKFLG		;SKIP IF NOT TAKING
	CALL	SNDMSG		;TAKING - TYPE OUT COMMAND
	CALL TSTCOL		;NO, ISSUE NEW LINE IF NEEDED
	RITMSG <? UETP: Invalid file specification, >
	CALLRET PUTERR		;GO OUTPUT CORRECT MESSAGE AND RETURN

; HERE TO SAVE OUTPUT JFN AND GET COMMAND CONFIRMATION

TAKE20:	MOVEM T2,OUTJFN		;SAVE LOGGIN FILE JFN
	CALL ENDCOM		;GO PARSE COMMAND CONFIRMATION
	 RET			;RETURN, BAD CONFIRMATION

; OPEN INPUT AND OUTPUT FILES

	MOVE T1,INJFN		;GET INPUT JFN
	MOVE T2,[7B5+OF%RD]	;7 BIT BYTES, READ ACCESS
	OPENF			;OPEN INPUT FILE
	 JRST [	CALL TSTCOL	;ERROR, ISSUE NEW LINE IF NEEDED
		RITMSG <? UETP: Cannot OPEN command file, >
		CALLRET PUTERR]	;GO ISSUE REST OF MESSAGE AND RETURN

	MOVE T1,OUTJFN		;GET OUTPUT JFN
	CAIN T1,.PRIOU		;STILL PRIMARY OUTPUT JFN ?
	JRST TAKE30		;NO OUTPUT JFN, GO ON
	MOVE T2,[7B5+OF%WR]	;7 BIT BYTES, WRITE ACCESS
	OPENF			;OPEN OUTPUT FILE
	 JRST [	CALL TSTCOL	;ERROR, ISSUE NEW LINE IF NEEDED
		MOVE T1,INJFN	;GET INPUT JFN AGAIN
		CLOSF		;CLOSE INPUT FILE
		 JFCL		;IGNORE ERRORS HERE
		RITMSG <? UETP: cannot OPEN logging file, >
		CALLRET PUTERR]	;GO OUTPUT REST OF MESSAGE

; NOW SAVE NEW JFN'S AND RETURN TO PARSER

TAKE30:	HRLZ T1,INJFN		;GET INPUT JFN
	HRR T1,OUTJFN		;GET OUTPUT JFN
	MOVEM T1,CMDBLK+.CMIOJ	;SAVE NEW JFN'S
	SETOM TAKFLG		;MARK THAT COMMANDS ARE COMING FROM FILE
	HRRZ	T1,OUTJFN	;GET OUTPUT JFN
	HRROI	T2,BUFFER	;POINT TO COMMAND BUFFER
	SETZ	T3,		;WRITE WHOLE ASCIZ STRING
	SETZ	T4,
	SOUT			;WRITE TAKE COMMAND INTO THE LOG FILE
	RET			;RETURN TO PARSER
		SUBTTL		WAIT - COMMAND TO WAIT N SECONDS
;
; THIS COMMAND IS IMPLEMENTED TO BE ABLE TO RUN UETP UNDER BATCH.
; IT SIMPLY DOES A DISMS FOR HHH:MM SO THAT BATCH WON'T KICK US OFF
; IT OPTIONALY CAN EXECUTE A STATUS COMMAND WHILE IN THE SLEEP CYCLE.

.WAIT:	HRROI	T2,[ASCIZ/FOR HHH:MM/]
	CALL	SKPNOI			;GO PARSE THE NOISE FIELD
	 RET				;ERROR RETURN
	CALL	PARSHR			;GO PARSE TIME QUANTITY HHH:MM
	RET
	SKIPE	T2			;SKIP IF WE GOT A TIME VALUE
	RET				;GOT CR/LF - JUST RETURN
	MOVE	Q1,T1			;SAVE THE WAIT TIME
	HRROI	T2,[ASCIZ/WITH STATUS EVERY/]
	CALL	SKPNOI			;GO PARSE THE NOISE
	RET
	CALL	PARSHR			;GO PARSE STATUS INTERVAL
	RET
	SKIPN	T2			;SKIP IF WE DIDN'T GET CR/LF (GOT TIME)
	JRST	DOWAIT			;GOT FIRST FDB - STATUS TIME
	SETOM	INWAIT			;FOR CTL/C CODE
	MOVE	T1,Q1			;NO STATUS JUST STRAIGHT WAITING
	DISMS				;NO STATUS - JUST WAIT
	SETZM	INWAIT			;TURN OFF CTL/C CHECKING
	RET				;RETURN TO CALLER
DOWAIT:	MOVE	Q2,T1			;SAVE STATUS INTERVAL
	CAMLE	Q1,Q2			;WAIT MUST BE LARGER THAN STATUS INTERVAL
	JRST	GOWAIT			;WAIT OK GO DO THE WAITING  LOOP
	RITMSG	<
?WAIT INTERVAL MUST BE LARGER THAN STATUS INTERVAL.
>
	RET
GOWAIT:	SETOM	INWAIT			;FOR CTL/C CODE
	MOVE	T1,Q2			;WAIT FOR THE STATUS INTERVAL
	DISMS
	SETZM	INWAIT			;TURN OFF CTL/C CHECKING
	CALL	STATUS			;GO DO THE STATUS
	 RET				;ERROR - RETURN
	SUB	Q1,Q2			;SUBTRACT INTERVAL WAITED FROM
	JUMPG	Q1,GOWAIT		;RET
	RET				;AND NOW RETURN
		SUBTTL	ABRTIM - ROUTINE TO END /CYCLE:HHH:MM TYPES JOBS
;
; THIS ROUTINE USES TIMER JSYS TO GET A TIMER INTERVAL EVERY MINUTE.  ON 
; INTERRUPT IT LOOKS AT ALL JOBS FOR A NT%TYM JOB THAT HAS OVER RUN IT'S
; TCBMAX TIME.  THOSE TYPES OF JOBS WILL BE STOPPED.
;
ABRTIM:	MOVE	T1,[.FHSLF,,1]		;INTERRUPT OURSELVES 
	MOVEI	T2,^D60000		;        AFTER ONE MINUTE
	MOVEI	T3,^D23			;		ON CHANNEL 23
	TIMER
	 JRST	[RITMSG<
%YOU ARE NOT ON RELEASE 3. JOBS WITH /CYCLE:HHH:MM WILL END ONLY IF THEY
  RETURN CONTORL TO UETP.
>
		 RET]
	RET
TIMTIC:	SAVE				;HERE ON INTERRUPT
	GTAD				;GET THE TIME FOR COMPARISONS
	MOVE	T4,T1			;SAVE FOR LATER COMPARISONS
	HRROI	T2,-1			;START READING FROM THE START
TIMLOP:	MOVEI	T1,READ			;GO READ A TCB
	CALL	SCHED
	JRST	TIMRET			;SCHED HAD PROBLEMS - GET OUT 
	TXNE	T3,SC%EOT		;DID WE READ ALL OF THEM
	JRST	TIMRET			;YES - GET OUT
	MOVE	T2,T1			;MOVE ADDRESS OF TCB
	MOVE	T1,TCBSTA(T2)		;GET THE STATUS VECTOR
	TXNN	T1,NT%TYM		;IS THIS JOB OF FORM /CYCLE:HHH:MM
	JRST	TIMLOP			;NO - KEEP LOOKING
	TXNN	T1,NT%RUN+NT%QUE	;ONLY CONSIDER RUNNING OR QUEUED JOBS
	JRST	TIMLOP			;NEITHER - KEEP LOOKING
	MOVE	T1,TCBMAX(T2)		;GET MAX RUN TIME
	ADD	T1,TCBTYM(T2)		;ADD TO HIS START TIME
	CAMGE	T4,T1			;HAS HIS PROJECTED END TIME PASSED
	JRST	TIMLOP			;NO - KEEP LOOKING
	TXNE	T1,NT%RUN		;SKIP IF JOB IS QUEUED
	AOS	TCBRUN(T2)		;BUMP RUN COUNT
	MOVEI	T1,ABORT		;GO KILL THE JOB
	PUSH	P,T2			;SAVE THE TCB ADDRESS
	CALL	SCHED
	JRST	TIMRET			;SCHED PROBLEMS - GET OUT
	POP	P,T2			;GET BACK THE TCB ADDRESS
	MOVE	T1,TCBSTA(T2)		;RESET ABORTED FLAG
	TXZ	T1,NT%ABR
	IORX	T1,NT%END		;TO ENDED
	MOVEM	T1,TCBSTA(T2)		;SAVE STATUS VECTOR
	JRST	TIMLOP			;DONE WITH HIM - KEEP LOOKING
TIMRET:	CALL	ABRTIM
	RESTOR
	DEBRK
		SUBTTL		ALLNMS - ROUTINE TO PICK NEXT NAME OF TBLUK TABLE
;
;ACCEPTS:	P4/ADDRESS OF TABLE
;		P5/MAX LENGTH OF TABLE
;
;RETURNS:	T2/NEXT ENTRY IN TABLE
;		P4/UPDATED TO POINT TO NEXT ENTRY
;		P5/DECREMENTED MAX COUNT
ALLNMS:	SAVEAC	<T3,T4>
ALLOOP:	SOJL	P5,ALLEOT		;ARE WE THRU
	AOJ	P4,			;POINT TO NEXT TABLE ENTRY
	HRRZ	T1,(P4)			;GET THE ENABLED ENTRY
	HLRO	T2,(P4)			;POINTER FOR NEXT ENTRY
	TDNN	T1,T4			;T4 HAS REQUEST - SKIP IF IT'S OFF
	JRST	ALLOOP			;KEEP LOOKING
	MOVEI	T1,READ			;GO GET TCB TO FIND CURRENT STATE
	CALL	SCHED			;TCB HANDLING ROUTINE
	RET
	MOVE	T1,TCBSTA(T2)		;NO - THEN GET ENTRIES STATUS
	MOVS	T2,(P4)			;POINTER FOR NEXT ENTRY
	RETSKP				;NORMAL RETURN
ALLEOT:	RET				;EOT RETURN
	
	SUBTTL SUBAOK		- ROUTINE TO ACCEPT SHIPPR'S RUNNING OK MSG
;
; IT BUMPS THE PC BY ONE AND DEBRAKES
;
SUBAOK:	SAVE
	AOS	RETPC1			;BUMP TO GET OUT OF THE WAIT
	MOVE	T1,[3,,PANIC]		;RESTORE INFERIOR DYING CHANNEL
	MOVEM	T1,ICHIFT		;SAVE
	RESTOR
	DEBRK

SUBERR:	HALTF
			SUBTTL  BOSTAK - ROUTINE TO TAKE UETP MSG'S FROM SWITCH

BOSTAK:	SAVE
	CALL	SNDTTY		;GO SEND MESSAGE TO LOGS IF NEEDED
	HRROI	T2,TNAME	;POINT TO NAME OF TEST SENDING MSG (FOR SCHED:)
	MOVE	T1,DEFTYP	;GET TYPE OF MESSAGE FIELD
	CAME	T1,[ASCII/START/]	;IS IT A START MSG
	JRST	TRYEND		;NO - TRY AN 'END' MSG
	MOVEI	T1,STRMSG	;SIGNAL SCHED THAT A JOB STARTED
	CALL	SCHED
	JRST	BSOUT		;EXIT
	JRST	BSOUT		;EXIT
TRYEND:	CAME	T1,[ASCII/END  /]	;WAS IT AN END MESSAGE
	JRST	TRYERR		;NO - TRY ERROR MESSAGES
	MOVEI	T1,ENDMSG	;SIGNAL END MESSAGE TO SCHED
	CALL	SCHED
	JRST	BSOUT		;EXIT
	JRST	BSOUT		;GO EXIT
TRYERR:	CAME	T1,[ASCII/ERROR/]	;IS IT AN ERROR MESSAGE
	JRST	BSOUT		;NO - GO EXIT
	MOVEI	T1,ERRMSG	;TELL SCHED JOB GOT AN ERROR
	CALL	SCHED		;GO HANDLE ERROR MESSAGES
	JFCL			;EVEN ON ERRORS WE NOTIFY INFERIOR
BSOUT:	MOVX	T2,<1B25>	;TELL SWITCH WE ARE DONE WITH MESSAGE
	MOVE	T1,SWHNDL	;SWITCHES HANDLE
	IIC
	RESTOR
	DEBRK
	RESTOR			;RESTOR THE REGS
	SUBTTL  BLKFIL	- ROUTINE TO REPLACE NULLS IN BUFFER WITH BLANKS

BLKFIL:	SAVEAC <T1,T2,T3,T4>
	MOVE	T1,[POINT 7,BASERC]	;START OF BUFFER AREA TO FILL
	MOVE	T2,[POINT 7,MSGREC]	;ENDING ADDRESS
	IBP	T2			;FIX-UP MACRO'S STRANGE SET-UP
	MOVEI	T3," "			;FILL WITH BLANKS
BLKLOP:	ILDB	T4,T1			;BUMP AND LOAD NEXT BYTE
	CAMN	T1,T2			;ARE WE AT END OF TABLE?
	RET				;YES - THEN RETURN
	SKIPN	T4			;KEEP LOOPING IF NOT ZERO
	DPB	T3,T1			;REPLACE ZERO WITH BLANK
	JRST	BLKLOP			;KEEP FILLING
		SUBTTL		CONMSG - TYPE THE CONFIRMATION MESSAGES
;
;ACCEPTS:	T1/POINTER TO THE CONFIRMATION MESSAGE
;RETURNS	+1,ALWAYS
;
CONMSG:	SAVEAC	<T1,T2,T3,T4>
	MOVE	T4,T1			;SAVE THE MESSAGE POINTER
	MOVE	T3,[ASCII/     /]	;PUT LEADING SPACE IN
	MOVEM	T3,WRKBUF		;BLANK OUT FIRST WORD
	MOVE	T1,[POINT 7,WRKBUF,6]	;WHERE MSG IS BEING BUILT
	HRROI	T2,-1			;CURRENT TIME ONLY
	MOVX	T3,OT%NDA+OT%SCL		;ONLY TIME - NO LEADING SPACES
	ODTIM
	MOVEI	T3," "				;SPACE BETWEEN TIME AND MSG
	IDPB	T3,T1
	MOVEI	T3,"["				;NOW BRACKET THE MESSAGE
	IDPB	T3,T1				;INTO WORK BUFFER
	SETZ	T3,				;WRITE WHOLE RECORD
	MOVE	T2,T4				;GET THE MESSAGE
	SOUT					;INTO THE BUFFER
	 ERJMP	[ERRSND<ERROR WITH SOUT AT CONMSG:>
		 RET]
	MOVEI	T3,"]"				;BRACKET END OF MESSAGE
	IDPB	T3,T1
	SETZ	T3,				;MAKE SURE A NULL IS AT THE END
	IDPB	T3,T1
	HRROI	T1,WRKBUF			;POINT TO MSG
	CALL	SNDMSG				;SEND THE MESSAGE
	RITMSG <
>						;AND SEND CR/LF
	RET
		SUBTTL		DIWAKE - DISABLE WAKE ROUTINE
;  THIS ROUTINE TURNS OFF THE CTL/C INTERRUPT FOR WAIT COMMAND
;RETURNS:	+1,ERRORS
;		+2,OTHERWISE
DIWAKE:	MOVEI	T1,.TICCC			;DISABLE CTL/C ON CHANNEL 35
	DTI
	 ERJMP	[ERRSND<ERROR WITH DTI JSYS AT DIWAKE:>
		 RET]
	MOVEI	T1,.FHSLF			;DISABLE OUT CHANNEL 35
	MOVE	T2,[1B35]			; TO NOT ACCEPT THE ASSIGNED CTL/C
	DIC
	 ERJMP	[ERRSND<ERROR WITH DIC JSYS IN DIWAKE:>
		 RET]
	RETSKP
		SUBTTL  ENAALL - ENABLE ALL THE CHANNELS
;RETURNS	+1,ALWAYS
ENAALL:	SAVEAC	<T1,T2>
	MOVEI	T1,.FHSLF	;ACTIVATE OUR CHANNELS
	MOVE	T2,[1B19!1B23!1B24!1B26!1B27!1B33!1B34]
	AIC			;ACTIVATE THEM
	RET
		SUBTTL ENABLD - BUILD TBLUK TYPE TABLE OF ENABLED TESTS
;
;ACCEPTS:	NO ARGUMENTS
;RETURNS:	NO ARGUMENTS
;
ENABLD:	SETZ	T1,			;RESET THE TABLE
	HLLM	T1,ENATBL		;ENATBL IS THE TBLUK TYPE TABLE
	HRROI	T2,-1			;INDICATES TO SCHED TO READ FIRST ONE
ENLOOP:	MOVEI	T1,READ			;FUNCTION CODE FOR SCHED - READ ENABLED
	CALL	SCHED			; TEST OFF MASTER TABLE
	RET
	TXNE	T3,SC%EOT		;END OF TABLE?
	RET				;YES
	MOVE	T4,T1			;SAVE TABLE POINTER FOR LOOP
	MOVEI	T1,ENATBL		;POINT TO TBLUK TYPE TABLE
	MOVE	T2,TCBDEP(T4)		;GET THE STATUS BITS AVAILABLE
	HRLI	T2,TCBNAM(T4)		;POINT TO TEST NAME
	TBADD				;GO ADD TO TABLE
	 ERJMP	[ERRSND <DUPLICATE ENTRIES IN SCHED'S TABLE. AT ENLOOP:>
		 RET]
	MOVE	T2,T4			;INDICATE TO SCHED WHICH ONE WE READ
	JRST	ENLOOP			;KEEP READING
		SUBTTL		ENWAKE - ENABLE THE CTL/C WAKE FEATURE FOR .WAIT
;
;RETURNS:	+1,ERROR
;		+2,OTHERWISE
ENWAKE:	HRROI	T1,-1				;CAN'T ENABLE CTL/C IF UNDER BATCH
	HRROI	T2,3				;BATCH WORD INTO AC3 ONLY
	MOVX	T3,.JIBAT			;THIS WORD WILL TELL US
	GETJI					;IF WE ARE UNDER BATCH
	 ERJMP	[ERRSND<ERROR WITH GETJI AT ENWAKE:>
		 RET]
	SKIPE	T3				;SKIP IF NOT UNDER BATCH
	RETSKP					;UNDER BATCH - FORGET CTL/C STUFF
	MOVEI	T1,.FHSLF			;FIRST ENABLE CTL/C CAPABLITIES
	MOVX	T3,SC%CTC
	EPCAP					;GO ENABLE THE CTL/C CAPABILITIES
	 ERJMP	[ERRSND<ERROR WITH EPCAP JSYS AT ENWAKE:>
		 RET]
	MOVE	T1,[.TICCC,,<ICH035-CHNTAB>]	;TAKE CTL/C ON CHANNEL 35
	ATI
	MOVEI	T1,.FHSLF			;ENABLE OUT CHANNEL 35
	MOVE	T2,[1B35]			; TO ACCEPT THE ASSIGNED CTL/C
	AIC
	 ERJMP	[ERRSND<ERROR WITH AIC JSYS IN ENWAKE:>
		 RET]
	RETSKP
;
;HERE IF CTL/C WHILE IN SLEEP ROUTINE

WAKEUP:	SKIPN	INWAIT				;SKIP IF IN COMMAND WAIT
	JRST	TRYEXC				;NO - TRY EXEC LEVEL
	SETZM	INWAIT				;TURN OFF CTL/C CHECKING
CTLRET:	MOVEI	T1,PARSE			;WE WILL RETURN PROCESS TO PARSE:
	HLL	T1,RETPC3			;ADD PC BITS
	MOVEM	T1,RETPC3			;SET-UP THE NEW RETURN FOR DEBRK
	DEBRK
TRYEXC:	RITMSG<
%TO GET TO EXEC LEVEL USE PUSH COMMAND.  TO EXIT PROGRAM USE EXIT COMMAND.
>
	JRST	CTLRET
		SUBTTL	EXIT - ROUTINE TO CLEAN-UP FOR ENDING UETP
;RETURNS:	+1,ALWAYS
;
EXIT:	HRROI	T1,[ASCIZ/LOGOUT /]
	CALL	XEQEXC		;GO LOGOFF FROM THE PTY
	JRST	LOGERR		;ERRORS ENCOUNTERED
	SETOM T1		;INDICATE ALL FILES SHOULD BE CLOSED
	CLOSF			;CLOSE ALL OPEN FILES
	 JRST	[ERRSND<ERROR WITH CLOSF AT .EXIT:>
		 JRST	.+1]	;UNEXPECTED ERROR
	HRROI	T1,-1		;NOW RELEASE ALL JFN'S
	RLJFN
	 JRST	[ERRSND<ERROR WITH RLJFN JSYS AT .EXIT:>
		 JRST	.+1]
	MOVEI	T1,.FHSLF
	DIR			;DISABLE THE SOFTWARE INTERRUPT SYSTEM
	MOVEI	T1,.FHINF	;NOW LET'S KILL ALL INFERIORS
	KFORK
	 ERJMP	[ERRSND<ERROR WITH KFORK AT .EXIT:>
		 JRST	.+1]
	RET
LOGERR:	RITMSG <
?ERRORS ENCOUNTERED IN LOGGING OFF FROM PTY.
>
	HALTF
	JRST	.-1
		SUBTTL  GETPTY	- ROUTINE TO GET PTY AND ASSOCIATED TTY FOR EXEC
;ROUTINE TO GET A PTY JFN
GETPTY:	SAVEAC	<Q1,Q2,Q3>
	MOVE	T1,[SIXBIT/PTYPAR/]	;GET # OF PTYS IN SYSTEM
	SYSGT			;...
	 ERJMP	[ERRSND<UNEXPECTED PROBLEMS WITH JSYS SYSGT AT GETPTY:>
		 HALTF]
	HRRZM	T1,Q1		;STORE TTY CORRESPONDENCE FOR PTY'S
	HLRZ	T4,T1		;ISOLATE PTY COUNT
	MOVN	T4,T4		;GET # OF PTYS IN SYSTEM
	HRLZS	T4
GETPT1:	MOVSI T1,600013		;GET PTY DESIGNATOR
	HRRI T1,(T4)		;TRY TO GET NEXT PTY
	DVCHR			;GET CHARACTERISTICS OF THIS PTY
	 ERJMP	[ERRSND<UNEXPECTED PROBLEMS WITH JSYS DVCHR AT GETPT1:>
		 HALTF]
	TLNN T2,(1B5)		;IS IT AVAILABLE?
	JRST   GETPT2		;NO
	MOVE T2,T1
	HRROI T1,WRKBUF		;TURN IT INTO AN ASCII STRING
	DEVST
	JRST	GETPT2
	MOVEI T2,":"		;TERMINATED BY A COLON
	IDPB T2,T1
	MOVEI T2,0
	IDPB T2,T1		;ENDED WITH A 0 BYTE
	MOVSI T1,1		;SHORT FORM GTJFN
	HRROI T2,WRKBUF
	GTJFN
	JRST	GETPT2		;NOT AVAILABLE
	MOVE T2,[7B5+1B19+1B20]	;NOW TRY TO OPEN IT
	PUSH P,T1
	OPENF
	JRST	GETPT3		;NOT AVAILABLE
	POP P,T1			;GET BACK JFN
	ADD T4,Q1		;TURN PTY UNIT # INTO TTY #
	TRO T4,(1B0)		;MAKE LEGAL TERMINAL DESIGNATOR
	HRRZM T4,TTYJFN		;STORE TTY DESIGNATOR
	HRRZM T1,PTYJFN		;STORE JFN ALSO
	MOVEI T1,100
	GTTYP			;FIND OUT WHAT TYPE OF TERMINAL WE'RE ON.
	 ERJMP	[ERRSND<UNEXPECTED PROBLEMS WITH JSYS GTTYP AT GETPTY:>
		 HALTF]
	MOVE T1,TTYJFN
	STTYP			;AND SET PTY TO SAME TYPE.
	 ERJMP	[ERRSND<UNEXPECTED PROBLEMS WITH JSYS STTYP AT GETPT1:>
		 HALTF]
	; ...
	;...
	MOVE	T1,PTYJFN	;NOW ASSIGN PTY INPUT TO CHANNEL  33
	MOVE	T2,[MO%WFI+MO%OIR+.MOAPI+<FLD (^D33,MO%SIC)>]
	MTOPR			;MAKE THE ASSIGNMENT
	 ERJMP	[ERRSND<MTOPR ERROR AT GETERR:>
		 HALTF]
	JRST	GOTPTY		;AND SET INTERRUPT SYSTEM
GETPT3:	POP P,T1			;GET BACK JFN
	RLJFN			;AND RELEASE IT
	  JFCL
GETPT2:	AOBJN T4,GETPT1		;TRY FOR ANOTHER PTY
GETRET:	RET			;ERROR - RETURN - NO PTY
GOTPTY:	RETSKP			;NORMAL - RETURN
		SUBTTL		PARSHR	- ROUTINE TO PARSE NUMBER OF HOURS
;
;RETURNS:	+1,ERRORS
;		+2,WITH T1/NUMBER OF HOURS IN INTERNAL UNIVERSAL TIME
;		        T2/0  - IF TIME WAS PARSED
;			  /-1 - IF CR/LF WAS PARSED
;
PARSHR:	SAVEAC	<T3,T4>
	MOVEI	T1,CMDBLK			;COMND STATE BLOCK
	MOVEI	T2,[FLDDB. (.CMNUM,,12,<TIME IN HHH:MM FORMAT, WHERE HHH & MM ARE>,,[FLDDB. (.CMCFM)])]	;PARSE NUMBER OF SECONDS
	COMND	
	 ERJMP [HRROI	T1,[ASCIZ/COMND JSYS ERRORS AT .PARSHR:/]
		 JRST	CMDERR]		;error, go check for eof on take file
	TXNN	T1,CM%NOP		;NO PARSE?
	JRST	GETHR			;NO - SEE IF WE GOT A ':'
TYMERR:	HRROI	T1,BUFFER		;GET READY TO PRINT COMMAND IF TAKING
	SKIPE	TAKFLG			;SKIP IF NOT TAKING
	CALL	SNDMSG			;TAKING - TYPE OUT COMMAND
	RITMSG <
?INVALID TIME VALUE, MUST BE OF FORM HHH:MM, WHERE HHH & MMM ARE NUMERIC.
>
	RET
GETHR:	MOVS	T4,T3			;SEE IF WE PARSE A NUMBER?
	CAMN	T4,T3			;SKIP IF WE GOT A CR/LF
	JRST	MINGET			;GET HOURS - GO GET MINUTES
	HRROI	T2,-1			;INDICATE THE CR/LF TO CALLER
	JRST	HOURET
MINGET:	MOVE	T1,CMDBLK+.CMPTR	;GETTING THE DELIMETER
	ILDB	T4,T1			;FIRST NUMERIC MUST END WITH :
	CAIE	T4,":"			;WAS IT TIME VALUE?
	JRST	TYMERR			;NO - MUST BE AN ERROR
	MOVEM	T2,T4			;SAVE THE WAIT HOURS
	IMULI	T4,^D60			;CONVERT TO MINUTES
	IBP	CMDBLK+.CMPTR		;BUMP PAST THE COLON
	SOS	CMDBLK+.CMINC		;AND DECREMENT BYTE COUNT
	MOVEI	T2,[FLDDB. (.CMNUM,,^D10)]	;NEXT FIELD MUST BE A NUMBER
	MOVEI	T1,CMDBLK		;POINT TO STATE BLOCK
	COMND
	 ERJMP [HRROI	T1,[ASCIZ/COMND JSYS ERRORS AT GETHR:/]
		 JRST	CMDERR]		;error, go check for eof on take file
	TXNE	T1,CM%NOP		;GOOD PARSE?
	JRST	TYMERR			;NO - ERROR - GO TELL USER
	CAILE	T2,^D60			;MINUTES ARE 0-60
	JRST	TYMERR			;ERROR - TYPE MESSAGE
	ADD	T2,T4			;GRAND TOTAL
	IMULI	T2,^D60000		;CONVERT MINUTES TO MILLISECONDS
	MOVE	T1,T2			;INTO THE PARM REG
	SETZ	T2,			;INDICATE WE GOT A TIME VALUE
HOURET:	RETSKP
		SUBTTL PARSKY - SUBROUTINE TO PARSE KEYWORDS
;
;ACCEPTS:	T1/ADDRESS OF TBLUK FORMAT TABLE OF KEYWORDS
;
;RETURNS:	+1, ERROR
;
;		+2,T1/FLAGS,,ADDR OF ASCII KEYWORD
;		   T2/PR%ALL - IF ALL WAS TYPED
;		      PR%ONE - IF  A PARTICULAR KEYWORD WAS CHOSEN
;
PARSKY:	MOVEI	T2,[FLDDB. (.CMKEY,,ALLTAB,,,[FLDDB. (.CMKEY)])]
	HRRZ	T3,.CMFNP(T2)		;GET ADDRESS OF THE SECOND FDB ABOVE
	MOVEM	T1,.CMDAT(T3)		; PLACE KEYWORD TABLE ADDRESS INTO IT
	MOVEI	T1,CMDBLK		;COMND STATE BLOCK
	COMND				;GO PARSE A KEYWORD (TEST NAME) OR "ALL"
	 ERJMP [HRROI	T1,[ASCIZ/COMND JSYS ERRORS AT PARSKY:/]
		 JRST	CMDERR]		;error, go check for eof on take file
	TXNN	T1,CM%NOP		;NO PARSE?
	JRST	PAPARM			;NO - GO RETURN THE PARAMS
	HRROI	T1,BUFFER		;GET READY TO PRINT COMMAND IF TAKING
	SKIPE	TAKFLG			;SKIP IF NOT TAKING
	CALL	SNDMSG			;TAKING - TYPE OUT COMMAND
	RITMSG <
?NO SUCH TEST AVAILABLE.
>
	RET
PAPARM:	MOVS	T1,T3			;IF BOTH HALVES THERE THE SAME WE GOT A
	CAME	T1,T3			; "ALL" KEYWORD AND WILL SKIP.
	JRST	[MOVS	T1,(T2)		;KEYWORD - GET TABLE ENTRY TO RETURN
		 MOVX	T2,PR%ONE	;INDICATE THAT WE GOT A KEYWORD
		 JRST	PARSAV]		;AND TAKE NORMAL RETURN
	MOVS	T1,(T2)		;KEYWORD - GET TABLE ENTRY TO RETURN
	MOVX	T2,PR%ALL		;INDICATE USER TYPED "ALL"
PARSAV:	MOVEM	T1,CURENT	;SAVE CURRENT PARSED KEYWORD VECTOR
	RETSKP				;NORMAL RETURN
		SUBTTL PARSSW - PARSE SWITCHES /CYCLE AND\OR /DEPTH
;
; THIS ROUTINE HAS TWO SUBROUTINES (GTCYCL AND GTDPTH).  THESE SUBROUTINES
; GET THE ACTUAL VALUE ASSOCIATED WITH EACH SWITCH.  ACCUMULATORS Q2 AND Q3
; ARE USED BY THEM TO SHOW THAT A VALUE WAS RETURNED.  INITIALLY THEY POINT
; TO THE ENTRIES FOR THE DEFAULT VALUES, IF NEW VALUES ARE ENTERED THEN
; THEIR POINTERS ARE PLACED IN THERE. AFTER CR/LF THE POINTERS ARE SWITCHED
; WITH THE TEMPORARY SET THEREBY CREATING NEW DEFAULTS.
;
; ACCEPTS:	T1/ADDRESS OF TBLUK TYPE TABLE OF SWITCHES TO GET
;RETURNS:	T1/CYCLE VALUE
;		T2/FLAGE INDICATING DEPTH WANTED
;
PARSSW:	SAVEAC <Q1,Q2,Q3>
	MOVEI	Q2,DEFCYC		;POINT TO DEFAULT CYCLE VALUE
	MOVEI	Q3,DEFDEP		;POINT TO DEFAULT DEPTH VALUE
	MOVE	Q1,T1			;SAVE T1
SWLOOP:	MOVEI	T2,[FLDDB. (.CMSWI,,,,/DEPTH,[FLDDB. (.CMCFM)])]
	HRRZM	Q1,.CMDAT(T2)		;PUT ADDRESS OF KEYWORD TABLE IN FDB
	MOVEI	T1,CMDBLK		;POINT TO COMND STATE BLOCK
	COMND				;GET THE SWITCH
	 ERJMP [HRROI	T1,[ASCIZ/COMND JSYS ERRORS AT SWLOOP:/]
		 JRST	CMDERR]		;error, go check for eof on take file
	TXNN	T1,CM%NOP		;NO PARSE?
	JRST	SWVAL			;NO - GO PARSE THE SWITCH VALUE
	HRROI	T1,BUFFER		;GET READY TO PRINT COMMAND IF TAKING
	SKIPE	TAKFLG			;SKIP IF NOT TAKING
	CALL	SNDMSG			;TAKING - TYPE OUT COMMAND
	RITMSG <
?INVALID SWITCH 
>
	RET
SWVAL:	MOVS	T1,T3			;IF BOTH HALVES ARE NOT THE SAME WE GOT A
	CAME	T1,T3			; A CR/LF AND WILL TAKE THE DEFAULTS
	JRST	[TLNN	Q1,400000	;BIT ON MEANS DON'T LOOP FOR CR/LF
		 JRST	SWRET		;NO CR/LF WANTED - RETURN
		 RITMSG<
%NO FUNCTION PERFORMED
>
		 RET]
	HRRZ	T1,(T2)			;GET ADDR OF SUBR TO PARSE VALUE
	CALL	(T1)			;CALL GTCYCL OR GTDPTH TO GET RIGHT VAL
	RET				;ERROR - RETURN
	TLNE	Q1,400000		;BIT ON MEANS DON'T LOOP FOR CR/LF
	JRST	SWRET			;NO CR/LF WANTED - RETURN
	TXNN	T1,CM%EOC		;DID WE GET CR/LF
	JRST	SWLOOP			;NO - KEEP GETTING SWITCHES
	; ...
	;...
SWRET:	HRRZ	T1,(Q3)			;CHECK THAT PROPER DEPTH IS INDICATED
	MOVS	T1,(T1)			;/DEPTH VALUE FOR THIS COMMAND
	TDNN	T1,CURENT		;SEE IF HE CAN DO THIS
	JRST	[RITMSG<
?NON-EXISTANT DEPTH REQUESTED.
>
		 RET]
	HRROI	T1,BUFFER		;GET READY TO PRINT COMMAND IF TAKING
	SKIPE	TAKFLG			;SKIP IF NOT TAKING
	CALL	SNDMSG			;TAKING - TYPE OUT COMMAND
	MOVE	T1,Q2			;RETURN POINTER TO /CYCLE VALUES TABLE
	MOVE	T2,Q3			;RETURN POINTER TO /DEPTH VALUES TABLE
	RETSKP				;  AND EXIT NORMALLY
		SUBTTL PARSTM - ROUTINE TO PARSE A TIME FIELD
;
; RETURNS: +1,ERROR
;	   +2,T1/UNIVERSAL TIME
;	      T2/-1, IF NO TIME WAS PARSED, JUST A CR/LF
;	          0, IF TIME WAS PARSED

PARSTM:SAVEAC <T3,T4>
	MOVEI	T2,[FLDDB. (.CMNUM,CM%SDH,12,<TIME QUANTITY OF FORM HHH:MM>,,[FLDDB. (.CMCFM)])]
	MOVEI	T1,CMDBLK		;COMND STATE BLOCK 
	COMND				;GO PARSE TIME OR CR/LF
	 ERJMP [HRROI	T1,[ASCIZ/COMND JSYS ERRORS AT PARSTM:/]
		 JRST	CMDERR]		;error, go check for eof on take file
	TXNN	T1,CM%NOP		;NO PARSE?
	JRST	TMVAL			;NO - GO RETURN THE TIME VALUE
	HRROI	T1,BUFFER		;GET READY TO PRINT COMMAND IF TAKING
	SKIPE	TAKFLG			;SKIP IF NOT TAKING
	CALL	SNDMSG			;TAKING - TYPE OUT COMMAND
	RITMSG <
?BAD TIME VALUE. ONLY VALUES OF FORMAT HHH:MM ALLOWED.
>
	RET
TMVAL:	MOVE	P1,T2			;PUT TIME VALUE IN HOLD REG
	MOVS	T4,T3			;IF BOTH HALVES NOT EQUAL THEN WE
	CAME	T4,T3			;  GOT A CR/LF
	JRST	TMOUTL			;YES - GO TYPE OUT THE LINE IF TAKING
	MOVE	T1,CMDBLK+.CMPTR	;GET LAST PARSE BYTE POINTER
	ILDB	T4,T1			;IF IT WAS A ":" THEN TIME PARSE 
	CAIE	T4,":"			;WAS OF FORM ":MM" AND WE ASSUME
	JRST	[RITMSG<
?BAD TIME VALUE. ONLY VALUES OF FORMAT HHH:MM ALLOWED.
>
		 RET]
	IBP	CMDBLK+.CMPTR		;BUMP PAST THE COLON
	SOS	CMDBLK+.CMINC		;AND DECREMENT BYTE COUNT
	MOVEI	T2,[FLDDB. (.CMNUM,CM%SDH,^D10,<MINUTES>)]	;NEXT FIELD MUST BE A NUMBER
	MOVEI	T1,CMDBLK		;POINT TO STATE BLOCK
	COMND
	 ERJMP [HRROI	T1,[ASCIZ/COMND JSYS ERRORS AT TMVAL:/]
		 JRST	CMDERR]		;error, go check for eof on take file
	TXNN	T1,CM%NOP		;GOOD PARSE?
	JRST	MACTYM			;YES - GO DO COMPUTATION
BADTYM:	HRROI	T1,BUFFER		;GET READY TO PRINT COMMAND IF TAKING
	SKIPE	TAKFLG			;SKIP IF NOT TAKING
	CALL	SNDMSG			;TAKING - TYPE OUT COMMAND
	RITMSG<
?BAD TIME VALUE. ONLY VALUES OF FORMAT HHH:MM ALLOWED.
>
	RET
MACTYM:	CAILE	T2,^D60			;MINUTES ARE 0-60
	JRST	BADTYM			;ERROR - TYPE MESSAGE
	MOVE	P2,T2			;SAVE THE MINUTES
	HRLZI	T1,1			;UNIVERSAL DAY 1,,0
	IDIVI	T1,^D24			; T1/^D24 GIVES UNIVERSAL HOUR	;
	IMUL	P1,T1			;NUMBER OF UNIVERSAL HOURS
	IDIVI	T1,^D60			;T1/^D60 GIVES UNIVESAL MINUTE
	IMUL	P2,T1			;NUMBER OF UNIVERSAL MINUTES
	ADD	P1,P2			;GRAND TOTAL
	SETZ	T2,			; ZERO HOURS. HERE IF NO 'HH' GIVEN
	GTAD				;GET CURRENT TIME
	ADD	T1,P1			;PUT TIME IN PROPER REG
	RETSKP
TMOUTL:	HRROI	T1,BUFFER		;GET READY TO PRINT COMMAND IF TAKING
	SKIPE	TAKFLG			;SKIP IF NOT TAKING
	CALL	SNDMSG			;TAKING - TYPE OUT COMMAND
	HRROI	T2,-1			;INDICATE THAT WE GOT NO TIME VALUE
	GTAD				;GET CURRENT TIME SINCE NO TIME ENTERED
	RETSKP
	SUBTTL SCHED - CENTRAL SCHEDULER ROUTINE
;
;ACCEPTS:	T1/FUNCTION CODE
;		T2/-1 OR  POINTER TO TEST NAME IN ASCIZ
;		T3/CYCLE SWITCH VALUE OR ZERO
;		T4/DEPTH SWITCH VALUE OR ZERO
;RETURNS:	T1/ADDRESS OF NEXT TCB BLOCK
;		T2/ADDRESS OF CURRENT BLOCK (FOR READ ONLY)
;		T3/FLAGS
SCHED:	SAVEAC	<Q1,Q2,Q3,Q3+1>
	DMOVEM	T2,Q2		;SAVE PARMS
	MOVEM	T4,Q3+1		;SAVE PARM REGS
	CAIN	T1,READ		;READ FROM TCB TABLE?
	JRST	DOREAD		;YES
	PUSH	P,T1		;SAVE T1
	MOVEI	T1,.FHSLF	;THIS NONSENSE IS BECAUSE: WE WANT TO RUN 
	MOVEI	T2,<1B<ICH027-CHNTAB>>	;DISABLED IN SCHED AND HAVE PTY'S ENABLED
	IIC			;TOPS-20 WON'T ALLOW THAT WITHOUT LOOSING
	WAIT			; SOME OF THE INTERRUPTS...SO WE RUN IN LEVEL
				; TWO WITH PTY STUFF HIGHER AND ALL ELSE LOWER
SCHINT:	DMOVE	T2,Q2		;RESTORE PARMS
	POP	P,T1
	CAIN	T1,STRMSG	;DID WE RECEIVE A START MESSAGE
	JRST	DOSTMS		;YES
	CAIN	T1,ENDMSG	;WAS IT AN END MESSAGE
	JRST	DOENMS		;YES
	CAIN	T1,ERRMSG	;WAS IT AN ERROR MESSAGE
	JRST	DOERMS		;YES
	CAIN	T1,ABORT	;SHOULD WE ABORT THE JOB
	JRST	DOABRT		;YES
	CAIN	T1,DELETE	;SHOULD WE DELETE A TCB
	JRST	DODEL		;YES
	CAIN	T1,CREATE	;SHOULD WE CREATE A TCB
	JRST	DOCREA		;YES
	CAIN	T1,MODIFY	;SHOULD WE MODIFY A TCB
	JRST	DOMOD		;YES
	CAIN	T1,STARTM	;SHOULD WE START UP ALL ENABLED TESTS
	JRST	DOSTRT		;YES
	RITMSG <
?ERROR IN UETP.EXE:BAD FUNCTION CODE AT SCHED:
>
	HALTF
	JRST	.-1
DOREAD:	CALL	FNDBLK		;GO FIND NAMED BLOCK
	JRST	ERRET		;ERROR - RETURN
	SETZ	T3,		;CLEAN THE FLAG REG
	CAMN	T2,[-1]		;IS THERE A NEXT BLOCK
	JRST	[MOVX	T3,SC%EOT	;NO - THEN FLAG THAT IT'S EOT
		 JRST	.+1]	;AND EXIT NORMALLY
	EXCH	T1,T2		;GIVE HIM NEXT BLOCK
	JRST	OKRET		;AND EXIT NORMALLY
	; ...
	;...
DOSTMS:	CALL	FNDBLK		;FIND NAMED TCB
	JRST	SCHERR		;ERROR - RETURN
	CAMN	T3,[SC%EOT]	;EOT MEANS JOB NOT FOUND
	JRST	NOJOB		;UNKNOWN JOB
	MOVE	T2,TCBSTA(T1)	;GET STATUS VECTOR
	TXZN	T2,NT%QUE	;NO LONGER QUEUED
	JRST	BADJOB		;ERROR ON THIS JUMP
	IORX	T2,NT%RUN	;SHOW STATUS IS RUNNING
	MOVEM	T2,TCBSTA(T1)	;AND SAVE
	JRST	SCHEOK		;AND EXIT NORMALLY
DOERMS:	CALL	FNDBLK		;FIND NAMED TCB
	JRST	SCHERR		;ERROR - RETURN
	CAMN	T3,[SC%EOT]	;EOT MEANS JOB NOT FOUND
	JRST	NOJOB		;UNKNOWN JOB
	AOS	TCBERR(T1)	;BUMP ERROR COUNT
	MOVE	T3,TCBSTA(T1)	;LOAD THE STATUS VECTOR
	TXO	T3,NT%ERR	;FLAG AS HAVING ERRORS
	MOVEM	T3,TCBSTA(T1)	;AND SAVE
	JRST	SCHEOK		;AND EXIT NORMALLY
DOENMS:	CALL	FNDBLK		;GET NAMED BLOCK
	JRST	SCHERR		;ERROR - RETURN
	CAMN	T3,[SC%EOT]	;EOT MEANS JOB NOT FOUND
	JRST	NOJOB		;UNKNOWN JOB
	AOS	TCBRUN(T1)	;BUMP NUMBER OF TIMES RUN COUNT
	MOVE	T2,TCBSTA(T1)	;GET MAX TIMES TO RUN
	TXNE	T2,NT%CON	;SKIP IF JOB IS NOT CONTINUOUS
	JRST	STRTJ		;YES - CONTINUOUS RUNNING
	TXNE	T2,NT%TYM	;SKIP IF NOT A TIME VALUE
	JRST	[MOVE	T3,T1	;SAVE THE TCB ADDRESS
		 GTAD		;GET CURRENT TIME AND DATE
		 EXCH	T1,T3	;EXCHANGE FOR JUMPING
		 MOVE	T2,TCBMAX(T1)	;GET THE MAX RUN TIME
		 ADD	T2,TCBTYM(T1)	;PLUS THE START TIME GIVES END TIME
		 CAMGE	T3,T2		;ARE WE PAST END TIME FOR THIS TEST
		 JRST	STRTJ	;NO - THEN START IT UP
		 JRST	ENDJ]	;YES - THEN TURN IT OFF
	TXNN	T2,NT%NUM	;ERROR IF NOT A NUMBER VALUE
	JRST	[RITMSG<
?LOGIC ERROR IN UETP.EXE AT DOENMS:, UNKNOWN BITS IN TCBSTA FOR /CYCLE: TYPE
>
		 JRST	SCHERR]	;ERROR - RETURN
	MOVE	T2,TCBMAX(T1)	;GET NUMBER OF /CYCLE:'S
	SUB	T2,TCBRUN(T1)	;<MAX ALLOWED>-<ALREADY COMPLETED>
	JUMPG	T2,STRTJ	;JUMP IF COUNT NOT EXHAUSTED
ENDJ:	MOVE	T2,TCBSTA(T1)	;RESET STATUS BIT TO SHOW IT'S ALL OVER
	TXZN	T2,NT%RUN
	JRST	BADJOB		;BAD FLAG VALUE
	TXO	T2,NT%END	;FLAG TEST AS ENDED
	MOVEM	T2,TCBSTA(T1)
	JRST	SCHEOK		;AND EXIT NORMALLY
	; ...
	;...
STRTJ:	MOVE	T2,TCBSTA(T1)	;RESET STATUS BIT TO SHOW IT'S GOING AGAIN
	TXZN	T2,NT%RUN+NT%ABR
	JRST	BADJOB		;BAD FLAG VALUE
	TXZE	T2,NT%ERR	;RESET ERROR  (ON LAST RUN) - SKIP IF NONE
	CALL	SAVLOG		;GO SAVE THE LOG FILE
	CALL	DELLOG		;DELETE THE LOG FILE
	IORX	T2,NT%QUE	;FLAG AS QUEUED AND JUST STARTED
	MOVEM	T2,TCBSTA(T1)	;AND SAVE
	MOVE	T2,T1		;MOVE THE TCB POINTER TO PARM REG
	CALL	STARTJ		;GO START THE JOB
	JRST	SCHERR		;ERROR - RETURN
	JRST	SCHEOK		;AND EXIT NORMALLY
DOABRT:	CALL	FNDBLK		;GET NAMED TCB
	JRST	SCHERR		;ERROR - RETURN
	MOVE	T2,TCBSTA(T1)	;GET THE STATUS BITS
	TDNN	T2,T4		;ABORT ONLY ABORTS SPECIFIED DEPTHS
	JRST	SCHEOK		;EXIT NORMALLY
	TXZ	T2,NT%QUE+NT%RUN+NT%END+NT%ABR+NT%ENA	;CLEAR PERTINENT BITS
	IORX	T2,NT%ABR	;SET ABORT'ED STATE
	MOVEM	T2,TCBSTA(T1)	;SAVE NEW STATUS VECTOR
	CALL	KILJOB		;GO KILL THE JOB
	JRST	SCHERR		;ERROR - RETURN
	JRST	SCHEOK		;AND EXIT NORMALLY
DODEL:	CALL	FNDBLK		;GET NAMED TCB
	JRST	SCHERR		;ERROR - RETURN
	MOVE	T2,TCBSTA(T1)	;IS JOB ENABLED
	TDNN	T2,T4		;DELETE ONLY DELETES SPECIFIED DEPTHS
	JRST	SCHEOK		;EXIT NORMALLY
	TXNN	T2,NT%ENA+NT%ABRT+NT%END	;IS IT?
	JRST	[RITMSG<
?ONLY ENDED,ENABLED AND/OR ABORTED TESTS CAN BE DISABLED
>
	 	JRST	SCHERR]	;ERROR - RETURN
	CALL	FREBLK			;GO FRE THE BLOCK
	JRST	SCHEOK		;AND EXIT NORMALLY
DOCREA:	CALL	FNDBLK		;GO SEE IF WE ALREADY HAVE ONE
	JRST	SCHERR		;ERROR - RETURN
	TXNN	T3,SC%EOT	;END OF TABLE MEANS IT WASN'T THERE
	JRST	[MOVE	T2,T1		;SAVE THE NAME ADDRESS
		 RITMSG<
?>					;THIS IS AN ERROR MSG
		 HRRO	T1,T2		;WRITE OUT OFFENDING NAME
		 CALL	SNDMSG
		 RITMSG< IS ALREADY ENABLED.>
		 JRST	SCHERR]
	CALL	GETBLK		;GET AN EMPTY TCB
	MOVE	T4,T1		;SAVE THE ADDRESS
	MOVE	T1,(Q3)		;GET THE VALUE FOR /CYCLE:
	MOVEM	T1,TCBMAX(T4)	;SET THE MAX NUMBER OF RUNS
	SETZM	TCBTYM(T4)	;CLEAN OUT START TIME
	OR	Q3+1,1(Q3)	;NOW MERGE THE FLAG BITS
	IORX	Q3+1,NT%ENA	;FLAG AS ENABLED
	MOVEM	Q3+1,TCBSTA(T4)	;SET THE DEPTH OF THIS RUN
	HLRM	Q2,TCBDEP(T4)	;SAVE ALL AVAILABLE DEPTH FLAGS
	MOVNI	T3,6		;NOW MOVE THE NAME STRING
	HRROI	T1,TCBNAM(T4)	;WHERE NAME IS TO GO
	HRRO	T2,Q2		;NAME POINTER
	SOUT
	 ERJMP [ERRSND<UNEXPECTED SOUT ERROR AT DOCREA:>
		 HALT
		 JRST	.-1]
	MOVE	T1,T4		;POINT TO BLOCK FOR RETURN
	JRST	SCHEOK		;AND EXIT NORMALLY
	; ...
	;...
DOMOD:	CALL	FNDBLK		;GET NAMED BLOCK
	JRST	SCHERR		;ERROR - RETURN
	MOVE	T2,TCBSTA(T1)	;GET STATUS BITS
	AND	T2,[-1-<NT%SUP+NT%INT+NT%MAX>]
	OR	T2,Q3+1		;SET THE NEW BITS
	SKIPE	Q3+1		;ZERO MEANS NO CHANGE
	MOVEM	T2,TCBSTA(T1)	;SAVE THE BITS
	JUMPE	Q3,DOMRET	;JUMP TO RETURN IF NO /CYCLE CHANGE
	MOVE	T2,(Q3)		;GET NEW /CYCLE VALUE
	MOVEM	T2,TCBMAX(T1)	;AND INTO CONTROL BLOCK
	MOVE	T2,TCBSTA(T1)	;NOW GET  THE STATUS BITS
	AND	T2,[-1-<NT%CON+NT%TYM+NT%NUM>] ;AND CLEAN OUT/CYCLETYPE
	OR	T2,1(Q3)	;NOW BRING IN NEW /CYCLE TYPE
	MOVEM	T2,TCBSTA(T1)	;AND SAVE IT
DOMRET:	JRST	SCHEOK		;AND EXIT NORMALLY
DOSTRT:	MOVEM	T2,STRTIM	;SAVE RUN START TIME
	HRROI	T2,-1		;START ALL JOBS - GET FIRST
DOSTLP:	CALL	FNDBLK
	JRST	SCHERR		;ERROR - RETURN
	CAMN	T2,[-1]		;ARE WE AT END OF TABLE
	JRST	SCHEOK		;AND EXIT NORMALLY
	MOVE	T1,TCBSTA(T2)	;GET STATUS VECTOR
	TXZN	T1,NT%ENA+NT%ABR	;DOUBLE CHECK THAT IT'S ENABLED OR ABORTED
	JRST	DOSTLP		;MUST HAVE BEEN MUNGED BEFORE
	IORX	T1,NT%QUE	;SHOW HE IS RUNNING
	MOVEM	T1,TCBSTA(T2)	;RESET THE STATUS VECTOR
	MOVE	T1,STRTIM	;WE WANT TO STAMP THE START TIME
	MOVEM	T1,TCBTYM(T2)	;AND INTO THE TCB
	CALL	STARTJ
	JRST	[RITMSG<
?ERROR IN STARTING BATCH JOB :>
		 HRROI	T1,TCBNAM(T2)	;POINT TO BAD NAME
		 CALL	SNDMSG		;WRITE IT OUT
		 MOVE	T1,TCBSTA(T2)	;CHANGE STATUS TO  NT%ABR
		 TXZ	T1,NT%QUE	;TURN OFF QUEUED BIT
		 IORX	T1,NT%ABR	;AND SHOW HE'S ABORTED
		 MOVEM	T1,TCBSTA(T2)	;AND PUT IT AWAY
		 JRST	.+1]
	JRST	DOSTLP			;KEEP STARTING THEM
BADJOB:	MOVE	T4,T1			;SAVE TCB POINTER
	RITMSG<
%ERROR IN IPCF TRAFFIC. UNRECOGNISED STATE OF JOB : >
	HRROI	T1,TCBNAM(T4)		;POINT TO UNKNOWN STATE OF JOB
	CALL	SNDMSG			;SHIP OUT THE NAME
	HRROI	T1,[ASCIZ/
/]
	CALL	SNDMSG
	JRST	SCHERR		;ERROR - RETURN
NOJOB:	RITMSG<
%ERROR IN IPCF TRAFFIC. UNRECOGNISED JOB : >
	MOVE	T1,Q2			;GET POINTER TO NAME OF UNKNOWN JOB
	CALL	SNDMSG			;SHIP OUT THE NAME
	HRROI	T1,[ASCIZ/
/]
	CALL	SNDMSG
	JRST	SCHERR			;ERROR - RETURN
SCHERR:	MOVEI	Q1,ERRET		;POINT TO ERROR DEBRK EXIT
	MOVEM	Q1,RETPC2		;RESET RETURN ADDRESS
	DEBRK				;RETURN TO PREVIOUS LEVEL AND RETURN

SCHEOK:	MOVEI	Q1,OKRET		;POINT TO ERROR DEBRK EXIT
	MOVEM	Q1,RETPC2		;RESET RETURN ADDRESS
	DEBRK				;RETURN TO PREVIOUS LEVEL AND RETURN
ERRET:	RET			;ERROR RETURN AFTER THE DEBRK
OKRET:	RETSKP			;NORMAL RETURN AFTER THE DEBRK
		SUBTTL  SCHED SUBROUTINES
;ACCEPTS:	T1/ADDRESS OF TCB WHOSE LOG IS TO BE DELETED
;RETURNS:	+1,ALWAYS
;
DELLOG:	SAVEAC	<T1,T2,T3>
	HRROI	T1,DELBUF		;POINT TO WHERE WE'LL BUILD FILE SPEC
	HRROI	T2,TNAME		;PUT THE  NAME IN THERE
	SETZ	T3,			;TEST NAME ENDS IN NULL
	SOUT				;PUT INTO WORK AREA
	 ERJMP	[ERRSND<PROBLEMS WITH SOUT JSYS AT DELLOG:>
		 RET]
	HRROI	T2,[ASCIZ/.LOG/]	;WE WILL DELETE LOG FILES
	SETZ	T3,			;MOVE ALL THE BYTES
	SOUT
	 ERJMP	[ERRSND<PROBLEMS WITH SECOND SOUT AT DELLOG:>
		 RET]
	MOVE	T1,[GJ%OLD+GJ%SHT]	;GET SHORT FILE JFN
	HRROI	T2,DELBUF		;POINT TO FILE SPEC
	GTJFN
	 RET				;ERROR - JUST RETURN
	HRRZ	T1,T1			;DELETE
	DELF
	 JRST	.+1
	HRROI	T1,-1			;GET OUR DIRECTORY NUMBER
	MOVE	T2,[-1,,T4]		; TO EXPUNGE IT
	MOVEI	T3,.JIDNO		;TAKE ONE WORD ONLY
	GETJI
	 JRST	[ERRSND<ERROR WITH GETJI AT DELLOG:>
		 RET]
	MOVE	T2,T4			;GET THE DIRECTORY NUMBER
	SETZM	T1			;DELETE FILES
	DELDF
	 ERJMP	[ERRSND<ERROR WITH DELDF AT DELLOG:>
		 RET]
	RET
;ACCEPTS:	T1/ADDRESS OF ASCII NAME STRING
;RETURNS:	T1/ADDRESS OF TCB FOR NAMED STRING
;		T2/ADDRESS OF NEXT TCB IN LIST
;
FNDBLK:	SAVEAC	<T4,Q1,Q2>
	MOVEI	T3,STRTCB-TCBSIZ	;POINT TO START OF TCB TABLE
	MOVE	T4,[POINT 1,BITTCB]	;POINT TO START OF BIT TABLE FOR TCB
	CAMN	T2,[-1]			;FIRST BLOCK REQUEST
	JRST	[CALL	NXTBLK		;YES - GO GET IT
		 EXCH	T1,T2		;SWAP NEXT AND CURRENT BLOCK VALUES
		 RETSKP]		;NORMAL RETURN
	MOVE	Q1,T2			;NO - SAVE THE NAME ADDRESS
FNDNXT:	CALL	NXTBLK			;GET NEXT TCB
	CAMN	T1,[-1]			;ARE WE AT END OF TABLE
	JRST	[MOVX	T3,SC%EOT	;YES - SHOW JOB NOT FOUND
		 RETSKP]		;AND GIVE AN ERROR RETURN
	MOVE	Q2,T1			;SAVE ADDRESS OF BLOCK JUST GOTTEN
	HRRO	T1,T1			;DROP FLAGS AND MAKE INTO POINTER
	HRRO	T2,Q1			;GET STRING WE'RE TRYING TO FIND
	STCMP				;COMPARE THE STRINGS
	JUMPN	T1,FNDNXT		;JUMP IS THEY ARE NOT EQUAL
	MOVE	T2,Q2			;BLOCK WE GOT IS PARAMETER FOR NEXT
	CALL	NXTBLK			;AND GET THE ONE AFTER
	EXCH	T1,T2			;T1/THIS BLOCK; T2/NEXT BLOCK (OR -1)
	SETZ	T3,			;ZERO OUT THE FLAG REG
	RETSKP

NXTBLK:	MOVEI	T3,TCBSIZ(T3)		;POINT TO NEXT BLOCK
	CAIGE	T3,ENDTCB		;ARE WE AT END OF TABLE?
	JRST	NXTINC			;NO - KEEP LOOKING
	HRROI	T1,-1			;YES - SHOW THAT WE'RE AT END
	RET				;NORMAL RETURN
NXTINC:	ILDB	T1,T4			;GET NEXT BIT FROM BIT TABLE
	JUMPE	T1,NXTBLK		;ZERO MEANS BLOCK NOT IN USE
	MOVE	T1,T3			;FOUND A BLOCK - PUT ADDRESS IN T1
	RET				;NORMAL - RETURN
FREBLK:	CAIGE	T1,STRTCB		;VERIFY THE ADDRESS
	JRST	[RITMSG<
?LOGIC ERROR IN UETP.EXE, INCORRECT TCB ADDRESS AT FREBLK:
>
		 HALTF
		 JRST	.-1]
	CAIL	T1,ENDTCB		;VERIFY UPPER BOUND
	JRST	[ERRSND<BAD TCB ADDRESS AT FREBLK:>
		 HALTF
		 JRST	.-1]
	SUBI	T1,STRTCB		;PTR-START ADD = OFFSET
	IDIVI	T1,TCBSIZ		;COMPUTE BLOCK NUMBER OFFSET
	ADJBP	T1,[POINT 1,BITTCB,0]	;INDEX INTO CORE BIT TABLE
	SETZ	T2,			;SET TO ZERO THE BIT
	DPB	T2,T1			;ZERO THE BIT
	RET
;
;GETBLK ROUTINE
;
GETBLK:	SAVEAC <T2,T3>
	MOVE	T1,[POINT 1,BITTCB,0]	;LOOK THRU BIT TABLE FOR A ZERO BIT
	MOVE	T2,[POINT 1,<BITTCB+<<<CORSIZ/TCBSIZ>/^D36>>>,35] ;SEARCH TO END
	SETZ	T3,			;CLEAN THE BYTE  REG
	LDB	T3,T1			;GET A BIT
	JUMPE	T3,FNDTCB		;BIT IS OFF - GO HANDLE
	IBP	T1			;BUMP TO NEXT BIT
	CAME	T1,T2			;ARE WE AT END
	JRST	.-4			;NO - KEEP LOOKING
	RITMSG	<
?LOGIC ERROR IN UETP.EXE CORE TABLE FULL. AT GETBLK:
>
	RET
FNDTCB:	MOVEI	T3,-1			;SET THE BIT TO ONE
	DPB	T3,T1			;BLOCK NOW TAKEN
	HRRZ	T2,T1			;ISOLATE THE WORD ADDRESS
	SUBI	T2,BITTCB		;COMPUTE WORD OFFSET
	IMULI	T2,^D36			;COMPUTE BIT OFFSET
	LSH	T1,^D-30		;GET BITS INTO THIS WORD
	MOVEI	T3,^D35			;SUBTRACT BYTE POINT P FROM MAX SIZE
	SUB	T3,T1			;TO CALCULATE NUMBER BITS INTO WORD
	ADD	T3,T2			;BIT OFFSET FOR THIS BLOCK
	IMULI	T3,TCBSIZ		;BLOCK OFFSET FOR THIS BLOCK
	MOVEI	T1,STRTCB(T3)		;MOVE TO PARM REG
	SETZM	(T1)			;NOW ZERO OUT THE NEW BLOCK
	HRL	T2,T1
	HRRI	T2,1(T1)
	BLT	T2,TCBSIZ-1(T1)		;ZERO TO LAST WORD
	RET				;AND RETURN
 SUBTTL	SAVLOG	-	ROUTINE TO RENAME LOG FILE
;
;RETURNS	+1,ALWAYS
;
SAVLOG:	SAVEAC <T1,T2,T3,T4,Q1,Q2>
	HRROI	T1,DELBUF		;POINT TO WHERE WE'LL BUILD FILE SPEC
	HRROI	T2,[ASCIZ/APPEND /]	;PUT THE  NAME IN THERE
	SETZ	T3,			;TEST NAME ENDS IN NULL
	SOUT				;PUT INTO WORK AREA
	 ERJMP	[ERRSND<PROBLEMS WITH SOUT JSYS AT SAVLOG:>
		 RET]
	HRROI	T2,TNAME		;PUT THE  NAME IN THERE
	SETZ	T3,			;TEST NAME ENDS IN NULL
	SOUT				;PUT INTO WORK AREA
	 ERJMP	[ERRSND<PROBLEMS WITH SOUT JSYS AT SAVLOG:>
		 RET]
	HRROI	T2,[ASCIZ/.LOG   /]	;WE WILL RENAME LOG FILES
	SETZ	T3,			;MOVE ALL THE BYTES
	SOUT
	 ERJMP	[ERRSND<PROBLEMS WITH SECOND SOUT AT SAVLOG:>
		 RET]
	HRROI	T2,TNAME		;PUT THE  NAME IN THERE
	SETZ	T3,			;TEST NAME ENDS IN NULL
	SOUT				;PUT INTO WORK AREA
	 ERJMP	[ERRSND<PROBLEMS WITH SOUT JSYS AT SAVLOG:>
		 RET]
	HRROI	T2,[ASCIZ/.ERRORS-LOG/]	;WE WILL SAVE LOGS WITH ERRORS
	SETZ	T3,			;MOVE ALL THE BYTES
	SOUT
	 ERJMP	[ERRSND<PROBLEMS WITH SECOND SOUT AT SAVLOG:>
		 RET]
	HRROI	T1,DELBUF		;HAVE EXEC COPY THE FILE
	CALL	XEQEXC
	RET
	RET
  SUBTTL	STATUS - ROUTINE TO PRINT OUT CURRENT STATUS
;
;RETURNS:	+1,ERROR
;		+2,OTHERWISE
STATUS:	SAVEAC<T1,T2,T3,T4,Q1,Q2>
	MOVX	T1,.FHSLF		;NO INTERRUPTIONS WHILE WE'RE DOING THIS
	DIR				;DISABLE THE INTERRUPT SYSTEM
	RITMSG<
>					;SPACE THE TERMINAL
	MOVE	T1,[POINT 7,WRKBUF]	;POINT TO WHERE DATE AND TIME WILL GO
	MOVEI	T3,"["			;BRACKET THE TIME AND DATE
	IDPB	T3,T1
	HRROI	T2,-1			;CURRENT DATE AND TIME
	ODTIM
	MOVEI	T3,"]"			;BRACKET THE TIME AND DATE
	IDPB	T3,T1
	MOVEI	T3,15			;PUT A CR INTO STRING
	IDPB	T3,T1
	MOVEI	T3,12			;AND A LINE FEED
	IDPB	T3,T1
	SETZ	T3,
	IDPB	T3,T1
	HRROI	T1,WRKBUF		;NOW WRITE OUT THE STRING
	CALL	SNDMSG
	RITMSG <    TEST  NAME   STATUS  TIMES TO  TIMES  ERROR     START
>
	RITMSG <    (FILE NAME)          BE RUN    RUN    COUNT     TIME
>
	RITMSG <    ===========  ======= ========  =====  ======  ========
>
	; ...
	;...
	HRROI	T2,-1			;TELL SCHED WE WANT HIS FIRST NAME
STLOOP:	MOVEI	T1,READ			;WE WANT TO READ THE TABLE
	CALL	SCHED			;GO GET NEXT ENABLED NAME
	JRST	ERROUT			;GO TAKE ERROR EXIT
	TXNE	T3,SC%EOT		;ARE WE AT END OF TABLE
	JRST	OKOUT			;GO TAKE NORMAL EXIT
	MOVE	Q2,T1			;PLACE IN BASE FOR FUTURE USE
	MOVE	T1,[ASCII/     /]
	MOVEM	T1,WRKBUF		;FILL WRKBUF WITH BLANKS
	MOVE	T1,[WRKBUF,,WRKBUF+1]
	BLT	T1,WRKBUF+<WRKSIZ-1>
	MOVEI	T1,^D4			;START LINE IN COLUMN 5
	ADJBP	T1,[POINT 7,WRKBUF]	;AND CREATE THE BYTE POINTER
	HRROI	T2,TCBNAM(Q2)		;POINT TO NAME
	SETZ	T3,			;MOVE WHOLE NAME INTO BUFFER
	SOUT				;MOVE THEM
	 ERJMP	[ERRSND <ERROR AT LABEL STLOOP. ERROR WITH SOUT>
		 JRST	ERROUT]
	MOVEI	T4," "			;SOUT MOVES THE NULL WE WILL OVERLAY IT
	MOVE	T2,T1			;MUST SAVE T1 FOR FUTURE SOUT'ING
	IDPB	T4,T2			;MAKE IT A BLANK
	MOVE	T4,TCBSTA(Q2)		;GET STATE VECTOR
	HRROI	T2,[ASCIZ/.SUP/]	;ADD DEPTH INDICATOR TO NAME
	TXNE	T4,NT%SUP		;SUPERFICIAL DEPTH?
	JRST	STSOUT			;YES - ADD TO BUFFER
	HRROI	T2,[ASCIZ/.INT/]	;MAYBE INTERMEDIATE
	TXNE	T4,NT%INT
	JRST	STSOUT			;YES - THEN OUTPUT
	HRROI	T2,[ASCIZ/.MAX/]	;MUST BE MAXIMUM DEPTH
	TXNE	T4,NT%MAX
	JRST	STSOUT			;YES - WRITE IT OUT
	RITMSG <
?LOGIC ERROR IN UETP.EXE:UNKNOWN STATE OF ENABLED ENTRY (AT STSOUT:)
>					;ERROR - DROPS THRU HERE
	HRROI	T2,[ASCIZ/.UNKNOWN/]
	; ...
	;...
STSOUT:	SETZ	T3,			;WRITE WHOLE LINE
	SOUT
	 ERJMP [ERRSND <UNEXPECTED ERRO IN SOUT AT STSOUT>
		 JRST	ERROUT]
	MOVEI	T3," "			;SOUT MOVES THE NULL WE WILL OVERLAY IT
	MOVE	T2,T1			;WE'LL NEED THE ORIGINAL POINTER
	IDPB	T3,T2			;MAKE IT A BLANK
	HRROI	T2,[ASCIZ/QUEUED/]	;THIS NAME IF HE IS QUEUED
	TXNE	T4,NT%QUE		;IS FLAG ON
	JRST	STSTAT			;YES - THEN PLACE THIS IN BUFFER
	HRROI	T2,[ASCIZ/RUNNING/]
	TXNE	T4,NT%RUN		;IS JOB RUNNING
	JRST	STSTAT			;YES - MOVE TO BUFFER
	HRROI	T2,[ASCIZ/ENDED/]
	TXNE	T4,NT%END		;IS IT DONE
	JRST	STSTAT			;YES - THEN MOVE INTO BUFFER
	HRROI	T2,[ASCIZ/ABORTED/]
	TXNE	T4,NT%ABR		;WAS IT ABORTED
	JRST	STSTAT			;YES - THEN ABORT MSG INTO BUFFER
	HRROI	T2,[ASCIZ/ENABLED/]
	TXNE	T4,NT%ENA		;IS IT JUST ENABLED
	JRST	STSTAT			;YES - PLACE IN BUFFER
	RITMSG<
?LOGIC ERROR IN UETP.EXE AT LABEL STSTAT:. STATUS BITS IN TCB WRONG.
>
	HRROI	T2,[ASCIZ/UNKNOWN/]
	; ...
	;...
STSTAT:	MOVEI	T1,^D17			;STARTING COLUMNS IN WRKBUF
	ADJBP	T1,[POINT 7,WRKBUF]	;WHERE TO STORE FIELD
	SETZ	T3,			;SETTING UP FOR A SOUT LATER
	SOUT				;WRITE THE STUFF OUT
	 ERJMP	[ERRSND <ERROR AT LABEL STSTAT. SOUT ERROR.>
		JRST	ERROUT]
	MOVEI	T4," "			;SOUT MOVES THE NULL WE WILL OVERLAY IT
	IDPB	T4,T1			;MAKE IT A BLANK
	MOVE	T2,TCBMAX(Q2)		;NOW FOR THE /CYCLE FIELD
	CAME	T2,[-1]			;-1 MEANS CONTINUOUS
	JRST	TYMNUM			;MAYBE IT'S A TIME VALUE OR COUNT
	HRROI	T2,[ASCIZ/CONTIN/]
	MOVEI	T1,^D26			;STARTING COLUMNS IN WRKBUF
	ADJBP	T1,[POINT 7,WRKBUF]	;WHERE TO STORE FIELD
	SOUT
	 ERJMP	[ERRSND<UNEXPCTED ERROR WITH SOUT AT TYMNUM:>
		 JRST	ERROUT]
	MOVEI	T4," "			;SOUT MOVES THE NULL WE WILL OVERLAY IT
	IDPB	T4,T1			;MAKE IT A BLANK
	JRST	STRUN			;GO FIX-UP  TIMES ALREADY RUN
TYMNUM:	MOVE	T1,TCBSTA(Q2)			;MAYBE IT'S A TIME FIELD
	TXNN	T1,NT%TYM		;SKIP IF TIME VALUE
	JRST	STANUM			;NO - THEN MUST BE NUMBER
	MOVE	T2,TCBMAX(Q2)		;GET THE TIME VALUE
	IDIV	T2,[<1,,0>/<^D24>]		;CALCULATE # OF HOURS (TRUNC MINUTES)
	MOVE	T4,T3			;SAVE THE REMAINDER (MINUTES)
	MOVEI	T1,^D27			;STARTING COLUMNS IN WRKBUF
	ADJBP	T1,[POINT 7,WRKBUF]	;WHERE TO STORE FIELD
	MOVE	T3,[NO%LFL+NO%AST+<FLD (3,NO%COL)>!^D10]	;3 COLUMSN BASE 10
	NOUT				;PUT IN BUFFER
	 ERJMP	[ERRSND<ERROR IN NOUT IN TYMNUM>
		 JRST	ERROUT]
	MOVEI	T2,":"			;COLON FOR SEPRATOR (HHH:MM)
	IDPB	T2,T1			;AND SAVE IT
	MOVE	T2,T4			;T4 HAD REMIAINDER FROM LAST IDIV (:MM)
	IDIV	T2,[<<1,,0>/<^D24>>/<^D60>]	;ACTUAL NUMBER OF MINUTES
	MOVE	T3,[NO%ZRO+NO%LFL+NO%AST+<FLD (2,NO%COL)>!^D10]	;TWO COLS BASE 10 MINUTES
	NOUT
	 ERJMP	[ERRSND<UNEXPECTED ERROR WITH NOUT JSYS AT TYMNUM>
		 JRST	ERROUT]
	MOVEI	T4," "			;SOUT MOVES THE NULL WE WILL OVERLAY IT
	MOVE	T2,T1			;MUST SAVE T1 FOR FUTURE SOUT'ING
	IDPB	T4,T2			;MAKE IT A BLANK
	JRST	STRUN			;CONTINUE
	; ...
	;...
STANUM:	TXNN	T1,NT%NUM		;WAS IT REALLY A NUMBER
	JRST	[RITMSG<
?LOGIC ERROR IN STATUS ROUTINE AT STANUM: (IN UETP.EXE).
>
		 JRST	ERROUT]
	MOVEI	T1,^D27			;STARTING COLUMNS IN WRKBUF
	ADJBP	T1,[POINT 7,WRKBUF]	;WHERE TO STORE FIELD
	MOVE	T2,TCBMAX(Q2)		;NUMBER OF TIMES TO RUN
	MOVE	T3,[NO%AST+NO%LFL+<6,,0>+^D10]	;FILL WITH *'S IF OVERFLOW
	NOUT					;OUTPUT CYLCE COUNT
	 ERJMP	[ERRSND<BEFORE LABEL STRUN. ERROR IN NOUT.>
		 JRST	STRUN]			;GO PROCESS RUN MSG
	MOVEI	T4," "			;SOUT MOVES THE NULL WE WILL OVERLAY IT
	MOVE	T2,T1			;MUST SAVE T1 FOR FUTURE SOUT'ING
	IDPB	T4,T2			;MAKE IT A BLANK
STRUN:	MOVE	T2,TCBRUN(Q2)			;GET NUMBER OF RUNS 
	MOVEI	T1,^D34			;STARTING COLUMNS IN WRKBUF
	ADJBP	T1,[POINT 7,WRKBUF]	;WHERE TO STORE FIELD
	MOVE	T3,[NO%AST+NO%LFL+<6,,0>+^D10]	;FILL WITH *'S IF OVERFLOW
	NOUT					;OUTPUT CYLCE COUNT
	 ERJMP	[ERRSND<JUST AFTER LABEL STRUN. ERROR IN NOUT.>
		 JRST	STRUN]			;GO PROCESS RUN MSG
	MOVEI	T4," "			;SOUT MOVES THE NULL WE WILL OVERLAY IT
	MOVE	T2,T1			;MUST SAVE T1 FOR FUTURE SOUT'ING
	IDPB	T4,T2			;MAKE IT A BLANK
	MOVE	T2,TCBERR(Q2)			;GET NUMBER OF ERRORS 
	MOVEI	T1,^D42			;STARTING COLUMNS IN WRKBUF
	ADJBP	T1,[POINT 7,WRKBUF]	;WHERE TO STORE FIELD
	MOVE	T3,[NO%AST+NO%LFL+<6,,0>+^D10]	;FILL WITH *'S IF OVERFLOW
	NOUT					;OUTPUT CYLCE COUNT
	 ERJMP	[ERRSND<JUST AFTER LABEL STRUN. ERROR IN NOUT.>
		 JRST	STRUN]			;GO PROCESS RUN MSG
	MOVEI	T4," "			;SOUT MOVES THE NULL WE WILL OVERLAY IT
	MOVE	T2,T1			;MUST SAVE T1 FOR FUTURE SOUT'ING
	IDPB	T4,T2			;MAKE IT A BLANK
	MOVEI	T1,^D50			;ADD CR/LF AND NULL
	ADJBP	T1,[POINT 7,WRKBUF]	;POINT TO THE SLOT
	MOVE	T2,TCBTYM(Q2)		;PUT OUT THE START TIME
	JUMPE	T2,STCRLF		;NO OUTPUT IF ZERO TIME
	SETZ	T3,
	ODTIM
	 ERJMP	[ERRSND<ODTIM ERROR AT STSTAT:>
		 JRST	ERROUT]
STCRLF:	MOVEI	T1,^D68			;ADD CR/LF AND NULL
	ADJBP	T1,[POINT 7,WRKBUF]	;POINT TO THE SLOT
	HRROI	T2,[ASCIZ/
/]
	SETZ	T3,			;MOVE WHOLE STRING
	SOUT
	 ERJMP	[ERRSND<SOUT ERROR AT STSTAT:>
		 JRST	ERROUT]
	HRROI	T1,WRKBUF		;POINT TO BUILT LINE
	CALL	SNDMSG			;OUTPUT THE BUFFER WE BUILT
	MOVE	T2,Q2			;PARAMTER FOR SCHED (ADD OF BLOK)
	JRST	STLOOP			;GET NEXT ITEM ON TABLE
ERROUT:	MOVX	T1,.FHSLF		;MUST TURN INTERRUPT SYSTEM ON
	EIR