Google
 

Trailing-Edge - PDP-10 Archives - BB-H348C-RM_1982 - swskit-v21/debugging-tools/ncu.mac
There are 3 other files named ncu.mac in the archive. Click here to see a list.
	TITLE	NCU  -  TEMPORARY NCU TO GET TO ALL SNICE FUNCTIONS

	SEARCH	MONSYM
	SEARCH	MACSYM

F=0
 SHOFLG=1B0
 ZERFLG=1B1
 TELFLG=1B2
 EOLFLG==1B3
 ATSFLG==1B4
 KNOFLG==1B5
DTEFLG==1B6
T1=1
T2=2
T3=3
T4=4
T5=5
P1=6
P2=7
P3=10
P4=11
SPCL=16
P=17

;INTERESTING VALUES

ALLDO==0
COUDO==0
DMCDO==14
DTEDO==777777
DUPDO==12
DZDO==30
KDPDO==34
KDZDO==36
KNODO==777777
LINDO==2
LOCDO==0
STADO==1
	SUBTTL	REVISION HISTORY
;;GET VERSION NUMBER SET UP
;
VMAJOR==1
VMINOR==0
VWHO==0
VEDIT==3
;
.JBVER==137
LOC	.JBVER
	BYTE	(3)VWHO(9)VMAJOR(6)VMINOR(18)VEDIT
RELOC	0

;1	UPGRADE TO UNDERSTAND DTE20 ON A SHOW STATUS KNOWN LINES PRINTOUT
;2	UPGRADE TO UNDERSTAND KDP AND KDZ LINE TYPES
;3	GET NODE NAME WITH .CMFLD TO AVOID RELEASE 4 .CMNOD CROCK (SGR)
	SUBTTL	MAINLINE PROGRAM
NCU:		;START OF THE PROGRAM

	RESET
	MOVE	P,[IOWD 20,PDL]

;SET UP THE INTERRUPT STUFF

	MOVEI	T1,.FHSLF	;MY FORK
	MOVE	T2,[XWD LEVTAB,CHNTAB] ;INTERRUPT TABLE ADDRESSES
	SIR			;SETUP INTERRUPT ROUTINE
	ERCAL	OOPS
	EIR			;ENABLE INTERRUPT ROUTINE
	ERCAL	OOPS
	MOVSI	T2,700000	;ALL MY DEFINED CHANNELS
	AIC			;ACTIVATE INTERUPT CHANNELS
	ERCAL	OOPS

;NOW FIND OUT WHAT HE WANTS TO DO

PARSE:	MOVEI	T1,CMSBLK	;SET UP COMND STATE BLOCK ADDRESS
	MOVEI	T2,CMINI		;INITIALIZE
	COMND
	 ERCAL	OOPS
REPARS:	SETZ	F,			;CLEAR FLAGS
REPAR1:	MOVEI	T2,CMKEY1		;OKAY, GET FIRST KEYWORD
	PUSHJ	P,GETCMD
	HRRZ	SPCL,(T2)
	JRST	(SPCL)			;GO DO ZERO OR SHOW

;THIS IS THE SHOW PROCESSING

SHODO:	MOVEI	T2,CMKEY2		;NOW ITS COUNTS OR STATUS
	PUSHJ	P,GETCMD
	HRRZ	T5,(T2)			;GET 0 OR 1
	CAIN	T5,EXEDO		;IT MIGHT BE A SHOW EXECUTOR COMMAND
	JRST	SHOEXE			;IF SO, DO IT
SHODO1:	MOVEI	T2,CMKEY3		;NOW ITS LINE, LOCAL, OR KNOWN
	PUSHJ	P,GETCMD
	HRRZ	T4,(T2)			;GET CODE
	CAIN	T4,KNODO		;IS KEYWORD 'KNOWN' ?
	JRST	[			;IF SO,
		 TXNE	F,KNOFLG	;HAS HE ALREADY SAID KNOWN?
		 JRST	PRSERR		;YES COMPLAIN
		 TXO	F,KNOFLG	;NO, SET FLAG
		 JRST	SHODO1		;FIND THE NEXT KEYWORD
		]
	LSH	T4,1			;DOUBLE
	ADDI	T4,(T5)			;NOW WE HAVE THE OPTION CODE
	MOVEI	T3,^D8			;GET FUNCTION CODE FOR READ
	MOVE	T5,NICBPT		;GET BYTE POINTER TO NICE MESSAGE
	IDPB	T3,T5			;PUT IN FUNCTION CODE
	IDPB	T4,T5			;PUT IN OPTION
	TXO	F,SHOFLG		;SET UP THAT SHOW IS THE REQUEST
	JRST	SNDNIC			;GO ASK FOR INFO

;THIS IS ZERO PROCESSING

ZERDO:	MOVEI	T1,.FHSLF		;GET FORK HANDLE
	RPCAP				;LET'S MAKE SURE THE GUY'S ENABLED
	 ERCAL	OOPS
	TXNN	T3,SC%WHL!SC%OPR	;ONLY OPR OR WHEEL WORK
	 JRST	[
		 HRROI	T1,[ASCIZ \%Must be OPERATOR or WHEEL enabled to use ZERO\]
		 PSOUT
		  ERCAL	OOPS
		 JRST	PARSE		;RETURN TO DO IT ALL OVER
		]
	MOVEI	T1,CMSBLK		;RESTORE COMND JSYS BLOCK ADDRESS
	MOVEI	T2,CMKEY3		;LINE OR LOCAL?
	PUSHJ	P,GETCMD
	MOVE	T5,NICBPT		;GET BYTE POINTER
	MOVEI	T3,^D9			;GET ZERO FUNCTION CODE
	HRRZ	T4,(T2)			;GET OPTION CODE
	IDPB	T3,T5			;PUT FUNCTION CODE IN
	IDPB	T4,T5			;PUT OPTION CODE IN
	TXO	F,ZERFLG		;SET UP THAT ZERO IS THE REQUEST

;WE KNOW WHAT HE WANTS, LET'S OPEN THE LINK AND REQUEST IT

SNDNIC:	HRR	F,T4		;SAVE OPTION FLAG FOR FUTURE REFERENCE
	TRNE	F,6		;IF THIS IS A LINE REQUEST,
	PUSHJ	P,LINPRS	;WE NEED THE LINE TYPE_NUMBER
	TXNE	F,EOLFLG	;ARE WE ALREADY AT END OF LINE?
	JRST	SNDNI1		;YES, SKIP FINISH OF LINE
	MOVEI	T2,CMCFM	;FINISH OFF THE COMMAND
	PUSHJ	P,GETCMD

SNDNI1:	TXNE	F,DTEFLG	;ARE WE CHECKING STATUS OF DTE-20?
	JRST	DTESTA		;YES, GET DTE-20 STATUS AND REPORT IT
	MOVX	T1,GJ%SHT	;GET SHORT FORM OF GTJFN
	HRROI	T2,NETSTR	;POINT TO NETSTR
	TXNE	F,TELFLG	;IF HE DID A TELL COMMAND
	HRROI	T2,TELSTR	;  USE THE NODE HE SPEC'ED
	GTJFN			;GET THE HANDLE
	ERCAL	OOPS
	HRRZM	T1,NETJFN	;SAVE NETWORK JFN

;NOW OPEN THE LINK

	MOVE	T2,[EXP 10B5!OF%RD!OF%WR]
	OPENF
	ERCAL	OOPS		;OPEN THE NETWORK
	MOVEI	T2,.MOACN	;GET READY FOR NETWORK INTERRUPTS
	MOVE	T3,[BYTE (9)0,1,2] ;THIS IS THE CHANNELS FOR EACH EVENT
	MTOPR
	ERCAL	OOPS
	PUSHJ	P,GOAWAY	;GO AWAY WHILE CONNECT HAPPENS

;CONNECT OK - NOW SEND THE REQUEST TO SNICE

	MOVE	T2,NICBPT	;GET BYTE POINTER FOR NICE MESSAGE
	MOVNI	T3,2		;ASSUME SEND ONLY 2 BYTES
	TRNE	F,6		;WERE WE RIGHT?
	POP	P,T3		;THIS IS A LINE REQUEST, GET # BYTES FROM STACK
	SOUTR
	PUSHJ	P,GOAWAY	;OKAY, WE'RE DONE FOR A WHILE

;GET HERE, WE GOT A DATA AVAILABLE INTERRUPT

	MOVE	T2,INPBPT	;GET INPUT BYTE POINTER
	MOVNI	T3,1000		;GET BUFFER SIZE
	SINR

;THIS IS STATUS BLOCK - CHECK STATUS

	MOVE	T2,INPBPT	;GET BYTE POINTER
	ILDB	T5,T2		;GET STATUS WORD
	CAIE	T5,1		;IF GOOD STATUS, LET'S DO THE WORK
	 JRST	NICERR		;ELSE, GO TELL OF THE ERROR

	TXNE	F,ZERFLG	;IS IT ZERO OR SHOW?
	JRST	ENDOPR		;ZERO, WE'RE DONE - GO CLEAN UP

;WELL, NOW DO ALL THE SHOW JUNK

	ILDB	P1,T2		;GET COUNT OF NUMBER OF BLOCKS COMING

SHOLP0:	SOJL	P1,ENDOPR	;WHEN NEG COUNT, WE'RE DONE - GO CLEAN UP
	MOVE	T1,NETJFN	;GET JFN FOR NETWORK
	MOVE	T2,INPBPT	;SET UP FOR
	MOVNI	T3,1000		; THE SINR
	SINR
	 ERCAL	OOPS
	MOVEI	P2,1000		;NOW FIND OUT HOW MANY BYTES WE HAVE
	ADD	P2,T3

	PUSHJ	P,CRLF
	HRROI	T1,[ASCIZ \Local node \] ;ASSUME IT LOCAL HE WANTS
	TRNE	F,4		;IS IT?
	HRROI	T1,[ASCIZ \Line \]	;NO, ITS LINE
	PSOUT
	 ERCAL	OOPS
	TRNE	F,1		;IS IT COUNTERS, 
	JRST	STADAT		; OR STATUS?

;COUNTER DATA

	HRROI	T1,[ASCIZ \counters of \]
	PSOUT
	 ERCAL	OOPS
	MOVE	T5,INPBPT	;GET RCVBUFFER BYTE POINTER
	ILDB	T3,T5		;GET OPTION CODE
	SUBI	P2,1		;DECREMENT COUNT
	PUSHJ	P,ASCPRT	;PRINT OUT LINE OR NODE NAME

;NOW WE LOOP THROUGH THE REST OF THE DATA FOR TYPE,VALUE

COULP0:	PUSHJ	P,CRLF
	SOJE	P2,SHOLP0	;DONE WITH THIS BLOCK OF DATA
	ILDB	P3,T5		;GET TYPE
	ILDB	T4,T5		;GET LOW ORDER BYTE
	ILDB	T2,T5		;GET HIGH ORDER BYTE
	TRNE	T2,200		;IS HIGH ORDER BIT ON?
	JRST	OVRFLW		;YES, TELL OF OVERFLOW
	LSH	T2,^D8		;SHIFT HIGH ORDER TO WHERE IT BELONGS
	OR	T2,T4		;PUT IN LOW ORDER
	MOVEI	T1,.PRIOU
	MOVEI	T3,^D10
	NOUT
	 ERCAL	OOPS
COULP1:	MOVE	T1,TYPTXT(P3)	;GET TEXT ADDRESSES
	TRNE	F,4		;IS THIS LOCAL OR LINE?
	MOVSS	T1		;LINE, GET PROPER ADDRESS
	HRLI	T1,777777	;SET TO STD BYTE POINTER
	PSOUT
	 ERCAL	OOPS
	SUBI	P2,2		;UPDATE BYTE COUNT TO PROPER NUMBER
	JRST	COULP0		;LOOP
OVRFLW:	HRROI	T1,[ASCIZ \OVRFLW\]
	PSOUT
	 ERCAL	OOPS
	JRST	COULP1

;STATUS DATA

STADAT:	HRROI	T1,[ASCIZ \status of \]
	PSOUT
	 ERCAL	OOPS
	MOVE	T5,INPBPT	;GET REC BUF BYTE POINTER
	IBP	T5		;SKIP OPTION CODE
	SUBI	P2,1		;UPDATE COUNTER
	PUSHJ	P,ASCPRT	;PRINT OUT LINE OF NODE NAME
	TRNE	F,4		;IS THIS LINE STAE OR LOCAL STATE

	JRST	LINSTA		;GO GIVE LINE STATE

	;WE KNOW THE NEXT FOUR BYTES ARE ALL ZEROES, SO SKIP
	PUSHJ	P,CRLF		;SEND <CR><LF>
	SUBI	P2,4
	IBP	T5		;NODE NUMBER
	IBP	T5		;NODE STATE
	IBP	T5		;OPERATOR LOGGING STATE
	IBP	T5		;MAINTENANCE LOGGING STATE
	;NOW THERE MIGHT BE  THE DEFAULT HOST NODE
	HRROI	T1,[ASCIZ \Default Host node: \]
	PSOUT
	 ERCAL	OOPS
	PUSHJ	P,ASCOUT
	;NOW GET ROUTING VERSION INFO
	PUSHJ	P,CRLF
	HRROI	T1,[ASCIZ \Routing version = \]
	PSOUT
	 ERCAL	OOPS
	PUSHJ	P,VERPRT	;PRINT THE VERSION NUMBER
	HRROI	T1,[ASCIZ \		Communications version = \]
	PSOUT
	 ERCAL	OOPS
	PUSHJ	P,VERPRT	;PRINT THE VERSION NUMBER
	PUSHJ	P,CRLF		;SEND OUT A <CR><LF>
	HRROI	T1,[ASCIZ \System version = \]
	PSOUT
	 ERCAL	OOPS
	PUSHJ	P,ASCOUT	;PRINT THE SYSTEM VERSION
	PUSHJ	P,CRLF		;PRINT OUT A <CR><LF>

	JRST	SHOLP0		;LOOP

;LINE STATE INFO

LINSTA:	HRROI	T1,[ASCIZ \	State: \]
	PSOUT
	 ERCAL	OOPS
	ILDB	T2,T5		;GET LINE STATE
	HRRO	T1,STATBL(T2)	; IN ASCII
	PSOUT
	 ERCAL	OOPS
	IBP	T5
	IBP	T5		;SKIP OPERATOR AND MAINT STATES
	TXZE	F,ATSFLG	;IS THIS A MULTIDROP LINE?
	JRST	SHOLP0		;YES, DON'T PRINT REMOTE INFO
	HRROI	T1,[ASCIZ \		Remote: \]
	PSOUT
	 ERCAL	OOPS
	PUSHJ	P,ASCOUT	;GET NODE NAME IF ANY

	JRST	SHOLP0

;WELL, WE'RE DONE NOW, CLEAN UP AND SAY FUNCTION COMPLETE

ENDOPR:	MOVE	T1,NETJFN
	CLOSF			;CLOSE NETWORK CONNECTION
	 ERCAL	OOPS
	PUSHJ	P,CRLF
	HRROI	T1,[ASCIZ \Requested NICE function completed.
\]
	PSOUT
	 ERCAL	OOPS
	JRST	PARSE

;SHOW STATE LINE DTE20 PROCESSING
;	THIS REQUIRES USE OF BOOT JSYS INSEAD OF NICE MESSAGE AT THIS TIME

DTESTA:	MOVEI	T1,.BTSTS	;GET STATUS FUNCTION
	MOVEI	T2,BTARG	;ARGUMENT BLOCK ADDRESS
	BOOT
	 ERCAL	OOPS
	HRROI	T1,[ASCIZ \Local DTE-20 # \]
	PSOUT
	 ERCAL	OOPS
	MOVEI	T1,.PRIOU
	MOVE	T2,BTARG+.BTDTE	;GET DTE NUMBER
	MOVEI	T3,^D8		;OUTPUT IN OCTAL (WHO CARES?)
	NOUT
	 ERCAL	OOPS
	HRROI	T1,[ASCIZ \ protocol status is: \]
	PSOUT
	 ERCAL	OOPS
	MOVE	T2,BTARG+.BTCOD	;GET STATUS
	MOVEI	T1,.PRIOU
	NOUT
	 ERCAL	OOPS
	AOJL	T2,DTEST1	;CHECK FOR LESS THAN ONE
	CAILE	T2,2		;MAKE SURE BOUNDS ARE OKAY (0-2)
	JRST	DTEST1		;YES, I DON'T KNOW HOW TO PROCESS IT THEN
	HRRO	T1,DTETBL(T2)	;GET STATUS HELP DESCRIPTION
	PSOUT
	 ERCAL	OOPS
DTEST1:	PUSHJ	P,CRLF
	JRST	PARSE

;SET COMMAND - PRESENTLY ONLY WORKS FOR EXECUTOR

SETDO:	MOVEI	T2,CMKEY5	;CAN ONLY SAY EXECUTOR
	PUSHJ	P,GETCMD
;DO NEXT WITH EYE ON THE FUTURE ???
	HRRZ	SPCL,(T2)	;GET THE DISPATCH ADDRESS
	JRST	(SPCL)		; AND GO THERE

EXEDO:	MOVE	SPCL,[POINT 7,NETSTR,27] ;SET UP PROPER ADDRESSING SCHEME
	PUSHJ	P,NODMOV	;AND MOVE NODE NAME TO DEFAULT
	HRROI	T1,[ASCIZ \Executor set\]
	PSOUT
	 ERCAL	OOPS
	JRST	PARSE


;TELL "NODE-NAME" COMMAND
;	WE KNOW THAT USER WANTS THIS MESSAGE TO GO TO OTHER THAN DEFAULT

TELDO:	TXO	F,TELFLG	;SET THAT THIS IS A TELL FUNCTION
	MOVE	SPCL,[POINT 7,TELSTR,27] ;SET UP PROPER ADDRESSING SCHEME
	PUSHJ	P,NODMOV	; AND MOVE NODE NAME FOR TEMPORARY IN

;OK, HE PROBABLY WANTS TO TELL THEM SOMETHING, SO...

	JRST	REPAR1		;(CAN'T LET 'EM TURN OFF TELFLG)

;NODMOV GETS NODE NAME AND PUTS IT WHERE WE WANT IT FOR SET EXECUTOR AND TELL

NODMOV:	MOVEI	T2,CMFLD	;GET NODE NAME FROM USER
	PUSHJ	P,GETCMD
	MOVEI	T2,CMCFM	;CONFIRM IT
	TXNN	F,TELFLG
	PUSHJ	P,GETCMD

;OKAY, NODE NAME WANTED IS NOW IN ATOM BUFFER

	SKIPA	T2,[POINT 7,ATOM] ;GET NODE NAME REQUESTED
NODM.1:	IDPB	T3,SPCL		;GET CHARACTER OF NODE NAME
	ILDB	T3,T2		; INTO STRING FOR JFN
	JUMPN	T3,NODM.1	;LOOP UNTILWE GET A NULL

;NOW WE FIX UP THE OBJECT CODE

	MOVE	T2,[POINT 7,TTASK] ;GET BYTE POINTER FOR OBJECT TYPE
NODM.2:	ILDB	T3,T2		;GET OBJECT TYPE CHAR
	IDPB	T3,SPCL		;INTO STRING
	JUMPN	T3,NODM.2	;LOOP UNTIL NULL
	POPJ	P,

;HINTS COMMAND

HINDO:	MOVEI	T2,CMCFM	;FINISH OFF COMMAND
	PUSHJ	P,GETCMD
	HRROI	T1,HINTXT	;GET ADDRESS OF HINT TEXT
	PSOUT
	 ERCAL	OOPS
	JRST	PARSE		;DONE, RETURN

;SHOW EXECUTOR - THIS CAUSES THE CURRENT JFN STRING TO BE PRINTED

SHOEXE:	MOVEI	T2,CMCFM	;FINISH OFF THE COMMAND LINE
	PUSHJ	P,GETCMD
	HRROI	T1,[ASCIZ \Executor: \]
	PSOUT
	 ERCAL	OOPS
	HRROI	T1,NETSTR	;GET ADDRESS OF JFN STRING
	PSOUT
	 ERCAL	OOPS
	PUSHJ	P,CRLF
	JRST	PARSE		;GO GET NEXT COMMAND
;	PRINT ROUTINES

ASCPRT:	;;;FIRST IS THERE AN ASCII NODE NAME, OR STD FORMAT LINE STUFF?
	TRNN	F,4		;IS IT LINE OR LOCAL?
	JRST	ASCOUT		;LOCAL - HAS ASCII NODE NAME
	ILDB	T3,T5		;GET FORMAT OF LINE ID
	CAIE	T3,1		;IS IT STANDARD?
	JRST	ASCOUT		;NO, IT MUST BE ASCII
	ILDB	T3,T5		;GET LINE TYPE
	HRRZ	T1,TYPTAB	;GET LENGTH OF LIST
	MOVNS	T1		;NEGATE
	HRLI	T1,TYPTAB+1	;GET ADDRESS OF TABLE
	MOVSS	T1
ASCPR1:	MOVE	T2,(T1)		;GET LINE TYPE
	CAIN	T3,(T2)		;IS THIS THE TYPE?
	JRST	ASCPR2		;YES!
	AOBJN	T1,ASCPR1	;NO, LOOP
	HRROI	T1,[ASCIZ \UNDEFINED LINE TYPE (\]
	PSOUT
	 ERCAL	OOPS
	MOVEI	T1,.PRIOU
	MOVE	T2,T3
	MOVEI	T3,^D8
	NOUT			;PRINT OUT LINE TYPE WE GOT THAT WE DON'T KNOW
	 ERCAL	OOPS
	HRLI	T2,[ASCIZ \) \]
ASCPR2:	HLRO	T1,T2		;GET PROPER BYTE POINTER
	PSOUT
	 ERCAL	OOPS		;PRINT LINE TYPE
	MOVEI	T1,.PRIOU
	MOVEI	T3,^D8
	ILDB	T4,T5		;GET NUMBER
	PUSHJ	P,ASCPR9
	;NOW IS THERE MORE OR THE NEXT TWO ZERO?
	ILDB	T4,T5		;IS THERE A LINE #?
	JUMPE	T4,ASCPR3	;NO, GO CHECK FOR A DROP #
	PUSHJ	P,ASCPR9
ASCPR3:	ILDB	T4,T5		;IS THERE A DROP #?
	JUMPE	T4,ASCPR4	;NO, FINISH UP
	TXO	F,ATSFLG	;SET THAT THIS IS A MULTIDROP LINE
	HRROI	T1,[ASCIZ \ Drop\]
	PSOUT
	 ERCAL	OOPS
	MOVEI	T1,.PRIOU
	PUSHJ	P,ASCPR9
ASCPR4:	SUBI	P2,4
	POPJ	P,

;ASCPR9 PRINT OUT THE DATA

ASCPR9:	MOVEI	T2,"_"
	BOUT
	 ERCAL	OOPS
	MOVE	T2,T4
	NOUT
	 ERCAL	OOPS
	POPJ	P,		;RETURN

ASCOUT:	ILDB	T3,T5		;GET NUMBER OF ASCII CAHRACTERS FOLLOWING
	JUMPE	T3,[
		 HRROI	T1,[ASCIZ \none\]
		 PSOUT
		 ERCAL	OOPS
		 POPJ	P,
		]
	MOVNS	T3		;TURN NEGATIVE
	ADD	P2,T3		;DECREMENT THE RECORD COUNT
	MOVE	T2,T5		;GET BYTE POINTER TO USE
	MOVEI	T1,.PRIOU	;SET PRINCIPAL OUTPUT DEVICE
	SOUT			;SEND IT
	 ERCAL	OOPS
	MOVE	T5,T2		;GET UPDATED POINTER (I HOPE)
	POPJ	P,		;RETURN

VERPRT:	MOVEI	T1,.PRIOU
	MOVEI	T3,^D8
	ILDB	T2,T5	;MAJOR VERSION #
	NOUT
	 ERCAL	OOPS
	MOVEI	T2,"."
	BOUT		;OUTPUT .
	 ERCAL	OOPS
	ILDB	T2,T5	;ECO #
	NOUT
	 ERCAL	OOPS
	MOVEI	T2,"."
	BOUT
	 ERCAL	OOPS
	ILDB	T2,T5	;REVISION #
	NOUT
	 ERCAL	OOPS
	SUBI	P2,3
	POPJ	P,		;RETURN

CRLF:	HRROI	T1,[ASCIZ \
\]
	PSOUT
	 ERCAL	OOPS
	POPJ	P,		;RETURN

;GET LINE TYPE_NUMBER

LINPRS:	MOVEI	T2,CMKEY4	;GET LINE TYPE
	TRNE	F,1		;IS THIS A SHOW STA LINE?
	MOVEI	T2,CMKEY6	;YES, HE CAN ASK FOR DTE-20
	TXNE	F,KNOFLG	;IS KNOWN KEYWORD FLAG SET?
	 SKIPA	T2,[EXP ALLAD]	;YES, DON'T GET COMMAND, SET ALL AS CMD
	PUSHJ	P,GETCMD
	HRRZ	T4,(T2)		;GET LINE TYPE CODE
	JUMPE	T4,[		;IF LINE TYPE = 0, HE SAID "ALL"
		 IDPB	T4,T5	;PUT INTO FORMAT BYTE THAT WE WANT ALL
		 MOVNI	T4,3	;GET THAT WE WANT TO SEND 3 BYTES
		 JRST	LINPR9	;AND DO RETURN WORK
		]
	CAIN	T4,DTEDO	;DID HE ASK FOR DTE-20 STATUS?
	TXO	F,DTEFLG	;YES, SET THE FLAG FOR LATER REFERENCE
	MOVEI	T3,1		;ELSE, USE STANDARD FORMAT
	IDPB	T3,T5		; PUT INDICATOR INTO MESSAGE
	IDPB	T4,T5		;AND PUT LIN TYPE INTO NICE MESSAGE
	SETZ	T4,		;SET DEFAULT NUMBERS FOR:
	PUSH	P,T5		;SAVE BYTE POINTER FOR A SEC
	MOVE	T3,T5		
	IDPB	T4,T3		;CONTROLLER #
	IDPB	T4,T3		;LINE #
	IDPB	T4,T3		;STATION #
	MOVEI	T4,3		;LOOP THRU NEXT AT MOST 3 TIMES
LINPR1:	MOVEI	T2,CMNUM	;NOW GET LINE NUMBER
	COMND
	 ERCAL	OOPS
	TXNE	T1,CM%NOP
	JRST	[
		 ILDB SPCL,CMSBLK+4
		 CAIN SPCL,"_"
		 JRST LINPR1
		 JRST PRSERR
		]
	HRRZ	T3,T3		;CLEAR LH OF T3
	CAIN	T3,CMCFM	;DOES HE WANT DEFAULTS?
	JRST	[
		 TXO	F,EOLFLG	;SET THAT END OF LINE WAS REACHED
		 JRST	LINPR8		;YEP, DO RETURN WORK
		]
	IDPB	T2,T5
	SOJN	T4,LINPR1	;LOOP IF WE'RE NOT DONE
LINPR8:	POP	P,T3		;GET THE BYTE POINTER I SAVED
	TXNN	F,DTEFLG	;IF DTE FLAG IS SET, DO SOME MORE WORK,
	JRST	LINP8A		; ELSE, RETURN

	ILDB	T1,T3		;GET THE "LINE NUMBER" HE ASKED FOR
	CAIN	T4,3		;DID HE ASK FOR DEFAULT?
	MOVEI	T1,1		;YES, IN THIS CASE IT'S 1
	MOVEM	T1,BTARG+.BTDTE	;SAVE FOR THE DTE WORK

LINP8A:	MOVNI	T4,7		;SET UP THAT WE HAVE 7 BYTES IN MESSAGE TO SEND

	;THIS IS THE RETURN WORK THAT'S NEEDED FOR THIS STUFF
	; THE NEGATIVE NUMBER OF BYTES TO SEND IN THE MESSAGE WILL BE ON THE
	; STACK AS PART OF THE RETURN FROM THIS ROUTINE TO BE USED BY THE SOUTR
LINPR9:	POP	P,SPCL		;GET RETURN ADDRESS
	PUSH	P,T4		;PUT NUMBER OF BYTES TO SEND ONTO STACK
	JRST	(SPCL)		;OK, NOW RETURN

;GETCMD - PARSE THE COMMAND LINE

GETCMD:	COMND
	 ERCAL	OOPS
	TXNE	T1,CM%NOP
	 JRST	PRSERR
	POPJ	P,
	SUBTTL	INTERRUPT HANDLING
;;;0002;;;


CONEVT:	PUSHJ	P,SAVREG	;SAVE THE REGISTERS

	MOVE	T1,NETJFN	;GET NET FILE HANDLE
	MOVEI	T2,.MORLS	;SET UP TO GET STATUS
	MTOPR
	ERCAL	OOPS
	TXNN	T3,MO%CON	;ARE WE CONNECTED?
	JRST	CONERR		;NO, WHAT'S WRONG?

	JRST	DISMIS		;DISMISS THE INTERRUPT

;DIDN'T GET CONNECTION, TELL USER WHAT'S UP

CONERR:	PUSHJ	P,CRLF
	HRROI	T1,[ASCIZ \?NSP CONNECT Error: \]

RLSPRT:	PSOUT
	ERCAL	OOPS
	MOVEI	T1,.PRIOU
	PUSH	P,T3
	PUSH	P,T3
	HLRZ	T2,T3		;MOVE ERROR AC TO PRINT OUT
	MOVEI	T3,^D8
	NOUT
	ERCAL	OOPS
	HRROI	T1,[ASCIZ \,,\]
	PSOUT
	ERCAL	OOPS
	MOVEI	T1,.PRIOU
	POP	P,T2
	HRRZ	T2,T2
	NOUT
	ERCAL	OOPS
	POP	P,T2
	TXNN	T2,MO%CON!MO%SRV!MO%WFC!MO%WCC!MO%EOM!MO%ABT!MO%SYN!MO%INT
	JRST	CONER1		;IF ALL THE ABOVE ARE ZERO, DO RH ONLY
	PUSHJ	P,CRLF
	HRROI	T1,[ASCIZ \LH= \]
	PSOUT
	ERCAL	OOPS
	JFFO	T2,.+1		;R0 HAS COUNT
	MOVE	T1,CONFLG(T3)	;GET ASSOCIATED MESSAGE (ONLY FIRST ONE)
	PSOUT
	ERCAL	OOPS
CONER1:	PUSHJ	P,CRLF
	HRROI	T1,[ASCIZ \RH= \]
	PSOUT
	ERCAL	OOPS
	MOVE	T3,[XWD -LDISER,DISERR]
CONLP1:	HLRZ	T1,(T3)		;GET REJECT CODE
	CAIE	T1,(T2)		;ARE THEY THE SAME
	AOBJN	T3,CONLP1		;NO, LOOP WHILE WE STILL HAVE ERRORS TO TEST
				;HERE WHEN WE FOUND ERROR OR RAN OUT OF TESTS
	HRRO	T1,(T3)		;GET STRING POINTER
	PSOUT
	ERCAL	OOPS
	PUSHJ	P,CRLF
	JRST	NCU


INTEVT:	PUSHJ	P,SAVREG	;SAVE THE REGISTERS

	MOVE	T1,NETJFN	;GET NETWORK FILE HANDLE
	MOVEI	T2,.MORIM	;READ INTERRUPT MESSAGE FUNCTION CODE
	MOVE	T3,[POINT 8,INTMSG] ;POINTER TO BUFFER
	MTOPR
	ERCAL	OOPS
	PUSHJ	P,CRLF
	HRROI	T1,[ASCIZ \?Unexpected NSP INTERRUPT message recieved:\]
	PSOUT
	ERCAL	OOPS
	PUSHJ	P,CRLF
	MOVE	T5,[POINT 8,INTMSG]
	MOVEI	T1,.PRIOU	;SET UP OUTPUT FILE HANDLE
	MOVE	T3,[EXP NO%MAG!4B17+^D8] ;OUTPUT OCTAL BYTES 4 COLUMNS/BYTE
INTLOP:	ILDB	T2,T5		;GET FIRST BYTE OF MESSAGE
	NOUT			;SEND IT TO TTY
	ERCAL	OOPS
	SOJG	T4,INTLOP	;LOOP IF WE NEED TO
	PUSHJ	P,CRLF

	JRST	DISMIS		;DISMISS THE INTERRUPT

DATAIN:	PUSHJ	P,SAVREG	;SAVE THE REGISTERS

	MOVE	T1,NETJFN	;GET NET FILE HANDLE
	MOVEI	T2,.MORLS	;READ LINK STATUS
	MTOPR			;TO ASSURE THER IS DATA FOR US
	ERCAL	OOPS
	TXNE	T3,MO%EOM	;IS THERE A MESSAGE WAITING?
	JRST	DISMIS		;YES, EVERYTHING IS OKAY

;	GET HERE IF NOT A MESSAGE AVAILABLE INTERRUPT. MEANS LINK FAILED
	PUSHJ	P,CRLF
	HRROI	T1,[ASCIZ \?NSP Logical Link Error: \]
	JRST	RLSPRT


SAVREG:	POP	P,SPCL	;PUT PC INTO 0 FOR A SEC
	PUSH	P,T1		;GO SAVE THE ACS
	PUSH	P,T2
	PUSH	P,T3
	PUSH	P,T4
	PUSH	P,T5
	JRST	@SPCL		;RETURN

DISMIS:	POP	P,T5
	POP	P,T4
	POP	P,T3
	POP	P,T2
	POP	P,T1		;RESTORE REGISTERS
	HRRZ	SPCL,PCLEV2	;GET ADDRESS OF WHERE WE INTERRUPTED
	CAIE	SPCL,GOAWAY+1	;ARE WE AT THE WAIT
	DEBRK			;NO, DISMIS INTERRUPT
	HRLI	SPCL,10000	;ELSE, GET USER MODE BIT
	ORM	SPCL,PCLEV2	;AND TURN IT ON
	DEBRK			;DISMISS

GOAWAY:	WAIT		;SLEEP UNTIL SOMETHING INTERSETING HAPPENS
	POPJ	P,		;WHEN IT DOES, GO BACK TO WHERE WE CAME FROM


;NETWORK ERROR AREA

;NICERR - T5 HAS ERROR CODE FROM NICE PROCESS

NICERR:	HRROI	T1,[ASCIZ \?NICE error return: \]
	PSOUT
	 ERCAL	OOPS
	MOVEI	T1,.PRIOU	;GET PRINC OUTPUT DEV JFN
	HRRO	T2,T5		;GET ERROR CODE
	TRO	T2,777400	;FILL IN LAST EIGHT BITS
	MOVEI	T3,^D10		;OUTPUT IN DECIMAL
	NOUT			;OUTPUT ERROR NUMBER
	 ERCAL 	OOPS
	PUSHJ	P,CRLF
	MOVE	T3,[XWD -LNICRE,NICRET]
NICER1:	HLRO	T1,(T3)		;GET POSSIBLE RETURN CODE
	CAME	T1,T2		;ARE THEY THE SAME?
	AOBJN	T3,NICER1	;NO, LOOP FOR NEXT
	HRRO	T1,(T3)		;GOT IT, GET BYTE POINTER FOR MESSAGE STRING
	PSOUT
	 ERCAL	OOPS
	PUSHJ	P,CRLF
	JRST	ENDOPR		;GO TRY AGAIN

;PRSERR - COMND JSYS COULDN'T PARSE THE WORDS


PRSERR:	MOVE	T5,CMSBLK+.CMPTR	;GET BYTE PTR TO WHERE ERRRO WAS FOUND
	ADDI	T5,ERRBUF-INPBUF+1	;ADD IN OFFSET
	MOVE	T3,T5			;SAVE BYTE POINTER FOR LATER
	MOVEI	T4,"^"		;GET A POINTER BYTE
	DPB	T4,T5		;PUT INTO ERROR POINTER BUFFER
	SETZ	T4,
	IDPB	T4,T5		;END MESSAGE
	HRROI	T1,ERRBUF	;GET ADDRESS OF ERROR POINTER BUFFER
	PSOUT
	 ERCAL	OOPS
	MOVEI	T4,"-"		;GET BLANK
	DPB	T4,T3
	IDPB	T4,T3		;AND REPLACE INTO BUFFER

	PUSHJ	P,CRLF
	HRROI	T1,[ASCIZ \?Could not parse indicated field, please re-enter entire line\]
	PSOUT
	 ERCAL	OOPS
	POP	P,T1
	JRST	PARSE


OOPS:	POP	P,ERRPC
	PUSHJ	P,SAVREG
;;ACS ARE IN ORDER ON STACK
	PUSHJ	P,CRLF
	HRROI	T1,[ASCIZ \?JSYS error - \]
	PSOUT
	HRLOI	T2,.FHSLF
	MOVEI	T1,.PRIOU
	SETZ	T3,
	ERSTR
	 HALTF
	 HALTF

;THIS IS NORMAL EXIT PROCESSING FROM EXIT COMMAND
;	IT IS ALSO WHERE ERROR PROCESSING FALLS THROUGH

EXIDO:	HALTF			;QUIT
;IF HE TYPES CONTINUE, GO BACK AND START ALL OVER
	JRST	NCU
	SUBTTL	DATA AREA
;NETWORK CODE WORKING STORAGE AND DATA AREA

BTARG:	BLOCK	2
NETJFN:	BLOCK	1
NETSTR:	ASCIZ	\DCN:-19\	;THIS IS DEFAULT STRING
	BLOCK	2
TELSTR:	ASCIZ	\DCN:\	;THIS IS STRING FROM TELL KEYWORD
	BLOCK	2
TTASK:	ASCIZ	\-19\
NICBPT:	POINT	8,NICMSG
NICMSG:	BYTE	(8)0,0,0,0,0,0,0,0
INPBPT:	POINT	8,RCVMSG
RCVMSG:	BLOCK	1000
INTMSG:	BLOCK	5

CONFLG:
	EXP	[ASCIZ \Link is connected\]
	EXP	[ASCIZ \Link is a server\]
	EXP	[ASCIZ \Link is waiting for a connect\]
	EXP	[ASCIZ \Link is waiting for a connect confirm\]
	EXP	[ASCIZ \Link has an entire message to be read\]
	EXP	[ASCIZ \Link has been aborted\]
	EXP	[ASCIZ \Link has been closed normally\]
	EXP	[ASCIZ \Link has an interrupt message available\]
DISERR:
	XWD	.DCX0,[ASCIZ \No special error\]
	XWD	.DCX1,[ASCIZ \Resource allocation failure\]
	XWD	.DCX2,[ASCIZ \Destination node does not exist\]
	XWD	.DCX3,[ASCIZ \Node shutting down\]
	XWD	.DCX4,[ASCIZ \Destination process does not exist\]
	XWD	.DCX5,[ASCIZ \Invalid name field\]
	XWD	.DCX11,[ASCIZ \User abort (asynchronous disconnect)\]
	XWD	.DCX32,[ASCIZ \Too many connections to node\]
	XWD	.DCX33,[ASCIZ \Too many connections to process\]
	XWD	.DCX34,[ASCIZ \Access not permitted - bad RQSTRID or PASSWORD\]
	XWD	.DCX35,[ASCIZ \Logical Link SERVICES mismatch\]
	XWD	.DCX36,[ASCIZ \Unacceptable ACCOUNT information\]
	XWD	.DCX37,[ASCIZ \Segment size too small\]
	XWD	.DCX38,[ASCIZ \Process aborted, timed out, or cancelled request\]
	XWD	.DCX39,[ASCIZ \No path to destination node\]
	XWD	.DCX40,[ASCIZ \Link aborted due to data loss\]
	XWD	.DCX41,[ASCIZ \Destination process does not exist\]
	XWD	.DCX42,[ASCIZ \Confirmation of Disconnect Initiate\]
	XWD	.DCX43,[ASCIZ \Image data field too long\]
LDISER==.-DISERR
	XWD	-1,[ASCIZ \Invalid return in RH of AC2\]

NICRET:	XWD	^D-1,[ASCIZ \Invalid function or option\]
	XWD	^D-2,[ASCIZ \Invalid message format\]
	XWD	^D-3,[ASCIZ \Insufficient status\]
	XWD	^D-8,[ASCIZ \Invalid line id\]
	XWD	^D-9,[ASCIZ \Line in wrong state\]
	XWD	^D-10,[ASCIZ \Line communications error\]
	XWD	^D-11,[ASCIZ \Invalid node id\]
	XWD	^D-12,[ASCIZ \Invalid server id\]
	XWD	^D-13,[ASCIZ \Invalid file\]
	XWD	^D-14,[ASCIZ \Configuration data base error\]
	XWD	^D-15,[ASCIZ \Resource error\]
	XWD	^D-16,[ASCIZ \Invalid parameter value\]
	XWD	^D-17,[ASCIZ \Line protocol error\]
	XWD	^D-18,[ASCIZ \File I/O error\]
LNICRE==.-NICRET
	XWD	0,[ASCIZ \?Unknown Nice error return\]
ERRPC:	BLOCK	1

DTETBL:	EXP	[ASCIZ \  (Not Running)\]
	EXP	[ASCIZ \  (RSX20F or DN64/65)\]
	EXP	[ASCIZ \  (DECnet)\]

STATBL:	EXP	[ASCIZ \On\]
	EXP	[ASCIZ \Off\]
	EXP	[ASCIZ \Invalid switch setting\]
	EXP	[ASCIZ \Loopback\]
	EXP	[ASCIZ \Maintenance\]

LEVTAB:	XWD	0,0
	XWD	0,PCLEV2
	XWD	0,0
PCLEV2:	BLOCK	1

CHNTAB:	XWD	2,CONEVT	;CONNECT EVENT
	XWD	2,INTEVT	;HOPE WE DON'T GET ANY
	XWD	2,DATAIN		;DATA RECIEVED
	REPEAT	33,<	XWD	0,0>

;COMND JSYS DATA AREA

CMSBLK:	EXP	CM%RAI!REPARS
	XWD	.PRIIN,.PRIOU
	POINT	7,PROMPT
	POINT	7,INPBUF
	POINT	7,INPBUF
	EXP	200
	EXP	0
	POINT	7,ATOM
	EXP	100
	EXP	0
PROMPT:	ASCIZ	\NCU>\
INPBUF:	BLOCK	32
ERRBUF:	REPEAT 32,<ASCII \-----\>
ATOM:	BLOCK	20

CMINI:	FLDDB.	.CMINI
CMKEY1:	FLDDB.	.CMKEY,,KEY1TB
CMKEY2:	FLDDB.	.CMKEY,,KEY2TB
CMKEY3:	FLDDB.	.CMKEY,,KEY3TB
CMKEY4:	FLDDB.	.CMKEY,,KEY4TB
CMKEY5:	FLDDB.	.CMKEY,,KEY5TB
CMKEY6:	FLDDB.	.CMKEY,,KEY6TB
CMNUM:	FLDDB.	.CMNUM,,<EXP ^D8>,,,CMCFM
CMNOD:	FLDDB.	.CMNOD,CM%PO
CMFLD:	FLDDB.	.CMFLD,,,<Node Name::>,,CMNOD
CMCFM:	FLDDB.	.CMCFM

KEY1TB:	XWD	6,6	;LENGTH OF LIST
	XWD	EXIASC,EXIDO
	XWD	HINASC,HINDO
	XWD	SETASC,SETDO
	XWD	SHOASC,SHODO
	XWD	TELASC,TELDO
	XWD	ZERASC,ZERDO

KEY2TB:	XWD	3,3
	XWD	COUASC,COUDO
	XWD	EXEASC,EXEDO
	XWD	STAASC,STADO

KEY3TB:	XWD	3,3
	XWD	KNOASC,KNODO
	XWD	LINASC,LINDO
	XWD	LOCASC,LOCDO

KEY4TB:	XWD	6,6
ALLAD:	XWD	ALLASC,ALLDO
	XWD	DMCASC,DMCDO
	XWD	DUPASC,DUPDO
	XWD	DZASC,DZDO
	XWD	KDPASC,KDPDO
	XWD	KDZASC,KDZDO

KEY5TB:	XWD	1,1
	XWD	EXEASC,EXEDO

KEY6TB:	XWD	7,7
	XWD	ALLASC,ALLDO
	XWD	DMCASC,DMCDO
	XWD	DTEASC,DTEDO
	XWD	DUPASC,DUPDO
	XWD	DZASC,DZDO
	XWD	KDPASC,KDPDO
	XWD	KDZASC,KDZDO

TYPTAB:	XWD	6,6
	XWD	DMCASC,DMCDO
	XWD	DTEASC,24
	XWD	DUPASC,DUPDO
	XWD	DZASC,DZDO
	XWD	KDPASC,KDPDO
	XWD	KDZASC,KDZDO

ALLASC:	ASCIZ	\ALL\
COUASC:	ASCIZ	\COUNTS\
DMCASC:	ASCIZ	\DMC\
DTEASC:	ASCIZ	\DTE20\
DUPASC:	ASCIZ	\DUP\
DZASC:	ASCIZ	\DZ\
EXEASC:	ASCIZ	\EXECUTOR\
EXIASC:	ASCIZ	\EXIT\
HINASC:	ASCIZ	\HINTS\
KDPASC:	ASCIZ	\KDP\
KDZASC:	ASCIZ	\KDZ\
KNOASC:	ASCIZ	\KNOWN\
LINASC:	ASCIZ	\LINE\
LOCASC:	ASCIZ	\LOCAL\
SETASC:	ASCIZ	\SET\
SHOASC:	ASCIZ	\SHOW\
STAASC:	ASCIZ	\STATUS\
TELASC:	ASCIZ	\TELL\
ZERASC:	ASCIZ	\ZERO\

TYPTXT:	XWD	LINE0,LOCL0
	XWD	LINE1,LOCL1
	XWD	LINE2,LOCL2
	XWD	LINE3,LOCL3
	XWD	LINE4,LOCL4
	XWD	LINE5,LOCL5
	XWD	LINE6,LOCL6
	XWD	LINE7,LOCL7
	XWD	LINE8,LOCL8
	XWD	0,LOCL9
	XWD	0,LOCL10

;LINE TEXT
LINE0:	ASCIZ	\		Seconds since last zeroed\
LINE1:	ASCIZ	\		Blocks received\
LINE2:	ASCIZ	\		Blocks sent\
LINE3:	ASCIZ	\		Retransmissions, line errors\
LINE4:	ASCIZ	\		Received line errors\
LINE5:	ASCIZ	\		Retransmissions, other than line errors or parity\
LINE6:	ASCIZ	\		Receive timeouts\
LINE7:	ASCIZ	\		Receive selection errors\
LINE8:	ASCIZ	\		Resource errors\

;LOCAL TEXT
LOCL0=LINE0
LOCL1:	ASCIZ	\		User messages sent\
LOCL2:	ASCIZ	\		User messages received\
LOCL3:	ASCIZ	\		Extraneous messages recieved\
LOCL4:	ASCIZ	\		Negative acknowledgements sent\
LOCL5:	ASCIZ	\		Format error other than routing\
LOCL6:	ASCIZ	\		Resource error\
LOCL7:	ASCIZ	\		Successful neighbor initializations\
LOCL8:	ASCIZ	\		Unsuccessful neighbor initializations\
LOCL9:	ASCIZ	\		Currently active logical links\
LOCL10:	ASCIZ	\		Maximum logical links active\

HINTXT:	ASCIZ	\
1.)	To do a "SHOW STATUS LINE DTE20 n", or any "ZERO" command, you
	must be enabled WHEEL or OPERATOR.

2.)	"SHOW STATUS LINE DTE20 n" is not a normal NICE function at this
	time, and is, therefore, intercepted within this program. This
	means that this command will ALWAYS display the status of the local
	systems DTEs without regard for the EXECUTOR set or the TELL command.
	The output from this command is the protocol state of the DTE.
	The SHOW STATUS LINE ALL command for a KL is processed by NICE
	and displays the state of the line and the remote node on the
	line.

3.)	The default values for DUP, KDP, and DMC controller, line, drop are all
	0. The default value for DTE20 number is 1, as this is normally the
	DTE20 that is running the DECnet-20 front end.

4.)	The commands SHOW COUNTS LOCAL and SHOW COUNTS KNOWN LINE
	will generate error messages when the executor is a KL or
	KS node. The MCB based nodes process these commands correctly.
\

LITS:	LIT
PDL:	BLOCK	20
	END	NCU