perm filename E3.MAC[SIM,SYS] blob sn#462216 filedate 1979-07-26 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00018 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002		SUBTTL	E3
C00008 00003
C00012 00004			SUBTTL E3BD
C00013 00005		SUBTTL	E3DB
C00015 00006		SUBTTL	E3BE
C00018 00007		SUBTTL	E3DM
C00024 00008		SUBTTL	E3EM
C00025 00009		PROC
C00034 00010		SUBTTL	E3IN
C00042 00011		SUBTTL	E3LI
C00047 00012		SUBTTL	E3LT
C00051 00013		SUBTTL	E3PAGE
C00054 00014		SUBTTL	E3PAGH
C00057 00015		SUBTTL	E3PDAT
C00059 00016
C00060 00017	E3LIC:	ASCIZ	/N/
C00061 00018	
C00062 ENDMK
C⊗;
	SUBTTL	E3



;AUTHORS:		KIM WALDEN
;			ELISABETH $LUND
;VERSION:	0
;PURPOSE:	CREATE A LST FILE AND ERROR MESSAGES ON THE USER'S TERMINAL
;CONTENTS:
;LOCAL SUBROUTINES:	E3BD		CONVERT BIN ASCII DEC
;			E3BE		CREATE BEGIN END NUMBERS
;			E3DM		SORT DM
;			E3EM		CREATE ERRORMESSAGES
;			E3LI		INVESTIGATE CONTROL WORD
;			E3IN
;			E3PAGE		CREATE PAGE HEADING
;EXTERNAL SUBROUTINES:	SEE BELOW



	SALL
	SEARCH SIMMAC
	CTITLE	E3
	SEARCH SIMMC3	;[104]
	TWOSEG
	RELOC	400000
	MACINIT
	P3INIT	;[104]
	LS1INIT



;EXTERNAL SUBROUTINES
EXTERN	I3S		;ROUTINE TO OPEN SOURCE CODE FILE
EXTERN	T3E		;CREATE STAT INF OF ERRORS
EXTERN	T3L		;CLOSE FILES
EXTERN	I3LS3		;OPEN LS3
EXTERN	I3L		;ROUTINE TO OPEN LS1
EXTERN	O3ERR		;ROUTINE TO READ ERROR HANDLING TABLES INTO CORE
EXTERN	O3RS		;READ LS1.TMP
EXTERN	O3WS		;WRITE LS3.TMP
EXTERN	O3RSC		;READ INFILE.SIM
EXTERN	O3SCLS		;READ LAST PART OF SOURCE AND OUTPUT TO LIST 
			;WITH NO EDITING OF LINENUMBERS ETC

EXTERN	SIMXRF		;CROSS REF LIST
EXTERN	ZLEREC		;WORD TO KEEP RECORD FROM LS1
;[104] EXTERN	ZDM	;DIAGNOSTICS BUFFER
EXTERN	ZSE		;SYMBOL TABLE
EXTERN	YBHSRC		;BUFFER HEADER SOURCE CODE
EXTERN	YBHLS3		;BUFFER HEADER LS3
EXTERN	Y3LINH		;BUFFER HEADER PRECEDING LINE
EXTERN	YELSRC		;LOOKUP ARG FOR SOURCE CODE
EXTERN	Y3DEV		;DEV OF SOURCE
EXTERN	YE3PGH		;PAGE HEADER LINE 1
EXTERN	YE3PNN		;NUMBER OF CHARACTERS IN LAST PART OF HEADER
EXTERN	YE3PNM		;PAGE HEADER LINE 2
EXTERN	Y3BUF		;BUFFER
EXTERN	YE3LIN		;LINE BUFFER
EXTERN	YE3LIP		;BYTE POINTER YE3LIN
EXTERN	YE3RUB		;PAGE RUBRIC
EXTERN	YE3NRU		;NUMBER OF BYTES IN RUBRIC
EXTERN	YE3ERR		;BUFFER ERRORMESSAGES
EXTERN	YE3END		;NUMBER OF END ON CURRENT LINE
EXTERN	YE3BEG		;NUMBER OF BEGIN GENERATED
EXTERN	YBEGSP		;STACK POINTER BEGIN STACK
EXTERN	YBEGNO		;NUMBER OF BEGINS IN SOURCE PROG
EXTERN	YE3PAG		;NUMBER OF LINES PER PAGES
EXTERN	YE3PGN		;CURRENT PAGE NUMBER
EXTERN	YE3PNO		;NUMBER OF LINES ON CURRENT PAGE
EXTERN	YE3LNO		;CURRENT LINENUMBER
EXTERN	YE3LS3		;NUMBER OF BYTES TO OUTPUT TO LS3.TMP
EXTERN	YE3D		;TABLE FOR ERROR HANDLING
EXTERN	YE3M
EXTERN	YE3MI
EXTERN	YE3DL
EXTERN	YSWITCH		;SWITCH WORD
EXTERN	Y3PLTE		;POINTER END OF LINE NUMBER TABLE
EXTERN	Y3PLTS		;POINTER START OF LINE NUMBER TABLE
EXTERN	Y3OPEN		;WORD CONTAINING SWITCHES
EXTERN	YDMPT3		;FOR ERROR HANDLING
EXTERN	YSIXB
EXTERN	YDMEND		;LENGTH OF UTILIZED PART OF DM
EXTERN	YDMB2
EXTERN	YZDM		;BUFFER USED WHEN SORTING ZDM
EXTERN	YZDMI		;BUFFER USED WHEN SORTING ZDM
EXTERN	YERRCT		;NUMBER OF ERRORS ENCOUNTERED
EXTERN	YWARCT		;NUMBER OF WARNINGS ENCOUNTERED
EXTERN	.JBVER

;ROUTINES CALLED FROM OTHER MODULES
INTERN	E3LICF		;UPDATE PAGE NUMBER AT FORM FEED OR VT
INTERN	E3BD		;ROUTINE TO CONVERT BIN DEC ASCII
INTERN	E3DB		;CONVERT FR DEC ASCII TO BIN
INTERN	E3EM		;ENTRY FOR ROUTINE CREATING ERRORMESSAGES
INTERN	E3		;ENTRY FOR MODULE E3



	;MACRO TO GENERATE TABLE CONTAINING SYMBOLS DEFINED IN THE MACRO SYMB
	;IN SIMMAC.MAC. THE SYMBOLS ARE SORTED IN NUMERIC ORDER
	;AND ARE GENERATED IN SIXBIT, TABLE USED FOR ERROR HANDLING
ERR1==0
	DEFINE ERRSY(A,B,C,D)<
			REPEAT B-ERR1,<0
					0>
			ERR1==B+1
			IFB <D>,<0
				 0>
			IFNB <D>,<SIXBIT ?D?
				ERR2==6
				IRPC D,<ERR2==ERR2-1>
				IFGE ERR2,<0>
				>
				>




E3:
	PROC
	SETZB	XDM1,YE3LNO
	LI	XDM2,1
	SETZM	YE3BEG
	SETZM	YE3NRU
	SETZM	YE3PGN		;[7] START WITH 0 IN YE3PGN AND LET
				; E3LICS UPDATE MAIN PAGE NUMBER
	SETZM	YE3PNO
	SETZM	YE3END
	LI	X0,QPAGE
	ST	X0,YE3PAG
IF
	SKIPN	YDMEND
	GOTO	FALSE
THEN
	;ERRORS
	EXEC	O3ERR			;READ ERROR TABLES INTO CORE IF ERRORS IN PROG
	EXEC	E3DM			;SORT ERROR MESSAGES IN LINENUMBER ORDER
	SETOM	ZDM-2
	L	X1,YDMEND
	SETOM	ZDM+1(X1)
FI
	EXEC	I3L				;OPEN LS1 
	L	X0,[POINT	7,YE3LIN]	;INIT BYTE POINTER
	ST	X0,YE3LIP
	SETZM	YE3LS3
LOOP
	EXEC	O3RS				;READ WORD FROM LS1
	SKIPA					;CORRECT RETURN
AS	GOTO	FALSE				;RETURN AT END OF FILE

	IF	TRNE	X1,1			;CHECK IF CONTROL WORD
		GOTO	FALSE
	THEN					;NOT A CONTROL WORD
		SKIPGE	X2,YE3NRU
		SETZB	X2,YE3NRU		;RESET COUNTER FIRST TEXT WORD
		ST	X1,YE3RUB(X2)		;STORE WORD IN PAGE HEADER
		AOS	YE3NRU			;COUNT OF NUMBER OF WORDS IN HEADER
	ELSE
		HLRZ	X0,X1
		LSH	X0,-↑D11
		IF	CAIE	X0,"I"
			GOTO	FALSE
		THEN	EXEC	E3IN			;LINE IDENTIFICATION WORD
		ELSE
			IF	CAIE	X0,"B"
				CAIN	X0,"E"
				GOTO	FALSE
			THEN	EXEC	E3LI		;INVESTIGATE CONTROLWORD
			ELSE	
				EXEC	E3BE		;GENERATE BEGIN END STRUCT
			FI
		FI
	FI
	GOTO	TRUE
SA					;END OF FILE
	;OUTPUT ERRORS WITH TO HIGH LINE NUMBER
WHILE
	CAML	XDM2,YDMEND
	GOTO	FALSE
DO
	EXEC	E3ERRE
OD
	;OUTPUT REMAINING CHARACTERS IN SOURCE (IF ANY)
	IFONA	YE3LST
	EXEC	O3SCLS
	LI	X0,1
	SKIPE	YWARCT			;COUNT NUMBER OF LINES TO OUTPUT 
	ADDI	X0,1
	SKIPE	YERRCT
	ADDI	X0,1
	CAML	X0,YE3PNO
	EXEC	E3P2			;OUTPUT NEW PAGE 
	EXEC	T3E			;CREATE STATISTICAL INFORMATION OF ERRORS 
IF
	IFOFFA	YE3LST
	GOTO	FALSE
THEN
	;CHECK IF LINENUMBER TABLE WANTED IN LIST FILE
	IF
		IFOFF	YSWY
		GOTO	FALSE
	THEN
		;REL FILE CREATED
		IFOFFA	NOREL
		EXEC	E3LT
	FI
	;CHECK IF CROSS REF LIST WANTED
	IFON	Y3SWC
	EXEC	SIMXRF
	;OUTPUT CR LF AT END OF LIST FILE
	LI	X1,E3CR
	EXEC	O3WS,[<2>]
FI
	EXEC	T3L			;RENAME LS3 DELETE LS1 CLOSE SOURCE CODE FILE
	RETURN
	EPROC
		SUBTTL E3BD



;PURPOSE:		CONVERT WORD IN BIN FORMAT TO ASCII DEC WITH LEADING SPACE
;ENTRY:			E3BD
;INPUT ARGUMENT:	REG X0 CONTAINING WORD IN BIN FORMAT  <= DEC 99999
;NORMAL EXIT:		RETURN
;ERROR EXIT:		-
;OUTPUT ARGUMENTS:	REG X1 CONTAING NUMBER IN DEC ASCII FORMAT
;			 LEFT JUSTIFIED AND PRECEDED BY BLANKS
;CALL FORMAT:		EXEC	E3BD


E3BD:	SAVE	<X2,X3>
	SETZB	X2,X3
	LOOP	IDIVI	X0,↑D10
		ADDI	X1,60			;CONVERT REMAINDER TO ASCII
		LSHC	X1,-7			;SAVE DIGITS IN X2
		ADDI	X3,7
	AS
		JUMPN	X0,TRUE
	SA
	LSHC	X1,1(X3)
	IOR	X1,[ASCIZ	/    /]
	RETURN
	SUBTTL	E3DB


;PURPOSE:		CONVERT	 WORD IN DEC ASCII FORMAT TO BIN
;ENTRY:			E3DB
;INPUT ARGUMENT:	REG X0 CONTAINING WORD TO CONVERT,
;			TEXT LEFTJUSTIFIED BUT MAY BE PRECEDED BY ZEROES
;NORMAL EXIT:		RETURN
;ERROR EXIT:		-
;OUTPUT ARGUMENT:	REG X1 CONTAINING WORD
;CALL FORMAT:		EXEC	E3DB



E3DB:	SAVE	<X2>
	IF
		SKIPN	X1,X0
		GOTO	FALSE			;CHECK IF WORD TO CONVERT
	THEN
		TRZ	X1,1
		SETZB	X2,X0
		LOOP
			LSHC	X0,7
		AS
			JUMPE	X0,TRUE
		SA
		
		LOOP
			IF
				CAIGE	X0,"0"
				GOTO	TRUE
				CAIG	X0,"9"
				GOTO	FALSE
			THEN
				;NO DEC DIGIT
				LI	X0,"0"
				IFN	QDEBUG,<SKPINC
						NOP
						OUTSTR	[ASCIZ /
		NOT AN ASCII CHARACTER TO CONVERT PASS 3
		/]>
			FI
			SUBI	X0,"0"
			ADDM	X0,X2
		AS
			JUMPE	X1,FALSE
			IMULI	X2,↑D10
			LI	X0,0
			LSHC	X0,7
			GOTO	TRUE
		SA	L	X1,X2
	FI
	RETURN
		
	SUBTTL	E3BE


;PURPOSE:		GENERATE BEGIN OR END NUMBER
;ENTRY:			E3BE
;ERROR EXIT:		I3OF IF OVER FLOW IN STACK
;NORMAL EXIT:		RETURN
;INPUT ARGUMENT:
;			REG X0 CONTAINING ASCII B OR E
;			YE3BEG	NUMBER OF BEGINS GENERATED
;			YE3END	NUMBER OF END ON CURRENT LINE
;			YBEGST	BEGIN STACK
;			YBEGSP	STACK POINTER
;OUTPUT ARGUMENTS:	BEGIN/END FOLLOWED BY NUMBER IN YE3LIN
;			YE3LIP	BYTE POINTER YE3LIN
;			IF THERE ARE SEVERAL BEGINS AND/OR ENDS ON A LINE
;			ONLY THE FIRST NUMBER OF BEGIN AND/OR LAST END IS PRINTED
;CALL FORMAT:		EXEC	E3BE



E3BE::
PROC
	SAVE	<X2,X6>
	L	X6,X0
	L	X2,YBEGSP			;STACK POINTER BEGIN STACK
	IF	CAIE	X6,"B"
		GOTO	FALSE
	THEN
		;UPDATE BEGIN NUMBER FOR EACH BEGIN ON LINE AND STORE IN STACK
		;MORE THAN 64 BEGINS AFTER EACH OTHER WITH NO END IN BETWEEN
		;CAUSE TERMAINATION ERROR,STACK OVERFLOW
		;ONLY THE NUMBER OF THE FIRST BEGIN IS PRINTED IN THE SOURCE LIST
		AOS	YE3BEG
		PUSH	X2,YE3BEG
		L	X0,YE3BEG
		;OUTPUT FIRST BEGIN NUMBER ON LINE
		SKIPN	YE3LS3
		EXEC	E3BEL
	ELSE
		;UPDATE END NUMBER 
	
		POP	X2,YE3END
		;RETURN AT ONCE IF TOO MANY END
		SKIPGE	YE3END
		AOBJN	X2,E3BE2
	FI
E3BE2:
	ST	X2,YBEGSP
	RETURN
	EPROC


E3BEL:
	;OUTPUT BEGIN/END NUMBER
	;INPUT X6=ASCII B OR E,
	;	X0=CURRENT NUMBER BIN
	IDPB	X6,YE3LIP
	AOS	YE3LS3
	EXEC	E3BD
	LI	X6,5
	LOOP
	
		LSHC	X0,7
	AS
		TRNN	X0,137
		SOJA	X6,TRUE
	SA
		ADDM	X6,YE3LS3
	LOOP
		IDPB	X0,YE3LIP
		LSHC	X0,7
	AS
		SOJG	X6,TRUE
	SA
	RETURN
	SUBTTL	E3DM


;PURPOSE:		SORT ZDM IN LINE NUMBER ORDER
;ENTRY:			E3DM
;INPUT ARGUMENT:	ZDM
;			YDMEND	INDEX OF FIRST FREE PLACE IN ZDM
;NORMAL EXIT:		RETURN
;ERROR EXIT:
;OUTPUT ARGUMENTS:	ZDM
;CALL FORMAT:		EXEC	E3DM


E3DM::
	PROC
	SAVE	<X2,X3,X4,X5,X6,X7,X10>
	SETZB	X2,X4
	L	X0,YDMEND			;INIT INDEXES
	CAIGE	X0,3
	GOTO	E3DME				;NO SORTING IF ONE OR NO ELEMENT

;SAVE IN YZDM ALL INDEXES OF ELEMENTS IN ZDM WITH FIRST LINENUMBER
;<= FIRST LINE NUMBER OF PRECEDING ELEMENT, THUS THERE WILL
;BE GROUPS WITH ELEMENTS IN INCREASING LINE NUMBER ORDER

	WHILE
		HRRZ	X0,ZDM(X2)
		ADDI	X2,3
		CAML	X2,YDMEND
		GOTO	FALSE
	DO
		HRRZ	X1,ZDM(X2)
		IF
			CAMGE	X0,X1
			GOTO	FALSE
		THEN
			ST	X2,YZDM(X4)
			ADDI	X4,1
			SETZM	YZDM(X4)
		FI
	OD
	JUMPE	X4,E3DME
	SETOFA	YE3DM				;INDICATE NO GROUPS SORTED
	SETZB	X2,X4
	SETZB	X5,X6
	SETZM	YZDMI
E3DM1:
	L	X2,YZDMI(X4)
	SKIPN	X3,YZDM(X6)			;GET START INDEXES OF THE TWO
						;GROUPS TO SORT NOW
	GOTO	E3DM6				;NO MORE GROUPS TO SORT
	MOVN	X7,X3				;NUMBER OF ELEMENTS IN FIRST GROUP
	IDIVI	X7,3
	HRL	X4,X7
	ADDI	X6,1
	SKIPN	X7,YZDM(X6)
	L	X7,YDMEND
	ST	X7,YDMB2
	MOVN	X7,X7
	IDIVI	X7,3
	HRL	X5,X7
	HRRZ	X0,ZDM(X2)
	HRRZ	X1,ZDM(X3)

;SORT TWO GROUPS IN INCREASING LINE NUMBER ORDER
;I.E. SAVE IN YZDMI INDEXES OF THE ELEMENTS IN ZDM
;PLACE INDEX OF ELEMENT WITH LOWEST LINE NUMBER FIRST ETC.

E3DM5:
	CAML	X0,X1
	GOTO	E3DM7
E3DM2:
	;ELEMENT IN FIRST GROUP LESS THAN EL IN SECOND GROUP
	ST	X2,YZDMI(X5)
	IF
		AOBJN	X4,FALSE
	THEN
		;NO MORE ELEMENTS IN THE FIRST GROUP
		IF
			IFONA	YE3DM
			GOTO	FALSE
		THEN
			LI	X4,0
			SETONA	YE3DM
		ELSE
			CAIN	X4,QLDM/3
			LI	X4,0
		FI
		LI	X0,-1
	ELSE
		;MORE ELEMENTS IN FIRST GROUP
		IF
			IFOFFA	YE3DM
			GOTO	FALSE
		THEN					;ALL TIMES EXCEPT FIRST:
			HRRZ	X2,X4
			CAIL	X2,QLDM/3
			HRRI	X4,0
			L	X2,YZDMI(X4)
		ELSE
			ADDI	X2,3
		FI
		HRRZ	X0,ZDM(X2)
	FI	GOTO	E3DM4
E3DM7:
	IF
		CAMG	X0,X1
		GOTO	FALSE
	E3DM3:
	THEN		;EL IN SECOND GROUP LESS THAN EL IN FIRST GROUP
	
		ST	X3,YZDMI(X5)
		ADDI	X3,3
		HRRZ	X1,ZDM(X3)
		CAML	X3,YDMB2
		LI	X1,-1
	ELSE
		;FIRST LINE NUMBERS ARE EQUAL
		HRRZ	X7,ZDM+1(X2)		;COMPARE INDEX OF SECOND LINE NUMBERS
		HRRZ	X10,ZDM+1(X3)
		CAMGE	X7,X10
		GOTO	E3DM2
		CAME	X7,X10
		GOTO	E3DM3
		L	X7,ZDM+1(X2)
		CAMG	X7,ZDM+1(X3)
		GOTO	E3DM2
		GOTO	E3DM3
	FI
E3DM4:
	HRRZ	X10,X5
	CAIL	X10,QLDM/3-1
	HRRI	X5,-1
	AOBJN	X5,E3DM5
	GOTO	E3DM1

E3DM6:
	;YZDMI NOW CONTAINS THE INDEXES OF ELEMENTS IN ZDM
	HRR	X5,X4				;INDEX OF FIRST EL
	MOVN	X0,YDMEND
	IDIVI	X0,3
	HRL	X5,X0
	LI	X0,QLDM/3-1
	SETZB	X3,X10
	LOOP
		L	X2,YZDMI(X5)
		LD	X6,ZDM(X2)
		STD	X6,YZDM(X3)
		L	X1,ZDM+2(X2)
		ST	X1,YZDM+2(X3)
		;IF LAST LINE OF ERROR NUMBER LESS THAN PRECEDING ONE
		;THEN LAST LINE:= PRECEDING LINENUMBER
		TLZ	X7,-1
		SKIPE	X3
		HRRZ	X10,YZDM-3+1(X3)
		CAMGE	X7,X10
		HRRM	X10,YZDM+1(X3)
		;CHECK THAT LAST LINE NUMBER OF MESSAGE >=FIRST ONE
		TLZ	X6,-1
		IF
			CAMG	X6,X7
			GOTO	FALSE
		THEN
			;LAST LINE NUMBER TOO SMALL
			HRRM	X6,YZDM+1(X3)
			IFN	QDEBUG,<SKPINC
					NOP
					OUTSTR	[ASCIZ	/LAST LINE NUMBER IN ERROR MESSAGE LESS THAN FIRST ONE
	/]>
		FI
		ADDI	X3,3
	AS
		CAIN	X0,(X5)
		TRO	X5,-1
		AOBJN	X5,TRUE
	SA
	HRRZI	X3,ZDM
	L	X2,YDMEND
	ADD	X2,X3
	HRLI	X3,YZDM
	BLT	X3,-1(X2)
E3DME:
	RETURN
	EPROC
	SUBTTL	E3EM

;PURPOSE:	THIS ROUTINE USES AN INDEX TO ZDM, WHICH WILL BE
;=======	IN REG XDM2 AT THE TIME OF CALL,
;		AND, WITH THE AID OF TABLES YE3D,YE3DL,YE3M,YE3MI,
;		PRODUCES AN ERROR MESSAGE IN ASCII,
;		WHICH IS PLACED IN YE3LIN AND YE3ERR. THE NUMBER
;		OF CHARACTERS IN YE3LIN IS STORED IN YE3LS3
;		AND THE NUMBER OF GENERATED <CR><LF>:S IS
;		SUBTRACTED FROM YE3PNO

;ENTRY:	E3EM
;INPUT ARGUMENT:	REG XDM2 CONTAINING INDEX OF ZDM
;NORMAL EXIT:		RETURN
;OUTPUT ARGUMENTS:	ERROR MESSAGE IN YE3LIN AND YE3ERR
;CALL FORMAT:		EXEC E3EM

QIERR=530
	PROC
E3EM:	SAVE	<X2,X3,X4,X5,X6,X7,X10,X11,X13,X14,X15>
RNAME	<XDM2>,<X12>
RNAME	<XERRN,XERRN1,XETYP,XE3MI,XN>,<X3,X4,X5,X13,X14>

;fetch error number from ZDM
	LF	XERRN,ZDMEN(XDM2,ZDM-1)	;[104]
;get entry from YE3MI and store in XE3MI
NUM:	L	X1,XERRN
	IDIVI	X1,2
	XCT	[HRLZ	XE3MI,YE3MI-1(X1)
		 HLLZ	XE3MI,YE3MI(X1)](X2)
	IF	JUMPN	XE3MI,FALSE
	THEN	;ILLEGAL ERROR NUMBER
		LI	XERRN,QIERR
		GOTO	NUM
	FI
	LF	XETYP,ZE3ETP(,XE3MI)
	IF	CAIE	XETYP,QT
		GOTO	FALSE
	THEN	;termination error
		SETONA	Y3TMES
	FI
;<CR> <LF> to LST file
	L	[BYTE(7)0,0,0,15,12]
	ST	YE3LIN
;convert and store error number and type
	SETZ	XERRN1,
	LSHC	XERRN,-6
	LSH	XERRN,4
	LSHC	XERRN,3
	LSH	XERRN,1
	LSH	XERRN1,-4
	IOR	XERRN,[ASCII/SIM00/]
	IOR	XERRN1,[ASCII/0  E /
			ASCII/0  T /
			ASCII/0  W /](XETYP)
	STD	XERRN,YE3ERR
	STD	XERRN,YE3LIN+1

RNAME	<XLIN0,XLIN,XLIN1,XSEM,XSEM1>,<XERRN,XERRN1,XETYP,X6,X7>

;convert and store line number
	LF	XLIN0,ZDML1(XDM2,ZDM-1)	;[104]
	LI	XN,5
	SETZB	XLIN,XLIN1
	LOOP	JUMPE	XLIN0,FALSE
		IDIVI	XLIN0,12
		ADDI	XLIN,60
		LSHC	XLIN,-7
	AS
		DECR	XN,TRUE
		GOTO	LINE
	SA
	LOOP	LI	XLIN,40
		LSHC	XLIN,-7
	AS
		DECR	XN,TRUE
	SA
LINE:	L	XLIN0,[ASCII/LINE /]
	ST	XLIN0,YE3ERR+2
	ST	XLIN1,YE3ERR+3
	ST	XLIN0,YE3LIN+3
	ST	XLIN1,YE3LIN+4
;convert and store semicolon number
	LF	XSEM,ZDMSM(XDM2,ZDM-1)	;[104]
	JUMPN	XSEM,[SETZ	XSEM1,
		      IDIVI	XSEM,12
		      JUMPE	XSEM,[ROTC	XSEM,-16
				      IOR	XSEM,[BYTE(7)72,60,40,40,40]
				      GOTO	SSEM]
		      LSHC	XSEM,26
		      LSH	XSEM1,-7
		      IOR	XSEM,XSEM1
		      IOR	XSEM,[BYTE(7)72,60,60,40,40]
		      GOTO	SSEM]
	L	XSEM,[ASCII/     /]	;supress number
SSEM:	ST	XSEM,YE3ERR+4
	ST	XSEM,YE3LIN+5

RNAME	<XIND,XIND1,XCHR,XCHR1,XLST,XTTY,XENT,XPTX,XE3M>,<XSEM,XSEM1,XLIN0,XLIN,XLIN1,X2,X10,X11,X15>

;calculate index to YE3M
	LF	XIND,ZE3IND(,XE3MI)
	IDIVI	XIND,3
;output error message
	L	XLST,[POINT 7,YE3LIN+5,34]
	L	XTTY,[POINT 7,YE3ERR+4,34]
	LI	36+5
	ST	YE3LS3
	SETOM	YSIXB
;init byte pointer
	L	[POINT	12,ZDM+1(XDM2)]
	ST	YDMPT3
;get pointer to first byte and number of bytes to be processed
	L	XE3M,[POINT	12,YE3M(XIND)
			POINT	12,YE3M(XIND),11
			POINT	12,YE3M(XIND),23](XIND1)
	LF	XN,ZE3NBW(,XE3MI)

RNAME	<XE3D>,<XE3MI>

NEW:	ILDB	XENT,XE3M
	IF
		CAIL	XENT,7775
		GOTO	FALSE
	THEN
		;ORDINARY WORD
		SETZ	XPTX,
;scan through YE3DL until word number interval found
SCAN:		LF	,ZE3ANB(XPTX)
		CAMGE	XENT
		AOJA	XPTX,SCAN
;get byte pointer to first char to be taken out of YE3D
		LF	,ZE3ANB(XPTX,-1)
		SUB	XENT,
		SOJ	XENT,
		IMUL	XENT,XPTX
		LF	XCHR,ZE3ACH(XPTX)
		ADD	XCHR,XENT
		IDIVI	XCHR,6
		L	XE3D,[POINT 6,YE3D(XCHR)
			      POINT 6,YE3D(XCHR),5
			      POINT 6,YE3D(XCHR),11
			      POINT 6,YE3D(XCHR),17
			      POINT 6,YE3D(XCHR),23
			      POINT 6,YE3D(XCHR),29](XCHR1)
	ELSE
		;TEXT OR IDENTIFIER IS TO BE EDITED
		IF
			CAIN	XENT,7777
			GOTO	FALSE
		THEN
		;ASCII TEXT OR NUMBER IS TO BE EDITED INTO MESSAGE
			SETZM	YSIXB
			IF
				CAIE	XENT,7776
				GOTO	FALSE
			THEN
				;[45] NEW CODE TO OUTPUT ERRORMESSAGES CONTAINING NAME OF A FILE
				;ADDRESS OF LOOKUP BLOCK IN ZDM+2
				HLRZ	XPTX,ZDM+1(XDM2)
				IF
					TRNE	XPTX,600000
					GOTO	FALSE
				THEN
					;RIGHT HALF OF THEIRD WORD IN ZDM CONTAINS ADDRESS
					;SIXBIT FORMAT
					SETOM	YSIXB
					LI	XPTX,12
					HRRZ	XE3D,ZDM+1(XDM2)
					LD	X0,(XE3D)		;GET NAME
					LSH	X1,-6
					IOR	X1,[SIXBIT/./]
					L	XE3D,[POINT 6,Y3BUF]
					STD	X0,Y3BUF
				ELSE
					;END OF [45]
					;ASCII TEXT
					LI	XPTX,5
					L	XE3D,[POINT 7,ZDM+1(XDM2)]
				FI
			ELSE
				;BIN NUMBER, CONVERT TO ASCII
				LI	XPTX,4
				ILDB	X0,YDMPT3
				EXEC	E3BD
				;COUNT NUMBER OF CHARACTERS
				LOOP
					LSHC	X0,7
				AS
					TLNN	X1,137B24
					SOJA	XPTX,TRUE
				SA
				ST	X1,Y3BUF
				L	XE3D,[POINT 7,Y3BUF]
			FI
		ELSE
			;IDENTIFIER OR CONTROLWORD
			ILDB	XE3D,YDMPT3
			;NO EDITING IF INDEX = 0
			JUMPE	XE3D,TONEW
			LSH	XE3D,1
			IF
				CAIGE	XE3D,2*Q1024
				GOTO	FALSE
			THEN
				;IDENTIFIER
				ADD	XE3D,[POINT 6,ZSE-4000]
			ELSE
				;SYMBOL IS TO BE EDITED
				ADD	XE3D,[POINT 6,E3CTW]
			FI
			;COUNT NUMBER OF CHARACTERS IN NAME
			LD	X0,(XE3D)
			LI	XPTX,1
			LOOP
				LSHC	X0,6
			AS
				JUMPE	X0,FALSE
				CAIN	X0,'&'
				GOTO	TRUE
				AOJA	XPTX,TRUE
			SA
		FI
	FI
	ADDM	XPTX,YE3LS3
;transfer the word from YE3D, followed by one blank
LOOP:	ILDB	XE3D
	SKIPE	X0
	SKIPE	YSIXB
	ADDI	40	;convert to ASCII if SIXBIT
	CAIN	"&"
	ILDB	XE3D	;IF special character
	IDPB	XLST
	IDPB	XTTY
	DECR	XPTX,LOOP
	SETOM	YSIXB
	LI	" "
	IDPB	XLST
	IDPB	XTTY
	AOS	YE3LS3
TONEW:
	DECR	XN,NEW	;jump to process next byte in YE3M
	LFE	,ZDML2(XDM2,ZDM-4)	;[104]
	LF	X1,ZDML2(XDM2,ZDM-1)	;[104]
	IF	CAMN	X1
		GOTO	FALSE
	THEN	;first error on this line
		SOS	YE3PNO
	ELSE	;not first error
		SETZM	YE3LIN	;remove leading <CR> <LF>
	FI
	LFE	,ZDML2(XDM2,ZDM+2)	;[104]
	IF	CAME	X1
		GOTO	FALSE
	THEN	;more errors to follow on this line
		HRREI	-3
		ADDM	YE3LS3
		L	X1,[BYTE(7)15,12,0,0,0]
	ELSE	;last error on this line
		L	X1,[BYTE(7)15,12,0,15,12]
		SOS	YE3PNO
	FI
REP:	LSHC	7
	IDPB	XLST
	IDPB	XTTY
	JUMPN	X1,REP
	IDPB	X1,XTTY
	SOS	YE3PNO
	RETURN


	EPROC
	SUBTTL	E3IN


;PURPOSE:		READ SOURCE CODE,CREATE LINE NUMBER AND STORE IN YE3LIN,
;			OUTPUT LINE TO LST FILE AND CREATE ERROR MESSAGE
;ENTRY:			E3IN
;INPUT ARGUMENT:	REG X1 CONTAINING CONTROLWORD FROM LS1
;			YE3LIN CONTAINING BEGIN/END NO
;			YE3LIP	BYTE POINTER YE3LIN
;			YE3LNO	CURRENT LINE NUMBER
;			YE3PNO	NUMBER OF LINES LEFT TO PRINT ON CURRENT PAGE

;NORMAL EXIT:		RETURN
;ERROR EXIT:		-
;OUTPUT ARGUMENTS:	-
;CALL FORMAT:		EXEC	E3IN
;CALLED SUBROUTINES:	E3BD, E3EM, E3P2, O3RS, O3RSC, O3WS



	;LOCAL JUMP TO E3IN EXISTS
E3IN::
	;SAVE RECORD
	ST	X1,ZLEREC
IF
	IFONA	YE3LST
	GOTO	FALSE
THEN
	;NO LIST FILE
	AOS	YE3LNO
	;SAVE START ADDR OF LINE
	LD	X5,YBHSRC+1
ELSE
	;LIST FILE IS TO BE GENERATED
	SKIPG	YE3PNO
	;OUTPUT NEW HEADER
	EXEC	E3P2
	L	X4,YBEGNO
	;CHECK IF END NUMBER IS TO BE OUTPUT BEFORE SOURCE LINE
	IF
		SKIPN	YE3END
		GOTO	FALSE
	THEN
		;END IS TO BE OUTPUT
		IF
			SKIPN	YE3LS3
			GOTO	FALSE
		THEN
			;BEGIN NUMBER ALREADY ON LINE
			;OUTPUT TAB OR SPACE
			IF
				CAIGE	X4,↑D100
				GOTO	FALSE
			THEN
				;MORE TAHN 100 BEGIN IN SOURCE 
				;OUTPUT TAB
				LI	X0,"	"
				IDPB	X0,YE3LIP
				AOS	YE3LS3
				SETONA	YE3TAB
			ELSE
				;OUTPUT SPACE AFTER BEGIN NO
				LI	X0," "
				LI	X1,4
				SUB	X1,YE3LS3
				LOOP
					IDPB	X0,YE3LIP
					AOS	YE3LS3
				AS
					SOJG	X1,TRUE
				SA
			FI
		FI
		LI	X6,"E"
		;OUTPUT END NUMBER
		L	X0,YE3END
		EXEC	E3BEL
		SETZM	YE3END
	FI
	LI	X0,"	"
	IDPB	X0,YE3LIP
	AOS	YE3LS3
	IF
		CAIL	X4,↑D100
		IFONA	YE3TAB
		GOTO	FALSE
	THEN
	
		IDPB	X0,YE3LIP		;STORE TWO TABS IF MORE THAN 100 BEGIN
		AOSA	YE3LS3
	FI
		SETOFA	YE3TAB
	IF
		IFOFF	ZLESRC
		GOTO	TRUE
		;CHECK IF CORRECT LINE NUMBER
		IFON	ZLEOK
		GOTO	FALSE
	THEN
		;INCORRECT OR NO LINENUMBER IN SOURCE CODE
		;CREATE LINE NUMBER 
	
		AOS	YE3LNO
		L	X0,YE3LNO
		EXEC	E3BD			;CONVERT LINE NUMBER TO DEC ASCII
		LOOP
			LSHC	X0,7
			IDPB	X0,YE3LIP
		AS
			JUMPN	X1,TRUE
		SA
		LI	X2,5
		IF
			IFON	ZLESRC
			GOTO	FALSE
		THEN
			;TAB IF NO LINE NUMBER IN SOURCE
			LI	X4,"	"
			IDPB	X4,YE3LIP
			LI	X2,6
		FI
		ADDM	X2,YE3LS3			;6 BYTES INTO LINE
	FI

	LD	X5,YBHLS3+1
	IF
		SKIPN	YE3LS3
		GOTO	FALSE
	THEN
		;OUTPUT BEG END NUMBER AND LINE NUMBER IF EXISTING TO LS3
		LI	X1,YE3LIN
		EXEC	O3WS,<YE3LS3>
	FI
FI
	;SAVE ADDRESS OF LINE TO BE USED IF FAULTY LINE
	STD	X5,Y3LINH+1
	EXEC	O3RSC				;READ SOURCE CODE LINE
IF
	IFOFFA	YE3LST
	GOTO	FALSE
THEN
	;SAVE POINTER TO POS AFTER CURRENT LINE 
	;AS PAGE HEADER MIGHT APPEAR IN OUTPUT BUFFER
	L	X0,YBHLS3+1
	ST	X0,Y3LINH
	SOS	YE3PNO	
FI
	CAML	XDM1,YDMEND			;CHECK IF MORE FAULTY STATMENT
	GOTO	E3IN1
	HRRZ	X1,ZDM(XDM1)			;CHECK IF FAULTY LINE
	CAMLE	X1,YE3LNO
	GOTO	E3IN1

	;FAULTY LINE
	IF
		IFONA	YE3TTY
		GOTO	FALSE
	THEN
		;OUTPUT ON TTY
		L	X0,[POINT	7,YE3LIN]
		ST	X0,YE3LIP
		IF
			IFONA	YE3LST
			GOTO	FALSE
		THEN
			;NO LIST FILE
			L	X0,YBHSRC+1
			L	X2,YBHSRC
		ELSE
			;Y3LINH CONTAINS POINTER TO POS AFTER CURRENT LINE
			;LIST FILE
			L	X0,Y3LINH
			L	X2,YBHLS3
		FI
		;OUTPUT LINE REFFERING TO ERROR
		LI	X4,↑D133
		LOOP
			IF
				SOSGE	Y3LINH+2
				GOTO	FALSE
			THEN
			;GET BYTE FROM SOURCE LINE 
			;AND STORE IN LOCAL BUFFER
				ILDB	X1,Y3LINH+1
				SKIPE	X1
				IDPB	X1,YE3LIP
			ELSE
			;MODIFY BYTE POINTER TO POINT TO NEXT CHAR
			;IN ANOTHER BUFFER
				ADDI	X2,1
				HRRM	X2,Y3LINH+1
				LI	X1,1200		;BUFFER SIZE
				ST	X1,Y3LINH+2
			FI
		AS
			CAME	X0,Y3LINH+1
			SOJGE	X4,TRUE
			LI	X1,0
			IDPB	X1,YE3LIP
			OUTSTR	YE3LIN
			JUMPGE	X4,FALSE
			L	X1,[POINT	7,YE3LIN]
			ST	X1,YE3LIP
			LI	X4,↑D133
			GOTO	TRUE
		SA
	FI

E3IN1:
	EXEC	E3ERR
	HRLZ	X1,ZLEREC
	TLZ	X1,1
	SETZM	YE3LS3
	L	X0,[POINT	7,YE3LIN]
	ST	X0,YE3LIP
	;CHECK IF THIS LINE WAS NOLIST
	IFONA	YE3OPL
	SETOFA	YE3LST
	JUMPN	X1,E3IN
	RETURN



E3ERR:
		;CHECK IF ERROR MESSAGE AFTER THIS LINE (INCLUDING LINE NO 0)
IF
	CAML	XDM2,YDMEND
	GOTO	FALSE
THEN
	WHILE
		HRRZ	X2,ZDM(XDM2)		;CHECK IF ERROR MESSAGE AFTER THIS LINE
		CAME	X2,YE3LNO

		GOTO	FALSE
	DO
E3ERRE:
		;ERROR MESSAGE AFTER THIS LINE
		IF
			IFOFFA	YE3LST
			GOTO	FALSE
		THEN
			;LIST FILE
			SKIPG	YE3PNO
			;OUTPUT HEADER
			EXEC	E3P2
		FI

			;YE3PNO IS UPDATED IN E3EM
		EXEC	E3EM				;CREATE ERROR MESSAGE
		IFOFFA	YE3TTY
		OUTSTR	YE3ERR
		IF
			IFOFFA	YE3LST			;OUTPUT MESSGAE IF LIST WANTED
			GOTO	FALSE
		THEN
			LI	X1,YE3LIN
			EXEC	O3WS,<YE3LS3>
		FI
		CAMG	XDM1,XDM2
		ADDI	XDM1,3
		ADDI	XDM2,3				;POINT TO NEXT MESSAGE
		CAMG	XDM2,YDMEND
	OD
FI
	IFONA	YE3LAS
	;OUTPUT PAGE HEADER
	EXEC	E3PAGE
	L	X0,[POINT 7,YE3LIN]
	ST	X0,YE3LIP
	RETURN
	SUBTTL	E3LI



COMMENT ;
PURPOSE:		INVESTIGATE AND TREAT CONTROLWORD FROM LS1
			UPDATE PAGE NUMBER AT FORM FEED
ENTRY:			E3LI
INPUT ARGUMENT:		REG X1 CONTAINING CONTROLWORD
NORMAL EXIT:		RETURN
ERROR EXIT:		-
OUTPUT ARGUMENTS:	SWITCHES INDICATING STATUS
			AND LOOKUP ARG SOURCE
			THE FOLLOWING SWITCHES ARE SET IN CASES LISTED BELOW
			AND SET OFF IN OPPOSITE CASES
			YE3LAS	FF,PAGE
			YE3TTY	NO ERRORS ON TTY
			YE3LST	LIST
			YE3OPL	NO LIST
			
			E3LI CONTAINS THE FOLLOWING SUBROUTINES:
			E3LICF	FORM FEED  CALLED FROM O3RSC IN O3

			E3LICP	PAGE
			E3LICN	N SIWTCH
			E3LICL	LIST
			E3LICS	INF OF SOURCE
CALL FORMAT:		EXEC	E3LI
;



E3LI::	PROC

	SAVE	<X2>
	LI	X0,0
	WHILE
		;CHECK IF NUMBER BEFORE SWITCH
		JUMPLE	X1,FALSE
	DO
		LSHC	X0,7
	OD
	TRZ	X1,-1
	TLZ	X1,3777
	LI	X2,4
	IF
		CAMN	X1,E3LIC(X2)
		GOTO	FALSE
	THEN
		SOJGE	X2,.-2
		IFN	QDEBUG,<SKPINC
				NOP
				OUTSTR	[ASCIZ	/FAULTY RECORD IN LS1/]>
	ELSE
		EXEC	@E3LIC1(X2)
	FI
	RETURN
	EPROC


E3LICP:						;PAGE
	IF
		JUMPE	X0,FALSE
	THEN					;STORE NEW VALUE OF LINES PER PAGE
		LSH	X0,1
		EXEC	E3DB
		ST	X1,YE3PAG
	FI
	;[7] UPDATE MAIN PAGE NUMBER
	;I.E. SAME ACTION AS FOR E3LICF

E3LICF:	SETONA	YE3LAS				;FORM FEED UPDATE MAIN NUMBER OF PAGE
	HRLZI	X0,1
	ADD	X0,YE3PGN
	HLLZM	X0,YE3PGN
	RETURN



E3LICN:					;ERRORS TERMINAL T/F
	IF	CAIE	X0,"-"
		GOTO	FALSE
	THEN				;ALLOW ERRORS ON TTY
		SETOFA	YE3TTY
	ELSE
		SETONA	YE3TTY		;NO ERRORS ON TTY
	FI	RETURN

E3LICL:					;LIST T/F
	IF	CAIE	X0,"-"
		GOTO	FALSE
	THEN
		;NO LIST OPTIONS(-L) IS PRINTED
		SETONA	YE3OPL
	ELSE
		IFOFF	YOPLST
		EXEC	I3LS3		;OPEN LIST FILE
		SETONA	YE3LST		;LIST
		SETOFA	YE3OPL
	FI
	RETURN



E3LICS:					;S RECORD
	;READ DEVICE OF SOURCE
	EXEC	O3RS
	ST	X1,Y3DEV
	LI	X2,0
	LOOP	EXEC	O3RS		;READ 3 WORDS LOOKUP ARG FOR SOURCE CODE
		ST	X1,YELSRC(X2)
		SKIPN	X2
		AOJA	X2,TRUE
		ADDI	X2,2
	AS	CAIG	X2,3
		GOTO	TRUE
	SA
	;IF NOLIST IN CUSP,NO PRINTING
	IFONA	YE3OPL
	SETOFA	YE3LST
	;SAVE PPN NUMBER WHICH WILL BE DESTROYED BY LOOKUP
	ST	X1,YE3PNN
	EXEC	I3S			;OPEN IN FILE
	EXEC	E3PAGH			;GENERATE PAGE HEADER
			;[7] UPDATE MAIN PAGE NUMBER. DO NOT CALL E3PAGE
			; BUT ZERO YE3PNO TO LET NEXT LINE GENERATE A NEW
			; PAGE. SECONDARY PAGE NUMBER(RIGHT HALF OF YE3PGN)
			; IS SET TO -1 SINCE A AOS IS PERFORMED BEFORE THE
			; NEW PAGE IS GENERATED, AND THIS WILL INCREASE
			; MAIN PAGE NUMBER AND ZERO SECONDARY PAGE NUMBER.
	HLLOS	YE3PGN
	SETZM	YE3PNO
			; END [7]

	EXEC	E3ERR
	RETURN
	SUBTTL	E3LT


;PURPOSE:		CREATE LINENUMBER TABLE AND OUTPUT TO LISTFILE
;ENTRY:			E3LT
;INPUT ARGUMENTS:	Y3PLTS	POINTER START OF LINE NUMBER TABLE
;			Y3PLTE	POINTER END OF LINE NUMBER TABLE

;NORMAL EXIT:		RETURN
;ERROR EXIT:		-
;OUTPUT ARGUMENTS:	-
;CALL FORMAT:		EXEC	E3LT



E3LT:
	PROC
	;CREATE HEADER AND OUTPUT IT
	LI	X1,YE3RUB
	HRLI	X1,E3LTAB
	BLT	X1,YE3RUB+3
	LI	X0,4
	ST	X0,YE3NRU
	HLRZ	X0,YE3PGN
	ADDI	X0,1
	MOVSM	X0,YE3PGN
	EXEC	E3PAGE

	;SET STARTVALUES
	;NUMBER OF LINES ON CURRENT PAGE
	LI	X5,QPAGE-3
	;INDEX LOCAL BUFFER
	LI	X3,0
	;LET X7 AND X10 CONTAIN TAB RESP CRLF
	LI	X7,QHT
	LI	X10,QCRLF
	LSHC	X7,1
	;COMPUTE NUMBER OF WORDS IN TABLE
	L	X12,Y3PLTE
	SUB	X12,Y3PLTS
	L	X11,Y3PLTS
	L	X13,X11

	;TREAT LINE MUMBERS ON ONE PAGE
	;5 COLUMNES WITH N NUMBERS IN EACH COLUMNE
	;WHERE N=DEFAULT NUMBER OF LINES PER PAGE-3
	;THE LINE NUMBERS ARE OUTPUT IN INCREASING ORDER COLUMNEWISE

	;CREATE POINTER TO POS AFTER LAST EL IN LINENUMBER TABLE
	LI	X0,5*<QPAGE-3>(X11)
	CAMGE	X0,Y3PLTE
	ST	X0,Y3PLTE

	LOOP
		;GET LINENUMBER
		HLRZ	X0,(X11)
		;GET RID OF BIT FROM DECLARATION ENTRY
		TRZ	X0,200000
		;SET MAX VALUE TO ZERO IF -I SWITCH IS SET
		XORI	X0,177777
		SKIPE	X0
		XORI	X0,177777
		;CONVERT TO ASCII
		EXEC	E3BD
		ST	X1,Y3BUF(X3)
		LI	X2,3
		LI	X0,QHT
		HRLZ	X1,(X11)
		;CONVERT ADDRESS TO OCTAL ASCII
		LOOP
			LSH	X0,4
			LSHC	X0,3
			ADDI	X0,60
		AS
			SOJGE	X2,TRUE
		SA
		LSH	X0,1
		ST	X0,Y3BUF+1(X3)
		;CONVERT REMAINING DIGITS IN ADDRESS
		LOOP
			LSH	X0,4
			LSHC	X0,3
			ADDI	X0,60
		AS
			AOJE	X2,TRUE
		SA
		LSH	X0,1+3*7
		ST	X0,Y3BUF+2(X3)

		;COMPUTE ADDRESS OF NEXT NUMBER ON CURRENT LINE
		ADDI	X11,QPAGE-3
		ADDI	X3,3
		IF
			CAML	X11,Y3PLTE
			GOTO	FALSE
		THEN
			;ELEMENT IS NOT IN LAST COLUMNE
			;MORE NUMBERS ON LINE, OUTPUT TAB
			IORM	X7,Y3BUF-1(X3)
		ELSE
			;NO MORE ELEMENTS ON CURRENT LINE, OUTPUT LINE
			IORM	X10,Y3BUF-1(X3)
			LI	X1,Y3BUF
			IMULI	X3,5
			;OUTPUT LINE TO LIST FILE
			EXEC	O3WS,<X3>
			LI	X3,0
			IF
				SOJG	X5,FALSE
				;NO HEADER IF LAST NUMBER
				CAIG	X12,1
				GOTO	FALSE
			THEN
				;NEW PAGE, OUTPUT HEADER
				EXEC	E3P2
				;5 GROUPS OF QPAGE-3 ELEMENTS ARE TREATED
				;TREAT NEXT GROUP
				SUBI	X11,-1+QPAGE-3
				L	X13,X11
				LI	X5,QPAGE-3
				;COMUPTE ADDRESS OF LAST EL ON CURRENT PAGE
				LI	X0,5*<QPAGE-3>
				CAIGE	X12,5*<QPAGE-3>
				L	X0,X12
				ADDM	X0,Y3PLTE
			ELSE
				AOS	X11,X13
			FI
		FI
	AS
		SOJG	X12,TRUE
	SA
	RETURN
	EPROC
	SUBTTL	E3PAGE



;PURPOSE:		GENERATE FINAL PAGE HEADER OUTPUT TO LIST
;ENTRY:			E3PAGE	TO GENERATE PAGE HEADING
;			E3P2	TO UPDATE SECONDARY NUMBER OF PAGE
;INPUT ARGUMENTS:	YE3PGN	CURRENT PAGE NUMBER
;			YE3PGH	STANDARD HEADER PART 1
;			YE3PNM	STANDARD HEADER PART 2
;			YE3PNN	NUMBER OF BYTES IN YE3PNM
;			YE3RUB	TEXT FROM PAGE SWITCH
;			YE3NRU	NUMEBR OF WORDS IN YE3RUB
;OUTPUT ARGUMENTS:	HEADER IN LIST FILE
;NORMAL EXIT:		RETURN
;ERROR EXIT:		-
;CALLED SUBROUTINES:	O3WS
;CALL FORMAT:		EXEC	E3P2 RESP EXEC E3PAGE

E3P2:					;UPDATE SECONDARY PAGE NUMBER
	AOS	YE3PGN
E3PAGE::
	SAVE	<X2,X3>
	SETOFA	YE3LAS
	HRRZS	YE3NRU			;NEW PAGE TEXT ALLOWED
	IFOFFA	YE3LST
	GOTO	E3PAG1
	LI	X1,YE3PGH
	;OUTPUT STANDARD PART OF HEADING
	EXEC	O3WS,<[↑D80]>
	HLRZ	X0,YE3PGN
	EXEC	E3BD
	IF	HRRZ	X0,YE3PGN
		JUMPE	X0,FALSE
	THEN	LSH	X1,7
		IORI	X1,"-"B34
		ST	X1,Y3BUF
		EXEC	E3BD
		WHILE
			TLNE	X1,20B24
			GOTO	FALSE
		DO
			LSH	X1,7
		OD
	ELSE
		SETZM	Y3BUF
	FI	ST	X1,Y3BUF+1
	LI	X1,Y3BUF
	L	X2,E3CR
	ST	X2,Y3BUF+2
	EXEC	O3WS,<[↑D12]>
	;OUTPUT NAME OF FILE ETC
	LI	X1,YE3PNM
	EXEC	O3WS,<YE3PNN>
	IF
		SKIPN	X2,YE3NRU
		GOTO	FALSE
	THEN
		LI	X1,YE3RUB			;OUTPUT TEXT FROM PAGE SWITCH
		IMULI	X2,5
		EXEC	O3WS,<X2>
	FI
	LI	X1,E3CR
	EXEC	O3WS,<[4]>
	L	X0,YE3PAG
	SUBI	X0,3
	ST	X0,YE3PNO
E3PAG1:
	HRROS	YE3NRU
	RETURN
	SUBTTL	E3PAGH


;PURPOSE:		GENERATE HEADER OF PAGE
;ENTRY:			E3PAGH
;INPUT ARGUMENTS:	-
;NORMAL EXIT:		RETURN
;OUTPUT ARGUMENTS:	-
;CALL FORMAT:		EXEC	E3PAGH


E3PAGH:
	PROC
	SAVE	<X3,X4>
	;GENARATE STANDARD PART OF HEADER AND OUTPUT TO LOCAL BUFFER

	LI	X1,YE3PGH
	HRLI	X1,E3SIM
	BLT	X1,YE3PGH+10
	;COMPUTE DATE
	DATE	X2,
	LI	X4,YE3PGH+11
	EXEC	E3PDAT
	;COMPUTE TIME

	MSTIME	X2,
	LI	X4,YE3PGH+14
	EXEC	E3PTIM
	;OUTPUT PAGE
	LI	X1,YE3PGH+16
	HRLI	X1,E3SIPA
	BLT	X1,YE3PGH+17

	;CONVERT NAME OF FILE FROM SIXBIT TO ASCII
	L	X3,[POINT 7,YE3PNM]
	SETZM	YE3PNM+1
	L	X1,YELSRC
	;CONVERT FILE NAME
	EXEC	E3PSA
	;CONVERT EXTENSION
	HLLZ	X1,YELSRC+1	;[4] DATE 75 ERROR Use only left half

	;CHECK IF EXT EXISTS

	IF
		JUMPE	X1,FALSE
	THEN
		;OUTPUT .EXT
		LI	X0,"."
		IDPB	X0,X3
		EXEC	E3PSA
	FI
	LI	X0,"	"
	IDPB	X0,X3

	;COMUPTE PPN NUMBER

	LI	X0,"["
	IDPB	X0,X3
	SKIPN	X4,YE3PNN
	GETPPN	X4,
	HLRZ	X0,X4
	EXEC	E3PPN
	LI	X0,","
	IDPB	X0,X3
	HRRZ	X0,X4
	EXEC	E3PPN
	LI	X0,"]"
	IDPB	X0,X3
	LI	X4,1(X3)
	LI	X0,0
	WHILE	CAIN	X4,(X3)
		GOTO	FALSE
	DO
		IDPB	X0,X3
	OD
	;COMPUTE NUMBER OF CHARACTERS IN SECOND PART OF HEADER
	;COMPUTE CREATION DAY OF FILE

	;[5] DATE 75 ERROR  Use also HIGH DATE 2 to compute creation day
	HRRZ	X0,YELSRC+1
	LSH	X0,-3
	TRZ	X0,707777

	HRRZ	X2,YELSRC+2
	TRZ	X2,770000

	IOR	X2,X0	;[5]

	EXEC	E3PDAT
	;COMPUTE CREATION TIME OF FILE
	L	X2,YELSRC+2
	TLZ	X2,777740
	LSH	X2,-↑D12
	ADDI	X4,3
	EXEC	E3PTIM
	SUBI	X4,YE3PNM-2
	IMULI	X4,5
	ST	X4,YE3PNN

	RETURN
	EPROC


E3PPN:
	;CONVERTS PPN NUMBER TO ASCII AND OUTPUT TO HEADER
	WHILE
		JUMPE	X0,FALSE
	DO
		LSHC	X0,-3
		LSH	X1,-4
		TLO	X1,"0"B24
	OD
	LOOP
		LSHC	X0,7
		IDPB	X0,X3
	AS
		JUMPN	X1,TRUE
	SA
	RETURN

E3PSA:
	LOOP
		LI	X0,0
		LSHC	X0,6
		ADDI	X0,40
		IDPB	X0,X3
	AS
		JUMPN	X1,TRUE
	SA
	RETURN
	SUBTTL	E3PDAT


;PURPOSE:		COMPUTE DATE AND TIME AND CONVERT TO ASCII
;ENTRY:			E3PDAT COMPUTE DAY
;			E3PTIM COMPUTE TIME
;INPUT ARGUMENTS:	E3PDAT:  REG X2 CONTAINING DATE
;			E3PTIM:  REG X2 CONTAINING TIME
;			REG X4 ADDRESS OF LOCAL BUFFER WHERE TO PUT CONVERTED TIME
;NORMAL EXIT:		RETURN
;OUTPUT ARGUMENTS:	-
;CALL FORMAT:	EXEC E3PDAT  RESP  EXEC E3PTIM


E3PDAT:
	PROC
	SAVE	<X3,X4>
	IDIVI	X2,↑D31
	LI	X0,1(X3)
	EXEC	E3BD			;CONVERT DAY TO ASCII
	LSH	X1,7
	IORI	X1,"-"B34
	ST	X1,@X4
	;COMPUTE MONTH
	IDIVI	X2,↑D12
	L	X3,E3MON(X3)
	ADDI	X4,1
	ST	X3,@X4
	;COMPUTE YEAR
	LI	X0,↑D1964(X2)
	EXEC	E3BD
	LSH	X1,7
	ADDI	X4,1
	ST	X1,@X4
	RETURN
	EPROC



E3PTIM:
	PROC
	SAVE	<X3,X4>
	;COMPUTE TIME
	CAIL	X2,↑D60000			;SKIP NEXT INSTR IF TIME IN MINUTES
	IDIVI	X2,↑D60000			;TIME IN MILLI SECONDS
	IDIVI	X2,↑D60
	L	X0,X2
	;CONVERT HOURS TO ASCII
	EXEC	E3BD
	LSH	X1,7
	IORI	X1,":"B34
	ST	X1,@X4
	L	X0,X3
	;CONVERT MINUTES TO ASCII
	EXEC	E3BD
	LSH	X1,↑D21
	TLO	X1,20B24
	TRO	X1,<QHT>B34
	ADDI	X4,1
	ST	X1,@X4
	RETURN
	EPROC
E3LIC:	ASCIZ	/N/
	ASCIZ	/L/
	ASCIZ	/S/
	ASCIZ	/P/

E3LIC1:	XWD	0,E3LICN
	XWD	0,E3LICL
	XWD	0,E3LICS
	XWD	0,E3LICP

E3LTAB:	ASCII	/	LINE NUMBER TABLE/
E3CR:	ASCIZ /

/
E3MON:					;MONTHS IN STANDARD TEXT
	ASCII /JAN-/
	ASCII /FEB-/
	ASCII /MAR-/
	ASCII /APR-/
	ASCII /MAY-/
	ASCII /JUN-/
	ASCII /JUL-/
	ASCII /AUG-/
	ASCII /SEP-/
	ASCII /OCT-/
	ASCII /NOV-/
	ASCII /DEC-/
E3SIM:	VERLST		;STANDARD PART OF HEADER
E3SIPA:	ASCII	/			 PAGE/
E3CTW:	SYMB	7,1,ERRSY
	LIT

	END