Google
 

Trailing-Edge - PDP-10 Archives - BB-H348C-RM_1982 - swskit-v21/debugging-tools/nspfmt.mac
There are no other files named nspfmt.mac in the archive.
	TITLE NSPFMT - Format DECnet messages
	SEARCH MONSYM,MACSYM
	.REQUIRE SYS:MACREL.REL
	SALL



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


YESFMT:	RESET
	MOVE P,[-PDLEN,,PDL]
	TMSG <
Formatted output to:  >
	MOVSI T1,(GJ%FNS+GJ%SHT)
	MOVE T2,[.PRIIN,,.PRIOU]
	GTJFN
	 JRST [MOVEI T1,.PRIOU
	       HRLOI T2,400000
	       SETZ T3,
	       ERSTR
	        JFCL
	        JFCL
		HALTF]
	MOVEM T1,FMTJFN
	MOVEI T1,.PRIIN
	CFIBF
	TMSG <Please enter 16-bit words in octal separated by
single spaces or commas. End the message with ^Z...
>
	MOVEI T1,.PRIIN
	MOVE MESSBP,[POINT 8,MESS]
	MOVE P1,[POINT 8,MESS]	;MESSAGE BUFFER
INLOOP:	MOVEI T3,^D8		;BASE 8
	NIN
	 JRST OUTFMT
	AOS MSGSIZ
	LSHC T2,-^D8		;SEPARATE THE...
	LSH T3,-^D28		;BYTES
	IDPB T3,P1		;SAVE FIRST BYTE
	IDPB T2,P1		;SAVE SECOND BYTE
	JRST INLOOP		;DO ALL BYTES
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


;NSP MESSAGE DATA

RTFLG:	0			;ROUTE FLAG
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
MESS:	BLOCK ^D500

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\
Formatted NSP messages - \]
	SETZ T3,
	SOUT
	SETO T2,
	SETZ T3,
	ODTIM
	 JFCL
	HRROI T2,[ASCIZ\
\]
	SETZ T3,
	SOUT
	MOVEI Q1,T2
	CALL GETBYT
	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
	MOVEI T4,SRCLEN
	MOVEI Q3,[POINT 7,SRCNOD,6]
	CALL GTEASC		;GET THE SOURCE NODE NAME
	MOVEI Q1,T2
	CALL GETBYT
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

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
	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:	CALL GETBYN
	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:	CALL GETBYN
	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:	ILDB T2,MESSBP
	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:	ILDB T2,MESSBP
	MOVEM T2,(Q1)
	SOS MSGSIZ
	RET

GETBYN:	PUSH P,T1
	MOVE T1,MESSBP
	ILDB T2,T1
	POP P,T1
	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:	ILDB T2,MESSBP
	SKIPN T2		;IS IT NULL?
	RET			;YES
	MOVEM T2,(T4)		;NO, GET IT
	MOVEM T2,Q1
	MOVE Q2,(Q3)
GTEAS1:	ILDB T2,MESSBP
	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:	ILDB T2,MESSBP
	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
	10			;IBM 3270-BSC GATEWAY
	11			;IBM 2780-BSC GATEWAY
	12			;IBM 3790-SDLC GATEWAY
	13			;TPS APPLICATION
	14			;RT-11 DIBOL APPLICATION
	15			;TOPS-20 TERMINAL HANDLER
	16			;TOPS-20 REMOTE SPOOLER
	17			;RSX-11M TASK CONTROL (V2)
	20			;TLK UTILITY
	21			;FAL (DAP V4)
	22			;RSX-11S REMOTE TASK LOADER
	23			;NICE
	77			;DECNET RSX TEST TOOL
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?
	MOVEI Q1,OTYPES		;YES
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\DECnet RSX Test Tool\]](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,100005		;YES
	HRRI T3,10
	NOUT
	 ERJMP [JSHLT]
	MOVEI T2," "
	BOUT
	BOUT
	MOVEI T4,6
	SUB T4,DSTLEN
WRTHD1:	BOUT
	SOJG T4,WRTHD1
	MOVE T2,[POINT 7,DSTNOD]
	SETZ T3,
	SOUT			;DESTINATION NODE NAME
	MOVEI T2," "
	BOUT
	MOVEI T4,6
	SUB T4,SRCLEN
WRTHD2:	BOUT
	SOJG 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

OUTJFN:	0
FILJFN:	0
LAST:	0
LPRINT:	0
INTRV:	0
LINTRV:	0
LSTTOD:	0
NXTTCK:	0
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


RDNSP:	HALTF
	END YESFMT