Google
 

Trailing-Edge - PDP-10 Archives - AP-D543V_SB - makvfu.mac
There are 30 other files named makvfu.mac in the archive. Click here to see a list.
	SUBTTL

;PROGRAM MAKVFU:

;	THIS PROGRAM PRODUCES A BINARY VFU IMAGE FOR LOADING 
;	INTO AN LP07 LINE PRINTER (DP2550). THE VFU IMAGE DESCRIBES
;	A MAXIMUM OF 8 CHANNELS AND 144 LINES. THE USER TYPES IN 
;	THE SPECIFICATIONS FOR EACH CHANNEL BY DESCRIBING THE LINE
;	OR LINES OF THE PAGE ON WHICH THE PRINTER WILL SKIP TO. THE
;	USER CAN SPECIFY THE LOGICAL AND PHYSICAL DIMENSIONS OF 
;	THE PRINTABLE PAGE. THIS PERMITS THE DEFINITION OF A FORMS
;	BREAK AREA AS WELL AS VARIABLE LENGTH "PAGES". THE USER
;	CAN ALSO SPECIFY THE PRINT DENSITY OF THE LINE
;	PRINTER. IE, 6 OR 8 LINES PER INCH.



;COPYRIGHT (C) 1977,1978 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	MACROS,MACTEN
	DEFTTL	(MAKVFU,1,,17,0,S.WELLS)
	.REQUIRE  SYS:HELPER.REL
	MAKTWO	(400000)		;DEFINE TWO SEGMENT PROGRAM
	GOHIGH				;START IN HIGH SEGMENT

;NOTES:	(1) THIS PROGRAM CONTAINS VARIABLES AND CODING TECHNIQUES
;	    THAT ASSUME AN ABSOLUTE CHANNEL MAXIMUM OF 12. THE 
;	    ENTIRE PROGRAM MUST BE THOROUGHLY CHECKED IF A CHANNEL SIZE
;	    GREATER THAN 12 IS DESIRED.

;	(2) THE MAXIMUM NUMBER OF LINES WAS DESIGNED TO BE VARIABLE.
;	    IE, MAXLIN CAN BE VARIED.

;	(3) THE EDIT HISTORY DESCRIBES CHANGES TO THE CODE NOT CONTAINED
;	    IN THE ORIGINAL CODING SHEETS. HOWEVER, THE
;	    FLOWCHARTS HAVE BEEN UPDATED TO REFLECT THESE EDITS.

;	(4) THE LARGER SUBROUTINES IN THIS PROGRAM USE THE VARIABLES
;	    AT THE END AS INPUT, EVEN THOUGH THEY ARE
;	    NOT EXPLICITLY CALLED OUT AS INPUTS TO THE 
;	    SUBROUTINES.

;	(5) MACRO 50A(425) DOES NOT SUPPORT DEFAULT ARGUMENTS TO MACROS.
;	    THUS, THE ARGUMENTS ARE CALLED OUT EXPLICITLY.

	SUBTTL	EDIT HISTORY

;[1] - FIRST RELEASE OF PROGRAM.  6/14/76

;[2] - CHANGED EXIT SUBROUTINE TO EXIT WITHOUT PRINTING THE EXIT
;      MESSAGE WHEN NO OUTPUT MESSAGE HAS BEEN EXECUTED.  6/21/76

;[3] - REMOVED "CHANNEL ASSIGNED MESSAGE" FROM INFO. BROKE OUT
;      NEW SUBROUTINE CALLED PLINE TO PRINT THE LINES DEFINED FOR
;      A CHANNEL. MODIFIED PLINE TO DETECT AND PRINT LINES FOR FORMS
;      BREAK CHANNELS.  6/21/76

;[4] - REMOVE MARK COMMAND  6/21/76

;[5] - CHANGED LPI MESSAGE IN INFO. MORE DESCRIPTIVE. CHANGED
;      LPI CODE TO ACCEPT 0 ARGUMENT  7/2/76

;[6] - CHANGED LPI MSG AGAIN IN INFO. REFERENCE HARDWARE  7/2/76

;[7] - CHANGED MESSAGE LABELS TO CONFORM TO DEC CONVENTION 7/2/76

;[8] - CHANGED DEFAULT LPI FROM 0 TO 6  7/2/76

;[9] - FIXED C 1[CR] BUG IN CHNL  7/2/76

;[10] - CHANGED LF TESTS TO TERMLF CALLS TO IGNORE SPACES
;       AND TABS AT END OF COMMAND  7/2/76

;[11] - CHANGED .PAGE CODE TO REDEFINE LENGTH IF PAGE GT LENGTH
;       WARNING ISSUED.  7/6/76

;[12] - CHANGED .LENTH CODE TO REDEFINE PAGE IF LENGTH LT PAGE.
;       WARNING ISSUED.  7/6/76

;[13] - CHANGE .INFO CODE TO EQUATE "I SPACE" WITH "I CR"
;       7/6/76

;[14] - ADD ERROR MSG E3 TO .INFO CODE  7/6/76

;[15] - FIX *O [1,2] BUG IN .OUTPT  7/7/76

;[16] - CHANGED SUBROUTINE TYI TO SUPPORT LOWER CASE ALPHABETICS
;	7/7/76

;[17] - changed pline to fix .info bug when length=pagsiz  7/7/76
	SUBTTL	MAKVFU MAINLINE PROGRAM MODULE

MAKVFU:
START:	RESET			;INIT THE WORLD
	MOVE	P,[IOWD 50,STK]	;INIT STACK
	PUSHJ	P,INIT		;INITIALIZE ALL VARIABLES
S5:	OUTSTR	ASTER		;OUTPUT PROMPT CHARACTER
	PUSHJ	P,GETSIX	;READ A KEYWORD
	JRST	S5		;IGNORE NULL INPUT
	SETOM	T1		;INIT KEYWORD MASK
	LDB	T2,[POINT 6,P3,5] ;LOAD P FIELD OF BYTE POINTER FROM
				  ;GETSIX. P FIELD CONTAINS COUNT OF
				  ;UNUSED BITS IN KEYWORD.
	LSH	T1,0(T2)	;CLEAR BITS IN MASK CORRESPONDING TO
				;UNUSED CHARACTERS IN KEYWORD.
	MOVEI	T2,NCOMS-1	;SETUP TABLE LENGTH-1 AS LOOP COUNTER
	SETOM	T4		;INIT COMMAND LOCATION
S10:	MOVE	T3,COMTAB(T2)	;READ NEXT COMMAND FROM CMD TABLE
	AND	T3,T1		;CLEAR CHARS NOT SPECIFIED IN KEYWORD
	CAME	T3,P2		;TEST-DOES KEYWORD MATCH MASKED CMD?
	JRST	S20		;NO-EXAMINE NEXT COMMAND
	JUMPGE	T4,S30		;TEST-AMBIGUOUS COMMAND? JUMP=YES
	HRRZ	T4,T2		;NO-SAVE TABLE PTR TO CMD
S20:	SOJGE	T2,S10		;TEST-END OF TABLE? JUMP=NO
	JUMPL	T4,S40		;TEST-ANY MATCH FOUND? JUMP=NO
	MOVE	T1,COMDIS(T4)	;PICK UP CMD DISPATCH TABLE ADDR
	PUSHJ	P,0(T1)		;CALL COMMAND SUBROUTINE
	JRST	S50
S30:	OUTSTR	E9		;ERROR-AMBIGUOUS COMMAND
	JRST	S50
S40:	OUTSTR	E10		;ERROR-ILLEGAL COMMAND
S50:	CAIE	P1,12		;TEST-TERMINATOR=LF?
	CLRBFI			;CLEAR INPUT BUFFER
	JRST	S5
	SUBTTL	COMMAND AND COMMAND DISPATCH TABLES

	DEFINE	C(A,B)
<
	SIXBIT	\A\
>

	DEFINE	COMS
<
	C	(CHANNE,.CHNL)	;CHANNEL COMMAND
	C	(EXIT,.EXIT)	;EXIT COMMAND
	C	(FORMS,.FORM)	;FORMS BREAK COMMAND
	C	(HELP,.HELP)	;HELP COMMAND
	C	(INFORM,.INFO)	;INFORMATION COMMAND
	C	(LENGTH,.LENTH)	;LENGTH COMMAND
	C	(LPI,.LPI)	;LINES PER INCH COMMAND
				;[4] REMOVED MARK COMMAND
	C	(OUTPUT,.OUTPT)	;OUTPUT COMMAND
	C	(PAGE,.PAGE)	;PAGE COMMAND
>

COMTAB:	COMS			;CREATE COMMAND TABLE

NCOMS==.-COMTAB			;COMPUTE TABLE LENGTH

	DEFINE	SCOMS
<
	C	(ALL,.ALL)	;ALL SUBCOMMAND
	C	(BOTTOM,.BOTOM)	;BOTTOM SUBCOMMAND
	C	(EVERY,.EVRY)	;EVERY SUBCOMMAND
	C	(LINES,.LINES)	;LINES SUBCOMMAND
	C	(TOP,.TOP)	;TOP SUBCOMMAND
>

SCOMTB:	SCOMS			;CREATE SUBCOMMAND TABLE

NSCOMS==.-SCOMTB		;COMPUTE TABLE LENGTH

	DEFINE	C(A,B)		;REDIFINE C TO CREATE DISPATCH TABLES
<
	EXP	B
>

COMDIS:	COMS			;CREATE CMD DISPATCH TABLE

SCOMDS:	SCOMS			;CREATE SUBCMD DISPATCH TABLE
	SUBTTL	CHANNEL COMMAND PROCESSING

;SUBROUTINE .CHNL:

;		PROCESS MAKVFU CHANNEL COMMAND.STORE CHANNEL NUMBER
;		IN CHANEL. CALL APPROPRIATE SUBCOMMAND ROUTINE.

;CALLING SEQUENCE:

;		PUSHJ	P,.CHNL

;NORMAL CALLING SEQUENCE:

;		PUSHJ	P,0(T1)
;		WHERE T1=18-BIT DISPATCH ADDRESS FOUND IN CMD TABLE

;INPUT:		P1 = ASCII TERMINATOR CHAR FROM GETSIX IN MAINLINE
;		DECIMAL TTY INPUT SPECIFYING CHANNEL NUMBER
;		ALPHANUMERIC TTY KEYWORD SPECIFYING CHANNEL SUBCOMMAND
;		  PLUS OPTIONAL DECIMAL INPUT DEPENDING ON SUBCOMMAND.

;OUTPUT:	OUTPUT OF SUBCOMMAND SUBROUTINES
;		CHNMSK BIT SET FOR CHANNEL SUCCESSFULLY PROCESSED
;		IDENTIFIED ERRORS E4,7,9
;		P1 = ASCII TERMINATOR CHAR FOR ENTIRE LINE


;AC'S USED:	T1,T2,T3,T4,P1,P2,P3

.CHNL:	CAIN	P1,12		;TEST-TERMINATOR=LF?
	JRST	C50		;YES-ERROR
	PUSHJ	P,GETDEC	;READ THE CHANNEL NUMBER
	JRST	C50		;NULL OR INVALID RETURN
	CAIN	P1,12		;[9] TEST- TERM = LF?
	JRST	C40		;[9] YES - ERROR
	JUMPLE	P2,C50		;TEST-CHANNEL GT 0? JUMP = NO
	CAILE	P2,MAXCHL	;TEST-CHANNEL LE MAX CHANNEL?
	JRST 	C50		;NO-PRINT ERROR
	MOVEM	P2,CHANEL	;SAVE CHANNEL NUMBER
	PUSHJ	P,GETSIX	;READ SUBCOMMAND
	JRST	C40		;NULL OR INVALID RETURN
	SETOM	T1		;INIT KEYWORD MASK
	LDB	T2,[POINT 6,P3,5] ;LOAD P-FIELD OF BYTE POINTER FROM
				  ;GETSIX. P-FIELD CONTAINS COUNT OF 
				  ;UNUSED BITS IN KEYWORD.
	LSH	T1,0(T2)	;CLEAR BITS IN MASK CORRESPONDING TO
				;UNUSED CHARS IN KEYWORD.
	MOVEI	T2,NSCOMS-1	;SETUP TABLE LENGTH -1 AS LOOP COUNTER
	SETOM	T4		;INIT SUB-COMMAND LOCATION
C10:	MOVE	T3,SCOMTB(T2)	;READ NEXT CMD FROM SUBCMD TABLE
	AND	T3,T1		;CLEAR CHARS NOT SPECIFIED IN KEYWORD
	CAME	T3,P2		;TEST- DOES KEYWORD MATCH MASKED CMD?
	JRST	C20		;NO-EXAMINE NEXT COMMAND
	JUMPGE	T4,C30		;TEST-AMBIGUOUS COMMAND? JUMP = YES
	HRRZ	T4,T2		;NO-SAVE TABLE PTR TO CMD
C20:	SOJGE	T2,C10		;TEST-END OF TABLE? JUMP=NO
	JUMPL	T4,C40		;TEST-ANY MATCH FOUND? JUMP=NO
	MOVE	T1,SCOMDS(T4)	;PICKUP SUBCMD DISPATCH TABLE ADDRESS
	PUSHJ	P,0(T1)		;CALL SUBCOMMAND ROUTINE
	JRST	C60		;ERROR-DON'T SET CHANNEL MASK BIT
	MOVEI	T2,1		;SET BIT IN CHANNEL MASK WORD CORRES-
	MOVE	T3,CHANEL	;  PONDING TO APPROPRIATE CHANNEL
	LSH	T2,0(T3)
	IORM	T2,CHNMSK
	JRST	C60
C30:	OUTSTR	E9		;ERROR - AMBIGUOUS COMMAND
	JRST	C60
C40:	OUTSTR	E4		;ERROR - ILLEGAL CHANNEL SUBCOMMAND
	JRST	C60
C50:	OUTSTR	E7		;ERROR - ILLEGAL CHANNEL ARGUMENT
C60:	POPJ	P,		;RETURN
	SUBTTL	EXIT COMMAND PROCESSING

;SUBROUTINE .EXIT:

;		PROCESS MAKVFU EXIT COMMAND. CAN BE RE-ENTERED VIA
;		CONT W/O DESTROYING DATA.

;CALLING SEQUENCE:

;		PUSHJ	P,.EXIT

;NORMAL CALLING SEQUENCE:

;		PUSHJ	P,0(T1)
;		WHERE T1 = 18-BIT DISPATCH ADDR FOUND IN CMD TABLE

;INPUT:		P1 = ASCII TERMINATOR CHAR FROM GETSIX IN MAINLINE

;OUTPUT:	RETURN TO MONITOR MODE. PROGRAM CAN BE CONTINUED WITH
;		CONT
;		IDENTIFIED ERRORS E3,14
;		OUTPUTS "EXIT" ON TTY

;AC'S USED:	P1

;AC'S SAVED:	P1

.EXIT:	PUSHJ	P,TERMLF	;[10] TEST-TERMINATOR=LF?
	JRST	EX10		;NO-ERROR
	SKIPE	OFLAG		;TEST-ANY OUTPUT DONE TO DISK?
	JRST	EX5		;YES-EXIT
	OUTSTR	CRLF
	OUTSTR	E14		;NO-ISSUE WARNING
	OUTSTR	E14A
	JRST	EX7		;[2] - EXIT W/O EXIT MSG
EX5:	OUTSTR	CRLF
	OUTSTR	M3		;OUTPUT EXIT MSG
EX7:	EXIT	1,		;EXIT W/ CONTINUE OPTION
	JRST	EX20		;RETURN ON CONTINUE
EX10:	OUTSTR	E3		;ERROR-GARBAGE AT EOC
EX20:	POPJ	P,		;RETURN
	SUBTTL	FORM COMMAND PROCESSING

;SUBROUTINE .FORM:

;		PROCESS MAKVFU FORM COMMAND. STORE RESULT IN FORMS.

;CALLING SEQUENCE:

;		PUSHJ	P,.FORM

;NORMAL CALLING SEQUENCE:

;		PUSHJ	P,0(T1)
;		WHERE T1= 18-BIT DISPATCH ADDRESS FOUND IN CMD TABLE

;INPUT:		P1 = ASCII TERMINATOR CHAR FROM GETSIX IN MAINLINE
;		DECIMAL INPUT FROM TTY (OPTIONAL) SPECIFYING FORMS
;		BREAK CHANNEL.

;OUTPUT:	FORMS LOCATION CLEARED FOR NO TTY INPUT.
;		BIT SET IN FORMS CORRESPONDING TO CHANNEL INPUT FOR 
;		VALID DECIMAL INPUT.
;		P1 = ASCII TERMAINATOR CHAR FOR ENTIRE LINE
;		IDENTIFIED ERRORS E3,7

;AC'S USED:	P1,P2,T1

.FORM:	CAIN	P1,12		;TEST-TERMINATOR =LF?
	JRST	F60		;YES-CLEAR FORMS PARAMETER
	PUSHJ	P,GETDEC	;READ CHANNEL NUMBER
	JRST	F50		;NULL OR ILLEGAL  INPUT
	PUSHJ	P,TERMLF	;[10] TEST-TERMINATOR = LF?
	JRST	F100		;NO-PRINT ERROR
	JUMPLE	P2,F90		;TEST-CHANNEL GT 0? JUMP=NO
	CAILE	P2,MAXCHL	;TEST-CHANNEL LE MAX CHANNEL NO.?
	JRST	F90		;NO-PRINT ERROR
	MOVEI	T1,1		;SET BIT IN FORMS CHANNEL
	LSH	T1,0(P2)	;  WORD CORRESPONDING TO 
	IORM	T1,FORMS	;  CHANNEL NUMBER.
	JRST	F110
F50:	CAIE	P1,12		;TEST-TERMINATOR=LF?
	JRST	F90		;NO-PRINT ERROR
F60:	SETZM	FORMS		;CLEAR FORMS CHANNEL WORD
	OUTSTR	M1		;OUTPUT FORMS CLEARED MSG
	JRST	F110
F90:	OUTSTR	E7		;ERROR-PRINT ILLEGAL CHANNEL ARGUMENT
	JRST	F110
F100:	OUTSTR	E3		;ERROR-PRINT GARBAGE AT EOC
F110:	POPJ	P,		;RETURN
	SUBTTL	HELP COMMAND PROCESSING

;SUBROUTINE .HELP:

;		PROCESS MAKVFU HELP COMMAND. PROGRAM SETS UP A 
;		CALL TO HELPER ON SYS: TO PRINT OUT THE HLP:
;		FILE FOUND ON [2,5]

;CALLING SEQUENCE:

;		PUSHJ	P,.HELP

;NORMAL CALLING SEQUENCE:

;		PUSHJ	P,0(T1)
;		WHERE T1= 18 BIT DISPATCH ADDR FOUND IN CMD TABLE

;INPUT:		P1 = ASCII TERMINATOR CHAR FROM GETSIX IN MAINLINE

;OUTPUT:	HLP:MAKVFU.HLP PRINTED ON TTY

;AC'S USED:	CX,P1

;AC'S SAVED:	P1

.HELP:	PUSHJ	P,TERMLF	;[10] TEST-TERMINATOR=LF?
	JRST	H10		;NO-ERROR
	MOVEI	CX,[[SIXBIT/MAKVFU/]] ;SETUP ARG PTR
	PJRST	HELPER##	;CALL HELPER WHICH DOES A
				;POPJ ON COMPLETION
H10:	OUTSTR	E3		;ERROR-GARBAGE AT EOC
	POPJ	P,		;RETURN
	SUBTTL	INFORMATION COMMAND PROCESSING

;SUBROUTINE .INFO:

;		PROCESS MAKVFU INFORMATION COMMAND.  PRINTS OUT THE
;		CURRENT PARAMETERS DEFINED FOR THE VFU. IT ACCEPTS
;		A CHANNEL ARGUMENT THAT SPECIFIES THE LINES DEFINED FOR
;		THE CHANNEL.

;CALLING SEQUENCE:

;		PUSHJ	P,.INFO

;NORMAL CALLING SEQUENCE:

;		PUSHJ	P,0(T1)
;		WHERE T1=18 BIT DISPATCH ADDR FOUND IN CMD TABLE

;INPUT:		OPTIONAL CHANNEL ARGUMENT FROM TTY
;		P1= ASCII TERMINATOR CHAR FROM GETSIX IN MAINLINE

;OUTPUT:	LENGTH,PAGE SIZE, CHANNELS ASSIGNED, CHANNELS MARKED,
;		AND FORMS BREAK CHANNELS FOR THE VFU.

;		OUTPUT FOR OPTIONAL CHANNEL ARGUMENT IS LISTING OF THE 
;		LINES DEFINED FOR THE CHANNEL.

;		P1 = ASCII TERMINATOR CHAR FOR ENTIRE LINE
;		IDENTIFIED ERROR E7

;AC'S USED:	P1,P2,T1

;AC'S SAVED:	P1 IF NO CHANNEL ARGUMENT IS GIVEN AS INPUT

.INFO:	CAIE	P1,12		;TEST-TERMINATOR=LF?
	JRST	I30		;NO-CHECK FOR CHANNEL ARG
I5:	OUTSTR	M4		;[13] OUTPUT LENGTH MSG
	MOVE	T1,LINPPG	;LOAD LENGTH ARG FOR PDECI
	PUSHJ	P,PDECI		;PRINT LENGTH ON TTY
	OUTSTR	CRLF		;TERMINATE LINE
	OUTSTR	M5		;OUTPUT PAGESIZE MSG
	MOVE	T1,PAGSIZ	;LOAD PAGSIZ ARG FOR PDECI
	PUSHJ	P,PDECI		;PRINT PAGE SIZE ON TTY
	OUTSTR	CRLF		;TERMINATE LINE
				;[3] REMOVED CHANNEL ASSIGNED INFO
				;[4] REMOVED MARK INFO
	SKIPN	Q1,FORMS	;TEST-ANY FORMS BREAK CHANNELS?
	JRST	I10		;[5] NO SKIP TO LPI CHECK
	OUTSTR	M8		;OUTPUT "FORMS BREAK CHANNELS"
	PUSHJ	P,NUMS		;OUTPUT FORMS BREAK CHANNELS NUMBERS
I10:	SKIPN	LPI		;[5] TEST-LPI = 0? SKIP=NO
	JRST	I20		;[5] YES
	OUTSTR	M10		;OUTPUT LPI MSG
	MOVE	T1,LPI		;LOAD LPI ARG FOR PDECI
	PUSHJ	P,PDECI		;PRINT LPI ON TTY
	OUTSTR	CRLF
	JRST	I70		;[5] END OF COMMAND
I20:	OUTSTR	M6		;[5] PRINT PREVIOUS LPI MSG
	JRST	I70		;END OF COMMAND
I30:	PUSHJ	P,GETDEC	;READ OPTIONAL CHANNEL NUMBER
	JRST	I50		;[13] NULL OR ILLEGAL ARG
	PUSHJ	P,TERMLF	;[10] TEST-TERMINATOR =LF?
	JRST	I65		;NO-ERROR-GARBAGE AT EOC
	JUMPLE	P2,I60		;TEST-CHANNEL GT 0? JUMP=NO
	CAILE	P2,^D8		;TEST-CHANNEL LE 8?
	JRST	I60		;NO-ERROR
	PUSHJ	P,PLINE		;[3] - PRINT LINES DEFINED FOR CHANNEL
	OUTSTR	CRLF		;TERMINATE LINE
	JRST	I70
I50:	CAIN	P1,12		;[13] TEST - TERMINATOR=LF?
	JRST	I5		;[13] YES-PROCESS AS IF "I CR"
I60:	OUTSTR	E7		;ERROR-ILLEGAL ARG
	JRST	I70		;[14]
I65:	OUTSTR	E3		;[14] ERROR - GARBAGE AT EOC
I70:	POPJ	P,		;RETURN
	SUBTTL	LENGTH COMMAND PROCESSING

;SUBROUTINE .LENTH:

;		PROCESS MAKVFU LENGTH COMMAND. STORE RESULT IN
;		LINPPG

;CALLING SEQUENCE:

;		PUSHJ	P,.LENTH

;NORMAL CALLING SEQUENCE:

;		PUSHJ	P,0(T1)
;		WHERE T1=18 BIT DISPATCH ADDRESS FOUND IN CMD TABLE.

;INPUT:		DECIMAL TTY INPUT SPECIFYING LENGTH PARAMETER
;		P1 = ASCII TERMINATOR CHAR FROM GETSIX IN MAINLINE

;OUTPUT:	DECIMAL INPUT IN LINPPG IF VALID
;		P1 = ASCII TERMINATOR CHAR FOR ENTIRE LINE
;		IDENTIFIED ERRORS E3,5

;AC'S USED:	P1,P2

.LENTH:	CAIN	P1,12		;TEST-TERMINATOR=LF?
	JRST	LE20		;YES-ERROR
	PUSHJ	P,GETDEC	;READ LENGTH VALUE FROM TTY
	JRST	LE20		;INVALID OR NULL RETURN
	PUSHJ	P,TERMLF	;[10] TEST-TERMINATOR=LF?
	JRST	LE35		;NO-PRINT GARBAGE MESSAGE
	CAILE	P2,MAXLIN+1	;TEST-INPUT LE 144?
	JRST 	LE20		;NO-PRINT ERROR
	CAML	P2,PAGSIZ	;[12] TEST-INPUT LT PAGSIZ?
	JRST	LE10		;[12] NO-SKIP PAGSIZ REDEFINITION
	MOVEM	P2,PAGSIZ	;[12] YES-REDEFINE PAGSIZ
	OUTSTR	E6		;[12] OUTPUT WARNING
	OUTSTR	M2		;[12] OUTPUT CHANNEL REDEFINE MSG
LE10:	MOVEM	P2,LINPPG	;[12] SAVE LENGTH
	JRST	LE40
LE20:	OUTSTR	E5		;ERROR-ILLEGAL LENGTH ARGUMENT
	JRST	LE40
LE35:	OUTSTR	E3		;ERROR-GARBAGE AT EOC
LE40:	POPJ	P,		;RETURN
	SUBTTL	LINES PER INCH COMMAND PROCESSING

;SUBROUTINE .LPI:

;		PROCESS MAKVFU LPI COMMAND. STORE RESULT IN LPI.

;CALLING SEQUENCE:

;		PUSHJ	P,.LPI

;NORMAL CALLING SEQUENCE:

;		PUSHJ	P,0(T1)
;		WHERE T1=18 BIT DISPATCH ADDR FOUND IN CMD TABLE

;INPUT:		DECIMAL TTY INPUT SPECIFYING LPI PARAMETER.
;		P1 = ASCII TERMINATOR CHAR FROM GETSIX IN MAINLINE

;OUTPUT:	DECIMAL INPUT IN LPI IF VALID
;		P1 = ASCII TERMINATOR CHAR FOR ENTIRE LINE
;		IDENTIFIED ERRORS E3,15

;AC'S USED:	P1,P2

.LPI:	CAIN	P1,12		;TEST-TERMINATOR =LF?
	JRST	LP20		;YES-ERROR
	PUSHJ	P,GETDEC	;READ LPI VALUE FROM TTY
	JRST	LP20		;NULL OR INVALID
	PUSHJ	P,TERMLF	;[10] TEST-TERMINATOR=LF?
	JRST	LP30		;NO-ERROR
	JUMPE	P2,LP10		;[5] MAKE LPI ACCEPT 0 ARGUMENT
				;[5] TEST-LPI = 0? JUMP=YES
	CAIN	P2,^D6		;TEST-LPI=6?
	JRST	LP10		;YES
	CAIE	P2,^D8		;TEST-LPI=8?
	JRST	LP20		;NO-ERROR
LP10:	MOVEM	P2,LPI		;SAVE LPI ARG
	JRST	LP40
LP20:	OUTSTR	E15		;ERROR-ILLEGAL LPI ARG
	JRST	LP40
LP30:	OUTSTR	E3		;ERROR-GARBAGE AT EOC
LP40:	POPJ	P,		;RETURN
	SUBTTL	OUTPUT COMMAND PROCESSING

;SUBROUTINE OUTPUT:

;		PROCESS MAKVFU OUTPUT COMMADN. ACCEPTS FILE
;		SPECIFICATIONS AND WRITES OUT A VFU BINARY IMAGE
;		INTO THE FILE SPECIFIED.

;		FORMAT = DSK:FILNAM.EXT[P,PN]
;		DEFAULT =DSK:NORMAL.VFU[0,0]

;		WARNING: SPACES AND TABS ARE NOT ALLOWED AS PART OF THE
;			 FILE SPEC

;CALLING SEQUENCE:

;		PUSHJ	P,.OUTPT

;NORMAL CALLING SEQUENCE:

;		PUSHJ	P,0(T1)
;		WHERE T1=18 BIT DISPATCH ADDR FOUND IN CMD TABLE

;INPUT:		FILE SPECIFICATION FROM TTY
;		P1 = ASCII TERMINATOR CHAR FROM GETSIX IN MAINLINE

;OUTPUT:	VFU BINARY IMAGE IN FILE SPECIFIED.
;		IDENTIFIED ERRORS 16
;		P1 = ASCII TERMINATOR CHAR FOR ENTIRE LINE

;AC'S USED:	P1,P2,P3,T1,T2,Q1,Q3


.OUTPT:

;READ FILE SPECIFICATION FROM TTY

	PUSHJ	P,DFAULT	;DEFINE FILE SPEC DEFAULTS
	CAIN	P1,12		;TEST-TERMINATOR=LF?
	JRST	U7		;YES-USE DEFAULT FILE SPEC
	PUSHJ	P,GTFLNM	;READ FILE SPEC
	JRST	U120		;ERROR-EXIT

;PROCESS FORMS BREAK CHANNELS

U7:	SKIPN	T1,FORMS	;TEST-FORMS BREAK CHANNEL SET?
	JRST	U30		;NO-SKIP FORMS PROCESSING
	PUSH	P,FORMS		;SAVE FORMS WORD
U10:	JFFO	T1,.+1		;PUT COUNT OF LEADING ZEROS IN T2
	SUBI	T2,^D35		;NEGATIVE CH. NO. = T2-35
	MOVN	T2,T2		;NEGATE FOR POSITIVE RESULT
	MOVEM	T2,CHANEL	;DEFINE CHANNEL FOR SETBIT
	MOVEI	T1,1		;GET 1B35
	LSH	T1,0(T2)	;SHIFT LEFT BY CHANNEL NO.
	ANDCAM	T1,FORMS	;TURN OFF BIT IN FORMS FOR CHANNEL
	MOVE	T1,PAGSIZ	;INIT INTERNAL LINE N0.= PAGE SIZE
U20:	PUSHJ	P,SETBIT	;SET BIT FOR FORMS BREAK LINE
	AOS	T1		;INC LINE COUNT
	CAMGE	T1,LINPPG	;TEST-END OF CHANNEL?
	JRST	U20		;NO
	SKIPE	T1,FORMS	;TEST-MORE FORMS BREAK CHANNELS?
	JRST	U10		;YES-COMPUTE NEXT FORMS CHANNEL
	POP	P,FORMS		;NO-RESTORE FORMS

;DETERMINE START CODE AND STORE IN EXTERNAL VFU AREA

U30:	SETZ	Q1,		;INIT LINE NO. FOR BLDVFU
	MOVE	Q3,VLOADP	;INIT BYTE PTR FOR VFU LOAD
	SKIPN	T1,LPI		;TEST-LPI SET TO 6 OR 8?
	JRST	U37		;NO-START W/ PREVIOUS LPI SETTING
	CAIE	T1,6		;TEST-LPI=6?
	JRST	U35		;NO
	MOVEI	T1,START6	;YES-SPECIFY 6 LPI START CODE
	JRST	U40
U35:	MOVEI	T1,START8	;SPECIFY 8 LPI START CODE
	JRST	U40
U37:	MOVEI	T1,STRT		;USE PREVIOUS LPI SETTING
U40:	IDPB	T1,Q3		;STORE START CODE IN EXTERNAL VFU AREA

;CONVERT INTERNAL VFU DATA TO EXTERNAL VFU DATA FORMAT

U50:	PUSHJ	P,BLDVFU	;BUILD WORD OF CHANNEL BITS FOR LINE
	LSHC	P2,-6		;SPLIT WORD INTO 2 BYTES(RT JUSTIFIED)
	LSH	P3,-^D30	;    P3=CH1-6,P2=CH7-8
	IDPB	P3,Q3		;STORE FIRST BYTE IN EXTERNAL VFU AREA
	IDPB	P2,Q3		;STORE 2ND   BYTE IN EXTERNAL VFU AREA
	AOS	Q1		;INCREMENT LINE COUNT
	CAMGE	Q1,LINPPG	;TEST-LINE COUNT EXCEED LENGTH?
	JRST	U50		;NO-BUILD ANOTHER LINE
	MOVEI	T1,STOP		;YES-PUT STOP BYTE IN EXTERNAL VFU AREA
	IDPB	T1,Q3

;OPEN FILE AND OUTPUT EXTERNAL VFU DATA TO FILE STRUCTURE

	OPEN	CH1,OPNBLK	;CONNECT SOFTWARE CHANNEL 1
	JRST	U110		;ERROR
	ENTER	CH1,ENTBLK	;DEFINE FILE SPEC
	JRST	U110		;ERROR
	OUTBUF	CH1,		;SET DEFAULT RING BUFFER SIZE
	OUTPUT	CH1,		;DUMMY OUT TO SETUP 7 BIT BYTE POINTER
	MOVE	Q3,VLOADP	;SETUP BYTE POINTER TO VFUBUF
U60:	ILDB	Q1,Q3		;LOAD BYTE FOR OUTPUT
	PUSHJ	P,IOSUB		;OUTPUT BYTE
	JRST	U110		;ERROR
	CAIE	Q1,STOP		;TEST-STOP BYTE OUTPUT?
	JRST	U60		;NO-CONTINUE OUTPUTTING

;ASSUMPTION:	EACH LINE OF DATA IN VFUBUF IS DESCRIBED BY 2 8-BIT
;		BYTES. ALSO, EACH SET OF VFUBUF DATA CONTAINS ONE START 
;		AND ONE STOP CODE. THUS, THE COUNT OF 8 BIT BYTES IN
;		VFUBUF IS ALWAYS EVEN, REGARDLESS OF THE NUMBER OF
;		LINES ALLOWED. THEREFORE, A CHECK FOR EVEN NO. OF BYTES,
;		AS REQUIRED BY THE LP100 CONTROLLER, IS NOT
;		NECESSARY. THIS PROGRAM IS NOT CAPABLE OF SENDING
;		AN ODD COUNT OF BYTES. THE 8 BIT BYTES IN VFUBUF GET
;		CONVERTED TO 7 BIT BYTES IN IOSUB, BUT THE BYTE COUNT
;		IS UNCHANGED.

	SETOM	OFLAG		;SET OUTPUT FLAG FOR EXIT
	RELEAS	CH1,		;RELEASE CHANNEL, OUTPUT BUFFER
	JRST	U120
U110:	OUTSTR	E16		;ERROR-OUTPUT FILE ERROR
U120:	POPJ	P,		;RETURN
	SUBTTL	PAGE COMMAND PROCESSING

;SUBROUTINE .PAGE:

;		PROCESS MAKVFU PAGE COMMAND. STORE RESULT IN PAGSIZ.

;CALLING SEQUENCE:

;		PUSHJ	P,.PAGE

;NORMAL CALLING SEQUENCE:

;		PUSHJ	P,0(T1)
;		WHERE T1=18 BIT DISPATCH ADDRESS FOUND IN CMD TABLE

;INPUT:		DECIMAL TTY INPUT SPECIFYING PAGE SIZE PARAMETER
;		P1 = ASCII TERMINATOR CHAR FROM GETSIX IN MAINLINE

;OUTPUT:	DECIMAL INPUT IN PAGSIZ IF VALID
;		P1 = ASCII TERMINATOR CHAR FOR ENTIRE LINE
;		IDENTIFIED ERRORS E3,8

;AC'S USED:	P1,P2

.PAGE:	CAIN	P1,12		;TEST-TERMINATOR = LF?
	JRST	PA10		;YES-ERROR
	PUSHJ	P,GETDEC	;READ A DECIMAL VALUE FROM TTY
	JRST	PA10		;NULL OR INVALID RETURN
	PUSHJ	P,TERMLF	;[10] TEST-TERMINATOR = LF?
	JRST	PA20		;NO-PRINT ERROR
	JUMPLE	P2,PA10		;TEST-VALUE GT 0? JUMP=NO
	CAMG	P2,LINPPG	;[11] TEST-VALUE GT LENGTH?
	JRST	PA5		;[11] NO-SKIP LENGTH  REDEFINITION
	MOVEM	P2,LINPPG	;[11] REDEFINE LENGTH
	OUTSTR	E2		;[11] PRINT WARNING
PA5:	MOVEM	P2,PAGSIZ	;[11] STORE NEW VALUE
	OUTSTR	M2		;OUTPUT CHANNEL REDEFINE MSG
	JRST	PA40
PA10:	OUTSTR	E8		;ERROR-ILLEGAL PAGE SIZE ARGUMENT
	JRST	PA40
PA20:	OUTSTR	E3		;ERROR-GARBAGE AT EOC
PA40:	POPJ	P,		;RETURN
	SUBTTL	ALL SUBCOMMAND PROCESSING

;SUBROUTINE .ALL:

;		PROCESS MAKVFU ALL SUBCOMMAND RELATED TO CHANNEL
;		COMMAND. SETS BIT FOR ALL LINES (NOT IN FORMS BREAK 
;		AREA) OF SPECIFIED CHANNEL IN INTERNAL VFU TABLE.

;CALLING SEQUENCE:

;		PUSHJ	P,.ALL
;		ERROR RETURN
;		NORMAL RETURN

;NORMAL CALLING SEQUENCE:

;		PUSHJ	P,0(T1)
;		ERROR RETURN
;		NORMAL RETURN
;		WHERE T1= 18-BIT DISPATCH ADDR FOUND IN SUBCMD TABLE

;INPUT:		P1 = TERMINATOR CHAR FROM GETSIX

;OUTPUT:	BITS SET IN VFU INTERNAL TABLE FOR ALL LINES OF 
;		SPECIFIED CHANNEL.

;AC'S USED:	P1,T1

;AC'S SAVED:	P1

.ALL:	PUSHJ	P,TERMLF	;[10] TEST-TERMINATOR=LF?
	JRST	A20		;NO- ERROR
	PUSHJ	P,CLRVFU	;CLEAR 4 WORDS FOR CHANNEL
	MOVEI	T1,1		;START W/ LINE 1
	SOS	T1		;CONVERT TO INTERNAL LINE NO.
A10:	PUSHJ	P,SETBIT	;SET BIT FOR SPECIFIED LINE OF CHANNEL
				;SPECIFIED IN CHANEL
	AOS	T1		;INCREMENT LINE NUMBER
	CAMGE	T1,PAGSIZ	;TEST-LINE GE PAGE SIZE?
	JRST 	A10		;NO-SET BIT FOR NEXT LINE
	AOS	(P)		;PRODUCE SKIP RETURN
	JRST	A30
A20:	OUTSTR	E3		;ERROR-GARBAGE AT EOC
A30:	POPJ	P,		;RETURN
	SUBTTL	BOTTOM SUBCOMMAND PROCESSING

;SUBROUTINE .BOTOM:

;		PROCESS MAKVFU BOTTOM SUBCOMMAND RELATED TO THE CHANNEL
;		COMMAND. SETS BIT IN LAST LINE BEFORE FORMS BREAK IN
;		INTERNAL VFU TABLE FOR SPECIFIED LINE.

;CALLING SEQUENCE:

;		PUSHJ	P,.BOTOM
;		ERROR RETURN
;		NORMAL RETURN

;NORMAL CALLING SEQUENCE:

;		PUSHJ	P,0(T1)
;		ERROR RETURN
;		NORMAL RETURN
;		WHERE T1= 18-BIT DISPATCH ADDR FOUND IN SUBCMD TABLE

;INPUT:		P1 = TERMINATOR CHARACTER FROM GETSIX

;OUTPUT:	BIT SET FOR LAST LINE BEFORE FORMS BREAK IN INTERNAL
;		VFU TABLE FOR CHANNEL SPECIFIED.

;AC'S USED:	T1,P1

;AC'S SAVED:	P1

.BOTOM:	PUSHJ	P,TERMLF	;[10] TEST-TERMINATOR=LF?
	JRST	B10		;NO-ERROR
	PUSHJ	P,CLRVFU	;CLEAR 4 WORDS FOR CHANNEL
	MOVE	T1,PAGSIZ	;SPECIFY PAGE SIZE AS EXTERNAL LINE
	SOS	T1		;CONVERT TO INTERNAL LINE NO. FOR SETBIT
	PUSHJ	P,SETBIT	;SET BIT IN LAST LINE OF CHANNEL
	AOS	(P)		;PRODUCE SKIP RETURN
	JRST	B20
B10:	OUTSTR	E3		;PRINT ERROR-GARBAGE AT EOC
B20:	POPJ	P,		;RETURN
	SUBTTL	EVERY SUBCOMMAND PROCESSING

;SUBROUTINE .EVRY:

;		PROCESS MAKVFU EVERY SUBCOMMAND RELATED TO CHANNEL
;		COMMAND. SET BITS IN LINES THAT ARE MULTIPLES OF THE
;		STEP SIZE + 1 IN THE INTERNAL VFU TABLE FOR THE
;		SPECIFIED CHANNEL. I.E., IF STEP SIZE = 10, THEN LINES
;		1,11,21,31,ETC WOULD BE SET.

;CALLING SEQUENCE:

;		PUSHJ	P,.EVRY
;		ERROR RETURN
;		NORMAL RETURN

;NORMAL CALLING SEQUENCE:

;		PUSHJ	P,0(T1)
;		ERROR RETURN
;		NORMAL RETURN
;		WHERE T1=18-BIT DISPATCH ADDR FOUND IN SUBCMD TABLE

;INPUT:		P1 = TERMINATOR CHARACTER FROM GETSIX IN MAINLINE

;OUTPUT:	BITS SET IN VFU INTERNAL FILE FOR THE LINES THAT
;		ARE 1 + MULTIPLES OF THE STEP SIZE (I.E., 1,21,
;		41, ETC FOR C 1 E 20[CR] )
;		P1 = ASCII TERMINATOR CHAR FOR ENTIRE LINE
;		IDENTIFIED ERRORS E3,11

;AC'S USED:	T1,P1,P2

;SECONDARY ENTRY POINT:

;		PUSHJ	P,EVINIT
;		ERROR RETURN
;		NORMAL RETURN

;		THIS ENTRY IS USED BY SUBROUTINE INIT TO DEFINE
;		THE DEFAULT VFU.THE ONLY INPUT FOR THIS ENTRY
;		IS P2 = EVERY ARGUMENT. OUTPUT IS SAME AS .EVRY.

.EVRY:	CAIN	P1,12		;TEST-TERMINATOR = LF?
	JRST	EV20		;YES-ERROR
	PUSHJ	P,GETDEC	;READ IN STEP SIZE
	JRST 	EV20		;NULL = ERROR
	PUSHJ	P,TERMLF	;[10] TEST-TERMINATOR=LF?
	JRST	EV30		;NO-ERROR
	JUMPLE	P2,EV20		;TEST-STEP SIZE GT 0? JUMP = NO
	CAMLE	P2,PAGSIZ	;TEST-STEP SIZE LE PAGE SIZE?
	JRST	EV20		;NO-ERROR
EVINIT:	PUSHJ	P,CLRVFU	;CLEAR 4 WORDS FOR CHANNEL
	MOVEI	T1,1		;START W/ LINE 1
	SOS	T1		;CONVERT TO INTERNAL LINE NO.
EV10:	PUSHJ	P,SETBIT	;SET BIT FOR LINE IN VFU
	ADD	T1,P2		;ADD STEP SIZE TO LINE NO.
	CAMGE	T1,PAGSIZ	;TEST-END OF CHANNEL?
	JRST	EV10		;NO-SET BIT FOR NEXT LINE
	AOS	(P)		;PRODUCE SKIP RETURN
	JRST	EV40
EV20:	OUTSTR	E11		;ERROR-ILLEGAL EVERY ARGUMENT
	JRST	EV40
EV30:	OUTSTR	E3		;ERROR-GARBAGE AT EOC
EV40:	POPJ	P,		;RETURN
	SUBTTL	LINES SUBCOMMAND PROCESSING

;SUBROUTINE .LINES:

;		PROCESS MAKVFU LINES SUBCOMMAND RELATED TO CHANNEL
;		COMMAND.  SETS BITS IN THE INTERNAL VFU TABLE FOR 
;		THE LINES AND CHANNEL SPECIFIED. ALL ERRORS CAUSE ENTIRE
;		COMMAND TO BE IGNORED.

;CALLING SEQUENCE:

;		PUSHJ	P,.LINES
;		ERROR RETURN
;		NORMAL RETURN

;NORMAL CALLING SEQUENCE:

;		PUSHJ	P,0(T1)
;		ERROR RETURN
;		NORMAL RETURN
;		WHERE T1=18-BIT DISPATCH ADDR FOUND IN SUBCMD TABLE

;INPUT:		P1 = ASCII TERMINATOR CHAR FROM GETSIX IN MAINLINE
;		DECIMAL TTY INPUT FOR SPECIFIC LINE NUMBERS

;OUTPUT:	BITS SET IN INTERNAL VFU FOR LINES AND CHANNEL SPECIFIED
;		P1 = ASCII TERMINATOR CHAR FOR ENTIRE LINE OF INPUT
;		IDENTIFIED ERRORS 12,13

;AC'S USED:	T1,P1,P2

.LINES:

;SAVE 4 WORDS OF ORIGINAL VFU BIT PATTERN FOR CHANNEL IN OLDVFU IN
;CASE OF ERROR

	MOVE	T1,CHANEL	;GET EXTERNAL CHANNEL NO.
	SOS	T1		;CONVERT TO INTERNAL CHANNEL NO.
	IMULI	T1,<MAXLIN/^D36+1> ;COMPUTE PTR TO START OF 4 WORD
				   ;CHANNEL BLOCK, REL TO CHNBUF
	ADDI	T1,CHNBUF	;COMPUTE ABS ADDR OF CHANNEL IN VFU
	MOVEM	T1,VFUADR	;SAVE ADDR FOR ERROR RECOVERY
	MOVSS	T1		;PUT SOURCE ADDR IN LH
	HRRI	T1,OLDVFU	;PUT DESTINATION ADDR IN RH
	BLT	T1,OLDVFU+3	;SAVE 4 WORDS STARTING AT OLDVFU

;CONTINUE WITH .LINES PROCESSING

	PUSHJ	P,CLRVFU	;CLEAR 4 WORD FOR CHANNEL
	CAIN	P1,12		;TEST-TERMINATOR = LF?
	JRST	L30		;YES-ERROR
L20:	PUSHJ	P,GETDEC	;[10] READ A LINE NO.
	JRST	L25		;INVALID OR NULL
	JUMPLE	P2,L30		;TEST-LINE NO. GT 0? JUMP=NO
	CAMLE	P2,PAGSIZ	;TEST-LINE NO. LE PAGE SIZE?
	JRST	L30		;NO - ERROR
	MOVE	T1,P2		;LOAD T1 FOR INPUT TO SETBIT
	SOS	T1		;CONVERT TO INTERNAL LINE NO.
	PUSHJ	P,SETBIT	;SET BIT FOR LINE IN CHANNEL
				;SPECIFIED BY CHANEL
	CAIE	P1,12		;TEST-TERMINATOR = LF?
	JRST	L20		;NO-GET ANOTHER LINE
	JRST	L27		;[10] SKIP RETURN
L25:	PUSHJ	P,TERMLF	;[10] TEST-CHECK FOR LF?
	JRST	L30		;[10] NO LF - ERROR
L27:	AOS	(P)		;[10] PRODUCE SKIP RETURN
	JRST	L40
L30:	OUTSTR	E12		;ERROR-ILLEGAL LINES ARG

;RESTORE ORIGINAL VFU DATA FOR CHANNEL FROM OLDVFU BECAUSE OF ERROR

	MOVE	T1,VFUADR	;PUT DEST ADDR IN RH
	MOVE	T2,T1		;SETUP END LOCATION-3
	HRLI	T1,OLDVFU	;PUT SOURCE ADDR IN LH
	BLT	T1,3(T2)	;RESTORE 4 WORDS OF VFU STARTING AT
				;VFUADR, ENDING AT VFUADR + 3

;CONTINUE .LINES PROCESSING

L40:	POPJ	P,		;RETURN
	SUBTTL	TOP SUBCOMMAND PROCESSING

;SUBROUTINE .TOP:

;		PROCESS MAKVFU TOP SUBCOMMAND RELATED TO THE 
;		CHANNEL COMMAND. SETS BIT IN LINE 1 OF CHANNEL
;		SPECIFIED IN INTERNAL VFU TABLE.

;CALLING SEQUENCE:

;		PUSHJ	P,.TOP
;		ERROR RETURN
;		NORMAL RETURN

;NORMAL CALLING SEQUENCE:

;		PUSHJ	P,0(T1)
;		ERROR RETURN
;		NORMAL RETURN
;		WHERE T1= 18-BIT DISPATCH ADDR FOUND IN SUBCMD TABLE

;INPUT:		P1 = ASCII TERMINATOR CHAR FROM GETSIX IN MAINLINE

;OUTPUT:	LINE I BIT SET IN INTERNAL VFU TABLE FOR CHANNEL
;		SPECIFIED.
;		IDENTIFIED ERROR E3

;AC'S USED:	T1,P1

;AC'S SAVED:	P1

.TOP:	PUSHJ	P,TERMLF	;[10] TEST-TERMINATOR=LF?
	JRST	T10		;NO-ERROR
	PUSHJ	P,CLRVFU	;CLEAR 4 WORDS FOR CHANNEL
	MOVEI	T1,1		;SPECIFY EXTERNAL LINE 1 FOR SETBIT
	SOS	T1		;CONVERT TO INTERNAL LINE NO.
	PUSHJ	P,SETBIT	;SET BIT IN LINE 1 OF CHANNEL SPECIFIED
				;IN CHANEL
	AOS	(P)		;PRODUCE SKIP RETURN
	JRST	T20
T10:	OUTSTR	E3		;PRINT ERROR-GARBAGE AT EOC
T20:	POPJ	P,		;RETURN
	SUBTTL	BITSET UTILITY SUBROUTINE

;SUBROUTINE BITSET:

;		THIS ROUTINE TESTS TO DETERMINE IF  A BIT IS SET IN THE
;		INTERNAL VFU TABLE FOR THE LINE NUMBER AND CHANNEL 
;		SPECIFIED. A SKIP RETURN INDICATES THAT THE LINE
;		FOR THE SPECIFIED CHANNEL HAS ITS BIT SET IN THE VFU
;		TABLE.

;CALLING SEQUENCE:

;		PUSHJ	P,BITSET
;		NOT SET RETURN
;		SET RETURN

;INPUT:		T1 = INTERNAL LINE NUMBER 0-143 (RH ONLY)
;		CHANEL = EXTERNAL CHANNEL NO 1-8

;OUTPUT:	SKIP RETURN IF BIT FOR LINE SET
;		NO SKIP IF NOT SET

;AC'S USED:	T1,T2,T3,T4

;AC'S SAVED:	T1

;NOTES:		(1) THE LOGIC USED HERE IS VERY SIMILAR TO SETBIT. SEE
;		    SETBIT FOR FURTHER DETAILS.

BITSET:	PUSH	P,T1		;SAVE LINE NUMBER ON STACK
	HRRZ	T1,T1		;CLEAR LEFT HALF
	IDIVI	T1,^D36		;GET WORD AND BIT POINTERS
	MOVE	T4,CHANEL
	SOS	T4		;COMPUTE INTERNAL CHANNEL NO.
	IMULI	T4,<MAXLIN/^D36+1>
	ADDI	T1,0(T4)
	MOVSI	T3,(1B0)	;SET BIT 0
	MOVNI	T2,0(T2)	;NEGATE TO ROTATE RIGHT
	ROT	T3,(T2)		;POSITION BIT SPECIFYING LINE NO.
	MOVE	T4,CHNBUF(T1)
	POP	P,T1		;RESTORE T1
	TDNE	T4,T3		;TEST-BIT SET FOR LINE IN CHANNEL?
	AOS	(P)		;YES-PRODUCE SKIP RETURN
	POPJ	P,		;RETURN
	SUBTTL	BLDVFU UTILITY SUBROUTINE

;SUBROUTINE BLDVFU:

;		THIS SUBROUTINE BUILDS AN EXTERNAL VFU WORD. THE VFU
;		WORD DESCIRBES ALL ASSIGNED CHANNELS FOR A GEVEN
;		INTERNAL LINE NUMBER.  BIT 35 = CHANNEL 1( NOT 0!)
;		BIT 28 = CHANNEL 8. THIS ROUTINE CONVERTS THE INTERNAL
;		VFU INGFORMATION FOR A LINE TO EXTERNAL

;CALLING SEQUENCE:

;		PUSHJ	P, BLDVFU

;INPUT:		Q1 = INTERNAL LINE NUMBER (0-143)

;OUTPUT:	P2 = LINE WORD. BIT35=CH 1,BIT 34 = CH 34,ETC

;AC'S USED:	T1,T2,T3,T4,Q1,P2

;AC'S SAVED:	Q1

BLDVFU:	SETZ	P2,		;INIT LINE WORD
	MOVSI	T3,-MAXCHL	;INIT FOR AL CHANNELS (-8,,0)
BL10:	MOVEI	T4,<MAXLIN/^D36+1> ;COMPUTE CHANNEL BUFFER SIZE(=4)
	MOVEI	T1,1		;SET BIT 1B35
	LSH	T1,1(T3)	;POSITION IT USING CHANNEL NO.
				;(T3)RH USED. (T3)LH NOT USED
	TDNN	T1,CHNMSK	;TEST-IS THIS CHANNEL ASSIGNED?
	JRST	BL20		;NO-CHECK FOR MARKING

;COMPUTE POINTER TO START OF 4 WORD CHANNEL BLOCK IN INTERNAL VFU
;TABLE (IVT), RELATIVE TO CHNBUF.

	IMULI	T4,0(T3)	;YES-WORDS/CHANNEL * CHANNEL

;COMPUTE WORD AND BIT POSITION IN IVT FOR SPECIFIED LINE RELATIVE TO
;START OF THE 4 WORD CHANNEL BLOCK. UPON COMPLETION OF THE FOLLOWING
;INSTRUCTION, T1 WILL CONTAIN THE WORD OFFSET RELATIVE TO THE START
;OF THE 4 WORD CHANNEL BLOCK, AND T2 WILL CONTAIN THE BIT OFFSET
;RELATIVE TO THE WORD IN T1.

	MOVEI	T1,0(Q1)	;GET LINE NO.
	IDIVI	T1,^D36		;COMPUTE WORD AND BIT OFFSET

;COMPUTE POINTER TO WORD IN IVT FOR SPECIFIED LINE, RELATIVE TO
;CHNBUF.

	ADDI	T4,0(T1)	;AD START BLK + WD PTR REL START

;POSITION BIT IN MASK CORRESPONDING TO BIT POSITION OF LINE NUMBER
;IN IVT FOR SPECIFIED CHANNEL AND LINE.

	MOVNI	T2,0(T2)	;NEGATE TO ROTATE RIGHT
	MOVSI	T1,(1B0)	;SET BIT 0 IN MASK
	ROT	T1,(T2)		;POSITION MASK BIT USING BIT OFFSET

;TEST- IS THE BIT SET IN THE IVT FOR THIS CHANNEL AND LINE?

	TDNE	T1,CHNBUF(T4)	;TEST-SET?
	JRST	BL30		;YES-SET IT IN EXTERNAL VFU TABLE
	JRST	BL40		;NO-CHECK NEXT CHANNEL

;TEST-IS MARKING IN FORCE? IF SO, SET BIT FOR CHANNEL

BL20:	SKIPN	MARKW		;TEST-IS MARKING IN FORCE?
	JRST	BL40		;NO-CHECK NEXT CHANNEL

;POSITION BIT ACCORDING TO CHANNEL NUMBER. SET IT IN LINE WORD

BL30:	MOVEI	T1,1		;GET 1B35
	LSH	T1,0(T3)	;POSITION ACCORDING TO CHANNEL
				;BIT 35=CHANNEL 1
	IOR	P2,T1		;SET I IN LINE WORD

;TEST-HAVE ALL 8 CHANNELS NEEN PROCESSED?

BL40:	AOBJN	T3,BL10		;TEST-ALL DONE? SKIP=NO
	POPJ	P,		;RETURN
	SUBTTL	CLRVFU UTILITY SUBROUTINE

;SUBROUTINE CLRVFU:

;		THIS ROUTINE CLEARS THE 4 WORDS IN THE
;		INTERNAL VFU TABLE ASSOCIATED WITH THE CHANNEL
;		NUMBER INPUT IN CHANEL.

;CALLING SEQUENCE:

;		PUSHJ	P,CLRVFU

;INPUT:		CHANEL = CHANNEL NUMBER

;OUTPUT:	4 WORDS IN INTERNAL VFU TABLE CLEARED FOR CHANNEL

;AC'S USED:	T1

CLRVFU:	MOVE	T1,CHANEL	;GET EXTERNAL NO.
	SOS	T1		;CONVERT TO INTERNAL NO.
	IMULI	T1,<MAXLIN/^D36+1> ;COMPUTE PTR TO START OF 4 WD BLK
	ADDI	T1,CHNBUF	;COMPUTE ABS ADDR OF CH IN CHNBUF
	SETZM	(T1)		;CLEAR THE 4 WORDS
	SETZM	1(T1)
	SETZM	2(T1)
	SETZM	3(T1)
	POPJ	P,		;RETURN
	SUBTTL	DFAULT UTILITY SUBROUTINE

;SUBROUTINE DFAULT:

;		DEFINES THE FOLLOWING FILE STRUCTURE DEFAULT
;		FOR THE INFORMATION USED BY OPEN AND ENTER.
;			DSK:NORMAL.VFU[0,0]

;CALLING SEQUENCE:

;		PUSHJ	P,DFAULT

;INPUT:		NONE

;OUTPUT:	DEFAULT FILE SPEC IN  STR,FILNAM,EXT,PPN

;AC'S USED:	T1

DFAULT:	MOVSI	T1,'DSK'		;DEFAULT STRUCTURE -OPEN BLOCK
	MOVEM	T1,STR
	MOVE	T1,[SIXBIT/NORMAL/]	;DEFAULT  FILENAME = NORMAL
	MOVEM	T1,FILNAM
	MOVSI	T1,'VFU'		;DEFAULT EXTENSION = VFU
	MOVEM	T1,EXT
	SETZM	PPN			;DEFAULT PPN = 0,0
	POPJ	P,			;RETURN
	SUBTTL	GETDEC AND GETOCT UTILITY SUBROUTINES

;SUBROUTINE GETDEC(GETOCT):

;		READ A DECIMAL (OCTAL) INTEGER NUMBER FROM TTY.
;		NUMBER STORED IN P2.
;		- RANGE: 36 BIT WORD
;		- LEADING BLANKS IGNORED
;		- ASCII 60-67 (OCTAL) VALID FOR GETOCT
;		- ASCII 60-71 (OCTAL) VALID FOR GETDEC
;		- ASCII 101-177 (OCTAL) INVALID CHARACTERS
;		- ASCII 0-57,72-100 (OCTAL) ARE TERMINATOR CHARS

;CALLING SEQUENCE:

;		PUSHJ	P,GETDEC(OR GETOCT)
;		ERROR RETURN - INVALID OR NULL INPUT
;		NORMAL RETURN

;INPUT:		NONE

;OUTPUT:	P1 = ASCII TERMINATOR CHAR FOR NORMAL RETURN
;		   = INVALID CHAR OR LF FOLLOWING NULL FOR ERROR RETURN
;		   = 9 IS INVALID CHAR FOR GETOCT - CAUSES ERROR RETURN
;		P2 = DECIMAL (OCTAL) NUMBER FOR NORMAL RETURN

;AC'S USED:	T1,T2,T4,P1,P2

;NOTES:		(1) THIS ROUTINE WAS DERIVED FROM S. PAAVOLA'S ROUTINE
;		    OF THE SAME NAME (WRITTEN 11/1/75). A TEST FOR NULL
;		    CHAR WAS ADDED AT G40: TO DISTINGUISH BETWEEN "0"
;		    AND NULL INPUT.

GETDEC:	SKIPA	T2,[^D10]	;SET DECIMAL RADIX
GETOCT:	MOVEI	T2,10		;SET OCTAL RADIX
	SETZ	T1,		;CLEAR NUMBER LOCATION
	SETZ	T4,		;CLEAR NON-NULL FLAG
GT10:	PUSHJ	P,TYI		;READ A CHAR
	JRST	GT50		;EOL = NULL = ERROR
	CAIN	P1," "		;TEST-CHAR = BLANK?
	JRST 	GT10		;YES-SKIP LEADING BLANKS
GT20:	CAIE	T2,10		;TEST-OCTAL RADIX?
	JRST 	GT30		;NO-SKIP TEST FOR 9
	CAIN	P1,"9"		;TEST-CHAR = 9?
	JRST	GT50		;YES-INVALID OCTAL CHAR
GT30:	CAIN	P1,"]"		;[15] TEST-CHAR = RT BRACKET?
	JRST	GT35		;[15] YES - VALID TERMINATOR
	CAIL	P1,"A"		;[15] TEST- CHAR VALID?
	JRST	GT50		;NO-INVALID CHAR
GT35:	CAIGE	P1,"0"		;TEST-CHAR= VALID DIGIT?
	JRST	GT40		;NO-TERMINATOR CHAR
	CAIL	P1,"0"(T2)	;TEST-CHAR LT RADIX?
	JRST	GT40		;NO-TERMINATOR
	SETO	T4,		;SET NON-NULL FLAG
	IMUL	T1,T2		;SHIFT DIGIT LEFT BY RADIX
	ADDI	T1,-"0"(P1)	;ADD NEW DIGIT
	PUSHJ	P,TYI		;READ NEXT CHARACTER
	JRST	GT40		;EOL
	JRST	GT20		;RANGE CHECK NEXT CHAR
GT40:	SKIPE	T4		;TEST-NULL INPUT? SKIP=YES
	AOS	(P)		;PRODUCE SKIP RETURN
GT50:	MOVE	P2,T1		;SETUP P2
	POPJ	P,		;RETURN
	SUBTTL	GETSIX UTILITY SUBROOUTINE

;SUBROUTINE GETSIX:

;		READ A KEYWORD FROM THE TTY. CONVERT TO SIXBIT,
;		STORE RESULT IN P2. STORE BYTE POINTER TO LAST
;		CHARACTER ENTERED IN P3.
;		- KEYWORD RANGE: 1-6 CHARACTERS
;		- LEADING BLANKS IGNORED
;		- ASCII 60-71,101-132 (OCTAL) VALID
;		- ALL OTHER CHAR ARE KEYWORD TERMINATORS

;CALLING SEQUENCE:

;		PUSHJ	P,GETSIX
;		NULL RETURN
;		NORMAL RETURN

;INPUT:		NONE

;OUTPUT:	P1 = ASCII TERMINATOR CHARACTER
;		P2 = SIXBIT KEYWORD(1-6 CHARS)
;		   = 0 FOR NULL RETURN
;		P3 = BYTE POINTER TO LAST BYTE ENTERED IN P2.
;		     (SETUP INITALLY BY POINT PSEUDO-OP)

;AC'S USED:	T1,T2,P1,P2,P3

;NOTES:		(1) THE P-FIELD OF THE SIXBIT BYTE POINTER 
;		    IS USED TO DETERMINE WHETHER THERE IS
;		    ROOM IN THE SIXBIT WORD TO STORE A 
;		    VALID CHARACTER. IF P-FIELD=0, THE CHAR IS
;		    IGNORED. THUS, A KEYWORD CAN BE LONGER
;		    THAN 6 CHARACTERS. HOWEVER, ONLY THE FIRST
;		    6 CHARS WILL BE RECOGNIZED.
;		(2) THIS ROUTINE WAS DERIVED FROM S. PAAVOLA'S
;		    ROUTINE OF THE SAME NAME (11/1/75)


GETSIX:	SETZM	T1		;CLEAR SIXBIT WORD
G10:	PUSHJ	P,TYI		;READ A CHAR
	JRST	G40		;EOL - NULL
	CAIN	P1," "		;TEST-CHAR = BLANK?
	JRST	G10		;YES-SKIP LEADING BLANKS
	MOVE	T2,[POINT 6,T1]	;NO-SETUP BYTE PTR IN T2
				;  TO LOAD 6 BIT CHARS IN T1
G20:	CAILE	P1,"Z"		;TEST-CHAR GT Z?
	JRST	G30		;YES-TERMINATOR CHAR
	CAIG	P1,"0"		;TEST-CHAR LT 0?
	JRST	G30		;YES-TERMINATOR CHAR
	CAIL	P1,"A"		;TEST-CHAR GE A?
	JRST	G22		;YES-VALID CHARACTER
	CAILE	P1,"9"		;TEST-CHAR GT 9?
	JRST	G30		;YES-TERMINATOR CHAR
G22:	TLNN	T2,777000	;TEST-ROOM FOR CHAR?
				; (P-FIELD OF T2)
	JRST	G25		;NO-READ CHAR UNTIL TERMINATOR
	SUBI	P1,40		;YES-COMPUTE SIXBIT VALUE
	IDPB	P1,T2		;DEPOSIT SIXBIT BYTE IN T1
G25:	PUSHJ	P,TYI		;READ NEXT CHAR
	JRST	G30		;EOL - EXIT
	JRST 	G20		;CHECK RANGE OF CHAR
G30:	JUMPE	T1,G40		;TEST-NULL RESULT?
	AOS	(P)		;NO-PRODUCE NORMAL RETURN
G40:	MOVE	P2,T1
	MOVE	P3,T2
	POPJ	P,		;RETURN
	SUBTTL	GTFLNM UTILITY SUBROUTINE

;SUBROUTINE GTFLNM:

;		READ A FILE SPECIFICATION FROM  THE TTY.
;		RESULT STORED IN FILE BLOCK FOR USE BY LOOKUP.
;		- FORMAT = DSK: FILNAM.EXT[P,PN]
;		- DEFAULT = DSK: NORMAL.VFU[0,0]

;		WARNING: SPACES AND TABS ARE NOT ALLOWED AS PART
;		OF THE FILE SPEC

;CALLING SEQUENCE:

;		PUSHJ	P,GTFLNM
;		ERROR RETURN
;		NORMAL RETURN

;INPUT:		NONE

;OUTPUT:	P1 = ASCII TERMINATOR CHAR FOR ENTIRE LINE

;		STR,FILNAM,EXT,PPN VARIABLES DEFINED

;		IDENTIFIED ERROR E1

;		THE ERROR MESSAGE "ILLEGAL FILE SPECIFICATION"
;		IS GENERATED FOR ALL ILLEGAL INPUT.  SPACES
;		AND TABS ARE NOT ALLOWED BEFORE THE COLON,PERIOD
;		LEFT AND RIGHT BRACKETS, AND CR.

;AC'S USED:	P1,P2,P4

;NOTES:		(1) THIS ROUTINE BASED ON S. PAAVOLA'S ROUTINE OF
;		    THE SAME NAME (WRITTEN 11/1/75). MODIFIED TO 
;		    HANDLE ALL COMBINATIONS OF FILE SPEC INPUT.

GTFLNM:	PUSHJ	P,GETSIX	;GET A KEYWORD
	JRST	GF20		;NULL = NO DSK:FILNAM.EXT
	CAIE	P1,":"		;TEST-KEYWORD=STRUCTURE?
	JRST	GF10		;NO-MUST BE FILE NAME
	MOVEM	P2,STR		;YES-SAVE STRUCTURE NAME
	PUSHJ	P,GETSIX	;GET ANOTHER KEYWORD
	JRST	GF20		;NO EXTENSION
GF10:	MOVEM	P2,FILNAM	;SAVE FILE NAME
	CAIE	P1,"."		;TEST-EXTENSION FOLLOWING?
	JRST	GF20		;NO-CHECK FOR PPN
	PUSHJ	P,GETSIX	;YES-READ IT IN
	JFCL			;NULL MEANS P2 = 0
	HLLZM	P2,EXT		;SAVE 3 CHAR EXTENSION
GF20:	CAIE	P1,"["		;TEST-PPN SPECIFIED?
	JRST	GF30		;NO-GO CHECK FOR LF
	PUSHJ	P,GETOCT	;YES-READ IN PROJ NUMBER
	JRST	GF40		;ERROR IN PROJ NO.
	HRLM	P2,PPN		;SAVE PROJ NO. IN LH
	CAIE	P1,","		;TEST-TERMINATOR = COMMA?
	JRST	GF40		;NO-FILE SPEC ERROR
	PUSHJ	P,GETOCT	;YES-READ IN PROG. NO.
	JRST	GF40		;ERROR IN PROG. NO.
	HRRM	P2,PPN		;SAVE PROG. NO. IN RH
	CAIN	P1,"]"		;TEST- TERMINATOR= RT BRACKET?
	PUSHJ	P,TYI		;NO-READ ANOTHER CHAR
	JFCL			;NO-OP -EOL TEST NEXT LINE
GF30:	PUSHJ	P,TERMLF	;[10] TEST-LAST CHAR=LF?
	JRST	GF40		;NO-PRINT ERROR
	AOS	(P)		;YES-PRODUCE SKIP RETURN
	JRST	GF50
GF40:	OUTSTR	E1		;ERROR-ILLEGAL FILE SPEC
	PUSHJ	P,DFAULT	;RESTORE FILE BLOCK DEFAULTS
GF50:	POPJ	P,		;RETURN
	SUBTTL	INIT UTILITY SUBROUTINE

;SUBROUTINE INIT:

;		INITIALIZE ALL VARIABLES

;CALLING SEQUENCE:

;		PUSHJ	P,INIT

;INPUT:		NONE

;OUTPUT:	VARIABLES DEFAULTED

;AC'S USED:	T1

INIT:	SETZM	BZCOR		;CLEAR ENTIRE LOW SEGMENT,MINUS STACK
	MOVE	T1,[BZCOR,,BZCOR+1]
	BLT	T1,ZZCOR
	MOVEI	T1,DLENTH	;LENGTH = 66
	MOVEM	T1,LINPPG
	MOVEI	T1,DPAGE	;PAGE SIZE = 60
	MOVEM	T1,PAGSIZ
	SETZM	MARKW		;NO MARKING
	MOVEI	T1,DCHN		;CHANNEL MASK = CH1-8
	MOVEM	T1,CHNMSK
	MOVEI	T1,DFORM	;FORMS BREAK CH = 5
	MOVEM	T1,FORMS
	SETZM	OFLAG		;CLEAR OUTPUT FLAG
	MOVEI	T1,6		;[8] SET LPI FLAG = 6
	MOVEM	T1,LPI
	MOVEI	T1,1
	MOVEM	T1,CHANEL	;DEFINE CHANNEL 1 TOP
	MOVEI	P1,12		;FOOL .TOP
	PUSHJ	P,.TOP
	JFCL
	AOS	CHANEL		;DEFINE CHANNEL 2 EVERY 30
	MOVEI	P2,^D30
	PUSHJ	P,EVINIT
	JFCL
	AOS	CHANEL		;DEFINE CHANNEL 3 EVERY 2
	MOVEI	P2,2
	PUSHJ	P,EVINIT
	JFCL
	AOS	CHANEL		;DEFINE CHANNEL 4 EVERY 3
	MOVEI	P2,3
	PUSHJ	P,EVINIT
	JFCL
	AOS	CHANEL		;DEFINE CHANNEL 5 ALL
	MOVEI	P1,12		;FOOL .ALL
	PUSHJ	P,.ALL
	JFCL
	AOS	CHANEL		;DEFINE CHANNEL 6 EVERY 10
	MOVEI	P2,^D10
	PUSHJ	P,EVINIT
	JFCL
	AOS	CHANEL		;DEFINE CHANNEL 7 EVERY 20
	MOVEI	P2,^D20
	PUSHJ	P,EVINIT
	JFCL
	AOS	CHANEL		;DEFINE CHANNEL 8 ALL
	MOVEI	P1,12		;FOOL .ALL
	PUSHJ	P,.ALL
	JFCL
	MOVSI	T1,BUFFO	;SETUP OUTPUT BRHB
	MOVEM	T1,BUFHDR
	POPJ	P,		;RETURN
	SUBTTL	IOSUB UTILITY SUBROUTINE

;SUBROUTINE IOSUB:

;		THIS SUBROUTINE STORES A BYTE CONATINED IN Q1
;		IN THE BUFFER SETUP BY A PREVIOUS OUTBUF MONITOR
;		CALL.WHEN THE BUFFER BECOMES FULL, AN OUTPUT UUO IS
;		ISSUED ON CH1. OUTPUT ERRORS WILL CAUSE NON-SKIP RETURNS

;INPUT:		Q1 = BYTE OF DATA (8 BITS )

;OUTPUT:	BYTE STORED IN OUTPUT BUFFER. (7 BITS) WHEN BUFFER
;		IS FULL, OUTPUT UUO ISSUED.

;CALLING SEQUENCE:

;		PUSHJ	P,IOSUB
;		ERROR RETURN
;		NORMAL RETURN

;AC'S USED:	Q1

IOSUB:	IDPB	Q1,BUFFO+1	;PUT 7 LOW ORDER BITS OF BYTES IN BUFFER
	SOSG	BUFFO+2		;TEST-BUFFER FULL?
	OUT	CH1,		;YES-OUTPUT BUFFER
	AOS	(P)		;PRODUCE SKIP RETURN
	POPJ	P,		;RETURN
	SUBTTL	NUMS UTILITY SUBROUTINE

;SUBROUTINE NUMS:

;		OUTPUT CHANNELS SPECIFIED IN A CHANNEL MASK WORD TO 
;		THE TTY. 8 CHANNELS AVAILABLE. OUTPUT IS OF THE
;		FORM:
;			CHANNELS ASSIGNED 1 3 4 7 8

;CALLING SEQUENCE:

;		PUSHJ	P,NUMS

;INPUT:		Q1=CHANNEL MASK WORD.CHANNEL 1=BIT34,CHANNEL 8=BIT27

;OUTPUT:	CHANNEL NUMBERS ON TTY SPECIFIED IN MASK WORD,
;		SEPERATED BY SPACES, TERMINATED BY CR.

;AC'S USED:	Q1,T1,P2

;NOTE:		(1) THE FOLLOWING CHANNEL NUMBER COUNTER IS 9 NOT 8
;		    BECAUSE BIT 35 IS ASSIGNED TO THE EXTERNAL CHANNEL 
;		    NUMBER 0 WHICH DOES NOT EXIST. IT WILL NEVER BE SET,
;		    BUT HAS TO BE INCLUDED IN THE LOOP .

NUMS:	MOVSI	P2,-^D9		;LH=LOOP CTR, RH= CHANNEL NO.
N10:	ROT	Q1,-1		;ROTATE CHANNEL BIT INTO SIGN BIT
	JUMPGE	Q1,N20		;TEST-BIT SET ? JUMP=NO
	MOVEI	T1,(P2)		;LOAD CHANNEL NO FOR PDECI
	PUSHJ	P,PDECI		;OUTPUT CHANNEL NUMBER
	OUTSTR	SP		;OUTPUT DELIMITING SPACE
N20:	AOBJN	P2,N10		;TEST-DONE W/ 8 CHANNELS? JUMP=NO
	OUTSTR	CRLF		;OUTPUT CR/LF
	POPJ	P,		;RETURN
	SUBTTL	PLINE UTILITY SUBROUTINE

;SUBROUTINE PLINE:

;		OUTPUTS THE LINES DEFINED IN THE INTERNAL VFU DATA 
;		AREA FOR THE SPECIFIED CHANNEL.

;CALLING SEQUENCE:

;		PUSHJ	P,PLINE

;INPUT:		P2 = CHANNEL NUMBER

;OUTPUT:	TTY MESSAGE DESCRIBING LINES DEFINED FOR CHANNEL

;AC'S USED:	T1,P2

PLINE:	MOVSI	T1,-^D144	;INIT LINE NUMBER FOR BITSET
	MOVEM	P2,CHANEL	;INIT CHANNEL NUMBER FOR BITSET
	OUTSTR	M9		;OUTPUT LINES MESSAGE
PL40:	PUSHJ	P,BITSET	;TEST-IS BIT SET FOR LINE + CHANNEL?
	JRST	PL50		;NO-LOOK AT NEXT LINE
	PUSH	P,T1		;YES-SAVE LINE T1
	HRRZS	T1		;CLEAR LH OF T1 FOR PDECI
	AOS	T1		;CONVERT TO EXTERNAL LINE NO.
	PUSHJ	P,PDECI		;OUTPUT LINE NUMBER
	OUTSTR	SP		;OUTPUT SPACE
	POP	P,T1		;RESTORE T1
PL50:	AOBJN	T1,PL40		;TEST-END OF CHANNEL? JUMP=NO
	move	t1,pagsiz	;[17]
	camn	t1,linppg	;[17] test-pagesiz = length?
	jrst	pl70		;[17] yes - skip forms processing
	SKIPN	T1,FORMS	;[3] TEST- ANY FORMS CHANNELS DEFINED?
	JRST	PL70		;[3] NO
	MOVE	T2,CHANEL	;[3] MAYBE - CHECK FOR SPECIFIC CHANNEL
	MOVEI	T3,1		;[3] SET BIT 1B35
	LSH	T3,0(T2)	;[3] SHIFT LEFT BY CHANNEL NO.
	TDNN	T3,T1		;[3] TEST-IS THIS CH A FORMS BREAK CH?
	JRST	PL70		;[3] NO
	MOVE	T1,PAGSIZ	;[3] START WITH PAGE SIZE
	AOS	T1		;[3] START W/ LINE AFTER PAGSIZ
PL60:	MOVE	T4,T1		;[3] SAVE T1
	PUSHJ	P,PDECI		;[3] PRINT ON TTY
	OUTSTR	SP		;[3] OUTPUT SPACE
	MOVE	T1,T4		;[3] RESTORE T1
	AOS	T1		;[3] INCREMENT LINE NO.
	CAMG	T1,LINPPG	;[3] TEST-LINE GT LENGTH?
	JRST	PL60		;[3] NO- PRINT ANOTHER LINE NO.
PL70:	POPJ	P,		;[3] RETURN
	SUBTTL	POCTI AND PDECI ULILITY SUBROUTINES

;SUBROUTINE POCTI (PDECI):

;		THIS SUBROUTINE CONVERTS A 36-BIT POSITIVE INTEGER TO
;		OCTAL (DECIMAL) AND PRINTS IT OUT ON THE TTY.  THESE
;		ROUTINES ARE DESCRIBED ON PG 2-77 OF SRM - VOL 5

;CALLING SEQUENCE:

;		PUSHJ	P,POCTI(PDECI)

;INPUT:		T1 =  36 BIT POSITIVE INTEGER

;OUTPUT:	NUMBER PRINTED OUT IN OCTAL (DECIMAL) ON TTY

;AC'S USED:	T1,T2,T3

POCTI:	SKIPA	T3,[^D8]	;SET OCTAL RADIX
PDECI:	MOVEI	T3,^D10		;SET DECIMAL RADIX
P10:	IDIVI	T1,(T3)		;DIVIDE BY RADIX
	HRLM	T2,(P)		;SAVE REMAINDER ON LH OF STACK
				;REMAINDER = LOW ORDER DIGIT
	SKIPE	T1		;TEST-END OF NUMBER? SKIP=YES
	PUSHJ	P,P10		;RECURSE TO PICK UP NEXT DIGIT
P20:	HLRZ	T1,(P)		;REMOVE DIGITS-REVERSE ORDER OFF STACK
	ADDI	T1,60		;CONVERT TO ASCII
	OUTCHR	T1		;OUTPUT DIGIT
	POPJ	P,		;RETURN VIA ADDRESS ON STACK

;NOTES:		(1) THE RETURN ADDRESS AFTER THE PUSHJ TO P10 IS P20.
;		    THE SKIPE T2 PERMITS EXITING FROM THE P10 LOOP W/O
;		    USING THE NORMAL POPJ TO RESTORE THE STACK.  THIS
;		    TECHNIQUE IS USED TO STORE DIGITS IN THE LEFT HALF 
;		    OF THE STACK LOCATIONS CONTAINING THE RETURN 
;		    ADDRESSES FOR P10.THE POPJ IN THIS ROUTINE TRANSFERS
;		    CONTROL N TIMES TO P20 FOR N DIGITS. THE N+1-TH POPJ
;		    RETURNS CONTROL TO THE ROUTINE THAT ORIGINALLY
;		    CALLED POCTI (PDECI).
	SUBTTL	SETBIT UTILITY SUBROUTINE

;SUBROUTINE SETBIT:

;		SET A BIT IN THE INTERNAL VFU TABLE CORRESPONDING
;		TO THE LINE NUMBER AND CHANNEL NUMBER SPECIFIED.

;CALLING SEQUENCE:

;		PUSHJ	P,SETBIT

;INPUT:		T1 = INTERNAL LINE NUMBER (0-143)
;		CHANEL = EXTERNAL CHANNEL NUMBER (1-8)

;OUTPUT:	T1 = LINE NUMBER PRESERVED
;		BIT SET IN INTERNAL VFU TABLE FOR GIVEN LINE,CHANNEL

;AC'S USED:	T1,T2,T3,T4

;NOTES:		(1) SEE VARIABLE SECTION FOR INTERNAL TABLE DESCRIPTION

SETBIT:	PUSH	P,T1		;SAVE EXTERNAL LINE NO. ON STACK

;COMPUTE LOCATION OF LINE IN 4 WORD CHANNEL BLOCK. UPON COMPLETION
;OF THE FOLLOWING COMMAND, T1 WILL CONTAIN THE POINTER TO THE WORD
;CONTAINING THE SPECIFIED LINE, RELATIVE TO THE START OF THE 4 WORD
;CHANNEL BLOCK. T2 WILL CONTAIN THE POSITION OF THE BIT IN THE WORD 
;CORRESPONDING TO THE LINE NUMBER.

	IDIVI	T1,^D36

;COMPUTE LOCATION OF LINE IN THE INTERNAL VFU TABLE. UPON COMPLETION
;OF THE SEQUENCE OF COMMANDS, T1 WILL CONTAIN THE POINTER TO THE 
;WORD CONTAINING THE SPECIFIED LINE, RELATIVE TO THE START OF THE 
;INTERNAL VFU TABLE. (CHNBUF)

	MOVE	T4,CHANEL	;GET EXTERNAL CHANNEL NO.
	SOS	T4		;CONVERT TO INTERNAL CHANNEL NO.
	IMULI	T4,<MAXLIN/^D36+1> ;COMPUTE PTR TO START OF
				;4 WORD CHANNEL BLOCK
	ADDI	T1,0(T4)	;COMPUTE WORD PTR REL TO CHNBUF


;SET BIT IN VFU TABLE CORRESPONDING TO SPECIFIED LINE AND CHANNEL NO.

	MOVSI	T3,(1B0)	;SET BIT 0
	MOVNI	T2,0(T2)	;NEGATE BIT POSITION TO ROTATE RIGHT
	ROT	T3,(T2)		;POSITION BIT SPECIFYING LINE NO.
	IORM	T3,CHNBUF(T1)	;SET BIT IN CHNBUF FOR LINE

;RESTORE LINE NUMBER FROM STACK AND RETURN

	POP	P,T1
	POPJ	P,		;RETURN
	SUBTTL	TERMLF UTILITY SUBROUTINE

;SUBROUTINE TERMLF

;		THIS SUBROUTINE CHECKS FOR LF TERMINATION AT 
;		EOC. SKIP OVER SPACES AND TABS. PRODUCE SKIP
;		RETURN FOR LF. PRODUCE NO SKIP RETURN FOR GARBAGE
;		THIS ROUTINE CREATED DURING EDIT [10]

;CALLING SEQUENCE:

;		PUSHJ	P,TERMLF
;		GARBAGE RETURN
;		EOL RETURN

;INPUT:		P1 = TERMINATOR CHARACTER

;OUTPUT:	P1 = LF FOR EOL RETURN, GARBAGE FOR NO SKIP RETURN

;AC'S USED:	P1

TERMLF:	CAIN	P1,12		;TEST-TERMINATOR = LF?
	JRST	TE20		;YES
TE5:	CAIN	P1,40		;TEST-TERMINATOR=SPACE?
	JRST	TE10		;YES
	CAIE	P1,11		;TEST-TERMINATOR=TAB?
	JRST	TE50		;NO-NO SKIP RETURN
TE10:	PUSHJ	P,TYI		;GET A CHARACTER
	JRST	TE20		;EOL
	JRST	TE5		;CHECK FOR SPACES AND TABS
TE20:	AOS	(P)		;PRODUCE SKIP RETURN
TE50:	POPJ	P,		;RETURN
	SUBTTL	TYI UTILITY SUBROUTINE

;SUBROUTINE TYI:

;		READ A CHAR FROM TTY. IGNORE CR. PRODUCE
;		SKIP RETURN FOR ALL CHAR BUT LF.

;CALLING SEQUENCE:

;		PUSHJ	P,TYI
;		EOL RETURN
;		NORMAL RETURN

;INPUT:		NONE

;OUTPUT:	P1 = ASCII CHARACTER

;AC'S USED:	P1

;NOTES:		(1) THIS ROUTINE WAS DERIVED FROM S. PAAVOLA'S
;		    ROUTINE OF THE SAME NAME. (WRITTEN 11/1/75)
;		    TTY DEVICE CALLS WERE CHANGED TO INCHWL'S
;		    TO SIMPLIFY LOGIC.
;		(2) EOL TEST REMOVED. THEREFORE, TYI AND ALL
;		    ROUTINES THAT USE IT ARE NOT FUNCTIONALLY
;		    EQUAL TO S. PAAVOLA'S.

TYI:	INCHWL	P1		;READ  A CHARACTER
	CAIN	P1,15		;TEST-CHAR = CR?
	JRST	TYI		;YES-IGNORE IT
	CAIN	P1,12		;TEST-CHAR = LF?
	JRST	TY20		;YES-EOL RETURN
	AOS	(P)		;NO - PRODUCE NORMAL RETURN
TY20:	CAIG	P1,140		;[16] TEST - CHAR GT L.C.A?
	JRST	TY30		;[16] NO
	CAIG	P1,172		;[16] TEST-CHAR LT L.C. Z?
	SUBI	P1,40		;[16] YES-CONVERT TO U.C.
TY30:	POPJ	P,		;[16] RETURN
	SUBTTL	CONSTANTS AREA

;CONSTANTS

MAXCHL==^D8		;MAXIMUM EXTERNAL CHANNEL NUMBER
MAXLIN==^D143		;MAXIMUM INTERNAL LINE NUMBER
STRT==25		;DAVFU START CODE - W/ PREVIOUS LPI SETTING
START6==26		;                 - 6 LINES PER INCH
START8==27		;                 - 8 LINES PER ICCH
STOP==126		;DAVFU STOP CODE
CH1==1			;SOFTWARE OUTPUT CHANNEL
DLENTH==^D66		;DEFAULT LENGTH VALUE
DPAGE==^D60		;DEFAULT PAGE SIZE VALUE
DCHN==776		;DEFAULT CHANNEL MASK- CH 1-8
DFORM==40		;DEFAULT FORMS BREAK CHANNE = 5
VLOADP:	POINT ^D8,VFUBUF	;BYTE POINTER TO EXTERNAL VFU AREA
	SUBTTL	MESSAGES

;MESSAGES

M1:	ASCIZ	/[ALL FORMS BREAK CHANNELS CLEARED]
/
M2:	ASCIZ	/[PAGE SIZE CHANGED. ALL CHANNELS SHOULD BE REDEFINED]
/
M3:	ASCIZ	/EXIT
/
M4:	ASCIZ	/LENGTH = /
M5:	ASCIZ	/PAGE SIZE = /

;[3] REMOVED M6 -  CHANNELS ASSIGNED"
;[4] REMOVED M7 - "MARKING UNASSIGNED CHANNELS"
;[5] CREATED NEW M6
;[6] MODIFIED M6 - OLD M6 = "USE PREVIOUS LPI SETTING"

M6:	ASCIZ	/LPI VALUE DEFINED BY SWITCH ON LINE PRINTER
/
M8:	ASCIZ	/FORMS BREAK CHANNELS = /

CRLF:	ASCIZ	/
/
SP:	ASCIZ	/ /
M9:	ASCIZ	/LINES /
ASTER:	ASCIZ	/*/
M10:	ASCIZ	/LINES PER INCH = /
	SUBTTL	ERROR MESSAGES

;ERROR MESSAGES

;[7] CHANGED ?MAKVFU: TO ?MAK???: TO CONFORM TO DEC CONVENTIONS
;[11] REMOVED UNUSED E2."ILLEG. OCT.NO.".REPLACED W/ WARNING
;[12] REMOVED UNUSED E6. "ILLEG. DEC. NO. " REPLACED W/ WARNING

E1:	ASCIZ	/?MAKIFS: ILLEGAL FILE SPECIFICATION
/
E2:	ASCIZ	/%MAKPEL: PAGE SIZE EXCEEDS LENGTH. LENGTH SET EQUAL TO PAGE SIZE

/
E3:	ASCIZ	/?MAKCIG: COMMAND IGNORED. GARBAGE AT END OF COMMAND
/
E4:	ASCIZ	/?MAKICS: ILLEGAL "CHANNEL" SUBCOMMAND
/
E5:	ASCIZ	/?MAKILA: ILLEGAL "LENGTH" ARGUMENT. RANGE: PAGESIZE - 144
/
E6:	ASCIZ	/%MAKLLP: LENGTH LESS THAN PAGE SIZE. PAGE SIZE SET EQUAL TO LENGTH

/
E7:	ASCIZ	/?MAKICA: ILLEGAL "CHANNEL" ARGUMENT. RANGE: 1-8
/
E8:	ASCIZ	/?MAKIPA: ILLEGAL "PAGE" ARGUMENT. RANGE: 1-LENGTH
/
E9:	ASCIZ	/?MAKACD: AMBIGUOUS COMMAND
/
E10:	ASCIZ	/?MAKICD: ILLEGAL COMMAND
/
E11:	ASCIZ	/?MAKIEA: ILLEGAL "EVERY" ARGUMENT. RANGE: 1-PAGE SIZE
/
E12:	ASCIZ	/?MAKILA: ILLEGAL "LINES" ARGUMENT. RANGE: 1-PAGE SIZE
/
E14:	ASCIZ	/?MAKOCN: OUTPUT COMMAND NEVER ISSUED.
/
E14A:	ASCIZ	/         TYPE CONT TO PRESERVE INPUT.
/
E15:	ASCIZ	/?MAKILI: ILLEGAL "LPI" INPUT. ENTER 0,6 OR 8
/
E16:	ASCIZ	/?MAKCGF: CAN'T GENERATE FILE SPECIFIED
/
	SUBTTL	VARIABLES

	LIT

	GOLOW		;PUT VARIABLES IN LOW SEGMENT

STK:	BLOCK	50	;STACK AREA - NOT CLEARED BY INIT!

BZCOR:
LINPPG:	BLOCK	1	;LENGTH - DEFAULT =^D66
PAGSIZ:	BLOCK	1	;PAGE SIZE - DEFAULT = ^D60
MARKW:	BLOCK	1	;MARK FLAG - DEFAULT = 0 (IE, NO MARKING)
CHNMSK:	BLOCK	1	;CHANNEL MASK - DEFAULT = 776 ( CHANNELS 1-8)
FORMS:	BLOCK	1	;FORMS BREAK - DEFAULT = 40 (CHANNEL 5)
			;BIT 35 = CHANNEL 0, BIT 34 = CHANNEL 1, ETC
			;CHANNEL 0 NOT LEGAL. SAME FORMAT FOR FORMS.
CHANEL:	BLOCK	1	;CURRENT CHANNEL NUMBER


CHNBUF:	BLOCK	MAXCHL*<MAXLIN/^D36+1> ;ALLOCATE INTERNAL VFU TABLE AREA
			; - LINES NUMBERED 0-143
			; - CHANNELS NUMBERED 0-7
			; - 4 WORDS/CHANNEL = 32 WORDS
			; - 144 LINES/CHANNEL
			; - 8 CHANNELS/VFU
			; - LINE 0 FOR CHANNEL 0 = BIT 0 OF CHNBUF+0

;THE INTERNAL TABLE IS SETUP AS FOLLOWS:

;	CHNBUF +0 =	CHANNEL 0, WORD 0,LINES 0-35
;		1		0	1	36-71
;		2		0	2	72-107
;		3		0	3	108-143
;		4		1	0	0-35
;		5		1	1	36-71
;		6		1	2	72-107
;		7		1	3	108-143
;		8		2	0	0-35
;		.		.	.	.
;		.		.	.	.
;		.		.	.	.
;		30		7	2	72-107
;		31		7	3	108-143

VFUBUF:	BLOCK	^D256	;ALLOCATE EXTERNAL VFU AREA
			; - 8 BIT BYTES
			; - 4 BYTES PER 36 BIT WORD
			; - BITS 7,8 OF EACH BYTE UNUSED

;THE FORMAT OF THE EXTERNAL VFU TABLE LOOKS LIKE THIS:

;	VFUBUF+0 =         BYTE 0, START CODE
;		 = LINE 1, BYTE 1, CHANNELS 1-6, CH 1=BIT15,CH 6=BIT 10
;		   LINE 1, BYTE 2, CHANNELS 7-8, CH 7=BIT23,CH 8=BIT 22
;		   LINE 2, BYTE 3, CHANNELS 1-6, CH 1=BIT31,CH 6=BIT 26
;	VFUBUF+1 = LINE 2, BYTE 0, CHANNELS 7-8, CH 7=BIT7,CH 8=BIT 6
;		   LINE 3, BYTE 1,          ..........
;		   LINE 3, BYTE 2,          ..........
;		   LINE 4, BYTE 3,          ..........
;			.
;			.
;			.
;		 = LINE 143, BYTE 1, CHANNELS 1-6,CH1=BIT15,CH6=BIT10
;		 = LINE 143, BYTE 2, CHANNELS 7-8,CH7=BIT23,CH8=BIT22
;		 = LINE 144, BYTE 3, CHANNELS 1-6,CH1=BIT31,CH6=BIT26
;	VFUBUF+72= LINE 144, BYTE 0, CHANNELS 7-8, CH7=BIT7,CH8=BIT6
;		 =           BYTE 1, STOP CODE



OLDVFU:	BLOCK	<MAXLIN/^D36+1>	;4 WORD BUFFER FOR .LINES ERROR RECOVERY
ENDOLD==.-1			;END OF BUFFER
VFUADR:	BLOCK	1		;VFU ADDRESS FOR ERROR RECOVERY
OFLAG:	BLOCK	1		;OUTPUT FLAG - SET IF OUTPUT COMMAND ISSUED
				;DEFAULT = 0
LPI:	BLOCK	1		;LINES PER INCH FLAG

;OPEN FILE BLOCK INFORMATION

OPNBLK:	BLOCK	1	;ASCII MODE (7 BIT)
STR:	BLOCK	1	;FILE STRUCTURE
BUFHDR:	BLOCK	1	;OUTPUT ONLY
	BLOCK	1	;NO INPUT
BUFFO:	BLOCK	3	;BUFFER RING HEADER BLOCK

;ENTER FILE BLOCK INFORMATION

ENTBLK:
FILNAM:	BLOCK	1	;FILE NAME
EXT:	BLOCK	1	;EXTENSION
	BLOCK	1
PPN:	BLOCK	1	;P,PN
ZZCOR:	BLOCK	1

	LIT

	END	START