From:	ADVAX::"""l_leahy""@star.enet.dec.com" "Lee Leahy DTN 381-0570 17-May-1991 1015" 17-MAY-1991 22:01:12.68
To:	arisia::everhart
CC:	
Subj:	MONLAT.MAR - Second section of 4

Received: by ADVAX.DECnet (utk-mail11 v1.5) ; Fri, 17 May 91 21:59:25 EDT
Received:  from mcnc by ge-dab.GE.COM (5.61/GE-DAB 1.15) with UUCP
	id AA27147 for ; Fri, 17 May 91 21:06:00 -0400
Received: from enet-gw.pa.dec.com by mcnc.mcnc.org (5.59/MCNC/3-21-91)
	id AA13535; Fri, 17 May 91 10:15:12 -0400
	for ARISIA.dnet.ge.com!EVERHART
Received: by enet-gw.pa.dec.com; id AA27308; Fri, 17 May 91 07:14:23 -0700
Message-Id: <9105171414.AA27308@enet-gw.pa.dec.com>
Received: from star.enet; by decwrl.enet; Fri, 17 May 91 07:14:28 PDT
Date: Fri, 17 May 91 07:14:28 PDT
From: Lee Leahy DTN 381-0570  17-May-1991 1015 <"l_leahy"@star.enet.dec.com>
To: arisia::everhart
Subject: MONLAT.MAR - Second section of 4
 
; Start up the second channel for getting the device ID and name.
 
	$QIOW_S	FUNC=#<IO$_SETMODE!IO$M_CTRL!IO$M_STARTUP>,-
		CHAN=CHNRMC,-
		IOSB=IOSB,-
		P2=#SIDPARMDSC
 
	BLBS	R0,START_REQ_OK2
	BRW	ERROR
 
START_REQ_OK2:
 
	MOVL	IOSB,R0
	BLBS	R0,START_IO_OK2
	CMPW	#SS$_BADPARAM,R0	; Was this a bad parameter?
	BNEQ	10$			; If not, use general error path
	CMPW	#NMA$C_PCLI_PTY,IOSB+4	; Was protocol type the bad parameter?
	BNEQ	10$			; If not, use general error path
	BSBW	BLANK
	PUSHAB	PT2MSG			; Print the protocol type error
	CALLS	#1,G^LIB$PUT_OUTPUT
	BRW	EXIT
10$:	BRW	ERROR
 
START_IO_OK2:
 
; Print program header
 
	BSBW	BLANK
	PUSHAB	HDRMSG1
	CALLS	#1,G^LIB$PUT_OUTPUT
 
GET_TEST:
 
; Print the prompt that requests which monitor request the user wants.  This
; is also the top of the loop that allows the user to make multiple monitor
; requests.
 
	BSBW	BLANK
	PUSHAB	INPMSG1
	CALLS	#1,G^LIB$PUT_OUTPUT
	PUSHAB	INPMSG2
	CALLS	#1,G^LIB$PUT_OUTPUT
	PUSHAB	INPMSG3
	CALLS	#1,G^LIB$PUT_OUTPUT
	PUSHAB	INPMSG4
	CALLS	#1,G^LIB$PUT_OUTPUT
	PUSHAB	INPMSG5
	CALLS	#1,G^LIB$PUT_OUTPUT
	BSBW	BLANK
 
; Read the user's input to our prompt for the number of the test to run.
 
	MOVL	#2,INPSTRDSC		; Set number of bytes to read
	PUSHAB	INPSIZ			; Push input size parameter
	PUSHAB	RPRMT			; Push prompt string parameter
	PUSHAB	INPSTRDSC		; Push String descriptor parameter
	CALLS	#3,G^LIB$GET_INPUT	; Read the user's input
 
; Convert the input to a test number.
 
	CLRL	R1			; Start with zero in test number
	CLRL	R2			; Clear # of input characters done
10$:	CMPW	R2,INPSIZ		; Have we processed all the input?
	BGEQU	20$			; If EQL, yes
	MOVZBL	INPSTR(R2),R0		; Get an input character
	SUBL2	#^A/0/,R0		; Convert to a digit
	MULL2	#^D10,R1		; Shift current decimal digits
	ADDL2	R0,R1			; Add new digit
	INCL	R2			; Bump # of input characters done
	BRB	10$			; Check next character
 
; Clear the per-test global variables.
 
20$:	CLRL	NODCNT
	CLRB	HOURS
	CLRB	MINUTES
	CLRB	SECONDS
	MOVL	R1,REQ
; Now perform the appropriate test based on the test number.
 
	CMPL	R1,#1			; Check if test #1
	BNEQ	30$			; If NEQ, no
	BSBW	TEST_1			; Do test
	BRW	GET_TEST		; Check for another test to run
30$:	CMPL	R1,#2			; Check if test #2
	BNEQ	40$			; If NEQ, no
	BSBW	TEST_2			; Do test
	BRW	GET_TEST		; Check for another test to run
40$:	CMPL	R1,#3			; Check if test #3
	BNEQ	50$			; If NEQ, no
	BSBW	TEST_3			; Do test
	BRW	GET_TEST		; Check for another test to run
 
; Not a supported test, so exit.
 
50$:	BRW	EXIT			; Not any of above, so exit

; Request #1
;
; This code receives all LAT packets coming into the node where the program
; is run for a length of time requested by the user. The packets are
; examined, and if the address is the first occurance thereof, the packet
; is stored.  After the set time is over, all packets stored (along with
; other information) are displayed.
 
TEST_1:
 
	BSBW	GET_TIME
	BSBW	SET_TIME
 
; We need to zero the device totals before we start receiving packets.
 
	MOVAB	DEVTBL,R5		; Start at beginning of table
10$:	CLRW	1(R5)			; Clear this counter
	TSTB	(R5)			; End of table?
	BEQL	20$			; If EQL, yes
	ADDL	#7,R5			; Skip to next entry
	BRB	10$			; Loop for more devices
20$:	CLRW	CTRMIS
	CLRW	CTRNAN
 
; Loop receiving and storing packets until time runs out.
 
RCV_T1:	BSBW	RCV_LAT			; Get a message
	BLBC	R0,PRINT_T1		; If time ran out, print results
	BSBW	STORE_NODE		; Store this node
	BRB	RCV_T1			; Loop for more
 
PRINT_T1:
 
; If we have no data, then print appropriate message.
 
	TSTL	NODCNT			; Anything in node table?
	BNEQ	PRINT_TBL_T1		; If NEQ, yes, so print them
 
; Print "no messages found" message.
 
	BSBW	BLANK
	PUSHAB	M1NONE
	CALLS	#1,G^LIB$PUT_OUTPUT
	RSB
 
PRINT_TBL_T1:
 
; Print the header
 
	BSBW	BLANK
	PUSHAB	M1HDR1
	CALLS	#1,G^LIB$PUT_OUTPUT
	PUSHAB	M1HDR2
	CALLS	#1,G^LIB$PUT_OUTPUT
 
; Now print all the nodes in the node table.
 
	DECL	NODCNT
10$:	BSBW	NEXT_R1			; Get address of next entry to print
	BLBS	R0,20$			; If LBS, there's an entry
	BRW	PRINT_SUM_R1
 
; Print the node found
 
20$:	BSBW	PRINT_NODE
 
; Now print the group codes enabled.
 
30$:	BSBW	GET_GCODES
	TSTL	NUMGC			; Any group codes found?
	BEQL	50$			; If EQL, no
 
; Put the Group codes on the stack for FAO arguments.
 
	MOVL	#^D33,M1CODE		; Set initial FAO string size
	MOVL	NUMGC,R1
40$:	MOVZBL	GCODES-1(R1),-(SP)	; R1 was one based offset
	ADDL	#5,M1CODE		; Add to size of FAO string
	SOBGTR	R1,40$			; Loop if more to store
 
	MOVL	#80,FAOLEN
	PUSHAL	FAOLEN			; Put length argument
	PUSHAL	FAODESC			; Push descriptor argument
	PUSHAL	M1CODE			; Push input string argument
	ADDL3	NUMGC,#3,R1		; Get number of arguments
	CALLS	R1,G^SYS$FAO		; Format the string
 
	PUSHAB	FAODESC
	CALLS	#1,G^LIB$PUT_OUTPUT
	BRB	30$			; Get more codes
 
50$:	MOVL	#1,(R2)			; Set low order bit so it's skipped
	PUSHAB	M1SEP1
	CALLS	#1,G^LIB$PUT_OUTPUT
	BRW	10$			; Get next node
 
PRINT_SUM_R1:
 
; Print the device totals.
 
;==========================================================================
; Print the header
 
	PUSHAB	M1SUM1
	CALLS	#1,G^LIB$PUT_OUTPUT
	BSBW	BLANK
	PUSHAB	M1SUM2
	CALLS	#1,G^LIB$PUT_OUTPUT
	PUSHAB	M1SUM3
	CALLS	#1,G^LIB$PUT_OUTPUT
 
;==========================================================================
; Print the device totals
 
	MOVAB	DEVTBL,R5		; Start at beginning of table
	CLRL	R7			; Start running total at zero
 
; Loop printing each device in the device table.
 
10$:	TSTB	(R5)			; End of table?
	BEQL	20$			; If EQL, yes
 
	TSTW	1(R5)			; Were any found?
	BEQL	15$			; If EQL, no, so don't print it
	ADDW	1(R5),R7		; Add to running total
	MOVL	3(R5),R6		; Get the address of the descriptor
	MOVL	#80,FAOLEN
	$FAO_S	CTRSTR=M1SUMM,-
		OUTLEN=FAOLEN,-
		OUTBUF=FAODESC,-
		P1=R6,-
		P2=1(R5)
	PUSHAB	FAODESC
	CALLS	#1,G^LIB$PUT_OUTPUT
15$:	ADDL	#7,R5			; Skip this entry
	BRB	10$			; Loop for more devices
 
; Now print the number of unknown devices if any were found.
 
20$:	TSTW	1(R5)
	BEQL	30$
	ADDW	1(R5),R7		; Add to running total
	MOVL	#80,FAOLEN
	$FAO_S	CTRSTR=M1SUMM,-
		OUTLEN=FAOLEN,-
		OUTBUF=FAODESC,-
		P1=#DEVUNK,-
		P2=1(R5)
	PUSHAB	FAODESC
	CALLS	#1,G^LIB$PUT_OUTPUT
 
; Now print the number of missing devices if any were found.
 
30$:	TSTW	CTRMIS
	BEQL	40$
	ADDW	CTRMIS,R7		; Add to running total
	MOVL	#80,FAOLEN
	$FAO_S	CTRSTR=M1SUMM,-
		OUTLEN=FAOLEN,-
		OUTBUF=FAODESC,-
		P1=#DEVMIS,-
		P2=CTRMIS
	PUSHAB	FAODESC
	CALLS	#1,G^LIB$PUT_OUTPUT
 
; Now print the number of devices that didn't answer.
 
40$:	TSTW	CTRNAN
	BEQL	50$
	ADDW	CTRNAN,R7		; Add to running total
	MOVL	#80,FAOLEN
	$FAO_S	CTRSTR=M1SUMM,-
		OUTLEN=FAOLEN,-
		OUTBUF=FAODESC,-
		P1=#DEVNAN,-
		P2=CTRNAN
	PUSHAB	FAODESC
	CALLS	#1,G^LIB$PUT_OUTPUT
 
; Now print the total.
 
50$:	PUSHAB	M1SUM3
	CALLS	#1,G^LIB$PUT_OUTPUT
	$FAO_S	CTRSTR=M1TOTL,-
		OUTLEN=FAOLEN,-
		OUTBUF=FAODESC,-
		P1=R7
	PUSHAB	FAODESC
	CALLS	#1,G^LIB$PUT_OUTPUT
	RSB

; Test #2
;
; This test asks the user for both a length of time to run the test for and
; a group code to watch for. Once the end time has been reached, the addresses
; of all nodes received with the specific group code enabled are printed.
 
TEST_2:
 
	BSBW	GET_TIME
	BSBW	BLANK
	BSBW	GET_GCODE
	BSBW	SET_TIME
 
; Loop receiving and storing nodes with a matching group code.
 
RCV_T2:	BSBW	RCV_LAT			; Get a message
	BLBC	R0,PRINT_T2		; If time ran out, print results
 
; First check if the appropriate group code is set in this message.
 
	MOVZBL	RCVBUF+12,R1		; Get group code length
	MOVC5	R1,RCVBUF+13,#0,-	; Copy (with zero extend) into
		#^X20,GCBITS		; a fixed place
	MOVZBL	GCODE,R1		; Get requested group code
	CLRL	R0			; To calc group code bit number,
	CLRL	R2			; start with 0 in R0 and R2
	EDIV	#8,R1,R0,R2		; R0=byte to check in the bit mask
					; R2=bit to check in that byte
	BBC	R2,GCBITS(R0),RCV_T2	; If group code not enabled, discard
	BSBW	STORE_NODE		; Store this node
	BRW	RCV_T2			; Loop for more nodes
 
PRINT_T2:
 
; If we have no data, then print appropriate message.
 
	TSTL	NODCNT			; Anything in DECNET table?
	BNEQ	PRINT_TBL_T2		; If NEQ, yes, so print them
 
; Print "no messages found" message.
 
	BSBW	BLANK
	MOVL	#80,FAOLEN
	$FAO_S	CTRSTR=M2NONE,-
		OUTLEN=FAOLEN,-
		OUTBUF=FAODESC,-
		P1=GCODE
	PUSHAB	FAODESC
	CALLS	#1,G^LIB$PUT_OUTPUT
	RSB
 
PRINT_TBL_T2:
 
; Print the header
 
	BSBW	BLANK
	MOVL	#80,FAOLEN
	$FAO_S	CTRSTR=M2HDR0,-
		OUTLEN=FAOLEN,-
		OUTBUF=FAODESC,-
		P1=GCODE
	PUSHAB	FAODESC
	CALLS	#1,G^LIB$PUT_OUTPUT
	PUSHAB	M1HDR1
	CALLS	#1,G^LIB$PUT_OUTPUT
	PUSHAB	M1HDR2
	CALLS	#1,G^LIB$PUT_OUTPUT
 
; Now print all the nodes in the node table.
 
	DECL	NODCNT
10$:	BSBW	NEXT_R1			; Get address of next entry to print
	BLBS	R0,20$			; If LBS, there's an entry
	RSB
 
; Print the node found
 
20$:	BSBW	PRINT_NODE
	MOVL	#1,(R2)			; Set low order bit so it's skipped
	BRW	10$			; Get next node

; Test #3
;
; This test asks the user for one address, and waits for a message from that
; address. Once a message from that address is found, a listing of all group
; codes enabled is given.
 
TEST_3:
 
; Start the test; continue until the end time is reached.
 
	BSBW	GET_TIME
	BSBW	BLANK
	BSBW	GET_ADDR
	BSBW	SET_TIME
 
RCV_T3:
 
	BSBW	RCV_LAT			; Get a message
	BLBS	R0,10$			; If we have a message, process it
 
; Print "no messages found" message.
 
	BSBW	BLANK
	MOVL	#80,FAOLEN
	$FAO_S	CTRSTR=M3NONE,-
		OUTLEN=FAOLEN,-
		OUTBUF=FAODESC,-
		P1=DSTADR,-
		P2=DSTADR+1,-
		P3=DSTADR+2,-
		P4=DSTADR+3,-
		P5=DSTADR+4,-
		P6=DSTADR+5
	PUSHAB	FAODESC
	CALLS	#1,G^LIB$PUT_OUTPUT
	RSB
 
; Check if the source address is the desired one.
 
10$:	MOVZBL	RCVBUF+12,R1
	MOVC5	R1,RCVBUF+13,#0,#^X20,GCBITS
	CMPC3	#6,RCVSA,DSTADR
	BNEQ	RCV_T3
 
; The address was the desired one, so print the results
 
PRINT_T3:
 
; Print the address.
 
	BSBW	BLANK
	MOVL	#80,FAOLEN
	$FAO_S	CTRSTR=M3ADDR,-
		OUTLEN=FAOLEN,-
		OUTBUF=FAODESC,-
		P1=RCVSA,-
		P2=RCVSA+1,-
		P3=RCVSA+2,-
		P4=RCVSA+3,-
		P5=RCVSA+4,-
		P6=RCVSA+5
	PUSHAB	FAODESC
	CALLS	#1,G^LIB$PUT_OUTPUT
 
; Print the DECnet node if this is a DECnet address
 
	CMPL	#^X000400AA,RCVSA	; Is this a DECnet address?
	BNEQ	1$			; If NEQ, no
	MOVW	RCVSA+4,R0
	BICW	#^XFC00,R0
	MOVZBL	RCVSA+5,R3
	ASHL	#-2,R3,R3
	MOVL	#80,FAOLEN
	$FAO_S	CTRSTR=M3NODE,-
		OUTLEN=FAOLEN,-
		OUTBUF=FAODESC,-
		P1=R3,-
		P2=R0
	PUSHAB	FAODESC
	CALLS	#1,G^LIB$PUT_OUTPUT
 
 
; Print the device ID and device name.
 
1$:	MOVL	DSTADR,SIDADDR
	MOVW	DSTADR+4,SIDADDR+4
	BSBW	GET_DEVID
	MOVL	#80,FAOLEN
	$FAO_S	CTRSTR=M3CONT,-
		OUTLEN=FAOLEN,-
		OUTBUF=FAODESC,-
		P1=DEVID,-
		P2=#DEVDSC
	PUSHAB	FAODESC	
	CALLS	#1,G^LIB$PUT_OUTPUT
 
; Print the node name if there is one.
 
	MOVZBL	RCVBUF+12,R1		; Get size of group code bits
	ADDL3	#^D13,R1,R4		; Offset to node name size
	MOVAL	RCVBUF+1,R5		; Calc address of string
	ADDL	R4,R5			; Address of string
	MOVZBL	RCVBUF(R4),R3		; Get size
	BEQL	10$			; If EQL, none to print
	MOVL	#80,FAOLEN
	$FAO_S	CTRSTR=M3IDN1,-
		OUTLEN=FAOLEN,-
		OUTBUF=FAODESC,-
		P1=R3,-
		P2=R5
	PUSHAB	FAODESC	
	CALLS	#1,G^LIB$PUT_OUTPUT
 
; Print the node descriptor if there is one.
 
10$:	ADDL	R3,R5			; Address of size
	MOVZBL	(R5)+,R3		; Get size
	BEQL	20$			; If EQL, none to print
	MOVL	#80,FAOLEN
	$FAO_S	CTRSTR=M3IDN2,-
		OUTLEN=FAOLEN,-
		OUTBUF=FAODESC,-
		P1=R3,-
		P2=R5
	PUSHAB	FAODESC	
	CALLS	#1,G^LIB$PUT_OUTPUT
 
; Print each service set.
 
20$:	ADDL	R3,R5			; Address of number of sets
