Google
 

Trailing-Edge - PDP-10 Archives - AP-4172F-BM - 3a-sources/makvfu.mac
There are 30 other files named makvfu.mac in the archive. Click here to see a list.
;<3-UTILITIES>MAKVFU.MAC.5, 16-Nov-77 14:39:30, EDIT BY KIRSCHEN
;<3-UTILITIES>MAKVFU.MAC.4, 16-Nov-77 14:36:53, EDIT BY KIRSCHEN
;UPDATE VERSION FOR RELEASE 3
;<3-UTILITIES>MAKVFU.MAC.3,  8-Nov-77 10:48:00, EDIT BY KIRSCHEN
;MORE COPYRIGHT UPDATING...
;<3-UTILITIES>MAKVFU.MAC.2, 28-Oct-77 10:52:57, EDIT BY KIRSCHEN
;UPDATE COPYRIGHT FOR RELEASE 3
;<1A-UTILITIES>MAKVFU.MAC.17,  6-MAY-76 10:43:27, EDIT BY HURLEY
;<1A-UTILITIES>MAKVFU.MAC.14,  4-MAY-76 11:10:05, EDIT BY MILLER
;<1A-UTILITIES>MAKVFU.MAC.13,  4-MAY-76 11:05:09, EDIT BY MILLER
;<1A-UTILITIES>MAKVFU.MAC.11,  6-APR-76 15:27:45, EDIT BY MILLER
;<1A-UTILITIES>MAKVFU.MAC.10, 31-MAR-76 11:06:50, EDIT BY MILLER
;<1A-UTILITIES>MAKVFU.MAC.9, 31-MAR-76 11:06:04, EDIT BY MILLER
;<1A-UTILITIES>MAKVFU.MAC.8, 31-MAR-76 11:04:29, EDIT BY MILLER
;<1A-UTILITIES>MAKVFU.MAC.7, 31-MAR-76 11:01:14, EDIT BY MILLER
;<V-SOURCES>MAKVFU.MAC.6, 30-MAR-76 16:18:33, EDIT BY MILLER
;<V-SOURCES>MAKVFU.MAC.5, 25-MAR-76 14:21:17, EDIT BY MILLER
;<V-SOURCES>MAKVFU.MAC.4, 25-MAR-76 14:16:51, EDIT BY MILLER
TITLE MAKVFU - PROGRAM TO GENERATE BINARY VFU FILES



;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1976, 1977, 1978 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

	SEARCH MONSYM,MACSYM
	.REQUIRE SYS:MACREL
	sall
	IFDEF .PSECT,<
	.DIRECT FLBLST>
	IFNDEF .PSECT,<
	.DIRECT .XTABM>

;DEFINITIONS

A==1
B==2
C==3
D==4
PNT==5
W==6
W1==7
W2==10
W3==11
P==17

; VERSION INFORMATION

VMAJOR==3		;MAJOR VERSION
VMINOR==0		;MINOR VERSION
VWHO==0			;WHO LAST EDITED (0=DEC DEVELOPMENT)
VEDIT==3		;EDIT NUMBER

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

;TXTPTR- MACRO TO SET UP BYTE POINTER TO A STRING

	DEFINE TXTPTR (MSG) <POINT 7,[ASCIZ/MSG/]>
INILPP==^D66		;INITIAL DEFAULT LINES/PAGE
NCHPW==5		;NUMBER OF ASCII CHARACTERS PER WORD
BUFSIZ==200		;SIZE OF INPUT TEXT BUFFER
ATMSIZ==200		;SIZE OF ATOM BUFFER
GJFSIZ==.GJRTY+2	;SIZE OF GTJFN BLOCK FOR COMND JSYS
MAXLIN==^D143		;MAXIMUM LINES IN VFU
MAXCHN==^D12		;MAX CHANNEL NUMBER
PDLN==50


PDL:	BLOCK PDLN		;PUSH DOWN LIST
CMDBLK:	BLOCK .CMGJB+5		;COMMAND STATE BLOCK FOR COMND JSYS
ATMBFR:	BLOCK ATMSIZ		;ATOM BUFFER
BUFFER:	BLOCK BUFSIZ		;INPUT TEXT BUFFER
GJFBLK:	BLOCK GJFSIZ		;GTJFN BLOCK FOR COMND JSYS
CHNBUF:	BLOCK ^D12*<MAXLIN/^D36+1> ;ALLOCATE VFU BIT MASK
CHNMSK:	BLOCK 1			;REMEMBER CHANNELS SPECIFIED
CHANEL:	BLOCK 1			;CURRENT CHANNEL
PAGSIZ:	PAGESZ:	BLOCK 1		;PAGE SIZE
LINPPG:	BLOCK 1			;LINES PER PAGE
VFUBUF:	BLOCK ^D256
MARKW:	BLOCK 1			;REMEMBER IF MARKING WANTED
FORMS:	BLOCK 1			;FORMS BREAK CHANNEL
ENDZRO==.-1

ENTVEC:	JRST START
	JRST START
	VMAKVF

PROMPT:	ASCIZ /MAKVFU>/

HLPTXT: ASCIZ /
Commands are:

EXIT		Return to command language
CHANNEL 	Specifies line or lines on which a channel will stop.
		Arguments are: ALL,LINES,EVERY.
FORMS-BREAK	SPecifies the channel or channels which will stop on
		the lines in the forms break margin.
MARK		Directs MAKVFU to set any unspecified channel to stop
		at all lines. This is equivalent to "CHANNEL n ALL"
		for each unspecified channel.
INFORMATION	Produces a brief summary of the VFU so far defined.
LENGTH		Specifies the physical length of the page. This value
		is defaulted to 66 at start-up time but may be changed
		with this command.
PAGE-SIZE	Specifies the logical length of the page. This parameter
		defines the number of printable lines per page and
		the difference between it and the physical length
		is the forms break margin.
HELP		Produces this text.
/

;COMMAND TABLES

CMDTAB:	ELEV1-.-1,,ELEV1-.-1
	XWD [ASCIZ /CHANNEL/],.CHNL
	XWD [ASCIZ /EXIT/],.EXIT
	XWD [ASCIZ /FORMS-BREAK/],.FORM
	XWD [ASCIZ /HELP/],.HELP
	XWD [ASCIZ /INFORMATION/],.INFO
	XWD [ASCIZ /LENGTH/],.LENTH
	XWD [ASCIZ /MARK/],.MARK
	XWD [ASCIZ /OUTPUT/],.OUTPT
	XWD [ASCIZ /PAGE-SIZE/],.PAGE
ELEV1:
LEV2:	ELEV2-.-1,,ELEV2-.-1
	XWD [ASCIZ /ALL/],.ALL
	XWD [ASCIZ /BOTTOM-OF-FORM/],.BOTOM
	XWD [ASCIZ /EVERY/],EVERY
	XWD [ASCIZ /LINE/],LINES
	XWD [ASCIZ /TOP-OF-FORM/],.TOP
ELEV2:

START:	RESET			;CLEAN UP
	SETZM CHNBUF		;SET UP TO CLEAR ALL DATA AREAS
	MOVE A,[CHNBUF,,CHNBUF+1]
	BLT A,ENDZRO		;ZAP ALL VULNERABLE DATA
	MOVEI A,INILPP		;ASSUME 66 LINES PER PAGE
	MOVEM A,LINPPG		;SET IT
	;..
	;..

; COMMAND PARSER AND DISPATCH

	HRROI A,PROMPT		;GET POINTER TO PROMPT STRING
	MOVEM A,CMDBLK+.CMRTY	;PUT RE-TYPE PROMPT POINTER IN STATE BLOCK
	HRROI A,BUFFER		;GET POINTER TO INPUT TEXT BUFFER
	MOVEM A,CMDBLK+.CMPTR	;SAVE POINTER TO COMMAND STRING
	MOVEM A,CMDBLK+.CMBFP	;SAVE POINTER TO START-OF-BUFFER
	MOVE A,[.PRIIN,,.PRIOU] ;GET PRIMARY INPUT,, OUTPUT JFN'S
	MOVEM A,CMDBLK+.CMIOJ	;SAVE PRIMARY JFN'S
	MOVEI A,PARSE1		;GET RE-PARSE ADDRESS
	MOVEM A,CMDBLK+.CMFLG	;SAVE RE-PARSE ADDRESS
	SETZM CMDBLK+.CMINC	;INITIALIZE # OF CHARACTERS AFTER POINTER
	MOVEI A,BUFSIZ*NCHPW	;GET # OF CHARACTERS IN BUFFER AREA
	MOVEM A,CMDBLK+.CMCNT	;SAVE INITIAL # OF FREE CHARACTER POSITIONS
	HRROI A,ATMBFR		;GET POINTER TO ATOM BUFFER
	MOVEM A,CMDBLK+.CMABP	;SAVE POINTER TO LAST ATOM INPUT
	MOVEI A,ATMSIZ*NCHPW	;GET # OF CHARACTERS IN ATOM BUFFER
	MOVEM A,CMDBLK+.CMABC	;SAVE COUNT OF SPACE LEFT IN ATOM BUFFER
PARSE:
COMMAN:	MOVE P,[IOWD PDLN,PDL]	;SET UP STACK
	MOVEI A,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMINI)] ;GET FUNCTION DESCRIPTOR BLOCK
	COMND			;INITIALIZE COMMAND SCANNER JSYS

PARSE1:	MOVE A,[GJFBLK,,GJFBLK+1] ;SET UP TO CLEAR GTJFN BLOCK
	SETZM GJFBLK		;CLEAR FIRST WORD OF BLOCK
	BLT A,GJFBLK+GJFSIZ-1	;CLEAR GTJFN BLOCK

	MOVEI A,GJFBLK		;GET ADDRESS OF GTJFN BLOCK
	MOVEM A,CMDBLK+.CMGJB	;STORE POINTER TO GTJFN BLOCK
	MOVEI A,CMDBLK		;GET POINTER TO COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMKEY,,CMDTAB)] ;GET FUNCTION BLOCK
	COMND			;DO INITIAL PARSE
	TXNN A,CM%NOP		;VALID COMMAND ENTERED ?
	JRST PARSE5		;YES, GO DISPATCH TO PROCESSING ROUTINE
	CALL TSTCOL		;GO SEE IF CRLF NEEDED
	TMSG <? MAKVFU: No such MAKVFU command as ">
	MOVE A,CMDBLK+.CMABP	;GET POINTER TO ATOM BUFFER
	PSOUT			;OUTPUT STRING ENTERED BY USER
	TMSG <"
>				;OUTPUT END-OF-MESSAGE
	JRST PARSE		;GO TRY TO GET A COMMAND AGAIN

PARSE5:	HRRZ A,(B)		;GET DISPATCH ADDRESS
	CALL (A)		;PERFORM REQUESTED FUNCTION
	JRST PARSE		;GO PARSE NEXT COMMAND
;DO SPACING

.LENTH:	STKVAR <SPCING>
	MOVEI A,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMNOI,,TXTPTR<OF PHYSICAL PAGE IS>)] ;GET FUNCTION
	COMND			;PARSE NOISE WORD
	MOVEI A,CMDBLK		;GET COMMAND STATE BLOCK ADDRESS
	MOVEI B,[FLDDB. (.CMNUM,,^D10,,66)] ;PARSE A DECIMAL NUMBER
	COMND			;GET SPACING
	TXNN A,CM%NOP		;NUMBER PARSED OK ?
	JRST LENTH2		;YES, GO SAVE THE NUMBER AND GET CONFIRMATION
	CALL TSTCOL		;NO, ISSUE CRLF IF NEEDED
	TMSG <MAKVFU: Invalid decimal number ">
	HRROI A,ATMBFR		;GET POINTER TO TEXT JUST ENTERED
	PSOUT			;OUTPUT TEXT JUST ENTERED
	TMSG <" for length
>				;OUTPUT REMAINDER OF MESSAGE
	RET			;RETURN WITH NO ACTION

; HERE ON GETTING A GOOD VALUE FOR THE LENGTH

LENTH2:	MOVEM B,SPCING		;SAVE SPACING
	MOVEI A,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMCFM)] ;REQUEST COMMAND CONFIRMATION
	COMND			;GET END OF COMMAND
	TXNE A,CM%NOP		;GOT VALID CONFIRMATION ?
	CALLRET COMER1		;NO, ISSUE MESSAGE AND RETURN

; HERE WITH A GOOD COMMAND - VERIFY THAT A LEGAL SPACING WAS ENTERED

	MOVE A,SPCING		;RESTORE SPACING
	SKIPE A			;GOT A GOOD VALUE?
	CAILE A,MAXLIN		;AND WITHIN PRACTICAL LIMITS?
	JRST SPACER		;NO, GO ISSUE ERROR MESSAGE
	CAMGE A,PAGSIZ		;MUST BE AT LEAST SAME AS LOGICAL SIZE
	JRST SPACER		;NOT
	MOVEM A,LINPPG
	RET			;RETURN TO PARSER

; HERE ON A BAD VALUE FOR SPACING

SPACER:	CALL TSTCOL			;ISSUE CRLF IF NEEDED
	TMSG <? MAKVFU: LENGTH ARGUMENT OUT OF RANGE
>
	RET			;RETURN TO WHENCE WE CAME ...
;MARK COMMAND

.MARK:	MOVEI A,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMNOI,,TXTPTR<UNASSIGNED CHANNELS>)]
	COMND			;PARSE NOISE FIELD
	MOVEI A,CMDBLK		;GET ADDRESS OF COMMANDS STATE BLOCK
	MOVEI B,[FLDDB. (.CMCFM)] ;GET CONFIRMATION FUNCTION
	COMND			;PARSE END OF COMMAND
	TXNE A,CM%NOP		;END OF COMMAND PARSED OK ?
	CALLRET COMER1		;NO, GO ISSUE MESSAGE
	SETOM MARKW		;REMEMBER TO DO MARKING
	RET			;RETURN TO WHENCE WE CAME ...


; INFO COMMAND

.INFO:	MOVEI A,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMNOI,,TXTPTR<ABOUT CURRENT VFU>)]
	COMND			;PARSE NOISE
	MOVEI A,CMDBLK		;GET COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMCFM)] ;CONFIRM FUNCTION
	COMND			;PARSE END OF COMMAND
	TXNE A,CM%NOP		;END OF COMMAND PARSED OK ?
	CALLRET COMER1		;NO, ISSUE MESSAGE

; HERE TO OUTPUT INFORMATION

INFO10:	TMSG <
LENGTH			>
	SKIPN B,LINPPG		;HAVE A LENGTH YET?
	MOVEI B,^D66		;NO. GET DEFAULT
	CALL NUMOUT		;AND DISPLAY A NUMBER
	SKIPN B,PAGSIZ		;HAVE A PAGE SIZE YET?
	JRST INFO20		;NO. GO ON
	TMSG <
PAGE SIZE		>
	CALL NUMOUT		;AND OUTPUT IT
INFO20:	SKIPN W2,CHNMSK		;HAVE ANY CHANNELS YET?
	JRST INFO30
	TMSG <
CHANNELS ASSIGNED	>
	CALL NUMS		;OUTPUT NUMBER LIST
INFO30:	SKIPN B,MARKW		;DOING MARKING?
	JRST INFO40		;NO
	TMSG <
MARKING UNASSIGNED CHANNELS>
INFO40:	SKIPN W2,FORMS		;DOING A FORMS CHANNEL?
	RET			;NO. ALL DONE
	TMSG <
FORMS CHANNELS		>
	CALLRET NUMS		;GO OUTPUT THEM

NUMS:	MOVSI W1,-^D12		;DO 12 CHANNELS
	ROT W2,-1		;SKIP 0
INFLOP:	ROT W2,-1		;GET NEXT CHANNEL
	JUMPGE W2,INFLO1	;NOT SET
	MOVEI B,1(W1)		;GET CHANNEL NUMBER
	CALL NUMOUT		;AND DISPLAY IT
	MOVEI A," "
	PBOUT			;MAKE IT LOOK NICE
INFLO1:	AOBJN W1,INFLOP		;DO ALL CHANNELS
	RET			;AND DONE
;FORM COMMAD TO DEFINE FORMS BREAK CHANNEL

.FORM:	STKVAR <FRMNUM>
	MOVEI A,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMNOI,,TXTPTR<IS>)] ;GET FUNCTION
	COMND			;PARSE NOISE WORD
	MOVEI A,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMNUM,,^D10)] ;GET DECIMAL NUMBER
	COMND			;PARSE NUMERIC ARGUMENT
	TXNE A,CM%NOP		;NUMBER PARSED OK ?
	JRST NOFRM		;NO, GO ISSUE ERROR MESSAGE
	MOVEM B,FRMNUM		;SAVE NUMBER ENTERED
	MOVEI A,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMCFM)] ;GET CONFIRMATION FUNCTION
	COMND			;PARSE END OF COMMAND
	TXNE A,CM%NOP		;END OF COMMAND PARSED OK ?
	CALLRET COMER1		;NO, GO ISSUE ERROR MESSAGE

; HERE WITH A VALID NUMBER

	MOVE A,FRMNUM		;RESTORE NUMBER ENTERED BY USER
	SKIPE A			;IN RANGE?
	CAILE A,^D12		;STILL?
	JRST BADFRM		;INVALID VALUE GIVEN
	MOVEI B,1		;GET A BIT
	LSH B,0(A)		;POSITION IT
	IORM B,FORMS		;REMEMBER THIS CHANNEL
	RET			;RETURN TO WHENCE WE CAME ...

; HERE IF NUMBER NOT PARSED OK

NOFRM:	CALL TSTCOL		;ISSUE NEW LINE IF NEEDED
	TMSG <? MAKVFU: Invalid decimal number entered
>				;OUTPUT MESSAGE
	RET			;RETURN

; HERE IF NUMBER ENTERED IS OUT OF RANGE

BADFRM:	CALL TSTCOL		;ISSUE NEW LINE IF NEEDED
	TMSG <MAKVFU: CHANNEL OUT OF RANGE
>
	RET			;RETURN TO WHENCE WE CAME ...
;DO PAGE SIZE

.PAGE:	STKVAR <PAGELN>
	MOVEI A,CMDBLK		;GET COMMAND STATE BLOCK ADDRESS
	MOVEI B,[FLDDB. (.CMNOI,,TXTPTR<IS>)] ;GET FUNCTION
	COMND			;PARSE NOISE WORD
	MOVEI A,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMNUM,,^D10)] ;GET FDB ADDRESS FOR NUMBER INPUT
	COMND			;PARSE DECIMAL PAGE SIZE
	TXNN A,CM%NOP		;NUMBER PARSED OK ?
	JRST PAGE05		;YES, GO ON AND SAVE THE PAGE SIZE
	CALL TSTCOL		;NO, ISSUE CRLF IF NEEDED
	TMSG <? MAKVFU: Invalid decimal number entered for page size
>				;OUTPUT MESSAGE
	RET			;RETURN

; HERE WITH A VALID PAGE SIZE - SAVE IT AND PARSE END OF COMMAND

PAGE05:	MOVEM B,PAGELN		;SAVE SIZE ENTERED
	MOVEI A,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMCFM) ] ;GET CONFIRMATION FUNCTION
	COMND			;PARSE END OF COMMAND
	TXNE A,CM%NOP		;END OF COMMAND PARSED OK ?
	CALLRET COMER1		;NO, GO ISSUE MESSAGE AND RETURN
	MOVE A,PAGELN		;RESTORE PAGE SIZE ENTERED
	CAMG A,LINPPG		;REASONABLE SIZE?
	SKIPN A			;A NON-ZERO PAGE SIZE?
	JRST BADSIZ		;NO. DON'T BELIEVE IT
	SKIPN PAGSIZ		;ALREADY HAVE ONE?
	JRST PAGE10		;NO, ALL SET
	PUSH P,A		;SAVE LINE NUMBER
	CALL TSTCOL		;YES, GO ISSUE CRLF IF NEEDED
	TMSG <% MAKVFU: PAGE SIZE ALREADY SPECIFIED. SUPERCEDED
>				;OUTPUT WARNING MESSAGE
	POP P,A			;RECOVER PAGE SIZE
PAGE10:	MOVEM A,PAGSIZ		;REMEMBER IT
	RET			;RETURN TO WHENCE WE CAME ...

; HERE ON A BAD PAGE SIZE SPECIFIED

BADSIZ:	CALL TSTCOL		;ISSUE NEW LINE IF NEEDED
	TMSG <? MAKVFU: Invalid ARGUMENT FOR PAGE SIZE. COMMAND IGNORED
>				;OUTPUT MESSAGE
	RET			;RETURN TO WHENCE WE CAME ...
;READ VFU CHANNEL ASSIGMENT AND SET UP VFU BIT PATTERN

.CHNL:	STKVAR <CHNARG>
	MOVEI A,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMNOI,,TXTPTR<NUMBER>)] ;GET FUNCTION
	COMND			;PARSE NOISE WORDS
	MOVEI A,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMNUM,,^D10)] ;GET DECIMAL NUMBER FUNCTION
	COMND			;PARSE CHANNEL NUMBER
	TXNN A,CM%NOP		;NUMBER PARSED OK ?
	JRST CHNL05		;YES, GO ON
	CALL TSTCOL		;NO, ISSUE NEW LINE IF NEEDED
	TMSG <? MAKVFU: Invalid decimal number entered for channel
>				;OUTPUT MESSAGE
	RET			;RETURN TOW WHENCE WE CAME ...

; HERE WITH A GOOD CHANNEL NUMBER

CHNL05:	SKIPLE B		;A VALID CHANNEL NUMBER?
	CAILE B,MAXCHN		;STILL?
	JRST [	CALL TSTCOL	;NO. TELL USER
		TMSG <? CHANNEL NUMBER OUT OF RANGE
>
		RET]		;AND IGNORE REST OF COMMAND
	MOVEM B,CHANEL		;REMEMBER CURRENT CHANNEL
	MOVEI A,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMKEY,,LEV2)] ;GET KEYWORD TABLE FUNCTION
	COMND			;PARSE NEXT SUBCOMMAND
	TXNN A,CM%NOP		;PARSED NEXT PART OK ?
	JRST CHNL10		;YES, GO ON
	CALL TSTCOL		;NO, ISSUE NEW LINE IF NEEDED
	TMSG <? MAKVFU: Invalid argument to CHANNEL command, ignored.
>				;OUTPUT MESSAGE
	RET			;RETURN...

; HERE WITH A VALID ARGUMENT

CHNL10:	MOVEM B,CHNARG		;SAVE ARGUMENT ADDRESS

; SET UP CHANNEL MASK AND DISPATCH

	MOVEI B,1
	MOVE A,CHANEL
	LSH B,0(A)		;POSITION A BIT
	IORM B,CHNMSK		;REMEMBER THIS CHANNEL SEEN
	MOVE A,CHNARG		;GET CHANNEL ARG ADDRESS
	HRRZ A,(A)		;GET DISPATCH ADDRESS FOR ARGUMENT ENTERED
	CALLRET (A)		;GO PROCESS ARGUMENT AND RETURN
;UTILITY SUBROUTINES

NUMOUT:	MOVEI A,.PRIOU		;PRIMARY OUT
	MOVEI C,12		;IN DECIMAL
	NOUT			;OUTPUT A NUMBER
	 JFCL
	RET			;AND DONE

PBLANK:	ILDB A,PNT		;NEXT ATOM
	CAIE A," "		;A BLANK?
	CAIN A,"	"
	JRST PBLANK		;YES. SKIP IT
	CAIN A,.CHCRT		;A CR?
	JRST PBLANK		;YES
	CAIN A,.CHLFD		;END OF LINE?
	RET			;YES. BAD
	MOVNI A,1		;BACK UP PNT
	IBP A,PNT
	MOVE PNT,A		;DO IT
	AOS (P)
	RET			;GOOD

;SET A BIT IN THE CHNBUF

SETBIT:	PUSH P,A
	IDIVI A,^D36		;GET WORD AND BIT
	MOVE W,CHANEL		;GET CHANNEL
	SOS W			;ADJUST FOR CRUDE COUNTING
	IMULI W,<MAXLIN/^D36+1>	;WORDS PER CHANNEL
	ADDI A,0(W)		;WORD TO SET
	MOVSI C,(1B0)		;GET A BIT
	MOVNI B,0(B)
	ROT C,(B)		;POSITION BIT
	IORM C,CHNBUF(A)	;SET IT
	POP P,A			;RETURN THE ARG
	RET			;AND DONE
;SUBCOMMANDS OF CHANNEL

;FIRST, DO TOP

.TOP:	MOVEI A,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMCFM) ] ;GET END OF COMMAND FUNCTION
	COMND			;PARSE END OF COMMAND
	TXNE A,CM%NOP		;END OF COMMAND PARSED OK ?
	CALLRET COMER1		;NO, GO ISSUE ERROR MESSAGE
	SKIPN PAGSIZ		;HAVE A PAGE SIZE YET?
	JRST [	CALL TSTCOL	;OUTPUT NEW LINE IF NEEDED
		TMSG <? MAKVFU: ILLEGAL TO SPECIFY "TOP" unless PAGE SIZE has been specified
>
		RET ]		;RETURN
	MOVEI A,0		;CHANNEL TO SET
	CALL SETBIT		;SET BIT FOR TOP
	ret			;return to whence we came ...

;DO BOTTOM

.BOTom:	MOVEI A,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMCFM) ] ;GET END OF COMMAND FUNCTION
	COMND			;PARSE END OF COMMAND
	TXNE A,CM%NOP		;END OF COMMAND PARSED OK ?
	CALLRET COMER1		;NO, GO ISSUE ERROR MESSAGE
	SKIPN PAGSIZ		;HAVE A PAGE SIZE YET?
	JRST [	CALL TSTCOL	;OUTPUT CRLF IF NEEDED
		tmsg <? makvfu: ILLEGAL TO SPECIFY "BOTTOM" unless PAGE SIZE has been specified
>				;OUTPUT MESSAGE
		RET ]		;RETURN
	MOVE A,PAGSIZ		;FIRST MARK IS AT THE BOTTOM
	CALLRET SETBIT		;GO SET BIT AND RETURN

;DO ALL LINES

.ALL:	MOVEI A,CMDBLK		;GET ADDRESS OF COMMAND STATE BLOCK
	MOVEI B,[FLDDB. (.CMCFM) ] ;GET END OF COMMAND FUNCTION
	COMND			;PARSE END OF COMMAND
	TXNE A,CM%NOP		;END OF COMMAND PARSED OK ?
	CALLRET COMER1		;NO