Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-03 - decus/20-0078/comp/t3.mac
There is 1 other file named t3.mac in the archive. Click here to see a list.
;<ENDERIN>T3.MAC.32,  5-Jan-77 14:02:15, Edit by ENDERIN
	SUBTTL	Terminate compilation
	SEARCH SIMMAC
	SALL

	CTITLE	T3

COMMENT ;

AUTHORS:	ELISABETH ALUND 
		OLOF BJORNER
		Lars Enderin (DEC-20 modifications) [225]

VERSION:	4 [1,6,12,22,104,162,204,225,246,260]

PURPOSES:	1.  To delete temporary files
		2.  To close output files	[162]
		3.  To type error messages on the TTY
		4.  To handle aborts from all three passes
		5.  To fetch next command line and switch to Pass 1
		    when appropriate.

CONTENTS:	SUBROUTINES:

;
INTERN	T3A	;FOR DELETION OF nnnATR.TMP
	EDIT(225)
TOPS10,<;[225]
INTERN	T3CHAR	;FOR FETCHING NEXT BYTE FROM COMMAND
>
INTERN	T3MOVE	;FOR MOVING COMMAND LINES FROM COMMAND BUFFER
INTERN	T3NAME	;FOR PACKING NEXT FILE SPECIFICATION PART IN SIXBIT
INTERN	T3E	;FOR CREATING STATISTICAL INFORMATION OF ERRORS
INTERN	T3I	;FOR DELETION OF IC2 and closing REL file
INTERN	T3L	;CORRESPONDING FOR LST-FILE
INTERN	T3T	;ROUTINE FOR ABORTS IN PASS 1 AND 2
INTERN	T3T3	;ROUTINE FOR ABORT IN PASS 3
INTERN	T3R	;Close REL file without superseding an old REL file
INTERN	T3REE	;HANDLE ^C REENTER
INTERN	T3X	;DELETE XRF.TMP
INTERN	T3	;Main routine

			EDIT(104)
	SEARCH SIMMC3	;[104]
	TWOSEG
	RELOC	400000
	MACINIT
	P3INIT	;[104]
	SYN	YPOLST,YPOLS3
;	EXTERNAL SUBROUTINES

	EXTERN	E3BD	;CONVERT FROM BIN TO ASCII
	EXTERN	E3DM	;SORT ZDM
	EXTERN	E3EM	;CREATE ERROR MESSAGE
	EXTERN	O3ERR	;READ ERROR TABLES INTO CORE
	EXTERN	O3WS	;WRITE LS3


	EXTERN	.JBERR	;ERROR COUNT
			EDIT(6)
	EXTERN	YBHREL	;[6] Buffer header for REL file
	EXTERN	YSWITCH	;WORD CONTAINING SWITCHES
	EXTERN	YSWCHA	;SIWTCHES CHANGED FROM DEFAULT
	EXTERN	YSWDEF	;DEFAULT VALUES OF SWITCHES
	EXTERN	YE3ERR	;;BUFFER FOR ERROR MESSAGE
	EXTERN	Y1LOWE
	EXTERN	Y3OPEN	;SWITCHES CONTAINING STATUS OF FILES
	EXTERN	Y3ENTRY	;[6] Entry point name for global class/proc
	EXTERN	YEXTS	;RENAME ARGUMENT REL AND LST FILE
	EXTERN	YESEM
	EXTERN	YWARCT	;NUMBER OF WARNINGS
	EXTERN	YERRCT	;NUMBER OF ERRORS
	EXTERN	Y3BUF	;BUFFER FOR INTERMEDIATE DATA
	EXTERN	Y3SWAP	;SWITCH AREA IN LOW SEGMENT
	EXTERN	YDMEND	;INDEX TO FIRST FREE ELEMENT IN ZDM
	EXTERN	YI1CB	;COMMAND LINE BUFFER
	EXTERN	YI1CBE	;END OF COMMAND LINE BUFFER
	EXTERN	YCBBH	;COMMAND BUFFER HEADER
	EXTERN	YCBUF	;COMMAND BUFFER


	X3BYTE==X10
	XT3P==X11
	XT3IND==X12
	SUBTTL	 T3, LOCAL MACROS

Comment*
	DELETE macro
	------------
	PURPOSE:
		DEBUG VERSION: CLOSE FILE
		PRODUCT VERSION: DELETE FILE
*

DEFINE	DELETE(FILE)<
	EXTERN	YEL'FILE
	IF
		SKIPN	YEL'FILE
		GOTO	FALSE
	THEN
	IFG QDEBUG,<
		CLOSE	QCH'FILE,
		STATZ	QCH'FILE,740K
		GOTO	[IOER	FILE
			ERRT	QT,Q.TER+5
			BRANCH	T3T3]
		>
	IFE QDEBUG,<
		SETZM	YEL'FILE
		RENAME	QCH'FILE,YEL'FILE
		GOTO	[IOER	FILE
			ERRT	QT,Q.TER+6
			BRANCH	T3T3]
		>
		SETOFF	YOP'FILE
		RELEASE	QCH'FILE,
	FI
>

DEFINE	IOER(FILE)<
	L	X1,[ASCIZ/FILE/]>

	;CLOSE FILE

				EDIT(162)
DEFINE	KLOSE(FILE,OPT)<
	CLOSE	QCH'FILE,OPT;;[162] Close option bits
	STATZ	QCH'FILE,740K
	GOTO	[IOER	FILE
		ERRT	QT,Q.TER+5
		BRANCH	T3T3]
	SETOFF	YOP'FILE
	RELEASE	QCH'FILE,
>

	;DELETE ALL TMP FILES IF IN DEBUG MODE, OTHERWISE CLOSE FILES

DEFINE	IRPDELETE(FILE)<
IRP FILE,<
IFE QDEBUG,<
	EXTERN	YEL'FILE
	IF
		IFOFF	YPO'FILE
		GOTO	FALSE
	THEN
		LOOKUP	QCH'FILE,YEL'FILE
		NOP	;NO MORE ERRORS
		SETOFF	YPO'FILE
	FI
	IF	IFOFF	YOP'FILE
		GOTO	FALSE
	THEN
		SETZM	YEL'FILE
		RENAME	QCH'FILE,YEL'FILE
		NOP
		SETOFF	YOP'FILE
		RELEASE	QCH'FILE,
	FI
	>
IFG QDEBUG,<
	IF
		IFON	YPO'FILE
		GOTO	FALSE
		IFOFF	YOP'FILE
		GOTO	FALSE
	THEN
		CLOSE	QCH'FILE,
		RELEASE	QCH'FILE,
	FI
	SETOFF	YPO'FILE
	SETOFF	YOP'FILE
	>
>
>

	;[162] NEWNAM macro not needed any more
	SUBTTL	LOCAL DATA AREAS


;NOTE THAT THE ORDER IS SIGNIFICANT

T3DEFA:	ASCII	/

DEFAULT SWITCHES USED
/
T3CHA:	ASCII	/

SWITCHES CHANGED FROM DEFAULT:

/
T3NO:	ASCII	/NO /
T3SWA:	ASCII	/CHECK OF ARRAY INDEX
/
T3SWD:	ASCII	/SYMBOL TABLE GENERATED FOR DEBUG
/
T3SWE:	ASCII	?EXTERNAL CLASS/PROCEDURE
?
T3SWI:	ASCII	/LINENUMBER TABLE GENERATED
/
T3SWQ:	ASCII	/CHECK OF QUALIFICATION
/
T3SWR:	ASCII	/RUNSWITCHES PRESENT
/
T3SWW:	ASCII	/WARNINGS GENERATED
/
T3SWS:	ASCII	/Non-standard search list
/	;[12]
	EDIT(12)
T3SEND:

T3SW:	;TABLE CONTAINING ADDRESS AND LENGTH OF TEXT FOR EACH SWITCH
	XWD	5*<T3SWD-T3SWA>,T3SWA
	XWD	5*<T3SWE-T3SWD>,T3SWD
	XWD	5*<T3SWI-T3SWE>,T3SWE
	XWD	5*<T3SWQ-T3SWI>,T3SWI
	XWD	5*<T3SWR-T3SWQ>,T3SWQ
	XWD	5*<T3SWW-T3SWR>,T3SWR
	XWD	5*<T3SWS-T3SWW>,T3SWW
	XWD	5*<T3SEND-T3SWS>,T3SWS	;[12]
T3SWCH:
	;TABLE  CONTAINING SWITCHES
	ASCII	/   A /
	ASCII	/   D /
	ASCII	/   E /
	ASCII	/   I /
	ASCII	/   Q /
	ASCII	/   R /
	ASCII	/   W /
	ASCII	/   S /	;[12]
	SUBTTL	T3A

	EDIT(10)
COMMENT;[10] NEW ROUTINE

PURPOSE:	DELETE nnnATR.TMP

ENTRY:		T3A

NORMAL EXIT:	RETURN

ERROR EXIT:	BRANCH	T3T3

CALL FORMAT:	EXEC	T3A

;



T3A:	DELETE	ATR
	RETURN
	SUBTTL	T3CHAR	GET NEXT BYTE

	EDIT(225)
TOPS10,<;[225]

COMMENT ;

PURPOSE:		TO FETCH NEXT BYTE FROM A  BUFFER AND 
			RETURN IMMEDIATELY IF IT IS NOT A DIGIT OR A LETTER
			LOWER CASE LETTERS ARE CONVERTED TO UPPER CASE.
			TAB IS CONVERTED TO SPACE.
ENTRY:			T3CHAR
INPUT ARGUMENT:		BYTE POINTER IN XT3P
OUTPUT ARGUMENT:	BYTE IN X3BYTE
			SKIP RETURN IF X3BYTE CONTAINS A LETTER OR A DIGIT
NORMAL EXIT:		RETURN
ERROR EXIT:		-
CALL FORMAT:		EXEC T3CHAR
USED ROUTINES:		-
USED REGISTER:	X3BYTE
ERROR MESSAGE:	-
;

T3CHAR:	PROC	
	ILDB 	X3BYTE,XT3P	;GET BYTE
	CAIE	X3BYTE,"%"
	CAIN	X3BYTE,"$"
	GOTO	L9		;ACCEPT DOLLAR AND PERCENT
	CAIN	X3BYTE,QHT	;IF TAB THEN
	LI	X3BYTE," "	;CONVERT IT TO SPACE
	CAIGE	X3BYTE,"0"
	RETURN			;NOT DIGIT OR LETTER!
	CAIG	X3BYTE,"9"
	GOTO	L9		;IF DIGIT
	CAIGE	X3BYTE,"A"
	RETURN
	CAIG	X3BYTE,"Z"
	GOTO	L9		;IF UPPER CASE LETTER
	CAIL	X3BYTE,"a"
	CAILE	X3BYTE,"z"
	RETURN
	SUBI	X3BYTE,40	;CONVERT TO UPPER CASE IF LOWER CASE
L9():!
	AOS	(XPDP)		;SKIP RETURN IF LETTER OR DIGIT
	RETURN
	EPROC
	>;[225]
	SUBTTL	T3MOVE

	EDIT(225)

TOPS20,<T3MOVE==:I1MOVE##>;[225]
TOPS10,<;[225]
COMMENT ;
PURPOSE:		TO MOVE NEXT COMMAND LINE FROM COMMAND BUFFER (YCBUF)
			TO COMMAND LINE BUFFER (YI1CB). THIS SUBROUTINE IS
			CALLED IN COMPIL MODE ONLY.
INPUT ARGUMENTS:	BYTE POINTER AND BYTE COUNTER SET IN
			COMMAND BUFFER HEADER, YCBBH.
OUTPUT ARGUMENTS:	NEXT COMMAND LINE IN YI1CB.
			YSWCM TRUE IF MORE COMMAND LINES IN BUFFER.
NORMAL EXIT:		RETURN, OR, IF END OF COMMAND FILE EXIT TO MONITOR
ERROR EXIT:		GOTO T3AB IF READ ERROR OR TOO LONG COMMAND LINE
CALL FORMAT:		EXEC T3MOVE
USED REGISTERS:		X0 BYTE TO BE MOVED
			X1 BYTE POINTER TO YI1CB
			X2 SCRATCH
USED ROUTINES:		T3GC, T3PC AND T3RCOM.
			THESE THREE SUBROUTINES ARE DEFINED LOCALLY
			WITHIN T3MOVE. T3PC IS ALSO USED BY T3CM.
ERROR MESSAGES		?Read error on command file
			?Command line exceeds 135 characters
;

T3MOVE:
	EXEC	T3GC
	CAIE	X0,QCR
	CAIN	X0,QLF
	GOTO	T3MOVE		;IGNORE LEADING CR AND LF IF ANY
	IF	;NULL HERE
		JUMPN	X0,FALSE
	THEN	;END OF COMMAND FILE IF TMPCOR!
		IFOFF	YSWCOM
		EXIT			;DIRECTLY IF CORE FILE
		GOTO	T3MOVE
	FI
	L	X1,[POINT 7,YI1CB]
	EXEC	T3PC
	RETURN			;IF BUFFER OVERFLOW
	LOOP	;AND MOVE BYTES UNTIL LINE FEED
		EXEC	T3GC
		JUMPE	X0,TRUE		;IGNORE NULLS!
		EXEC	T3PC
		RETURN			;IF BUFFER OVERFLOW
	AS	CAIE	X0,QLF
		GOTO	TRUE
	SA
	AOS	(XPDP)
	RETURN

T3GC:
	SOSG	YCBBH+2		;DECREASE BYTE COUNTER
	EXEC	T3RCOM		;READ NEXT BUFFER IF CURRENT IS EMPTY
	ILDB	X0,YCBBH+1	;GET NEXT BYTE
	RETURN
>
	EDIT(225)
TOPS20,<T3PC==:I1PC##>;[225]
TOPS10,<;[225]
T3PC:
	HRRZ	X2,X1
	SUBI	X2,YI1CBE
	IF	;END OF COMMAND LINE BUFFER
		JUMPL	X2,FALSE
	THEN	;ERROR
		OUTSTR	[ASCIZ/
?Command line exceeds 135 characters/]
		IFOFF	YI1CCL
		CLRBFI			;CLEAR BUFFER IN RUN MODE
		SETOFF	YI1CCL		;SWITCH TO RUN MODE
		RETURN
	FI
	IDPB	X0,X1		;STORE BYTE IN COMMAND LINE BUFFER
	AOS	(XPDP)
	RETURN

T3RCOM:
	IN	QCHCOM,YCBUF+1
	RETURN			;IF READ OK
	IF	;END OF FILE
		STATZ	QCHCOM,740000
		GOTO	FALSE
	THEN	;DELETE COMMAND FILE
		LI	X1,0
		RENAME	QCHCOM,X1
		NOP
		EXIT
	FI
	OUTSTR	[ASCIZ/
?Read error on command file/]
	EXIT
>;[225]
	SUBTTL	T3NAME

	EDIT(225)
TOPS20,<T3NAME==:I1NAME##>;[225]
TOPS10,<;[225]
COMMENT ;
PURPOSE:		TO PACK NEXT SYMBOLIC NAME IN SIXBIT IN X0.
			DELIMITER IS ANY NON-DIGIT AND NON-LETTER BYTE.
			NAMES LONGER THAN 6 BYTES ARE TRUNCATED WITHOUT WARNING.
			LEADING SPACES ARE IGNORED.
ENTRY:			T3NAME
INPUT ARGUMENT:		BYTE POINTER IN XT3P
OUTPUT ARGUMENT:	DELIMITER IN X3BYTE
			NAME IN X0
NORMAL EXIT:		RETURN
ERROR EXIT:		-
CALL FORMAT:		EXEC T3NAME
USED ROUTINES:		T3CHAR
USED REGISTERS:		X0	RETURN ARGUMENT
			X3BYTE	DELIMITER AFTER NAME
			XT3IND	POINTER TO X0
ERROR MESSAGE:		-
;

T3NAME:
	SETZ
	MOVSI	XT3IND,(POINT 6)	;Pointer to X0
	WHILE	; LETTER OR DIGIT
		EXEC	T3CHAR
		 GOTO	FALSE		
	DO	SUBI	X3BYTE,40	;CONVERT TO SIXBIT
		TRNN	77		;SKIP IF 6 BYTES ALREADY
		IDPB	X3BYTE,XT3IND	;STORE IN X0
	OD
	CAIN	X3BYTE," "
	 JUMPE	X0,T3NAME		;SKIP LEADING SPACES
	RETURN
>;[225]
	SUBTTL	T3E


COMMENT ;
PURPOSE:		Output to TTY and LS3 if relevant:
			- Information on non-default switch settings
			- Report if a new ATR file was generated
			- Error statistics
			- Report if no new REL file was created
			Update job error count (.JBERR)
ENTRY:			T3E
INPUT ARGUMENT:		YSWITCH	SWITCHES
			YSWCHA COMPILER SWITCHES CHANGED FROM DEFAULT
			YSWDEF	DEFAULT VALUE OF COMPILER SWITCHES
	
NORMAL EXIT		RETURN
ERROR EXIT:		-
OUTPUT ARGUMENTS:	INFORMATION ON TTY AND IN SOURCE LIST
			.JBERR
USED SUBROUTINES:	O3WS,E3BD
CALL FORMAT:		EXEC	T3E
;





T3E:
	CLEARO
	;OUTPUT INFORMATION ON SWITCHES USED
	IF	;List is generated
		IFOFFA	YE3LST
		GOTO	FALSE
	THEN
		IF	;No switches changed
			SKIPE	X4,YSWCHA
			GOTO	FALSE
		THEN	;DEFAULT SWITCHES
			LI	X1,T3DEFA
			EXEC	O3WS,<[XWD	5*<T3CHA-T3DEFA>]>
		ELSE	;SOME SWITCH(ES) CHANGED FROM DEFAULT VALUE
			LI	X1,T3CHA
			EXEC	O3WS,<[XWD	5*<T3NO-T3CHA>]>
			LI	X3,0
						EDIT(12)
			MOVSI	X2,-QNSWCH	;[12]
			LOOP
				;CHECK EACH SWITCH FOR CHANGE
				LSHC	X3,1
				IF
					JUMPE	X3,FALSE
				THEN
					;THIS SWITCH CHANGED
					;GET CURRENT SWITCH
					L	X6,T3SWCH(X2)
					LI	X0,5
					TRZ	X3,1
					;GET DEFAULT STATUS
					L	X1,YSWDEF
					LSH	X1,(X2)
					IF	;Switch is on
						TLNN	X1,1B18
						GOTO	FALSE
					THEN
						;DEFAULT IS ON CHANGED TO OFF OUTPUT NO
						IOR	X6,[ASCIZ	/  -/]
						L	X7,T3NO
						ADDI	X0,3
					FI
					STD	X6,Y3BUF
					LI	X1,Y3BUF
					EXEC	O3WS,<X0>
					HRRZ	X1,T3SW(X2)
					HLRZ	X0,T3SW(X2)
					EXEC	O3WS,<X0>
				FI
			AS
				JUMPE	X4,FALSE
				AOBJN	X2,TRUE
			SA
		FI
			edit(22)
		IF	;A new ATR file was created
			IFONA	NEWATR	;[22]
			IFOFFA	OLDATR
			GOTO	FALSE
		THEN	;Put a message in the listing
			LI	X1,T3ATR
			LI	X0,5*<T3ATRE-T3ATR>	;[22]
			IFONA	NEWUNR			;[22]
			LI	X0,5*<T3ATRF-T3ATR>	;[22]
			EXEC	O3WS,<X0>		;[22]
	FI	FI
	IF	;[22] New ATR generated
		IFONA	NEWATR	;[22]
		IFOFFA	OLDATR
		GOTO	FALSE
	THEN	;Type message on TTY
		OUTSTR	T3ATR
		IFONA	NEWUNR
		OUTSTR	T3ATRE
	FI	;[22]
	IF
		SKIPN	YWARCT
		SKIPE	YDMEND
		GOTO	FALSE				;RETURN AT ONCE IF NO ERRORS
		IFON	YSWTRM
		GOTO	FALSE
	THEN
		;NO ERRORS
		IF
			IFOFFA	YE3LST
			GOTO	FALSE
		THEN	;LIST WANTED 
			LI	X1,T3NE
			EXEC	O3WS,<[XWD 5*<T3EI-T3NE>]>
		FI
		IFOFF	YI1CCL
		;NO OUTPUT IF COMMAND FILE
		OUTSTR	T3NE
	ELSE		;OUTPUT STAT. INF OF ERRORS
		IF
			IFOFFA	YE3LST
			GOTO	FALSE
		THEN
			IF
				IFOFFA	NOREL
				GOTO	FALSE
			THEN
				;NO NEW REL FILE
				LI	X1,T3REL
				EXEC	O3WS,<[XWD	5*<T3RELE-T3REL>]>
			FI
			LI	X1,T3EI
			EXEC	O3WS,<[^D20]>
		FI
		IFONA	NOREL
		OUTSTR	T3REL
		OUTSTR	T3EI
		IF	SKIPN	X6,YWARCT
			GOTO	FALSE
		THEN	;OUTPUT NUMBER OF WARNINGS
			L	X0,YWARCT
			HRLI	X2,T3MW
			EXEC	T3E1
		FI
		IF	SKIPN	YERRCT
			GOTO	FALSE
		THEN	;OUTPUT NUMBER OF ERRORS
			L	X0,YERRCT
			AOS	.JBERR
			HRLI	X2,T3ME
			EXEC	T3E1
			ADD	X6,YERRCT
		FI
		IF
			IFOFF	YSWTRM
			GOTO	FALSE
		THEN	;TERMINATION ERROR HAS OCCURRED
			OUTSTR	T3MT
			IF
				IFOFFA	YE3LST
				GOTO	FALSE
			THEN	;OUTPUT MESSAGE ON LIST FILE
				LI	X1,T3MT
				EXEC	O3WS,<[^D21]>
			FI
			AOS	.JBERR
		FI
		;OUTPUT MESSAGE ONLY 50 ERRORS OUTPUT IF RELEVANT
		IF
			CAIG	X6,^D50
			GOTO	FALSE
		THEN
			OUTSTR	T3MERR
			IF
				IFOFFA	YE3LST
				GOTO	FALSE
			THEN
				LI	X1,T3MERR
				EXEC	O3WS,<[XWD	5*<T3ATR-T3MERR>]> ;[1]
							;OUTPUT T3MERR ON LIST
			FI
		FI
	FI
	;INDICATE STATISTICAL INFORMATION OUTPUT
	SETONA	Y3STAT
	RETURN

T3E1:	EXEC	E3BD				;CREATE LINE CONTAINING NO OF ERRORS
	ST	X1,Y3BUF
	HRRI	X2,Y3BUF+1
	BLT	X2,Y3BUF+4
	IF
		IFOFFA	YE3LST
		GOTO	FALSE
	THEN	LI	X1,Y3BUF
		EXEC	O3WS,<[^D23]>			;OUTPUT TO LST
	
	FI
	OUTSTR	Y3BUF
	RETURN

	;SIGNIFICANT ORDER BETWEEN TABLES
T3NE:	ASCIZ /
NO ERRORS DETECTED
/
T3EI:	ASCIZ /
ERRORS DETECTED:
/
T3ME:	ASCIZ	/ TYPE E MESSAGES
/
T3MW:	ASCIZ	/ TYPE W MESSAGES
/
T3MT:	ASCIZ	/?TERMINATION ERROR
/

T3REL:	ASCIZ	/
NO NEW REL FILE GENERATED
/
T3RELE:
T3MERR:	ASCIZ	/
	SOME ERROR OR WARNING MESSAGES SUPPRESSED
/
T3ATR:	ASCIZ	/
NEW ATR FILE GENERATED
/	;[22]
T3ATRE:	ASCIZ	/RECOMPILE DEPENDENT PROGRAMS
/
T3ATRF:	;[22]
	edit(22)
	SUBTTL	T3I

	edit(162)

COMMENT ;[162]
PURPOSE:		To close REL file, delete IC2
ENTRY:			T3I, alternatively T3ID [204]
Input:			-
Output:			-
NORMAL EXIT:		RETURN
ERROR EXIT:		BRANCH T3T3
CALL FORMAT:		EXEC T3I
USED ROUTINES:		-
;

T3I:	PROC
	SETOFA	NOREL	;Show REL file was created
	CLOSE	QCHREL,	;[162] Just close now
	STATZ	QCHREL,740K
			edit(225)
	  GOTO	L8	;[225] On error
				edit(6)
	DEFINE E<YEXTS+4>	;[6] Enter block
	TOPS10,<;[225]
	;The following pertains to edit no [6]
	L	X1,E+3		;[6] [162] PPN
	L	X3,Y3ENTRY	;[6]
	IF	;[6] Entry name still to be changed
		JUMPE	X3,FALSE
	THEN	;Must look up file again and change 1st block
		SETSTS	QCHREL,14+1B30	;Synchronous binary mode
		LOOKUP	QCHREL,E
		GOTO	L9	;[225] Lookup error
		;Prepare for ENTER
		ST	X1,E+3		;Restore ppn
		ENTER	QCHREL,E
		GOTO	L9	;On error
		USETI	QCHREL,1
		L	X2,YBHREL	;Current buffer
		IN	QCHREL,(X2)
		SKIPA
		GOTO	L9		;On error
		ST	X3,4(X2)	;Change name of entry point
		USETO	QCHREL,1	;Find first block for output
		OUT	QCHREL,(X2)	;Replace first block
		SKIPA			;If ok
		GOTO	L9		;On error
	FI
	>;[225]
	RELEASE	QCHREL,
		edit(225)
	TOPS20,<;[225]
	SKIPN	Y3ENTRY
	GOTO	T3ID
	JF==-3		;JFN OFFSET (SEE LOWSEG)
	E1==Y3LKU##+8
	LD	E
	STD	E1
	LD	E+2
	STD	E1+2
	LI	X1,E1
	HRLI	X1,(GJ%OLD)
	EXEC	O1JFN##
	GOTO	L9
	HRRZ	X1,JF+E1	;JFN
	L	X2,[^D36B5+OF%RD+OF%WR+OF%HER+OF%NWT+OF%PLN]
	OPENF
	GOTO	L9
	L	X2,Y3ENTRY
	LI	X3,2	;Offset of entry name in REL file
	ROUT
	ERJMP	L9
	LI	X1,(X1)	;JFN, no special options for CLOSF
	CLOSF
	GOTO	L9
	>;[225] End of DEC-20 variant
	PURGE	E	;[6,225]
	SETOFF	YOPREL
	edit(204)
T3ID:	;[204] Entry for deleting IC2 only
	DELETE	IC2
	RETURN

L8():!	IOER	REL	;[225] Close error on REL file
	ERRT	QT,Q.TER+5
	BRANCH	T3T3

L9():!	IOER	REL	;[225] Output error on REL file
	ERRT	QT,Q.TER+6
	BRANCH	T3T3
	EPROC
	SUBTTL	T3L

COMMENT ;
PURPOSE:		TO DELETE LS1, CLOSE LST FILE
			 AND RELEASE THE SOURCE CODE FILE, IF LIST FILE IS GENERATED
ENTRY:			T3L
INPUT ARGUMENT:		-
OUTPUT ARGUMENT:	-
NORMAL EXIT:		RETURN
ERROR EXIT:		BRANCH T3T3
CALL FORMAT:		EXEC T3L
USED ROUTINES:		-
ERROR MESSAGE:		YT3E2
;

T3L:
	DELETE	LS1
	;RETURN IF NO LIST FILE IS GENERATED
	IFOFF	YOPLS3
	RETURN
			edit(162)
	KLOSE	SRC,0	;[162]
	;[162] Close and release LST channel
			edit(6)
	RELEASE	QCHLS3,	;[6]
	SETOFF	YOPLS3	;[6]
	RETURN		;[6]
	SUBTTL	T3R


;PURPOSE:		Close REL file without creating new REL file
;			Delete IC2 also [204]
;ENTRY:			T3R
;INPUT ARGUMENTS:	-
;OUTPUT ARGUMENTS:	-
;NORMAL EXIT:		RETURN
;ERROR EXIT:		-
;CALL FORMAT:		EXEC	T3R


T3R:
				edit(204)
	EXEC	T3ID		;[204] Delete IC2
				edit(162)
	KLOSE	(REL,40)	;[162] Inhibit supersede of old file
	RETURN
	SUBTTL	TERMINATION ROUTINES


COMMENT ;
PURPOSE:		TO CLOSE ALL OPENED FILES AND TERMINATE COMPILATION
			UPDATE .JBERR
			TAKE CARE OF ^C REENTER
ENTRY:			T3T	WHEN TERMINATION ERROR IN PASS 1 OR 2
			T3T3	TERMINATION ERROR IN PASS 3
			T3REE	^C REENTER
INPUT ARGUMENT:		SWITCH-ARRAY IN Y3OPEN DENOTING OPENED FILES
			YDMEND=0 IF ^C REENTER
OUTPUT ARGUMENT:	-
NORMAL EXIT:		TO MONITOR WITH EXIT
ERROR EXIT:		-
CALL FORMAT:		BRANCH T3T	RESP	BRANCH T3T3 
USED ROUTINES:		I3E,O3ERR,O3TR,O3WT,E3EM,T3E,E3DM
;


T3T3:	SETZM	YESEM
T3T:
	AOS	.JBERR

	L	X1,Y3OPEN
	;EXIT IF MORE THAN ONE TERMINATION ERROR
	IFONA	Y3TERM
	 GOTO	[OUTSTR	[ASCIZ/
SIM561 T ?Unrecoverable errors
/]
		BRANCH	T3]
T3REE:
	edit(162)
	IRPDELETE<LS1,IC1,DF1,IC2,ZSE,XRF,ATR>	;[162] Do not include REL, LST
	IF
		IFOFF	YOPSRC
		GOTO	FALSE
	THEN
		CLOSE	QCHSRC,
		SETOFF	YOPSRC
		RELEASE	QCHSRC,
	FI
	IF
		IFOFF	YOPEXT
		GOTO	FALSE
	THEN
		CLOSE	QCHEXT,
		SETOFF	YOPEXT
		RELEASE	QCHEXT,
	FI
	SETONA	Y3TERM
	IF	SKIPN	YDMEND
		GOTO	FALSE

	THEN	;OUTPUT ERRORS ON TTY
		IF
			IFONA	Y3ERR
			GOTO	FALSE
		THEN
		;NO ERROR TABLES IN CORE
			EXEC	O3ERR		;READ TABLES FOR ERROR HANDLING INTO CORE
			EXEC	E3DM
			LI	XDM2,1	;INDEX TO ZDM
		FI
		WHILE	;ERRORS IN ZDM
			CAML	XDM2,YDMEND
			GOTO	FALSE
		DO	;OUTUT ONE ERROR
			EXEC	E3EM
			OUTSTR	YE3ERR
			ADDI	XDM2,3
		OD
		IF
			IFONA	Y3STAT
			GOTO	FALSE
		THEN
			SETOFA	YE3LST
			EXEC	T3E
		ELSE
			OUTSTR	T3MT
		FI
	ELSE
	;ERROR ALREADY WRITTEN IN PASS 1
		OUTSTR	T3MT
	FI
	BRANCH	T3
T3X:
		;DELETE XRF.TMP
	DELETE	XRF
	RETURN
	SUBTTL	T3 MAIN ROUTINE

COMMENT /
PURPOSES:		TO READ NEXT COMMAND FROM TTY OR IF IN COMPIL MODE
			TO SEARCH NEXT COMMAND LINE FOR NEXT CUSP
			DEFINITION (DELIMITER "!") AND IN THAT
			CASE RUN NEXT CUSP.
			ALGORITHM:
			BEGIN	IF RUN MODE THEN READ NEXT COMMAND FROM TTY
				ELSE
				BEGIN	IF NOT MORE COMMANDS THEN
					BEGIN	DELETE COMMAND FILE;
						EXIT
					END;
					T3NAME;
					IF NOT "!" THEN T3NAME;
					IF "!" THEN RUN NEXT CUSP;
				END;
				SWAP TO PASS 1;
			END
ENTRY:			T3
INPUT ARGUMENTS:	-
OUTPUT ARGUMENTS:	-
NORMAL EXIT:		TO MONITOR (EXIT UUO) ON END OF COMMAND FILE,
			BRANCH TO PASS 1 OTHERWISE.
ERROR EXIT:		TO MONITOR (EXIT UUO) IF GETSEG FAILED
USED ROUTINES:		T3NAME,T3PC.
USED REGISTERS:		X0,X1,X2,X3,X4,X5,X6,X10,X11,X12
ERROR MESSAGES:		-
/

	OPDEF	PUTCHAR	[XEC	T3PC]
	edit(246)
TOPS20,<OPDEF TTYCOMMAND [XEC I1TTYC##]>;[246]
TOPS10,<OPDEF TTYCOMMAND [XEC T3TTYC]>	;[246]

T3:	PROC
	HLLZS	.JBREN## ;DO NOT ALLOW REENTER WHEN READING FILE SPECIFICATIONS
	IF	;RUN MODE
		IFON	YI1CCL
		GOTO	FALSE
	THEN	;READ IN NEXT COMMAND FROM TTY
L1():!		SETOFF	YI1CCL		;[246]
		TTYCOMMAND		;[246]
		 GOTO	L1		;IF NOT SATISFACTORY
	ELSE	;SEE IF NEXT LINE CONTAINS RUN REQUEST
		EXEC	T3MOVE		;MOVE NEXT COMMAND LINE
		 GOTO	L1		;from TTY on ERROR
	FI	;[246]
TOPS10,<;[246] Let Pass 1 handle the command line
	L	XT3P,[POINT 7,YI1CB]
	EXEC	T3NAME
	SETZB	X2,X3
	SETZB	X4,X5
	SETZB	X6,X7		;SET UP RUN UUO ARGUMENTS
	IF	;DELIMITER IS "!"
		CAIE	X3BYTE,"!"
		GOTO	FALSE
L2():!	THEN	ST	X0,X3		;CUSP NAME IN X3
		IF	;COMMAND FILE
			IFOFF	YSWCOM
			GOTO	FALSE
		THEN	;TIME TO DELETE IT!
			LI	X1,0
			RENAME	QCHCOM,X1
			NOP
		FI
COMMENT *	LINK 10 WILL STOP THE ATTEMPT TO EXECUTE A JOB CONTAINING ANY ERRORS.
		THE FOLLOWING CODE MAKES IT POSSIBLE TO PREVENT LOADING AND EXECUTION
		WITHOUT ANY CALL OF NEW CUSPS
			IF	;ERROR(S) IN PREV. COMPILATION(S)
				SKIPN	.JBERR
				GOTO	FALSE
			THEN	;SKIP CALL OF NEXT CUSP
				OUTSTR	[ASCIZ/
?LOADING AND EXECUTION DELETED/]
				EXIT
			FI
	*

		SKIPN	X0,X2
		MOVSI	X2,'SYS'	;DEFAULT DEVICE
		L	X1,[XWD 1,X2]	;NEXT CUSP +1, ARG IN X2
		RUN	X1,
		HALT
	FI
	ST	X0,X2		;SAVE POSSIBLE DEVICE
	EXEC	T3NAME
	CAIN	X3BYTE,"!"
	GOTO	L2
>;[246]
	;NOW SWAP TO PASS 1
	edit(225)
TOPS10,<;[225]
	L	X3,[XWD 1,Y1LOWE]
	IFG QTRACE,<EXTERN	YTRPAS
			IFON	YTRSW
			HRRI	X3,0
			>
		edit(260)
	SWAPPA	(SIMULA,S1,-1,QP1PPN)
>
TOPS20,<BRANCH 400010>;[225,260]
	EPROC
	SUBTTL	T3TTYC [225] Read command from TTY

	edit(225)

Comment;
Purpose:	Input command from user TTY.
Input:		None
Output:		Command line in YI1CB
Normal exit:	Skip return
Alternate exit:	EXIT to monitor level if last command was finished by ^Z
Error exit:	Non-skip return
Used ac's:	X0,X1,X2
Calls:		PUTCHAR (T3PC)
;

T3TTYC:	PROC
	CLEARO		;CLEAR CONTROL-O
			edit(220)
	IFON	YSWCZ	;[220]
	EXIT		;[220]
	OUTSTR	[ASCIZ/
*/]
	L	X1,[POINT 7,YI1CB]
	LOOP	;UNTIL CR, ^Z OR ALTMODE
		INCHWL	X0
		CAIN	X0,033		;IF ALTMODE
		LI	X0,QCR		;THEN SUBSTITUTE CR
			edit(220)
		IF	;[220] ^Z
			CAIE	X0,"Z"-"A"+1
			GOTO	FALSE
		THEN	;SET ^Z FLAG, RETURN <CR>
			SETON	YSWCZ
			LI	X0,QCR
		FI
		IF	;NOT LINE FEED
			CAIN	X0,QLF		;IGNORE LINE FEED
			GOTO	FALSE
		THEN	;STORE BYTE IN COMMAND LINE BUFFER
			PUTCHAR
			GOTO	L9		;IF OVERFLOW
		FI
	AS	CAIE	X0,QCR
		GOTO	TRUE
	SA
	LI	X0,QLF
	PUTCHAR
	GOTO	L9		;IF OVERFLOW
L8():!	AOS(XPDP)
L9():!	RETURN
	EPROC

	LIT
	END