Google
 

Trailing-Edge - PDP-10 Archives - BB-H348C-RM_1982 - swskit-v21/debugging-tools/dnsr/dnsr.mac
There are no other files named dnsr.mac in the archive.
;<GRANT.DECNET>DNSR.MAC.2,  4-Dec-81 15:43:29, EDIT BY GRANT
;Make INCR=170, allow for larger NSP segment sizes
;<GRANT.DECNET.5>DNSR.MAC.5, 13-Apr-81 11:41:10, EDIT BY GRANT
;Internal message header now 7 words, was 4
;<PERF-TOOLS>DNSR.MAC.14, 25-Mar-81 11:18:44, EDIT BY GRANT
;Add new object types
;Print out object number as well as descriptive string
;<PERF-TOOLS>DNSR.MAC.11, 31-Oct-80 16:56:10, EDIT BY MURPHY
;COMBINED DNSEND AND DNREAD AGAIN

	TITLE DNSR - SNOOP PROGRAM TO COLLECT NSP MESSAGES
	SUBTTL The SNOOPer
	SEARCH MONSYM,MACSYM
	SALL
	.REQUIRE SYMSUB

	EXTERN ST2ADR,ADR2ST

;ITEMS IN DATA BLOCK

INCR==170			;NUMBER OF ITEMS
INTRVL==^D1			;COLLECTED EVERY 1 MILLISECS
NBPT==2				;NUMBER OF BREAKPOINTS
CCZCHN==0			;^Z CHANNEL
OPDEF IFIW [1B0]		;INSTRUCTION FORMAT INDIRECT WORD
PIOFF==400
PION==200

T1=1
T2=2
T3=3
T4=4
Q1=5
Q2=6
Q3=7
P1=10
P2=11
P3=12
P4=13
P5=14
I=15
CX=16
P=17

BPRPAG==100
BPRCOD==BPRPAG_11
;TOP

	BLOCK 1000

TIMER:	RESET
	MOVE P,[IOWD PDLEN,PDL]
	MOVEI I,BPRCOD
	XJRSTF [0
		REL3]
	ERJMP .+1
	TDZA T1,T1		;NO EXT ADR
REL3:	SETO T1,
	MOVEM T1,MONTYP(I)
	MOVEI T1,.FHSLF
	MOVE T2,[LEVTAB,,CHNTAB]
	SIR
	EIR
	MOVE T2,[1B<CCZCHN>]
	AIC
	MOVE T1,[.TICCZ,,CCZCHN]
	ATI			;ENABLE ^Z INTERRUPT
	TMSG <Output Report Label:  >
	HRROI T1,PRGNAM
	MOVE T2,[RD%BEL+5*PRGNML-1]
	RDTTY
	 JRST ERROR
	SETZM INDEX(I)
	SETZM TOTAL(I)
	SETZM PNTR(I)
	SETZM LAST
	SETZM LPRINT
	SETZM LSTTOD
	SETZM ITIME
	SETZM LTOD(I)
	SETZM TABLE(I)
	HRLI T1,TABLE(I)
	HRRI T1,TABLE+1(I)
	BLT T1,TABLE+TABLEN-1(I)
	SETZM OVRFLO(I)
	MOVEI T1,.SNPLC
	MOVEI T2,<BPRLEN+777>/1000
	MOVEI T3,BPRPAG
	SNOOP
	 JRST ERROR
	LSH T2,11
	MOVEM T2,INDEX(I)
	; ..
;RELOCATE BREAKPOINT CODE

	; ..
	MOVSI Q1,-INSTBL
TIMER1:	HLRZ T1,INSTAB(Q1)
	HRRZ T2,INSTAB(Q1)
	ADD T2,INDEX(I)
	HRRM T2,BPRCOD(T1)
	AOBJN Q1,TIMER1

;LOOK UP SYMBOLS

	MOVSI Q1,-SYMTBL
	JUMPE Q1,TIMER4
TIMER2:	MOVEI T1,.SNPSY
	MOVE T2,SYMTAB(Q1)
	MOVE T3,SYMTAB+1(Q1)
	SNOOP
	 JRST ERROR
	HLRE T3,SYMTAB+2(Q1)	;GET SYMBOL OFFSET
	ADD T2,T3		;ADJUST VALUE BY OFFSET
	HRRZ T3,SYMTAB+2(Q1)
	CAIL T3,TIMER		;IN LOCAL CODE?
	ADDM T2,0(T3)		;YES
	CAIGE T3,TIMER		;IN BREAKPOINT CODE?
	ADDM T2,BPRCOD(T3)
	ADD Q1,[2,,2]
	AOBJN Q1,TIMER2

;SET BREAKPOINTS

TIMER4:	MOVSI Q1,-NBPT
SETBP1:	MOVEI T1,.SNPDB
	MOVEI T2,1(Q1)
	MOVE T3,BP1ADR(Q1)
	SKIPE MONTYP(I)
	JRST [	HLRZ T4,BPI(Q1)	;EXT ADR BP ROUTINE ENTRY
		HRLI T4,(XPCW)	;CONSTRUCT BP INSTRUCTION
		JRST SETBP2]
	HRRZ T4,BPI(Q1)
	HRLI T4,(JSR)		;CONSTRUCT BP INSTRUCTION
SETBP2:	ADD T4,INDEX(I)
	TLZ T4,37
	SNOOP
	 JRST ERROR
	AOBJN Q1,SETBP1

;OPEN FILE FOR DATA

	MOVSI T1,(GJ%SHT+GJ%FOU)
	HRROI T2,[ASCIZ/SM.DAT/]
	GTJFN
	 JRST ERROR
	MOVEM T1,FILJFN
	MOVE T2,[440000,,OF%RD+OF%WR]
	OPENF
	 JRST ERROR
	MOVEI T1,INTRVL
	MOVEM T1,INTRV
	SETZM LINTRV

;START SNOOPING

	MOVEI T1,.SNPIB
	SNOOP
	 JRST ERROR
	HRROI T1,[ASCIZ/
TYPE ^Z TO STOP SNOOPING!   /]
	PSOUT
TIMER3:	MOVE T1,TOTAL(I)
	IDIVI T1,INCR
	SUB T1,LPRINT
	CAIL T1,^D10
	JRST [	MOVEI T1,101
		MOVE T2,TOTAL(I)
		IDIVI T2,INCR
		MOVEM T2,LPRINT
		MOVEI T3,12
		NOUT
		 JFCL
		MOVEI T2,11
		BOUT
		JRST .+1]
	MOVE T1,TOTAL(I)
	SUB T1,LAST
	JUMPE T1,WAIT
	CAIL T1,TABLEN
	JRST [	MOVEI T1,7
		PBOUT
		TMSG <*overrun* >
		JRST .+1]
	MOVE T2,LAST
	IDIVI T2,TABLEN		;COMPUTE CURRENT INDEX IN TABLE
	MOVE T2,T3		;START SOUT THERE
	MOVN T3,T3		;COMPUTE DISTANCE TO END OF TABLE
	ADDI T3,TABLEN
	CAMLE T3,T1		;MIN (WORDS THERE, WORDS TO END OF TABLE)
	MOVE T3,T1
	ADDM T3,LAST		;UPDATE PTR
	MOVN T3,T3
	MOVE T1,FILJFN
	HRLI T2,(POINT 36,0)
	ADDI T2,TABLE(I)
	SOUT
	SETZM LINTRV
	JRST TIMER3

WAIT:	SKIPE QUITF		;QUIT?
	JRST TYPANS		;YES
	MOVEI T1,^D500
WAITX:	DISMS
	JRST TIMER3

;^Z INTERRUPT TO STOP DATA COLLECTION

CCZINT:	MOVEM T1,INTAC1		;SAVE AN AC
	SETOM QUITF		;SET FLAG TO QUIT
	HRRZ T1,PIPC2		;CHECK PC
	CAIN T1,WAITX+1		;AT DISMS?
	MOVEI T1,TIMER3		;YES, DEBRK TO TIMER3
	HRRM T1,PIPC2
	MOVE T1,INTAC1
	DEBRK

LEVTAB:	PIPC1
	PIPC2
	PIPC3

CHNTAB:	2,,CCZINT
	BLOCK ^D35
	SUBTTL Raw Data Output


TYPANS:	MOVEI T1,.SNPUL
	SNOOP
	 JRST ERROR
TYPAN2:	MOVE T1,LAST
	IDIVI T1,TABLEN
	HRRZ T1,FILJFN
	HRLI T2,(POINT 36,0)
	ADDI T2,TABLE(I)
	MOVE T3,TOTAL(I)
	SUB T3,LAST
	JUMPLE T3,TYPAN1
	CAIL T3,TABLEN/2
	MOVEI T3,TABLEN/2
	ADDM T3,LAST
	MOVNS T3
	SOUT
	JRST TYPAN2

TYPAN1:	HRRZ T1,FILJFN
	TLO T1,400000
	CLOSF
	 JRST ERROR
	HRRZS T1
	MOVE T2,[440000,,OF%RD]
	OPENF
	 JRST ERROR
TYPAN0:	TMSG <
Do you want "raw" data output? (Y or N)  >
	CALL YESNO
	JUMPE T1,ASKFMT		;JUMP IF NO
YESRAW:	TMSG <
Raw output to:  >
	MOVSI T1,(GJ%FOU+GJ%FNS+GJ%CFM+GJ%MSG+GJ%SHT)
	MOVE T2,[.PRIIN,,.PRIOU]
	GTJFN
	 JRST [MOVEI T1,.PRIOU
	       HRLOI T2,400000
	       SETZ T3,
	       ERSTR
	        JFCL
	        JFCL
	       JRST YESRAW]
	MOVEM T1,RAWJFN
ASKFMT:	TMSG <
Do you want "formatted" output? (Y or N)  >
	CALL YESNO
	JUMPE T1,TRYRAW		;JUMP IF NO
YESFMT:	TMSG <
Formatted output to:  >
	MOVSI T1,(GJ%FOU+GJ%FNS+GJ%CFM+GJ%MSG+GJ%SHT)
	MOVE T2,[.PRIIN,,.PRIOU]
	GTJFN
	 JRST [MOVEI T1,.PRIOU
	       HRLOI T2,400000
	       SETZ T3,
	       ERSTR
	        JFCL
	        JFCL
	       JRST YESRAW]
	MOVEM T1,FMTJFN
TRYRAW:	MOVE T1,RAWJFN
	JUMPN T1,OUTRAW
TRYFMT:	MOVE T1,FMTJFN
	JUMPN T1,OUTFMT
	MOVE T1,FILJFN		;GET SM.DAT JFN
	TLO T1,400000		;DON'T RELEASE JFN
	CLOSF			;CLOSE
	 JFCL			;AND
	DELF			;DELETE
	 JFCL			;IT
	HALTF			;ALL DONE
	JRST TIMER


OUTRAW:	MOVE T1,RAWJFN
	MOVE T2,[70000,,100000]
	OPENF
	 JRST [	MOVEI T1,101
		HRLOI T2,400000
		SETZ T3,
		ERSTR
		JFCL
		JFCL
		HRRZ T1,RAWJFN
		RLJFN
		JFCL
		JRST YESRAW]
	SETZ I,
TYPLOP:	HRRZ T1,FILJFN
	SETZ T2,
	SFPTR
	 JRST ERROR
	MOVE T1,RAWJFN
	HRROI T2,PRGNAM
	SETZ T3,
	SOUT
	HRROI T2,[ASCIZ/
TRACE OF NSP MESSAGES - /]
	MOVEI T3,0
	SOUT
	SETO T2,
	SETZ T3,
	ODTIM
	 JFCL
	HRROI T2,[ASCIZ/

TOTAL SAMPLES TAKEN = /]
	SETZ T3,
	SOUT
	MOVE T2,TOTAL+BPRCOD
	IDIVI T2,INCR
	MOVEI T3,12
	NOUT
	 JFCL
	HRROI T2,[ASCIZ/

/]
	MOVEI T3,0
	SOUT
	CALL TYPFIL
	HRRZ T1,RAWJFN
	CLOSF
	 JFCL
	JRST TRYFMT

TYPFIL:	SETZM ITIME
TYPFL1:	HRRZ T1,FILJFN
	MOVE T2,[POINT 36,BUF]
	MOVNI T3,INCR
	SIN
	 ERJMP TYPFLD
	CALL PLINE
	AOS ITIME
	JRST TYPFL1

TYPFLD:	HRRZ T1,RAWJFN
	MOVEI T2,14
	BOUT
	RET
DEFINE NUMOUT (LOC,BASE)<
   IFNB <LOC>,<MOVE T2,LOC>
	MOVEI T3,^D'BASE
	NOUT
	 NOP>

DEFINE TABOUT <
	MOVEI T2,.CHTAB
	BOUT>

PLINE:	MOVE T1,RAWJFN
	MOVE T3,BUF
	SUBI T3,1
	HRROI T2,[ASCIZ/RECEIVED MESSAGE/]
	SKIPE T3
	HRROI T2,[ASCIZ\SENT MESSAGE\]
	SETZ T3,
	SOUT
	HRROI T2,[ASCIZ/
/]
	SOUT
	MOVE T3,BUF+3
	HRRZS T3
	ANDI T3,7777
	IDIVI T3,4
	SKIPE T4
	AOS T3
	MOVEI T4,7(T3)		;7 = NO. OF MAGIC WORDS BEFORE ACTUAL NSP MESSAGE
	CAILE T4,INCR-1
	MOVEI T4,INCR-1
	MOVNS T4
	HRL T4,T4
	HRRI T4,BUF+1
PLINE1:	MOVE T2,(T4)
	MOVE T3,[NO%LFL!NO%MAG!<^D12B17>!10]
	NOUT
	 JFCL
	MOVEI T2,11
	BOUT
	BOUT
	MOVE Q1,[POINT 8,(T4)]
	MOVE T3,[NO%MAG!NO%LFL!<3B17>!10]
	ILDB T2,Q1
	NOUT
	 JFCL
	MOVEI T2," "
	BOUT
	ILDB T2,Q1
	NOUT
	 JFCL
	MOVEI T2," "
	BOUT
	ILDB T2,Q1
	NOUT
	 JFCL
	MOVEI T2," "
	BOUT
	ILDB T2,Q1
	NOUT
	 JFCL
	MOVEI T2,11
	BOUT
	BOUT
	MOVE Q1,[POINT 8,(T4)]
	ILDB T2,Q1
	CAIGE T2,40
	JRST [	MOVEI T2,"^"
		BOUT
		LDB T2,Q1
		TRO T2,100
		JRST .+1]
	BOUT
	MOVEI T2," "
	BOUT
	ILDB T2,Q1
	CAIGE T2,40
	JRST [	MOVEI T2,"^"
		BOUT
		LDB T2,Q1
		TRO T2,100
		JRST .+1]
	BOUT
	MOVEI T2," "
	BOUT
	ILDB T2,Q1
	CAIGE T2,40
	JRST [	MOVEI T2,"^"
		BOUT
		LDB T2,Q1
		TRO T2,100
		JRST .+1]
	BOUT
	MOVEI T2," "
	BOUT
	ILDB T2,Q1
	CAIGE T2,40
	JRST [	MOVEI T2,"^"
		BOUT
		LDB T2,Q1
		TRO T2,100
		JRST .+1]
	BOUT
	MOVEI T2," "
	BOUT
	HRROI T2,[ASCIZ/
/]
	MOVEI T3,0
	SOUT
	AOBJN T4,PLINE1
	HRROI T2,[ASCIZ/


/]
	SETZ T3,
	SOUT
	RET

GETADR:	MOVE T1,[100,,101]
	HRROI T2,STRING
	MOVE T3,[RD%BRK!RD%TOP!RD%JFN+STRNGL]
	RDTXT
	 JRST ERROR
	HRROI T1,STRING
	MOVEI T3,10
	NIN
	 JRST ERROR
	POPJ P,

GETOCT:	MOVEI T4,^D8		;RAD8
	SKIPA
GETDEC:	MOVEI T4,^D10		;RAD10
	MOVE T1,[100,,101]
	HRROI T2,STRING
	MOVE T3,[RD%BRK!RD%TOP!RD%JFN+STRNGL]
	RDTXT
	 JRST ERROR
	HRROI T1,STRING
	MOVE T3,T4
	NIN
	 JRST ERROR
	POPJ P,

;GET YES OR NO ANSWER
;RETURN +1: T1/ 0 - NO, -1 - YES

YESNO:	HRROI T1,STRING
	MOVE T2,[RD%BEL!RD%RAI!RD%CRF+STRNGL*5-1]
	SETZ T3,
	RDTTY
	 JRST ERROR
	LDB T2,[POINT 7,STRING,6]
	CAIN T2,"Y"
	JRST [	SETO T1,
		RET]
	CAIN T2,"N"
	JRST [	SETZ T1,
		RET]
	TMSG <? YES OR NO: >
	JRST YESNO

ERROR:	MOVEI T1,101
	HRLOI T2,400000
	SETZ T3,
	ERSTR
	JFCL
	JFCL
	MOVE T1,FILJFN		;GET SM.DAT JFN
	TLO T1,400000		;DON'T RELEASE JFN
	CLOSF			;CLOSE
	 JFCL			;AND
	DELF			;DELETE
	 JFCL			;IT
	HALTF
	JRST TIMER
	SUBTTL Formatted Data

FILSIZ:	0			;NO. OF 12-BIT BYTES IN SM.DAT
MSGSIZ:	0			;NO. OF 12-BIT BYTES IN MESSAGE
JFN12:	0			;JFN FOR 12-BIT BYTE OPENING
JFN8:	0			;JFN FOR 8-BIT BYTE OPENING
RAWJFN:	0			;JFN OF "RAW" OUTPUT FILE
FMTJFN:	0			;JFN OF "FORMATTED" OUTPUT FILE
QUITF:	0
INTAC1:	0
PIPC1:	0
PIPC2:	0
PIPC3:	0
SELECT:	0			;0=ALL NODES, 1=USER BEING SELECTIVE
SELNAM:	BLOCK 2			;NAME OF NODE USER SELECTED
SELNUM:	0			;NUMBER OF NODE USER SELECTED


;NSP MESSAGE DATA

RTFLG:	0			;ROUTE FLAG
INOUT:	0			;-1=???, 0=INCOMING, 1=OUTGOING
DSTLEN:	0			;LENGTH OF DESTINATION NODE NAME
DSTNOD:	BLOCK 2			;DESTINATION NODE NAME
SRCLEN:	0			;LENGTH OF SOURCE NODE NAME
SRCNOD:	BLOCK 2			;SOURCE NODE NAME
MSGFLG:	0			;MESSAGE FLAGS
DSTADR:	0			;DESTINATION LINK ADDRESS
SRCADR:	0			;SOURCE LINK ADDRESS
ACKNAK:	0			;0=NO ACKNUM FIELD, -1=YES
ACKNUM:	0			;ACK NO.
SEGNUM:	0			;SEGMENT NO.
SERVIC:	0			;SERVICES
INFO:	0			;INFORMATION
SEGSIZ:	0			;SEGMENT SIZE
DFORM:	0			;DEST PROCESS NAME FORMAT
DOBJT:	0			;DEST OBJECT TYPE
DDESCL:	0			;DEST DESCRIPTOR LENGTH
DDESC:	BLOCK 4			;DEST DESCRIPTOR
DGCODE:	0			;DEST GROUP CODE
DUCODE:	0			;DEST USER CODE
SFORM:	0			;SOURCE PROCESS NAME FORMAT
SOBJT:	0			;SOURCE OBJECT TYPE
SDESCL:	0			;SOURCE DESCRIPTOR LENGTH
SDESC:	BLOCK 4			;SOURCE DESCRIPTOR
SGCODE:	0			;SOURCE GROUP CODE
SUCODE:	0			;SOURCE USER CODE
MENU:	0			;MENU
RQSIDL:	0			;REQUESTOR ID LENGTH
RQSID:	BLOCK 4			;REQUESTOR ID
PWORDL:	0			;PASSWORD LENGTH
PWORD:	BLOCK 2			;PASSWORD
ACCNTL:	0			;ACCOUNT LENGTH
ACCNT:	BLOCK 4			;ACCOUNT
UDATAL:	0			;USER DATA LENGTH
UDATA:	BLOCK 4			;USER DATA
LSFLAG:	0			;LINK SERVICE FLAGS
FCVAL:	0			;FLOW CONTROL VALUE
REASON:	0			;DISCONNECT REASON
STTYPE:	0			;START TYPE
NODADR:	0			;SOURCE NODE NUMBER
NAMLEN:	0			;LENGTH OF SOURCE NODE NAME (NODE INIT)
NODNAM:	BLOCK 2			;SOURCE NODE NAME (NODE INIT)
FUNCS:	0			;FUNCTIONS SUPPORTED AT THIS NODE
REQS:	0			;FUNCTIONS REQUESTED AT RECEIVER
BLKSIZ:	0			;BLOCK SIZE
NSPSIZ:	0			;NSP SEGMENT SIZE
MAXLNK:	0			;NO. OF LINKS
ROUTVR:	0			;NSP ROUTING VERSION
COMMVR:	0			;NSP COMMUNICATIONS VERSION
SYVLEN:	0			;LENGTH OF SYSTEM DESCRIPTION
SYSVR:	BLOCK 7			;OPERATING SYSTEM DESCRIPTION
PASSWD:	BLOCK 2			;PASSWORD
DATA:	BLOCK 100		;DATA MESSAGE
ENDFLD:	0

OUTFMT:	MOVE T1,FMTJFN
	MOVE T2,[7B5+OF%RD+OF%WR]
	OPENF			;OUTPUT FILE FOR 7-BIT BYTES
	 ERJMP [JSHLT]
	HRROI T2,PRGNAM
	SETZ T3,
	SOUT
	HRROI T2,[ASCIZ\
TRACE OF NSP MESSAGES - \]
	SETZ T3,
	SOUT
	SETO T2,
	SETZ T3,
	ODTIM
	 JFCL
	HRROI T2,[ASCIZ\

TOTAL SAMPLES TAKEN = \]
	SETZ T3,
	SOUT
	MOVE T2,TOTAL+BPRCOD
	IDIVI T2,INCR
	MOVEI T3,12
	NOUT
	 JFCL
	MOVSI T1,(GJ%OLD+GJ%SHT)
	HRROI T2,[ASCIZ\SM.DAT\]
	GTJFN			;FOR THE DATA FILE (12-BIT)
	 ERJMP [JSHLT]
	MOVEM T1,JFN12		;SAVE IT
	MOVE T2,[<14B5>+OF%RD]
	OPENF			;FOR 12-BIT BYTES
	 ERJMP [JSHLT]
	MOVSI T1,(GJ%OLD+GJ%SHT)
	HRROI T2,[ASCIZ\SM.DAT\]
	GTJFN			;FOR THE DATA FILE (8-BIT)
	 ERJMP [JSHLT]
	MOVEM T1,JFN8		;SAVE IT
	MOVE T2,[<10B5>+OF%RD]
	OPENF			;FOR 8-BIT BYTES
	 ERJMP [JSHLT]
	MOVE T2,[1,,.FBSIZ]	;GET NO. OF 36-BIT BYTES IN FILES
	MOVEI T3,T4		;PUT IT IN 4
	GTFDB
	 ERJMP [JSHLT]
	IMULI T4,3		;GET NO. OF 12-BIT BYTES
	MOVEM T4,FILSIZ		;SAVE IT
	MOVEI P1,13		;INIT THE 12-BIT POINTER
	MOVEI P2,40		;INIT THE 8-BIT POINTER (40 = NO. OF MAGIC BYTES
				;BEFORE ACTUAL NSP MESSAGE)
;Read an NSP Message

RDNSP:	SETZM RTFLG
	HRLI Q1,RTFLG
	HRRI Q1,RTFLG+1
	BLT Q1,ENDFLD
	MOVE T1,FMTJFN
	HRROI T2,[ASCIZ\

*\]
	SETZ T3,
	SOUT
	MOVE T1,FILSIZ		;GET THE 12-BIT FILE SIZE
	CAMG T1,P1		;EOF?
	JRST [MOVE T1,FMTJFN	;YES, RETRIEVE THE OUTPUT JFN
	      CLOSF		;CLOSE THE FILE
	       ERJMP [JSHLT]
	      MOVE T1,FILJFN	;GET SM.DAT JFN
	      TLO T1,400000	;DON'T RELEASE JFN
	      CLOSF		;CLOSE
	       JFCL		;AND
	      DELF		;DELETE
	       JFCL		;IT
	      HALTF]
	MOVE T1,JFN12		;RETRIEVE THE JFN
	MOVEI T3,-11(P1)
	RIN
	CAIN T2,1
	JRST [	HRROI T3,[ASCIZ /RECEIVED MSG
 /]
		SETZM INOUT	;SAY SO
		JRST RDNSP1]
	CAIN T2,2
	JRST [	HRROI T3,[ASCIZ /SENT MSG
 /]
		MOVEI T1,1	;SAY
		MOVEM T1,INOUT	;SO
		JRST RDNSP1]
	HRROI T3,[ASCIZ /???
 /]
	SETOM INOUT		;UNKNOWN MSG
RDNSP1:	MOVE T1,FMTJFN
	MOVE T2,T3
	SETZ T3,
	SOUT
	MOVE T1,JFN12
	MOVE T3,P1		;MOVE TO MESSAGE SIZE
	RIN			;GET IT
	SUBI T2,1		;ADJUST IT
	MOVEM T2,MSGSIZ		;SAVE IT
	MOVE T3,P1		;RETRIEVE 12-POINTER
	ADDI T3,300		;ADJUST FOR NEXT MESSAGE
	MOVEM T3,P1		;SAVE IT
	MOVE T1,JFN8		;SWITCH TO 8-BIT BYTES
	MOVE T3,P2		;RETRIEVE THE 8-BIT POINTER
	MOVE T2,MSGSIZ		;RETRIEVE THE MESSAGE SIZE
	IDIVI T2,4		;MODULO 4
	SKIPE T3		;DOES IT FALL ON A WORD BOUNDARY
	ADDI T2,1		;NO, FIX IT
	IMULI T2,4		;CONVERT BACK TO NO. OF BYTES
	MOVE T3,P2		;SAVE IT
	RIN			;GET THE FIRST BYTE IN THE NSP MESSAGE
	MOVE T4,T3		;RETRIEVE 8-BIT POINTER
	ADDI T4,400		;POINT TO NEXT MESSAGE
	MOVEM T4,P2		;SAVE IT
	CAIE T2,106		;IS FIRST BYTE THE ROUTE FLAG?
	JRST GETTYP		;NO, THEN NO ROUTE HEADER
	MOVEM T2,RTFLG		;SAVE THE ROUTE FLAG
	MOVEI T4,DSTLEN
	MOVEI Q3,[POINT 7,DSTNOD,6]
	CALL GTEASC		;GET THE DEST NODE NAME
	SKIPN SELECT		;USER BEING SELECTIVE?
	JRST RDNSP2		;NO, NO CHECKING NEEDED
	SKIPLE INOUT		;YES, MSG OUTGOING?
	JRST [	MOVE T2,[440700,,DSTNOD]	;BP TO MSG'S DESTINATION
		MOVE T4,[440700,,SELNUM]	;BP TO NODE NUMBER
		MOVE Q3,DSTLEN			;LENGTH OF MSG'S DESTINATION
		CALL COMPAR			;A MATCH?
		 JRST RDNSP			;NO, NEXT MSG
		JRST .+1]			;YES, ONWARD
RDNSP2:	MOVEI T4,SRCLEN
	MOVEI Q3,[POINT 7,SRCNOD,6]
	CALL GTEASC		;GET THE SOURCE NODE NAME
	SKIPN SELECT		;USER BEING SELECTIVE?
	JRST RDNSP3		;NO, NO CHECKING NEEDED
	SKIPN INOUT		;YES, MSG INCOMING?
	JRST [	MOVE T2,[440700,,SRCNOD]	;BP TO MSG'S SOURCE
		MOVE T4,[440700,,SELNUM]	;BP TO NODE NUMBER
		MOVE Q3,SRCLEN			;LENGTH OF MSG'S SOURCE
		CALL COMPAR			;A MATCH?
		 SKIPA				;NO, TRY NAME
		JRST RDNSP3			;YES, MOVE ON
		MOVE T2,[440700,,SRCNOD]	;BP TO MSG'S SOURCE
		MOVE T4,[440700,,SELNAM]	;BP TO NODE NAME
		MOVE Q3,SRCLEN			;LENGTH OF MSG'S SOURCE
		CALL COMPAR			;A MATCH?
		 JRST RDNSP			;NO, NEXT MSG
		JRST .+1]
RDNSP3:	ADDI T3,1		;MOVE TO NEXT BYTE IN MESSAGE
	RIN			;GET IT
GETTYP:	MOVEM T2,MSGFLG		;SAVE IT
	MOVEI Q1,MTYPES		;GET NO. OF LEGAL MESSAGE TYPES
GETTY1:	CAMN T2,MSGTYP(Q1)	;IS THIS ONE?
	JRST [MOVE Q2,RWDSPT(Q1)	;YES, GO READ IT IN
	      HLRZS Q2
	      JRST @Q2]	
	SOJGE Q1,GETTY1		;NO, ARE THERE MORE TYPES?
	MOVE T1,FMTJFN		;NO, ERROR
	HRROI T2,[ASCIZ\UNKNOWN NSP MESSAGE TYPE
\]
	SETZ T3,
	SOUT
	JRST RDNSP		;GET THE NEXT MESSAGE
;COMPARE TWO STRINGS
;ACCEPTS:	T2/ BYTE POINTER TO STRING 1
;		T4/ BYTE POINTER TO STRING 2
;		Q3/ COUNT OF CHARS. IN STRINGS
;RETURNS:	+1 NO MATCH
;		+2 MATCH
;PRESERVES T3,T4

COMPAR:	PUSH P,P1
	PUSH P,P2
	SOS Q3			;FIXUP COUNTER FOR THE LOOP
CMPRLP:	ILDB P1,T2		;GET NEXT BYTE
	ILDB P2,T4		;GET THIS ONE'S NEXT
	CAME P1,P2		;MATCH?
	JRST [	POP P,P2	;NO
		POP P,P1
		RET]
	SOJGE Q3,CMPRLP		;DO ALL THE BYTES
	POP P,P2		;A MATCH
	POP P,P1
	RETSKP
;Write an NSP Message

WRNSP:	MOVE T1,FMTJFN		;RETRIEVE THE OUTPUT FILE JFN
	MOVE T4,RTFLG		;RETRIEVE THE ROUTE FLAG
	JUMPE T4,WRTYPE		;IS THERE ONE?
	HRROI T2,[ASCIZ\ RTFLG-DSNODE-SRNODE-\]	;YES
	SETZ T3,
	SOUT
WRTYPE:	JUMPN T4,WRTYP2		;NO ROUTE HEADER
	MOVE T2,MSGFLG		;CHECK MESSAGE TYPE
	CAIN T2,130		;IS IT NODE INIT?
	JRST WRTYP2		;YES, DON'T SKIP SPACE FOR RTHDR
	HRROI T2,[ASCIZ\                     \]
	SETZ T3,
	SOUT
WRTYP2:	HRROI T2,[ASCIZ\MSTYPE-\]
	SETZ T3,
	SOUT
	MOVE T2,MSGFLG		;RETRIEVE THE MESSAGE TYPE
	MOVEI Q1,MTYPES		;RETRIEVE NO. OF LEGAL TYPES
WRTYP1:	CAMN T2,MSGTYP(Q1)	;IS THIS ONE?
	JRST [MOVE Q2,RWDSPT(Q1)	;YES, GO WRITE IT OUT
	      HRRZS Q2
	      JRST @Q2]
	SOJGE Q1,WRTYP1		;NO, TRY AGAIN
	MOVE T1,FILJFN		;GET SM.DAT JFN
	TLO T1,400000		;DON'T RELEASE JFN
	CLOSF			;CLOSE
	 JFCL			;AND
	DELF			;DELETE
	 JFCL			;IT
	HALTF			;ALL DONE
;NSP MESSAGE TYPES

MSGTYP:	0			;MOM
	4			;ACK OF DATA
	10			;NOP
	20			;LS
	24			;ACK OF INT OR LS
	30			;CI
	40			;BOM
	50			;CC
	60			;INT
	70			;DI
	100			;EOM
	110			;DC
	130			;NODE INTT OR NODE VERIFY
	140			;BOM,EOM
MTYPES=.-MSGTYP-1



;DISPATCH TABLE FOR READING AND WRITING NSP MESSAGES

RWDSPT:	RDATIN,,WDATIN		;MOM
	RACK,,WACK		;ACK OF DATA
	RNOP,,WNOP		;NOP
	RLS,,WLS		;LS
	RACK,,WACK		;ACK OF INT OR LS
	RCICC,,WCICC		;CI
	RDATIN,,WDATIN		;BOM
	RCICC,,WCICC		;CC
	RDATIN,,WDATIN		;INT
	RDIDC,,WDIDC		;DI
	RDATIN,,WDATIN		;EOM
	RDIDC,,WDIDC		;DC
	RNDINV,,WNDINV		;NODE INIT OR NODEVERIFY
	RDATIN,,WDATIN		;BOM,EOM

;READ A NORMAL DATA SEGMENT OR INTERRUPT MESSAGE

RDATIN:	MOVEI Q1,DSTADR
	CALL GETTWO		;GET DEST LINK ADDRESS
	MOVEI Q1,SRCADR
	CALL GETTWO		;GET SOURCE LINK ADDRESS
CHKACK:	ADDI T3,2
	RIN
	SUBI T3,2
	ANDI T2,200		;IS THIS THE ACKNUM FIELD?
	JUMPE T2,CHKAC1		;NO
	SETOM ACKNAK		;YES, SET THE ACKNUM FLAG	
	MOVEI Q1,ACKNUM
	CALL GETTWO		;GET ACKNUM
CHKAC1:	MOVEI Q1,SEGNUM
	CALL GETTWO		;GET SEGNUM
	CALL RDATA		;GET DATA
	JRST WRNSP		;GO WRITE IT OUT


;READ A LINK SERVICE MESSAGE

RLS:	MOVEI Q1,DSTADR
	CALL GETTWO		;GET DEST LINK ADDRESS
	MOVEI Q1,SRCADR
	CALL GETTWO		;GET SOURCE LINK ADDRESS
RLSAKC:	ADDI T3,2
	RIN
	SUBI T3,2
	ANDI T2,200		;IS THIS THE ACKNUM FIELD?
	JUMPE T2,RLSAK1		;NO
	SETOM ACKNAK		;YES, THE ACKNUM FLAG
	MOVEI Q1,ACKNUM
	CALL GETTWO		;GET ACKNUM
RLSAK1:	MOVEI Q1,SEGNUM
	CALL GETTWO		;GET SEGNUM
	MOVEI Q1,LSFLAG
	CALL GETBYT		;GET LINK SERVICE FLAGS
	MOVEI Q1,FCVAL
	CALL GETBYT		;GET FLOW CONTROL VALUES
	JRST WRNSP		;GO WRITE IT OUT


;READ A NOP MESSAGE - THE TEST DATA IS IGNORED


RNOP:	JRST WRNSP
;READ A CONNECT INITIATE OR CONNECT CONFIRM MESSAGE

RCICC:	MOVEI Q1,DSTADR
	CALL GETTWO		;GET DEST LINK ADRESS
	MOVEI Q1,SRCADR
	CALL GETTWO		;GET SOURCE LINK ADDRESS
	MOVEI Q1,SERVIC
	CALL GETBYT		;GET SERVICES
	MOVEI Q1,INFO
	CALL GETBYT		;GET INFO
	MOVEI Q1,SEGSIZ
	CALL GETTWO		;GET SEGMENT SIZE
	MOVE T4,MSGFLG		;RETRIEVE MESSAGE TYPE
	CAIN T4,50		;IS IT A CC
	JRST [CALL RDATA	;YES, GET DATA
	      JRST WRNSP]	;GO WRITE IT OUT
	MOVEI Q1,DFORM		;NO, MUST BE A CI
	CALL GETBYT		;GET DEST PROCESS NAME FORMAT
	MOVEI Q1,DOBJT
	CALL GETBYT		;GET OBJECT TYPE
	MOVE T2,DFORM
	SKIPN T2		;IS IT OBJECT TYPE ONLY?
	JRST RSRPRO		;YES
	CAIN T2,1		;NO, IS IT OBJECT TYPE AND DESCRIPTOR?
	JRST [MOVEI T4,DDESCL	;YES
	      MOVEI Q3,[POINT 7,DDESC,6]
	      CALL GTEASC	;GET THE DESCRIPTOR
	      JRST RSRPRO]	;MOVE TO SOURCE PROCESS NAME
	MOVEI Q1,DGCODE		;NO, MUST HAVE EVERYTHING THEN
	GETTWO			;GET GROUP CODE
	MOVEI Q1,DUCODE
	GETTWO			;GET USER CODE
	MOVEI T4,DDESCL
	MOVEI Q3,[POINT 7,DDESC,6]
	CALL GTEASC		;GET THE DESCRIPTOR
RSRPRO:	MOVEI Q1,SFORM
	CALL GETBYT		;GET SOURCE PROCESS NAME FORMAT
	MOVEI Q1,SOBJT
	CALL GETBYT		;GET OBJECT TYPE
	MOVE T2,SFORM
	SKIPN T2		;IS IT OBJECT TYPE ONLY?
	JRST RDMENU		;YES
	CAIN T2,1		;IS IT OBJECT TYPE AND DESCRIPTOR?
	JRST [MOVEI T4,SDESCL	;YES
	      MOVEI Q3,[POINT 7,SDESC,6]
	      CALL GTEASC	;GET THE DESCRIPTOR
	      JRST RDMENU]	;MOVE TO MENU
	MOVEI Q1,SGCODE		;NO, MUST HAVE EVERYTHING THEN
	CALL GETTWO		;GET GROUP CODE
	MOVEI Q1,SUCODE
	CALL GETTWO		;GET USER CODE
	MOVEI T4,SDESCL
	MOVEI Q3,[POINT 7,SDESC,6]
	CALL GTEASC		;GET THE DESCRIPTOR
RDMENU:	MOVEI Q1,MENU
	CALL GETBYT		;GET MENU
	TRNE T2,1		;ARE RQSTRID, PASSWRD, AND ACCOUNT INCLUDED?
	JRST [MOVEI T4,RQSIDL	;YES
	      MOVEI Q3,[POINT 7,RQSID,6]
	      CALL GTEASC	;GET REQUESTOR ID
	      MOVEI T4,PWORDL
	      MOVEI Q3,[POINT 7,PWORD,6]
	      CALL GTEASC	;GET PASSWORD
	      MOVEI T4,ACCNTL
	      MOVEI Q3,[POINT 7,ACCNT,6]
	      CALL GTEASC	;GET ACCOUNT
	      JRST .+1]
	TRNE T2,2		;IS USER DATA INCLUDED?
	JRST [MOVEI T4,UDATAL	;YES
	      MOVEI Q3,[POINT 7,UDATA,6]
	      CALL GTEASC	;GET USER DATA
	      JRST .+1]
	JRST WRNSP		;GO WRITE IT OUT



;READ AN ACK MESSAGE

RACK:	MOVEI Q1,DSTADR
	CALL GETTWO		;GET DEST LINK ADDRESS
	MOVEI Q1,SRCADR
	CALL GETTWO		;GET SOURCE LINK ADDRESS
	SETOM ACKNAK		;SET "THERE IS AN ACKNUM" FLAG
	MOVEI Q1,ACKNUM
	CALL GETTWO		;GET ACKNUM
	JRST WRNSP		;GO WRITE IT OUT



;READ A DISCONNECT INITIATE OR DISCONNECT CONFIRM MESSAGE

RDIDC:	MOVEI Q1,DSTADR
	CALL GETTWO		;GET DEST LINK ADDRESS
	MOVEI Q1,SRCADR
	CALL GETTWO		;GET SOURCE LINK ADDRESS
	MOVEI Q1,REASON
	CALL GETTWO		;GET REASON
	MOVE T4,MSGFLG		;RETRIEVE MESSAGE TYPE
	CAIN T4,70		;IS IT A DI?
	JRST WRNSP		;YES, GO WRITE IT OUT
	CALL RDATA		;NO, MUST BE DC, GET DATA
	JRST WRNSP		;GO WRITE IT OUT
;READ A NODE INITIALIZATION OR NODE VERIFICATION MESSAGE

RNDINV:	MOVEI Q1,STTYPE
	CALL GETBYT		;GET START TYPE
	MOVEI Q1,NODADR
	CALL GTEBIN		;GET NODE NUMBER
	MOVEI T4,NAMLEN
	MOVEI Q3,[POINT 7,NODNAM,6]
	CALL GTEASC		;GET NODE NAME
	MOVEI Q1,FUNCS
	CALL GETBYT		;GET FUNCTIONS PROVIDED
	MOVEI Q1,REQS
	CALL GETBYT		;GET FUNCTIONS REQUESTED
	MOVEI Q1,BLKSIZ
	CALL GETTWO		;GET BLOCK SIZE
	MOVEI Q1,NSPSIZ
	CALL GETTWO		;GET MESSAGE SIZE
	MOVEI Q1,MAXLNK
	CALL GETTWO		;GET MAXIMUM LINKS ALLOWED
	MOVEI Q1,ROUTVR
	CALL GET3		;GET ROUTING VERSION
	MOVEI Q1,COMMVR
	CALL GET3		;GET COMMUNICATIONS VERSION
	MOVEI T4,SYVLEN
	MOVEI Q3,[POINT 7,SYSVR,6]
	CALL GTEASC		;GET SYSTEM DESCRIPTION
	JRST WRNSP		;GO WRITE IT OUT
;SUBROUTINE TO READ THE DATA FIELD OF A MESSAGE
;	T1/JFN


RDATA:	MOVE Q1,MSGSIZ		;RETRIEVE THE MESSAGE SIZE
	MOVE Q2,[POINT 8,DATA]
RDATA1:	ADDI T3,1
	RIN			;THE NEXT BYTE IN THE MESSAGE
	IDPB T2,Q2		;SAVE IT
	SOJG Q1,RDATA1		;ANY MORE?
	RET			;NO, ALL DONE



;SUBROUTINE TO GET THE NEXT BYTE IN THE NSP MESSAGE
;
;	T1/JFN
;	Q1/PLACE TO PUT IT

GETBYT:	ADDI T3,1
	RIN
	MOVEM T2,(Q1)
	SOS MSGSIZ
	RET

;SUBROUTINE TO GET THE NEXT TWO BYTES IN THE NSP MESSAGE
;
;	T1/JFN
;	Q1/PLACE TO PUT THEM

GETTWO:	CALL GETBYT
	MOVE Q2,(Q1)
	CALL GETBYT
	MOVEM Q2,(Q1)
	LSH T2,10
	IORM T2,(Q1)
	RET

;SUBROUTINE TO GET THE NEXT THREE BYTES IN THE NSP MESSAGE
;
;	T1/JFN
;	Q1/PLACE TO PUT THEM

GET3:	CALL GETTWO
	MOVE Q2,(Q1)
	CALL GETBYT
	MOVEM Q2,(Q1)
	LSH T2,20
	IORM T2,(Q1)
	RET
;SUBROUTINE TO GET AN EXTENSIBLE ASCII FIELD FROM THE NSP MESSAGE
;
;	T1/JFN
;	T4/PLACE TO STORE SIZE
;	Q3/PLACE TO STORE STRING

GTEASC:	ADDI T3,1
	RIN
	SKIPN T2		;IS IT NULL?
	RET			;YES
	MOVEM T2,(T4)		;NO, GET IT
	MOVEM T2,Q1
	MOVE Q2,(Q3)
GTEAS1:	ADDI T3,1
	RIN
	DPB T2,Q2
	SOSE Q1
	JRST [MOVEI T2,1
	      ADJBP T2,Q2
	      MOVEM T2,Q2
	      JRST GTEAS1]
	MOVEI T2,1
	ADJBP T2,Q2
	SETZ T4,
	DPB T4,T2
	RET


;SUBROUTINE TO GET AN EXTENSIBLE BINARY FIELD FROM THE NSP MESSAGE
;
;	T1/JFN
;	T3/CURRENT BYTE POSITION IN MESSAGE
;	Q1/LOCATION TO PUT VALUE
;
; THIS ROUTINE ONLY WORKS FOR AN EXTENSIBLE FIELD UP TO 5 BYTES.
; SINCE NSP 3.1 DOESN'T DEFINE ANY EXTENSIBLE FIELD AS HAVING A
; MAXIMUM THAT LARGE, THIS CODE SHOULD SATISFY EXISTING NEEDS.

GTEBIN:	SETZM @Q1		;ZERO THE DESTINATION VALUE
	SETZ Q2,		;ZERO THE INTERMEDIATE CALCULATION
GTEB1:	ADDI T3,1		;POINT TO NEXT BYTE
	RIN			;FETCH IT
	LSH Q2,7		;ADJUST THE DESTINATION WORD
	DPB T2,[POINT 7,Q2,35]	;DROP IN THE NEXT BYTE
	TRNE T2,200		;EXTENSIBLE BIT ON?
	JRST GTEB1		;YES, GET NEXT BYTE
	MOVEM Q2,@Q1		;NO, DEPOSIT THE FINAL VALUE
	RET			;ALL DONE
;WRITE AN ACK MESSAGE

WACK:	HRROI T2,[ASCIZ\DSLINK-SRLINK-ACKNUM     *****

\]
	SETZ T3,
	SOUT
	CALL WRTHDR		;WRITE THE ROUTE HEADER
	CALL WMSGTY		;WRITE THE MESSAGE TYPE
	CALL WADDRS		;WRITE THE LINK ADDRESSES
	CALL WACKNO		;WRITE ACKNUM FIELD
	JRST RDNSP		;GO READ NEXT MESSAGE


;WRITE A LINK SERVICE MESSAGE

WLS:	HRROI T2,[ASCIZ\DSLINK-SRLINK-ACKNUM-SEGNUM-LSFLGS-FCVAL     *****

\]
	SETZ T3,
	SOUT
	CALL WRTHDR		;WRITE THE ROUTE HEADER
	CALL WMSGTY		;WRITE THE MESSAGE TYPE
	CALL WADDRS		;WRITE THE LINK ADDRESSES
	CALL WACKNO		;WRITE ACKNUM FIELD
	CALL WSEGNO		;WRITE THE SEGMENT NO.
	MOVE T4,LSFLAG		;RETRIEVE THE LINK SERVICE FLAGS
	ANDI T4,14		;GET THE FLOW CONTROL INTERPRETATION PORTION
	SKIPE T4
	JRST [MOVEI T2,"I"
	      BOUT		;INTERRUPT REQUEST COUNT
	      JRST WLS1]
	MOVEI T2,"D"
	BOUT			;DATA SEGMENT OR MESSAGE REQUEST COUNT
WLS1:	MOVEI T2," "
	BOUT
	MOVE T4,LSFLAG
	ANDI T4,3		;GET THE FLOW CONTROL VALUE PORTION
	SKIPN T4
	JRST [HRROI T2,[ASCIZ\STAY \]
	      SETZ T3,
	      SOUT		;NO CHANGE IN FLOW CONTROL
	      JRST WLS2]
	SOSN T4
	JRST [HRROI T2,[ASCIZ\STOP \]
	      SETZ T3,
	      SOUT		;STOP SENDING
	      JRST WLS2]
	HRROI T2,[ASCIZ\STRT \]
	SETZ T3,
	SOUT			;START SENDING AGAIN
WLS2:	MOVE T2,FCVAL		;RETRIEVE THE FLOW CONTROL VALUE
	HRLI T3,100005
	HRRI T3,10
	NOUT			;IN OCTAL
	 ERJMP [JSHLT]
	JRST RDNSP		;GO READ THE NEXT MESSAGE


;WRITE A NOP MESSAGE

WNOP:	CALL WRTHDR		;WRITE THE ROUTE HEADER
	CALL WMSGTY		;WRITE MESSAGE TYPE
	JRST RDNSP		;GO READ THE NEXT MESSAGE
	
;WRITE A CONNECT INITIATE OR CONNECT CONFIRM MESSAGE

WCICC:	HRROI T2,[ASCIZ\DSLINK-SRLINK-SRVCES-INFO-SEGSIZ     *****

\]
	SETZ T3,
	SOUT
	CALL WRTHDR		;WRITE THE ROUTE HEADER
	CALL WMSGTY		;WRITE THE MESSAGE TYPE
	CALL WADDRS		;WRITE THE LINK ADDRESSES
	MOVE T4,SERVIC		;RETRIEVE THE SERVICES FIELD
	TRNN T4,1		;BIT 0 MUST BE ON
	JRST BADSRV		;IF NOT, SAY SO
	LSH T4,-2		;MOVE TO FLOW CONTROL OPITON BITS
	ANDI T4,3		;GET THEM
	SKIPN T4		;ANY SERVICES REQUESTED?
	JRST [HRROI T2,[ASCIZ\ NONE  \]	;NO
	      SETZ T3,
	      SOUT
	      JRST WCICC1]
	CAIN T4,1		;SEGMENT REQUEST COUNT?
	JRST [HRROI T2,[ASCIZ\SEG RC \]	;YES
	      SETZ T3,
	      SOUT
	      JRST WCICC1]
	CAIN T4,2		;MESSAGE REQUEST COUNT?
	JRST [HRROI T2,[ASCIZ\MSG RC \]	;YES
	      SETZ T3,
	      SOUT
              JRST WCICC1]

BADSRV:	JRST [HRROI T2,[ASCIZ\  ??? \]
              SETZ T3,
              SOUT
              JRST WCICC1]

WCICC1:	MOVE T2,INFO		;RETRIEVE THE INFO FIELD
	HRLI T3,100004
	HRRI T3,10
	NOUT			;IN OCTAL
	 ERJMP [JSHLT]
	MOVEI T2," "
	BOUT
	MOVE T2,SEGSIZ		;RETRIEVE THE SEGMENT SIZE
	HRLI T3,100006
	HRRI T3,10
	NOUT			;IN OCTAL
	 ERJMP [JSHLT]
	MOVE T4,MSGFLG		;RETRIEVE THE MESSAGE TYPE
	CAIN T4,50		;IS IT A CC?
	JRST [CALL WDATA	;YES, WRITE THE DATA
	      JRST RDNSP]	;GO READ THE NEXT MESSAGE
	HRROI T2,[ASCIZ\

----- Destination Process -----

Object Type = \]		;NO, IT'S A CI
	SETZ T3,
	SOUT
	MOVE T2,DOBJT		;GET OBJECT TYPE
	MOVE T3,DFORM		;GET FORMAT TYPE
	CALL WOBJT		;WRITE IT OUT
	MOVE T2,DFORM		;GET THE FORMAT
	SKIPN T2		;IS IT OBJECT TYPE ONLY?
	JRST WSRPRO		;YES
	CAIN T2,1		;NO, IS IT OBJECT AND DESCRIPTOR?
	JRST WDDESC		;YES
	HRROI T2,[ASCIZ\
Group Code = \]
	SETZ T3,
	SOUT
	MOVE T2,DGCODE		;GET GROUP CODE
	HRLI T3,100007
	HRRI T3,10
	NOUT			;IN OCTAL
	 ERJMP [JSHLT]
	HRROI T2,[ASCIZ\
User Code = \]
	SETZ T3,
	SOUT
	MOVE T2,DUCODE		;GET USER CODE
	HRLI T3,100007
	HRRI T3,10
	NOUT			;IN OCTAL
	 ERJMP [JSHLT]
WDDESC:	HRROI T2,[ASCIZ\
Descriptor = \]
	SETZ T3,
	SOUT
	MOVE T2,[POINT 7,DDESC]
	SETZ T3,
	SOUT			;THE DESCRIPTOR
WSRPRO:	HRROI T2,[ASCIZ\

----- Source Process -----

Object Type = \]
	SETZ T3,
	SOUT
	MOVE T2,SOBJT		;GET OBJECT TYPE
	MOVE T3,SFORM		;GET FORMAT TYPE
	CALL WOBJT		;WRITE IT OUT
	MOVE T2,SFORM		;GET THE FORMAT
	SKIPN T2		;IS IT OBJECT TYPE ONLY?
	JRST CHKMEN		;YES
	CAIN T2,1		;NO, IS IT OBJECT AND DESCRIPTOR?
	JRST WSDESC		;YES
	HRROI T2,[ASCIZ\
Group Code = \]
	SETZ T3,
	SOUT
	MOVE T2,SGCODE		;GET GROUP CODE
	HRLI T3,100007
	HRRI T3,10
	NOUT			;IN OCTAL
	 ERJMP [JSHLT]
	HRROI T2,[ASCIZ\
User Code = \]
	SETZ T3,
	SOUT
	MOVE T2,SUCODE		;GET USER CODE
	HRLI T3,100007
	HRRI T3,10
	NOUT			;IN OCTAL
	 ERJMP [JSHLT]
WSDESC:	HRROI T2,[ASCIZ\
Descriptor = \]
	SETZ T3,
	SOUT
	MOVE T2,[POINT 7,SDESC]
	SETZ T3,
	SOUT			;THE DESCRIPTOR
CHKMEN:	MOVE T2,MENU		;GET MENU
	TRNE T2,1		;ARE RQSTRID, PASSWRD, AND ACCOUNT INCLUDED?
	JRST [HRROI T2,[ASCIZ\
Requestor ID = \]		;YES
	      SETZ T3,
	      SOUT
	      MOVE T2,[POINT 7,RQSID]
	      SETZ T3,
	      SOUT
	      HRROI T2,[ASCIZ\
Password = \]
	      SETZ T3,
	      SOUT
	      MOVE T2,[POINT 7,PWORD]
	      SETZ T3,
	      SOUT
	      HRROI T2,[ASCIZ\
Account = \]
	      SETZ T3,
	      SOUT
	      MOVE T2,[POINT 7,ACCNT]
	      SETZ T3,
	      SOUT
	      JRST .+1]
	TRNE 2,2		;IS USER DATA INCLUDED?
	JRST [HRROI T2,[ASCIZ\
User Data = \]			;YES
	      SETZ T3,
	      SOUT
	      MOVE T2,[POINT 7,UDATA]
	      SETZ T3,
	      SOUT
	      JRST .+1]
	JRST RDNSP
;NSP OBJECT TYPES

OBJTYP:	0			;GENERAL TASK, USER PROCESS
	1			;FAL (DAP V1)
	2			;URD
	3			;ATS
	4			;CTS
	5			;RSX-11M TASK CONTROL (V1)
	6			;OSI
	7			;NRM
	^D8			;IBM 3270-BSC GATEWAY
	^D9			;IBM 2780-BSC GATEWAY
	^D10			;IBM 3790-SDLC GATEWAY
	^D11			;TPS APPLICATION
	^D12			;RT-11 DIBOL APPLICATION
	^D13			;TOPS-20 TERMINAL HANDLER
	^D14			;TOPS-20 REMOTE SPOOLER
	^D15			;RSX-11M TASK CONTROL (V2)
	^D16			;TLK UTILITY
	^D17			;FAL (DAP V4)
	^D18			;RSX-11S REMOTE TASK LOADER
	^D19			;NICE
	^D20			;RSTS/E MEDIA TRANSFER PROGRAM (NETCPY)
	^D21			;RSTS/E HOMOGENEOUS NVT
	^D22			;MAIL LISTENER
	^D23			;NVT
	^D24			;TERMINAL CONCENTRATOR
	^D25			;LOOPBACK MIRROR
	^D26			;EVENT RECEIVER
	^D27			;VMS PERSONAL MESSAGE FACILITY
	^D28			;FTS
	^D63			;DECNET RSX TEST TOOL
	^D65			;MCB Topology Task
	^D123			;Poor man's routing (PSTHRU)
OTYPES=.-OBJTYP-1
;SUBROUTINE TO WRITE OBJECT TYPE
;
;	T1/JFN
;	T2/OBJECT TYPE NO.
;	T3/FORMAT TYPE

WOBJT:	JUMPN T3,WOBJT3		;IS IT OBJECT TYPE  ONLY?
	PUSH P,T2		;YES, SAVE OBJECT NUMBER
	MOVEI T3,^D10		;OUTPUT THE
	NOUT			; OBJECT NUMBER
	 ERJMP [JSHLT]
	HRROI T2,[ASCIZ\ - \]
	SETZ T3,
	SOUT
	POP P,T2		;RETRIEVE THE OBJECT NUMBER
	MOVEI Q1,OTYPES		;GET NUMBER OF TYPES
WOBJT1:	CAMN T2,OBJTYP(Q1)
	JRST WOBJT2
	SOJGE Q1,WOBJT1
	CAIG T2,77
	JRST [HRROI T2,[ASCIZ\Reserved for DECnet use\]
	      SETZ T3,
	      SOUT
	      RET]
	CAIG T2,177
	JRST [HRROI T2,[ASCIZ\Reserved for DECnet control\]
	      SETZ T3,
	      SOUT
	      RET]
	CAIG T2,377
	JRST [HRROI T2,[ASCIZ\Reserved for customer extensions\]
	      SETZ T3,
	      SOUT
	      RET]
	HRROI T2,[ASCIZ\????? Illegal Object Type ?????\]
	SETZ T3,
	SOUT
	RET
WOBJT2:	HRRO T2,[EXP[ASCIZ\General Task or User Process\]
	         EXP[ASCIZ\FAL (DAP V1)\]
	         EXP[ASCIZ\Unit Record Services\]
	         EXP[ASCIZ\Application Terminal Services\]
	         EXP[ASCIZ\Command Terminal Services\]
	         EXP[ASCIZ\RSX-11M Task Control (V1)\]
	         EXP[ASCIZ\Operator Services Interface\]
	         EXP[ASCIZ\Node Resource Manager\]
	         EXP[ASCIZ\IBM 3270-BSC Gateway\]
	         EXP[ASCIZ\IBM 2780-BSC Gateway\]
	         EXP[ASCIZ\IBM 3790-SDLC Gateway\]
	         EXP[ASCIZ\TPS Applicaion\]
	         EXP[ASCIZ\RT-11 DIBOL Application\]
	         EXP[ASCIZ\TOPS-20 Terminal Handler\]
	         EXP[ASCIZ\TOPS-20 Remote Spooler\]
	         EXP[ASCIZ\RSX-11M Task Control (V2)\]
	         EXP[ASCIZ\TLK Utility\]
	         EXP[ASCIZ\FAL (DAP V4)\]
	         EXP[ASCIZ\RSX-11S Remote Task Loader\]
	         EXP[ASCIZ\NICE Process\]
		EXP[ASCIZ\RSTS/E Media Transfer Program (NETCPY)\]
		EXP[ASCIZ\RSTS/E Homogeneous NVT\]
		EXP[ASCIZ\Mail Listener\]
		EXP[ASCIZ\NVT\]
		EXP[ASCIZ\Terminal Concentrator\]
		EXP[ASCIZ\Loopback Mirror\]
		EXP[ASCIZ\Event Receiver\]
		EXP[ASCIZ\VMS Personal Message Facility\]
		EXP[ASCIZ\FTS\]
		EXP[ASCIZ\DECnet RSX Test Tool\]
		EXP[ASCIZ\MCB Toplogy Task\]](Q1)
	SETZ T3,
	SOUT
	RET
WOBJT3:	SKIPE T2		;OBJECT TYPE SHOULD BE ZERO, IS IT?
	JRST [HRROI T2,[ASCIZ\??? Invalid Object Type ???\]	;NO
	      SETZ T3,
	      SOUT		;SAY SO
	      RET]
	HRLI T3,100002		;YES
	HRRI T3,10
	NOUT
	 ERJMP [JSHLT]
	RET


;WRITE A NORMAL DATA SEGMENT OR INTERRUPT MESSAGE

WDATIN:	HRROI T2,[ASCIZ\DSLINK-SRLINK-ACKNUM-SEGNUM     *****

\]
	SETZ T3,
	SOUT
	CALL WRTHDR		;WRITE THE ROUTE HEADER
	CALL WMSGTY		;WRITE THE MESSAGE TYPE
	CALL WADDRS		;WRITE THE LINK ADDRESSES
	MOVE T4,ACKNAK		;GET ACKNUM FIELD FLAG
	SKIPN T4,ACKNAK		;IS THERE AN ACKNUM FIELD?
	JRST [HRROI T2,[ASCIZ\       \]	;NO
	      SETZ T3,
	      SOUT
	      JRST WDATI1]
	CALL WACKNO		;YES, WRITE ACKNUM
WDATI1:	CALL WSEGNO		;WRITE SEGNUM
	CALL WDATA		;WRITE DATA
	JRST RDNSP		;GO READ NEXT MESSAGE
;WRITE A DISCONNECT INITIATE OR DISCONNECT CONFIRM MESSAGE

WDIDC:	HRROI T2,[ASCIZ\DSLINK-SRLINK     *****

\]
	SETZ T3,
	SOUT
	CALL WRTHDR		;WRITE THE ROUTE HEADER
	CALL WMSGTY		;WRITE THE MESSAGE TYPE
	CALL WADDRS		;WRITE THE LINK ADDRESSES
	HRROI T2,[ASCIZ\

Reason = \]
	SETZ T3,
	SOUT
	MOVE T2,REASON		;GET THE REASON CODE
	MOVEI Q1,NRESNS		;GET NO. OF VAILD REASONS
WDIDC1:	CAMN T2,DISREA(Q1)	;IS THIS ONE?
	JRST WDIDC2		;YES, GO WRITE IT OUT
	SOJGE Q1,WDIDC1		;NO, TRY AGAIN?
	MOVEI T3,12		;NOT A DEFINED REASON CODE
	NOUT			;OUTPUT IT IN DECIMAL
	 ERJMP [JSHLT]
	JRST WDIDC3
WDIDC2:	HRROI T2,@REATXT(Q1)	;GET THE RIGHT REASON
	SETZ T3,
	SOUT			;WRITE IT OUT
WDIDC3:	MOVE T4,MSGTYP		;RETRIEVE MESSAGE TYPE
	CAIE T4,110		;IS IT A DC?
	CALL WDATA		;NO, MUST BE DI, WRITE THE DATA
	JRST RDNSP		;GO READ NEXT MESSAGE
	
;DISCONNECT REASON CODES

DISREA:	0			;NO ERROR
	1			;RESOURCE ALLOCATION FAILURE
	2			;DESTINATION NODE DOES NOT EXIST
	3			;NODE SHUTTING DOWN
	4			;DESTINATION PROCESS DOES NOT EXIST
	5			;INVALID PROCESS NAME FIELD
	6			;DESTINATION PROCESS QUEUE OVERFLOW
	7			;UNSPECIFIED ERROR CONDITION
	^D8			;THIRD PARTY ABORTED THE LINK
	^D9			;LINK ABORT BY DIALOGUE PROCESS
	^D24			;FLOW CONTROL VIOLATION
	^D32			;TOO MANY CONNECTIONS TO NODE
	^D33			;TOO MANY CONNECTIONS TO DESTINATION PROCESS
	^D34			;ACCESS NOT PERMITTED
	^D35			;LOGICAL LINK SERVICES MISMATCH
	^D36			;UNACCEPTABLE ACCOUNT INFORMATION
	^D37			;SEGSIZE TOO SMALL
	^D38			;DIALOGUE PROCESS ABORTED
	^D39			;NO PATH TO DESTINATION NODE
	^D40			;FLOW CONTROL FAILURE
	^D41			;DSTADDR LOGICAL LINK DOES NOT EXIST
	^D42			;CONFIRMATION OF DI
	^D43			;IMAGE DATA FIELD TOO LONG
NRESNS=.-DISREA-1

;REASON DESCRIPTIONS

REATXT:	[ASCIZ\No error\]
	[ASCIZ\Resource allocation failure\]
	[ASCIZ\Destination node does not exist\]
	[ASCIZ\Node shutting down\]
	[ASCIZ\Destination process does not exist\]
	[ASCIZ\Invalid process name field\]
	[ASCIZ\Destination process queue overflow\]
	[ASCIZ\Unspecified error condition\]
	[ASCIZ\Third party aborted the link\]
	[ASCIZ\Link aborted by dialogue process\]
	[ASCIZ\Flow control violation - illegal FCVAL\]
	[ASCIZ\Too many connections to node\]
	[ASCIZ\Too many connections to destination process\]
	[ASCIZ\Access not permitted - unacceptable RQSTRID or PASSWORD\]
	[ASCIZ\Logical link SERVICES mismatch\]
	[ASCIZ\Unacceptable ACCOUNT information\]
	[ASCIZ\SEGSIZE too small\]
	[ASCIZ\Dialogue process aborted, timed out, or cancelled request\]
	[ASCIZ\No path to destination node\]
	[ASCIZ\Flow control failure\]
	[ASCIZ\DSTADDR logical link does not exist\]
	[ASCIZ\Confirmation of DI\]
	[ASCIZ\Image data field too long\]
;WRITE A NODE INITIALIZATION OR NODE VERIFICATION MESSAGE

WNDINV:	MOVE T2,STTYPE		;GET START TYPE
	CAIN T2,2		;IS IT A NODE VERIFY?
	JRST VERIFY		;YES
	CAIE T2,1		;NO, IS IT NODE INIT?
	JRST [HRROI T2,[ASCIZ\

????? Illegal Start Type in Node Initialization Message ?????\]
	      JRST RDNSP]	;GO READ NEXT MESSAGE
INIT:	HRROI T2,[ASCIZ\STYPE-NODNUM-NODNAM--FUNCS---REQUESTS---BLKSIZ-NSPSIZE-MLINKS     *****

\]
	SETZ T3,
	SOUT
	CALL WMSGTY		;WRITE THE MESSAGE TYPE
	HRROI T2,[ASCIZ\ INIT\]
	SETZ T3,
	SOUT			;NODE INIT
	MOVE T2,NODADR		;RETRIEVE NODE NUMBER
	HRLI T3,100006
	HRRI T3,10
	NOUT			;OUTPUT NODE NUMBER
	 ERJMP [JSHLT]
	MOVEI T2," "
	MOVEI T4,11
	SUB T4,NAMLEN
INIT1:	BOUT
	SOJG T4,INIT1
	MOVE T2,[POINT 7,NODNAM]
	SETZ T3,
	SOUT			;OUTPUT NODE NAME
	MOVE T2,FUNCS		;RETRIEVE FUNCTIONS SUPPORTED
	SKIPN T2		;INTERCEPT?
	JRST [HRROI T2,[ASCIZ\ NO INT \]	;NO
	      SETZ T3,
	      SOUT		;OUTPUT "NO INTERCEPT"
	      JRST INIT2]
	HRROI T2,[ASCIZ\  INT  \]	;YES
	SETZ T3,
	SOUT			;OUTPUT "INTERCEPT"
INIT2:	MOVE T2,REQS		;GET THE REQUESTED FUNCTIONS
	ANDI T2,6
	LSH T2,-1
	SKIPN T2
	JRST [HRROI T2,[ASCIZ\NO INT,\]
	      SETZ T3,
	      SOUT		;NO INTERCEPT
	      JRST INIT3]
	CAIN T2,3
	JRST [HRROI T2,[ASCIZ\ INT  ,\]
	      SETZ T3,
	      SOUT		;INTERCEPT
	      JRST INIT3]
	HRROI T2,[ASCIZ\RESRVD,\]
	SETZ T3,
	SOUT			;RESERVED
INIT3:	MOVE T2,REQS		;GET REQUESTED FUNCTIONS
	ANDI T2,REQS
	SKIPN T2
	JRST [HRROI T2,[ASCIZ\NO VER \]
	      SETZ T3,
	      SOUT		;NO VERIFICATION
	      JRST INIT4]
	HRROI T2,[ASCIZ\ VER   \]
	SETZ T3,
	SOUT			;VERIFICATOIN
INIT4:	MOVE T2,BLKSIZ		;GET THE BLOCK SIZE
	HRLI T3,100006
	HRRI T3,10
	NOUT
	 ERJMP [JSHLT]
	MOVE T2,NSPSIZ		;GET NSP MESSAGE SIZE
	HRLI T3,100007
	HRRI T3,10
	NOUT
	 ERJMP [JSHLT]
	MOVE T2,MAXLNK		;GET MAXIMUM NO. OF LINKS SUPPORTED
	HRLI T3,100007
	HRRI T3,10
	NOUT
	 ERJMP [JSHLT]
	HRROI T2,[ASCIZ\

Routing Version:  Version No. = \]
	SETZ T3,
	SOUT
	MOVE T2,ROUTVR		;GET THE ROUTING VERSION
	ANDI T2,377		;GET THE FIRST BYTE
	HRLI T3,100004
	HRRI T3,12
	NOUT
	 ERJMP [JSHLT]
	HRROI T2,[ASCIZ\
                  ECO No. = \]
	SETZ T3,
	SOUT
	MOVE T2,ROUTVR
	ANDI T2,177400		;GET THE SECOND BYTE
	LSH T2,-10
	HRLI T3,100004
	HRRI T3,12
	NOUT
	 ERJMP [JSHLT]
	HRROI T2,[ASCIZ\
                  Customer Level No. = \]
	SETZ T3,
	SOUT
	MOVE T2,ROUTVR
	AND T2,[77600000]	;GET THE THIRD BYTE
	LSH T2,-20
	HRLI T3,100004
	HRRI T3,12
	NOUT
	 ERJMP [JSHLT]
	HRROI T2,[ASCIZ\

Communicaions Version:  Version No. = \]
	SETZ T3,
	SOUT
	MOVE T2,COMMVR		;GET THE COMMUNICATIONS VERSION
	ANDI T2,377		;GET THE FIRST BYTE
	HRLI T3,100004
	HRRI T3,12
	NOUT
	 ERJMP [JSHLT]
	HRROI T2,[ASCIZ\
                        ECO No. = \]
	SETZ T3,
	SOUT
	MOVE T2,COMMVR
	ANDI T2,144700		;GET THE SECOND BYTE
	LSH T2,-10
	HRLI T3,100004
	HRRI T3,12
	NOUT
	 ERJMP [JSHLT]
	HRROI T2,[ASCIZ\
                        Customer Level No. = \]
	SETZ T3,
	SOUT
	MOVE T2,COMMVR
	AND T2,[77600000]	;GET THE THIRD BYTE
	LSH T2,-20
	HRLI T3,100004
	HRRI T3,12
	NOUT
	 ERJMP [JSHLT]
	HRROI T2,[ASCIZ\

System Description = \]
	SETZ T3,
	SOUT
	MOVE T2,[POINT 7,SYSVR]
	SETZ T3,
	SOUT
	JRST RDNSP		;GO READ THE NEXT MESSAGE
VERIFY:	HRROI T2,[ASCIZ\STYPE PASSWORD

\]
	SETZ T3,
	SOUT
	CALL MSGTYP		;OUTPUT MESSAGE TYPE
	HRROI T2,[ASCIZ\ VER  \]
	SETZ T3,
	SOUT			;OUTPUT "VERIFY"
	MOVE T2,[POINT 7,PASSWD]
	SETZ T3,
	SOUT			;OUTPUT PASSWORD
	JRST RDNSP		;GO READ NEXT MESSAGE
;SUBROUTINE TO WRITE THE ROUTE HEADER

WRTHDR:	MOVE T2,RTFLG
	SKIPN T2		;IS THERE A ROUTE HEADER?
	JRST [HRROI T2,[ASCIZ\                      \]	;NO
	      SETZ T3,
	      SOUT
	      RET]
	HRLI T3,100007		;YES
	HRRI T3,10
	NOUT
	 ERJMP [JSHLT]
	MOVEI T2," "
	BOUT
	MOVEI T4,6
	SUB T4,DSTLEN
	SKIPA
WRTHD1:	BOUT
	SOJGE T4,WRTHD1
	MOVE T2,[POINT 7,DSTNOD]
	SETZ T3,
	SOUT			;DESTINATION NODE NAME
	MOVEI T2," "
	BOUT
	MOVEI T4,6
	SUB T4,SRCLEN
	SKIPA
WRTHD2:	BOUT
	SOJGE T4,WRTHD2
	MOVE T2,[POINT 7,SRCNOD]
	SETZ T3,
	SOUT			;SOURCE NODE NAME
	MOVEI T2," "
	BOUT
	RET
	 ERJMP [JSHLT]
	MOVEI T2," "
	BOUT
	RET
;SUBROUTINE TO WRITE THE ACKNUM FIELD

WACKNO:	MOVE Q1,ACKNAK		;GET ACKNUM FIELD FLAG
	JUMPE Q1,WACKN3		;IS THERE AN ACKNUM FIELD?
	MOVE Q1,ACKNUM		;YES
	ANDI Q1,7777		;GET THE SEGMENT NUMBER
	MOVE Q2,ACKNUM		;SAVE IT
	ANDI Q2,70000
	JUMPN Q2,WACKN1		;IS IT AN ACK?
	MOVEI T2,"A"		;YES
	BOUT			;SAY SO
	JRST WACKN2
WACKN1:	MOVEI T2,"N"		;IT IS A NAK
	BOUT			;SAY SO
WACKN2:	MOVEI T2," "
	BOUT
	MOVE T2,Q1		;RETRIEVE THE SEGMENT NUMBER
	HRLI T3,100004
	HRRI T3,10
	NOUT			;IN OCTAL
	 ERJMP [JSHLT]
	MOVEI T2," "
	BOUT
	RET
WACKN3:	HRROI T2,[ASCIZ\       \]
	SETZ T3,
	SOUT			;NO ACKNUM FIELD
	RET




;SUBROUTINE TO WRITE THE DEST NODE AND SOURCE LINK ADDRESS FIELDS

WADDRS:	MOVE T2,DSTADR		;RETRIEVE DEST LINK ADDRESS
	HRLI T3,100006
	HRRI T3,10
	NOUT			;IN OCTAL
	 ERJMP [JSHLT]
	MOVEI T2," "
	BOUT
	MOVE T2,SRCADR		;RETRIEVE THE SOURCE LINK ADDRESS
	HRLI T3,100006
	HRRI T3,10
	NOUT			;IN OCTAL
	 ERJMP [JSHLT]
	MOVEI T2," "
	BOUT
	RET
;SUBROUTINE TO WRITE THE DATA MESSAGE

WDATA:	MOVE Q1,MSGSIZ		;RETRIEVE MESSAGE SIZE
	HRROI T2,[ASCIZ\

 DATA (ASCII) =
\]
	SETZ T3,
	SOUT
	MOVE T4,[POINT 8,DATA]	;POINT TO DATA PORTION OF MESSAGE
WDATA1:	ILDB T2,T4		;GET NEXT BYTE
	BOUT
	SOJG Q1,WDATA1		;ANY MORE?
	MOVE Q1,MSGSIZ		;NO, RETRIEVE MESSAGE SIZE AGAIN
	HRROI T2,[ASCIZ\

 DATA (BINARY) =
\]
	SETZ T3,
	SOUT
	MOVE T4,[POINT 8,DATA]	;POINT TO DATA PORTION OF MESSAGE
	HRLI T3,100004		;USE 4 COLUMNS
	HRRI T3,10		;OUTPUT IN OCTAL
WDATA2:	ILDB T2,T4		;GET NEXT BYTE
	NOUT
	 ERJMP [JSHLT]
	SOJG Q1,WDATA2		;ANY MORE?
	RET			;NO, ALL DONE
;SUBROUTINE TO WRITE THE MESSAGE FLAGS FIELD

WMSGTY:	MOVE T2,MSGFLG		;RETRIEVE THE MESSAGE TYPE
	MOVEI Q1,MTYPES		;RETRIEVE THE NO. OF LEGAL MESSAGE TYPES
WMSGT1:	CAMN T2,MSGTYP(Q1)	;IS THIS ONE?
	JRST WMSGT2		;YES
	SOJGE Q1,WMSGT1		;NO, TRY AGAIN?
	HALTF			;NO, WILL NEVER HAPPEN!
WMSGT2:	HRRO T2,[EXP[ASCIZ\  MOM  \]
		 EXP[ASCIZ\DA ACK \]
	         EXP[ASCIZ\ NOP   \]
	         EXP[ASCIZ\  LS   \]
	         EXP[ASCIZ\LS ACK \]
	         EXP[ASCIZ\  CI   \]
	         EXP[ASCIZ\  BOM  \]	
	         EXP[ASCIZ\  CC   \]
	         EXP[ASCIZ\  INT  \]
	         EXP[ASCIZ\  DI   \]
	         EXP[ASCIZ\  EOM  \]
	         EXP[ASCIZ\  DC   \]
	         EXP[ASCIZ\N INIT \]
	         EXP[ASCIZ\BomEom \]](Q1)
	SETZ T3,
	SOUT
	RET


;SUBROUTINE TO WRITE THE SEGNUM FIELD

WSEGNO:	MOVE T2,SEGNUM		;RETRIEVE THE SEGNUM 
	HRLI T3,100006
	HRRI T3,10
	NOUT			;IN OCTAL
	 ERJMP [JSHLT]
	MOVEI T2," "
	BOUT
	RET




;SUBROUTINE TO WRITE THE FCVAL FIELD

WFCVAL:	MOVE T2,FCVAL		;RETRIEVE THE FLOW CONTROL VALUE
	HRLI T3,100006
	HRRI T3,10
	NOUT			;IN OCTAL
	 ERJMP [JSHLT]
	RET
	SUBTTL Breakpoints

;BREAKPOINT INSTRUCTIONS

DEFINE BPTR (Q)<
	BPTR1(\Q)>

   DEFINE BPTR1 (Q)<
	XBP'Q'R,,BP'Q'R>

BPI:
   XX==0
   REPEAT NBPT,<
	BPTR XX
	XX=XX+1>

DEFINE SYM (NAME,PTR,MODUL,OFFSET)<
	RADIX50 0,NAME
   IFNB <MODUL>,<RADIX50 0,MODUL>
   IFB <MODUL>,<0>
   IFNDEF NAME,<
NAME:>
	XWD OFFSET,PTR>

OUTJFN:	0
FILJFN:	0
LAST:	0
LPRINT:	0
INTRV:	0
LINTRV:	0
LSTTOD:	0
NXTTCK:	0
BUF:	BLOCK INCR
ITIME:	0
BP1ADR:	0
BP2ADR:	0
BP3ADR:	0

	STRNGL==20
STRING:	BLOCK STRNGL

SYMBOL:	BLOCK 10

	PRGNML==40
PRGNAM:	BLOCK PRGNML

FRKCNT:	0
	FRKTBL==1000
FRKTAB:	BLOCK FRKTBL

	PDLEN==100
PDL:	BLOCK PDLEN
;MACROS FOR GENERATING MONITOR AND LOCAL REFERENCES IN RELOCATED CODE

;MONITOR SYMBOL REFERENCE

DEFINE MONREF (INST,MSY,%TAG)<
%TAG:!	INST
	MONRR <SYM MSY,%TAG
>>

;SET OF REMOTE MACROS FOR ABOVE

DEFINE MONRR (..XXX)<
	MONRR2 <..XXX>,
>

DEFINE MONRR2 (..NEW,..OLD)<
   DEFINE MONRR (..XXX)<
	MONRR2 <..XXX>,<..OLD
	..NEW
>>>

DEFINE MONRH <
   DEFINE MONRR2 (..NEW,..OLD)<
	..OLD>
   MONRR ()>

;LOCAL SYMBOL REFERENCE

DEFINE LOCREF (INST,LSY,%TAG)<
%TAG:!	INST
	LOCRR < %TAG,,LSY
>>

;SET OF REMOTE MACROS FOR ABOVE

DEFINE LOCRR (..XXX)<
	LOCRR2 <..XXX>,
>

DEFINE LOCRR2 (..NEW,..OLD)<
   DEFINE LOCRR (..XXX)<
	LOCRR2 <..XXX>,<..OLD
	..NEW
>>>

DEFINE LOCRH <
   DEFINE LOCRR2 (..NEW,..OLD)<
	..OLD>
   LOCRR ()>
DEFINE BP (Q)<
 XBP'Q'R:0
	0
	0
	LOCREF <0>,XBP'Q'

 BP'Q'R: 0
 XBP'Q':	CONO PI,PIOFF

   >

DEFINE ENDBP (Q)<
	MOVE I,SAV1I(I)
	CONO PI,PION
	LOCREF <SKIPE>,MONTYP
	LOCREF <XJRSTF>,XBP'Q'R
	LOCREF <JRSTF @0>,BP'Q'R>

	LIT

LOC BPRPAG_11
PHASE 0

BPR:

BP (0)
	LOCREF <MOVEM I,>,SAV1I
	LOCREF <MOVE I,>,INDEX
	MOVEM T1,SAV1T1(I)
	MOVEI T1,1		;THIS IS BPT 1
	JRST BP0(I)
RBP0:	MOVE T1,SAV1T1(I)
	ENDBP (0)

BP (1)
	LOCREF <MOVEM I,>,SAV1I
	LOCREF <MOVE I,>,INDEX
	MOVEM T1,SAV1T1(I)
	MOVEI T1,2		;THIS IS BPT 2
	JRST BP0(I)		;DO THE WORK
RBP1:	MOVE T1,SAV1T1(I)
	ENDBP (1)
;COMMON CODE FOR BPTS

BP0:	MOVEM T2,SAV1T2(I)
	MOVEM T3,SAV1T3(I)
	MOVEM T4,SAV1T4(I)
	MOVEM Q1,SAV1Q1(I)
	HRRZ T3,PNTR(I)
	ADDI T3,TABLE(I)
	MOVEM T1,(T3)
	ADDI T3,1
	MOVEI T4,INCR-2(T3)
	HRLI T3,-7(T2)		;7 = NO. OF MAGIC WORDS BEFORE ACTUAL NSP MESSAGE
	BLT T3,(T4)
	MOVEI T2,INCR
	ADDM T2,TOTAL(I)
	MOVE T2,PNTR(I)
	ADDI T2,INCR
	CAIL T2,TABLEN
	MOVEI T2,0
	MOVEM T2,PNTR(I)
BP1A:	ADDI T1,-1(I)
	MOVEI T1,@[IFIW RBP0(I)
		IFIW RBP1(I)](T1)	;GET RETURN ADDRESS
	MOVE T2,SAV1T2(I)
	MOVE T3,SAV1T3(I)
	MOVE T4,SAV1T4(I)
	MOVE Q1,SAV1Q1(I)
	JRST 0(T1)
SAV1T1:	0
SAV1T2:	0
SAV1T3:	0
SAV1T4:	0
SAV1Q1:	0
SAV1I:	0
PNTR:	0
LTOD:	0
JOBNUM:	0
MONTYP:	0

INDEX:	0
TOTAL:	0
TABLEN==6000
TABLE:	BLOCK TABLEN
OVRFLO:	0
FORKN:	0

LIT				;LITERALS IN PHASED CODE
BPRLEN==.-BPR

DEPHASE
RELOC

INSTAB:	LOCRH
INSTBL==.-INSTAB

SYMTAB:
	SYM NSPQ,BP1ADR,NSPSRV
	SYM SNDMSG,BP2ADR,NSPSRV,12
	MONRH
SYMTBL==.-SYMTAB

	END TIMER