Google
 

Trailing-Edge - PDP-10 Archives - BB-H240E-BM_1985 - tools/setnod.mac
There are 3 other files named setnod.mac in the archive. Click here to see a list.
; UPD ID= 14, SNARK:<6.1.TOOLS-TAPE>SETNOD.MAC.3,   4-Feb-85 11:07:42 by GLINDELL
;KL2102:<LSCSNET>SETNOD.MAC.2 18-Jan-85 11:50:17, Edit by GMAROTTA
; Add LIST command to display nodes in internal node table.
; UPD ID= 25, SNARK:<6.1.UTILITIES>SETNOD.MAC.4, 13-Aug-84 10:14:36 by GLINDELL
;Make default file spec be SYSTEM:NODE-DATA.BIN, not PS:<OPERATOR>
; UPD ID= 17, SNARK:<6.1.UTILITIES>SETNOD.MAC.3, 3-Jul-84 14:28:06 by GLINDELL
;Type out error message if INSERT fails to set all nodes
;WORK:<GLINDELL.MONITOR>SETNOD.MAC.27  7-Jun-84 13:53:27, Edit by GLINDELL
; Add GET/SAVE/INSERT commands. Change function of SET command.

	TITLE	SETNOD

	SEARCH	MACSYM,MONSYM	;GET SYMBOLS
	SALL			;NICE LOOKING MACROS

	VMAJOR==1		;MAJOR VERSION
	VMINOR==0		;MINOR VERSION
	VEDIT==101		;EDIT NUMBER
	VWHO==0			;WHO MODIFIED

;ACCUMULATORS:

	F=0			;FLAGS
	T1=1			;TEMPORARY AC'S
	T2=2
	T3=3
	T4=4
	N=7			;Safe place to save a number
	P1=10			;STRING POINTERS
	P2=11
	NP=12			;Node pointer
	TP=13			;temporary node pointer for LIST command
	P=17			;STACK

;DEFAULT PARAMETERS:

	PDLSIZ==50		;SIZE OF PUSHDOWN STACK
	TMPSIZ==100		;SIZE OF TEMPORARY BUFFER AREA
	TXTLEN==^D200		;SIZE OF COMMAND BUFFERS

	NODTAB==100000		;Start at page 100000
	NODTOP==677777		;End at page 677
	SUBTTL MACROS AND OPDEFS

	OPDEF	CALL	[PUSHJ P,]	;TO CALL A SUBROUTINE
	OPDEF	RET	[POPJ P,]	;TO RETURN
	OPDEF	PJRST	[JRST]		;PUSHJ/POPJ
	OPDEF	RETSKP	[JRST SKPRET]	;SKIP RETURN

	DEFINE	AA(NAME,DATA),<		;;MACRO FOR COMMAND TABLES
	XWD	[ASCIZ/NAME/],DATA
>

	DEFINE	TEXT(STRING),<		;;MACRO FOR ASCIZ TEXT
	XLIST
	ASCIZ	@STRING@
	LIST
>

	DEFINE	DIE(TEXT,FLAG<0>,ADDR<REEN>),<	;;MACRO FOR ERRORS

	JRST	[
IFN	<FLAG>,<
		HRROI T1,[ASCIZ/
? TEXT - /]
		HRROI	T4,ADDR
		JRST	DIEADR]
>

	IFE	<FLAG>,<
		HRROI T1,[ASCIZ/
? TEXT

/]
		MOVEI	T4,ADDR
		JRST	DIEADR]
>
>

	DEFINE	CMMD(ARG),<		;;MACRO TO DO A GENERAL COMMAND
	MOVEI T1,CMDBLK
	MOVEI	T2,ARG
	CALL	DOCMMD
>

	DEFINE	NOISE(TEXT),<		;;MACRO FOR NOISE
	MOVEI T1,CMDBLK
	MOVEI	T2,[ASCIZ/TEXT/]
	CALL	DONOIS
>

	DEFINE	CONFRM,<		;MACRO FOR CONFIRMING A LINE
	CALL	DOCNFM
>

	DEFINE	DECNUM,<		;MACRO FOR PARSING A DECIMAL NUMBER
	CALL	DODECN
>
	SUBTTL	COMMAND SCANNER AND INITIALIZATION

ENTRY:	JRST	START		;START ADDRESS
	JRST	REEN		;REENTER ADDRESS
	BYTE	(3)VWHO(9)VMAJOR(6)VMINOR(18)VEDIT ;VERSION

START:	RESET			;CLEAR EVERYTHING
	SETZB	F,ZERBEG	;CLEAR FLAGS AND FIRST ZERO AREA
	MOVE	T1,[XWD ZERBEG,ZERBEG+1] ;GET READY
	BLT	T1,ZEREND	;CLEAR SOME VARIABLES
	MOVEI NP,NODTAB		;Load node table address

REEN:	MOVE	P,[IOWD	PDLSIZ,PDL] ;SET UP STACK
	CALL	NEWCMD		;GO GET A SERIES OF COMMANDS
	JRST	REEN		;RESTART


NEWCMD:	MOVEM	P,SAVEP		;SAVE STACK FOR REPARSING
	MOVEI	T1,CMDBLK	;POINT TO COMMAND BLOCK
	CMMD	[FLDDB. (.CMINI)] ;INITIALIZE

NEWPAR:	MOVE	P,SAVEP		;RESTORE THE STACK
	MOVEI	T1,CMDBLK	;POINT TO THE COMMAND BLOCK
	CMMD	[FLDDB. (.CMKEY,,CMDTAB)] ;GET A COMMAND
	MOVE	T2,(T2)		;GET ADDRESS OF ROUTINE
	CALL	(T2)		;PROCESS THE COMMAND
	  JRST	NEWCMD		;AND GET A NEW COMMAND
	RET
	SUBTTL COMMAND TABLES


CMDTAB:	XWD	CMDLEN,CMDLEN		;HEADER
	AA	ENTER,[RET]	 	;ENTER NCP (A NO-OP)
	AA	EXIT,CMDXIT		;EXIT COMMAND
	AA	GET,CMDGET		;GET command
	AA	HELP,CMDHLP		;TYPE HELP MESSAGE
	AA	INSERT,CMDINS		;INSERT command
	AA	LIST,CMDLIS		;LIST command
	AA	RETURN,[RETSKP]		;EXIT PROGRAM
	AA	SAVE,CMDSAV		;SAVE command
	AA	SET,CMDSET		;SET NODE NAME COMMAND
	AA	TAKE,CMDTAK		;TAKE COMMAND

	CMDLEN==.-CMDTAB-1		;NUMBER OF COMMANDS

CMDNOD:	XWD	1,1			;SET NODE
	AA	NODE,0

CMDNAM:	XWD	1,1			;SET NODE <NNN> NAME
	AA	NAME,0

LISLST:	XWD	4,4			;LIST command table
	AA	AREA,LISARE
	AA	KNOWN,LISKNN
	AA	NODE,LISNOD
	AA	TOTAL,LISTOT

KNOLIS:	XWD	1,1			;LIST KNOWN NODES
	AA	NODES,0
	SUBTTL	THE SIMPLE COMMANDS

CMDXIT:	NOISE	(FROM PROGRAM)	;DO NOISE
	CONFRM			;CONFIRM THE LINE
	HALTF			;HALT
	RET

CMDHLP:	NOISE	(WITH PROGRAM)	;DO NOISE
	CONFRM			;CONFIRM THE LINE
	HRROI	T1,HLPTXT	;POINT TO HELP MESSAGE
	PSOUT			;TYPE IT
	RET			;DONE
	SUBTTL	TAKE command

CMDTAK:	NOISE	(COMMANDS FROM FILE) ;DO NOISE
	CMMD	[FLDDB. (.CMIFI)] ;TAKE INPUT FROM A FILE
	MOVEM	T2,JFNTAK	;SAVE TAKE FILE JFN
	CONFRM			;CONFIRM THE LINE
	HRRZ	T1,JFNTAK	;MOVE JFN FOR OPENF
	MOVX	T2,<7B5+OF%RD>	;OPEN THE FILE
	OPENF
	  ERJMP	ERRTAK		;JUMP ON ERROR
	HRL	T1,T1		;SET AS PRIMARY INPUT JFN
	HRRI	T1,<.NULIO>	;NULL OUTPUT
	MOVEM	T1,CMDBLK+.CMIOJ;INPUT / OUTPUT JFNS
	CALL	NEWCMD		;DO A SERIES OF COMMANDS
	MOVX	T2,<XWD .PRIIN,.PRIOU> ;SET BACK TO TTY
	MOVEM	T2,CMDBLK+.CMIOJ;INPUT / OUTPUT JFNS
	RET			;RETURN
	SUBTTL	GET command

CMDGET:	NOISE (NODE DEFINITIONS FROM FILE)
	MOVX T1,GJ%OLD		;Old file
	MOVEM T1,JFNBLK+.GJGEN	; in flags word
	HRROI T1,[ASCIZ /SYSTEM/] ;From SYSTEM:
	MOVEM T1,JFNBLK+.GJDEV	; is default device
	SETZM T1,JFNBLK+.GJDIR	; No default directory
	HRROI T1,[ASCIZ /NODE-DATA/] ;NODE-DATA
	MOVEM T1,JFNBLK+.GJNAM	; is default NAME
	HRROI T1,[ASCIZ /BIN/]	; BIN
	MOVEM T1,JFNBLK+.GJEXT	;  is default extension
	CMMD [FLDDB. (.CMFIL,,,,<SYSTEM:NODE-DATA.BIN>)]
	MOVEM T2,JFNBIN		;Save JFN
	CONFRM			;Now confirm
	MOVE T1,JFNBIN		;Get JFN of data file
	MOVX T2,FLD(^D36,OF%BSZ)!OF%RD	;36-bit bytes, read access
	OPENF%			;Open it
	 ERJMP [DIE (<Couldnt open data file>,1)]
	MOVE T2,[XWD 1,.FBSIZ]	;Read byte count
	MOVEI T3,FDBBLK		;Put into FDBBLK
	GTFDB%			;Read..
	MOVE T1,FDBBLK		;Get byte count
	ADD T1,NP		;Add node table address
	CAIL T1,NODTOP		;Do we have space to read all of the file?
	DIE (<Not enough space to read all data file>)
	MOVE T1,JFNBIN		;Get JFN
	MOVE T2,[POINT 36,(NP)]	;Where to store data
	MOVN T3,FDBBLK		;Read exactly all of file
	SIN%			;Here we go..
	ADD NP,FDBBLK		;Add # of words in table
	MOVE T1,JFNBIN		;Now
	CLOSF%			; close the file
	 TRN			;  and ignore error
	RET			;Done with this command
	SUBTTL	SAVE command

CMDSAV:	NOISE (CURRENT NODE DEFINITIONS IN FILE)
	MOVX T1,GJ%NEW!GJ%FOU	;New file + next generation
	MOVEM T1,JFNBLK+.GJGEN	; in flags word
	HRROI T1,[ASCIZ /SYSTEM/] ;From SYSTEM:
	MOVEM T1,JFNBLK+.GJDEV	; is default device
	SETZM T1,JFNBLK+.GJDIR	; No default directory
	HRROI T1,[ASCIZ /NODE-DATA/] ;NODE-DATA
	MOVEM T1,JFNBLK+.GJNAM	; is default NAME
	HRROI T1,[ASCIZ /BIN/]	; BIN
	MOVEM T1,JFNBLK+.GJEXT	;  is default extension
	CMMD [FLDDB. (.CMFIL,,,,<SYSTEM:NODE-DATA.BIN>)]
	MOVEM T2,JFNBIN		;Save JFN
	CONFRM			;Now confirm
	MOVE T1,JFNBIN		;Get JFN
	MOVX T2,FLD(^D36,OF%BSZ)!OF%RD!OF%WR ;36-bit bytes, read/write access
	OPENF%
	 ERJMP [DIE (<Couldnt open data file for write>,1)]
	MOVE T2,[POINT 36,NODTAB] ;Save from node table and forward
	MOVE T3,NP		;Get current pointer
	SUBI T3,NODTAB		; and subtract beginning to get # to transfer
	MOVNS T3		;Transfer exact # of bytes
	SOUT%			;Do it..
	MOVE T1,JFNBIN		;Get JFN
	CLOSF%			; and close the file
	 TRN			;  and ignore error
	RET			;Done with command
	SUBTTL	SET NODE NAME COMMAND

CMDSET:	SETZM	NODADR		;Start clean
	CMMD	[FLDDB. (.CMKEY,,CMDNOD)] ;GET A COMMAND
	DECNUM			;Get the area number maybe
	MOVE	N,T2		;Save it until we check for area number
	MOVEI	T2,TOKSTR	;See if there is a dot between two numbers
	HRROM	T2,TOKBLK+.CMDAT;SAVE AS DATA
	MOVEI	T2,TOKBLK	;POINT TO BLOCK
	COMND			;PARSE THE FUNCTION
	 ERJMP	BADCMD		;ERROR, GO COMPLAIN
	TXNE	T1,CM%NOP	;Did we get what we asked for?
	 JRST	NOAREA		;No, then assume no area
	DPB	N,NDAREA	;Save the area number
	DECNUM			;Get the node number
	DPB	T2,NODNUM	;Save the node number
	TRNA
NOAREA:	MOVEM	N,NODADR	 ;Save just a node number
	CMMD	[FLDDB. (.CMKEY,,CMDNAM)] ;GET A COMMAND
	CMMD	[FLDDB. (.CMTXT)] ;PARSE THE REST OF THE LINE
	CONFRM			;CONFIRM THE LINE
	MOVE	P1,[POINT 7,ATMBUF];Get node name
	CAIL NP,NODTOP		;Reached the top of data space
	DIE (Internal tables full,1)
	MOVE P2,[POINT 6,(NP)]	;Sixbit byte pointer to node space
	CALL	STORND		;go convert and store the node name
	MOVE T1,NODADR		;Get node address
	MOVEM T1,1(NP)		; and store in node table
	ADDI NP,2		;Update node pointer
	RET			;Done with command

; routine to store ASCII node name in sixbit

STORND:	MOVEI T3,6		;Max # in node name
	DO.			;LOOP over node name
	  SOJL T3,ENDLP.	; Exit if done 6 chars
	  ILDB T2,P1		; Get a byte
	  CAILE T2,"Z"		; Lower case?
	  SUBI T2," "		;  -yes, make upper case
	  CAIG T2," "		; End on space or less
	  EXIT.			;  ..
	  SUBI T2," "		; Make sixbit
	  IDPB T2,P2		; and store it
	  LOOP.
	ENDDO.
	RET			;done, return
	SUBTTL	LIST command

CMDLIS:	CMMD	[FLDDB. (.CMKEY,,LISLST)] ;get a command
	SETZM	AREFLG			;zero area command flag
	CAIE	NP,NODTAB		;is there data in the node table?
	JRST	LIS1			;yes, continue parsing LIST command
	TMSG	<
node table is empty>			;no, print error message
	RET				;and return
LIS1:	HRRZ	T1,(T2)			;get dispatch address
	CALL	(T1)			;dispatch to routine
	RET				;return after executing command

;FDBs for LIST NODE command, decimal number or text

LADDB:	FLDDB. (.CMNUM,<CM%SDH>,12,<decimal node address>,,LNDDB)
LNDDB:	FLDDB. (.CMTXT,<CM%SDH>,,<6 character node name>)

LISNOD:	CMMD	LADDB			;parse for argument to LIST NODE
	CAMN	T3,[LADDB,,LADDB]	;was argument a decimal number?
	JRST	LISADD			;yes, jump to find address routine
	CONFRM				;argument was text, confirm it
	MOVE	P1,[POINT 7,ATMBUF]	;source pointer to node name text
	MOVE	P2,[POINT 6,T4]		;destination pointer to T4
	SETZ	T4,			;start with a fresh register
	CALL	STORND			;convert and store the node name
	TMSG	<
>					;print a CRLF
	MOVEI	TP,NODTAB		;TP points to first word of table
NODLP:	CAMN	T4,(TP)			;does argument match table entry?
	JRST	FOUNOD			;yes, found a match, go display it
	ADDI	TP,2			;no, increment node table index
	CAME	TP,NP			;have we checked the whole talbe?
	JRST	NODLP			;no, check next node name entry
	TMSG	<requested node not defined> ;yes, inform user of no match
	RET				;and return

LISADD:	MOVE	N,T2			;save decimal argument
	MOVEI	T2,TOKSTR		;see if arg has a dot
	HRROM	T2,TOKBLK+.CMDAT	;save token in token block
	MOVEI	T2,TOKBLK		;point to block
	COMND				;parse the function
	ERJMP	BADCMD			;error, go complain
	TXNE	T1,CM%NOP		;did we get what we asked for?
	JRST	ADD1			;no, then assume no area
	DPB	N,[POINT 6,T4,25]	;yes, store area number in T4
	DECNUM				;parse remainder of argument
	DPB	T2,[POINT 10,T4,35]	;store it in T4 as the node number
	SKIPA				;skip the next instruction
ADD1:	MOVE	T4,N			;if no dot, store arg as node number
	CONFRM				;confirm it
	TMSG	<
>					;print a CRLF
	MOVEI	TP,NODTAB+1		;initialize TP with 2nd table entry
					;so we are looking at node addresses
ADDLP:	CAMN	T4,(TP)			;does argument match table entry?
	SOJA	TP,FOUNOD		;yes, point to node name and display
	ADDI	TP,2			;no, increment index by 2
	CAMG	TP,NP			;have we checked all addresses?
	JRST	ADDLP			;no, go check the next one
	TMSG	<requested address not defined> ;yes, inform user of no match
	RET				;and return

FOUNOD:	MOVE	T2,[POINT 6,(TP)]	;source pointer to matched node name
	MOVE	T3,[POINT 7,NODSTR]	;destination pointer to temp string
	CALL	TYPNOD			;print the node name
	MOVEI	T2,11			;get a TAB
	BOUT				;print it
	MOVE	T4,1(TP)		;get the corresponding node address
	MOVEM	T4,NODADR		;save it in temp address storage
	LDB	T2,NDAREA		;extract the area number
	MOVEI	T1,.PRIOU		;to tty
	MOVEI	T3,12			;in decimal
	NOUT%				;print it
	JFCL				;ignore error
	MOVEI	T2,"."			;get a dot
	BOUT%				;print it
	LDB	T2,NODNUM		;extract the node number
	NOUT%				;and print it
	JFCL				;ignore error
	TMSG	<

>					;print 2 CRLFs
	RET				;and return

LISARE:	SETOM	AREFLG			;set AREA flag
	MOVEI	T1,CMDBLK		;set up for parsing
	DECNUM				;a decimal number
	MOVE	N,T2			;save it
	CONFRM				;and confirm it
	CAIGE	N,2			;is the argument less than 2 ?
	JRST	TOOBG
	CAIG	N,^D63			;or greater than 63 ?
	JRST	LIS2			;no, continue with routine
TOOBG:	TMSG	<
area number not in range 2 to 63>	;yes, print error message
	RET				;and return
LIS2:	SETZ	P2,			;argument is good, zero node counter
	MOVEI	TP,NODTAB		;initialize table index
ARELP:	MOVE	T4,1(TP)		;get node address from table
	MOVEM	T4,NODADR		;move it to a storage word
	LDB	T2,NDAREA		;extract the area number from there
	CAMN	T2,N			;does it match the given argument?
	JRST	NXTARE			;yes, go display the area
	ADDI	TP,2			;no, increment index by 2
	CAME	TP,NP			;have we checked the entire table?
	JRST	ARELP			;no, check the next entry
	TMSG	<
no nodes defined in requested area>	;yes, inform user of no match
	RET				;and return

LISKNN:	CMMD	[FLDDB. (.CMKEY,,KNOLIS)] ;get NODES keyword
	CONFRM				;confirm it
	SETOM	ANUM			;initialize area num storage to -1
	SETZ	P2,			;zero node counter
	MOVEI	TP,NODTAB		;initialize index to first entry
ALLLP:	MOVE	T4,1(TP)		;get address from table
	MOVEM	T4,NODADR		;store it
	LDB	T2,NDAREA		;extract area number
	CAMN	T2,ANUM			;has the area number changed?
	JRST	NXTNOD			;no, display the next node
	SKIPE	AREFLG			;yes, is this AREA command?
	JRST	ALLDON			;yes, done, print total and return
NXTARE:	MOVEM	T2,ANUM			;save new area number
	CAIL	P1,5			;if at end of a row of nodes
	JRST	NOCR			;skip the extra CRLF
	TMSG	<
>					;else print the extra CRLF
NOCR:	TMSG	<
[AREA >					;print text for area number
	MOVEI	T1,.PRIOU		;to tty
	MOVE	T2,ANUM			;the current area number
	MOVEI	T3,12			;in decimal
	NOUT%				;print it
	JFCL				;ignore error
	TMSG	<]
>					;complete text string
	MOVEI	P1,5			;initialize the column counter
NXTNOD:	MOVE	T2,[POINT 6,(TP)]	;source pointer to node name
	MOVE	T3,[POINT 7,NODSTR]	;destination pointer to temp string
	CALL	TYPNOD			;print the node name
	MOVEI	T2,11			;get a TAB
	BOUT				;print it
	MOVEI	T1,.PRIOU		;to tty
	LDB	T2,NODNUM		;extract the node number
	MOVE	T3,[1B2+3B17+12B35]	;in decimal, 3 places, leading filler
	NOUT%				;print it
	JFCL				;ignore error
	AOS	P2			;increment node counter
	ADDI	TP,2			;increment table index
	CAML	TP,NP			;have we checked the entire table?
	JRST	ALLDON			;yes, print total and return
	SOJE	P1,ROWDON		;no, decrement column counter
	MOVEI	T2,11			;get a TAB if not at end of column
	BOUT				;and print it
	JRST	ALLLP			;then go back for more
ROWDON:	TMSG	<
>					;if column count is zero, print CRLF
	MOVEI	P1,5			;reset column count
	JRST	ALLLP			;and go back for more
ALLDON:	TMSG	<

TOTAL NODES FOUND: >			;print text at end of display
	MOVEI	T1,.PRIOU		;to tty
	MOVE	T2,P2			;get the node count
	MOVEI	T3,12			;in decimal
	NOUT				;print it
	JFCL				;ignore error
	TMSG	<

>					;print 2 CRLFs
	RET				;and return

LISTOT:	NOISE	(nodes defined in node table) ;some noise
	CONFRM				;confirm the LIST TOTAL command
	MOVE	P2,NP			;get the current end of table pointer
	SUBI	P2,NODTAB		;subtract beginning to get table size
	ASH	P2,-1			;divide by 2 for number of nodes
	JRST	ALLDON			;display it and return
	SUBTTL	INSERT command

CMDINS:	NOISE (CURRENT NODE DEFINITIONS)
	CONFRM			;Now confirm
	MOVE T1,NP		;Get NP
	SUBI T1,NODTAB		;Calculate # of words written to node table
	ASH T1,-1		; and make into # of nodes
	MOVEM T1,NODBLK+.NDNNN	;Store that in node block
	MOVEM T1,P1		; and save it in P1
	MOVEI T1,NODTAB		;Get address of node table
	MOVEM T1,NODBLK+.NDNTA	; and node table address too
	MOVEI T1,.NDINT		;Insert table function
	MOVEI T2,NODBLK		; and address of node block
	NODE%			;Do NODE% jsys
	 ERJMP [DIE(<NODE% jsys failed>,1)]
;The # of successfully processed nodes is returned in .NDNNN. Check if
;all nodes succeeded, and if not, type out an indication of what node failed
	MOVE T1,NODBLK+.NDNNN	;Get # of nodes done
	CAMG P1,T1		;Done all nodes?
	RET			; -yes, just return
	MOVE P1,T1		;Get index of failing node
	ASH P1,1		;Each entry is 2 words
	ADDI P1,NODTAB		; and add table address
	TMSG <
?SETNOD: Failed at node >
	MOVE T2,[POINT 6,(P1)]	;Point to sixbit node name
	MOVE T3,[POINT 7,NODSTR] ;Point to ASCIZ representation of node name
	CALL TYPNOD		;go convert and display node name
	TMSG <
>
	RET

; routine to display a sixbit node name

TYPNOD:	MOVEI T1,6		;Max chars in node name
	DO.			;LOOP over chars in node name
	  ILDB T4,T2		;  Get a byte
	  SKIPN T4		;  Exit on zero byte
	  EXIT.			;   ..
	  ADDI T4," "		;  Make ASCII
	  IDPB T4,T3		;  Store the ASCII byte
	  SOJG T1,TOP.		;  Loop back and do next char
	ENDDO.
	SETZ T4,		;Make ASCIZ string
	IDPB T4,T3		; and deposit zero byte
	MOVEI T1,.PRIOU		;To primary output
	HRROI T2,NODSTR		;Type node name
	SETZ T3,		;ASCIZ
	SOUT%
	RET
	SUBTTL HELP text


HLPTXT:	TEXT	<
Commands are the following:

	ENTER		Enter NCP.

	EXIT		Leave the program.

	GET		Get node definitions from file

	HELP		Type this text.

	INSERT		Insert current node definitions in monitor

	LIST		Display node definitions

	RETURN		Return from NCP.

	SAVE		Save node definitions in file

	SET		Set node name.

	TAKE		Take commands from file.

>
	SUBTTL	COMMAND JSYS SUBROUTINES


;SUBROUTINES TO DO THE COMND JSYS.  THESE ROUTINES RETURN TO THE COMMAND
;SCANNER FOR A NEW COMMAND IF AN ERROR OCCURS, UNLESS THE CALL TO THEM
;WAS FOLLOWED BY AN ERJMP, IN WHICH CASE IT IS TAKEN.


DODECN:	MOVEI	T2,[FLDDB. (.CMNUX,,^D10)] ;PARSE A DECIMAL NUMBER
	JRST	DOCMMD		;AND GO DO THE COMMD JSYS

DONOIS:	HRROM	T2,NOIBLK+.CMDAT;SAVE AS DATA
	MOVEI	T2,NOIBLK	;POINT TO BLOCK
	JRST	DOCMMD		;AND GO DO COMND JSYS

DOCNFM:	MOVEI	T2,[FLDDB. (.CMCFM)] ;GET CONFIRM FUNCTION
DOCMMD:	COMND			;PARSE THE FUNCTION
	  ERJMP	BADCMD		;ERROR, GO COMPLAIN
	TXNN	T1,CM%NOP	;PARSED CORRECTLY?
	  RET			;YES, DONE

BADCMD:	HLLZ	T2,(P)		;GET THE FOLLOWING INSTRUCTION
	TLZ	T2,(<@(17)>)	;REMOVE INDIRECT AND INDEX FIELDS
	CAMN	T2,[ERCAL]	;IS THIS AN ERCAL?
	JRST	@(P)		;YES, GO WHERE HE WANTS
	POP	P,T3		;NO, RESTORE ADDRESS
	CAMN	T2,[ERJMP]	;IS THIS AN ERJMP?
	JRST	@T3		;YES, GO TO IT
	JRST	ERROR		;NO, GO COMPLAIN
	SUBTTL	ERROR HANDLING

;HERE ON SOME ERRORS.  LOCATION DIEADR TYPES OUT A SPECIFIED TEXT AND
;A POSSIBLE ERROR MESSAGE, LOCATION ERROR JUST TYPES THE ERROR TEXT.
;MOST ERRORS GO TO THE REENTER ADDRESS OF THE PROGRAM.  LOCATION QUIT
;EXITS AND STAYS THAT WAY.

DIEADR:	MOVX	T2,<XWD .PRIIN,.PRIOU> ;SET BACK TO TTY
	MOVEM	T2,CMDBLK+.CMIOJ;INPUT / OUTPUT JFNS
	PSOUT			;TYPE THE STRING
	JUMPL	T4,ERRTYP	;GO TYPE ERROR STRING IF DESIRED
	JRST	(T4)		;OTHERWISE GO WHERE WE SHOULD


ERRTAK:	MOVX	T2,<XWD .PRIIN,.PRIOU> ;SET BACK TO TTY
	MOVEM	T2,CMDBLK+.CMIOJ;INPUT / OUTPUT JFNS
ERROR:	HRROI	T1,[ASCIZ/
? /]				;GET READY
	PSOUT			;TYPE BEGINNING OF STRING
	MOVEI	T4,[RET]	;SET UP ROUTINE TO GO TO

ERRTYP:	MOVEI	T1,.PRIOU	;PRIMARY OUTPUT
	HRLOI	T2,.FHSLF	;MY FORK, LAST ERROR
	SETZ	T3,		;INFINITE OUTPUT
	ERSTR			;TYPE THE STRING
	JFCL
	JFCL
	HRROI	T1,[ASCIZ/

/]				;GET ENDING TEXT
	PSOUT			;OUTPUT IT
	JRST	(T4)		;GO TO PROPER PLACE

QUIT:	RESET			;CLEAR ALL I/O
	HALTF			;STOP
	JRST	.-1		;STAY THERE

SKPRET:	AOS	(P)		;SKIP RETURN
	RET
	SUBTTL	INITIALIZED DATA

CMDBLK:	EXP	NEWPAR		;FLAGS AND REPARSE ADDRESS
	XWD	.PRIIN,.PRIOU	;INPUT AND OUTPUT JFNS <
	XWD	-1,[ASCIZ/SETNOD>/]	;CONTROL-R POINTER
	XWD	-1,TXTBUF	;POINTER TO TEXT BUFFER
	XWD	-1,TXTBUF	;POINTER TO CURRENT POSITION
	EXP	TXTLEN		;NUMBER OF CHARS IN BUFFER
	EXP	0		;COUNT
	XWD	-1,ATMBUF	;POINTER TO ATOM BUFFER
	EXP	TXTLEN		;NUMBER OF CHARACTERS IN BUFFER
	EXP	JFNBLK		;POINTER TO GTJFN BLOCK

JFNBLK:	EXP	0		;FLAGS AND GENERATION NUMBER
	XWD	.PRIIN,.PRIOU	;INPUT AND OUTPUT JFNS
	BLOCK	20		;NO DEFAULTS

NOIBLK:	FLDDB.	(.CMNOI)	;BLOCK FOR NOISE FUNCTION

TOKBLK:	FLDDB.	(.CMTOK)	;BLOCK FOR TOKEN FUNCTION
	BLOCK	1

TOKSTR:	ASCIZ/./

NODNUM:	POINT	10,NODADR,35	;Node number pointer
NDAREA: POINT	6,NODADR,25	;Area number pointer

	XLIST			;DUMP THE LITERALS
	LIT
	LIST
	SUBTTL	ZEROED DATA

	ZERBEG==.		;FIRST LOCATION TO ZERO ON STARTUP

PDL:	BLOCK	PDLSIZ		;STACK ROOM
SAVEP:	BLOCK	1		;STORAGE OF STACK POINTER
TXTBUF:	BLOCK	TXTLEN/5+1	;BUFFER FOR COMMAND JSYS
ATMBUF:	BLOCK	TXTLEN/5+1	;BUFFER FOR ATOM BUFFER
TEMP:	BLOCK	TMPSIZ		;TEMPORARY STORAGE

JFN:	BLOCK	1		;INPUT JFN
JFNOUT:	BLOCK	1		;OUTPUT JFN
JFNTAK:	BLOCK	1		;TAKE FILE JFN
JFNBIN:	BLOCK	1		;Binary file JFN

NODADR:	BLOCK	1		;NODE address
NODBLK:	BLOCK	2		;NODE% jsys block
NODSTR:	BLOCK	2		;Node name

FDBBLK:	BLOCK	1		;Read FDB information space
ANUM:	BLOCK	1		;temporay area number storage
AREFLG:	BLOCK	1		;flag denoting LIST AREA command
	ZEREND==.-1		;LAST LOCATION TO CLEAR

	END	<XWD 3,ENTRY>