Google
 

Trailing-Edge - PDP-10 Archives - BB-H348C-RM_1982 - swskit-v21/debugging-tools/dts/dtsint.mac
There are no other files named dtsint.mac in the archive.


;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1978 BY DIGITAL EQUIPMENT CORPORATION
;
	TITLE DTSINT - DTS INTERRUPT MESSAGE TEST EXECUTION MODULE

	SEARCH DTSUNV,MACSYM,MONSYM
	SALL
	LIST

	ENTRY DTSINT

	PRINT==200
	IDELAY==1		;DELAY BETWEEN INTERRUPT MESSAGES
	INTVLM==^D10		;FREQUENCY TO PRINT INTERVAL MESSAGE
	WAITVI==5		;TIME TO WAIT ON ECHO

	PAGE
	SUBTTL DTSINT - DTS INTERRUPT MESSAGE TEST 

;+
;DTSINT - THIS ROUTINE PERFORMS THE DTS INTERRUPT MESSAGE TEST TO A DTR SERVER ON
; ANOTHER NODE IN THE NETWORK. THE ROUTINE IS CALLED BY THE DTS DRIVER
; AFTER THE CONNECT INTERRUPT HAS OCCURED AND THE LINK HAS A ZERO
; REASON CODE. THE CONNECT INTERRUPT COULD HAVE BEEN THE RESULT OF THE
; MONITOR RECEIVING EITHER AN NSP CONNECT CONFIRM OR DISCONNECT INITIATE.
;
;ACCEPTS:	T1/ ADDRESS OF ARGUMENT BLOCK
;		LCBPTR/ ADDRESS OF LCB
;
;	ARGUMENT BLOCK/ (.DTTIM) ELAPSED TIME TO RUN TEST
;			(.DTBUF) NUMBER OF SEND BUFFERS TO USE
;			(.DTBAU) BAUD RATE
;			(.DTNOD) POINTER TO NODE NAME
;			(.DTCNT) OPTIONAL DATA BYTE COUNT
;			(.DTTYP) TEST TYPE + PRINT OPTION
;			(.DTSUB) TEST SUBTYPE
;			(.DTFOP) FLOW CONTROL OPTION
;			(.DTMSG) MESSAGE LENGTH
;				 USER DATA
;
;CALLED BY: CALL DTSINT
;
;RETURNS+1: SUCCESS
;	+2: FAILURE
;-



DTSINT:				;ENTRY
	TRVAR <ARGPTR>		;STORAGE FOR VARIABLES
	MOVEM T1,ARGPTR		;SAVE ADDRESS OF ARGUMENT BLOCK
	CALL DTSPRT		;PRINT MESSAGE

;RESET TIME EXPIRED FLAG

	SETZM TIMEUP		;ZERO FOR TEST TO CONTINUE
	SETZM IEKERF		;CLEAR ECHO ERROR FLAG

;MAKE SURE WE GOT CONNECTED
; SEE THE NOTE IN THE MAINLINE DRIVER SOURCE CODE RELATIVE TO
; THE VERACITY OF WHETHER THE LINK WAS ACCPETED BY DTR

	LOAD T1,LCBSTS		;GET LINK STATUS
	TXZN T1,MO%LWC		;WAS LINK CONNECTED ?
	PRTERR <LINK NEVER CONNECTED>,,<$GOTO(INTABT)> ;NO....
				; THEN ASSUME NOT ACCEPTED BY DTR


;SET UP TO GET INTERRUPT WHEN TEST TIME EXPIRES

	MOVE T1,ARGPTR		;GET POINTER TO ARGUMENT BLOCK
	MOVE T2,.DTTIM(T1)	;GET LENGTH OF TIME TO RUN TEST
	IMULI T2,^D1000		;MAKE IT MILLISECONDS
	LDB T3,[POINT 9,IHBLK+4,8] ;GET CHANNEL NUMBER
	MOVE T1,[.FHSLF,,.TIMEL] ;THIS PROCESS / ELAPSED TIME
	TIMER
	 JSRET 

;STORE DISPATCH ADDRESSES IN LCB

	$PIOFF			;TURN OFF INTERRUPTS 
	MOVEI T1,TIMEXP		;GET ADDRESS OF ROUTINE TO END TEST
	STOR T1,LCBTID		;STORE TIMER DISPATCH ADDRESS IN LCB
	MOVEI T1,READAT		;GET ADDRESS OF ROUTINE TO READ DATA
	STOR T1,LCBDID		;STORE DATA DISPATCH ADDRESS IN LCB
	MOVEI T1,READIM		;GET ADDRESS OF ROUTINE TO READ INTERRUPT MSG
	STOR T1,LCBIID		;STORE IN LCB DISPATCH FIELD
	$PION			;ALLOW INTERRUPTS AGAIN

;INITIALIZE LCB FIELDS

	SETZRO LCBSND		;SET MESSAGE SEND COUNT TO ZERO
	SETZRO LCBSBC		;CLEAR SEND BYTE COUNT
	SETZRO LCBISC		;CLEAR INT MSG COUNTS
	SETZRO LCBIRC

;ADD CODE TO %%%%%%%%%%%%
; SAVE THE CURRENT CLOCK TIME FOR BAUD RATE CALCULATION
; IF YOU WANT DO PERF CALC........%%%%%%%%

	MOVE T1,ARGPTR		;GET POINTER TO ARGUMENT BLOCK
	MOVE T2,.DTSUB(T1)	;GET INTTYPE

;DISPATCH BASED ON INTTYPE

	CALL @INTTBL(T2)	;DISPATCH TO SPECIFIC TEST TYPE
	RETBAD INTABT		;FAIL RETURN, ABORT LINK & JFN
	CALL INTSYN		;DISCONNECT AND CLOSE LINK
	RETSKP			;SUCCESS RETURN

INTSYN:				;HERE TO DISCONNECT THE LINK
	SETZRO LCBABT		;SYNCH DISCONNECT
	SETZRO LCBRSN		;REASON CODE ZERO
	SETZRO LCBSOC		;SEND NO OPTIONAL DATA
	CALL REJLNK		;DISCONNECT LINK WITH REASON = 0
	RETBAD LNKERR		;FAILED, TELL WHY..
	SETZRO LCBRJF		;RELEASE JFN
	CALL CLZLNK		;NOW CLOSE IT
	RETBAD ERXLNK
	RET

INTABT:				;HERE TO ABORT LINK & CLOSE JFN
	SETONE LCBABT		;ABORT LINK
	SETZRO LCBRJF		;RELEASE JFN
	CALL CLZLNK		;NOW CLOSE IT
	RETBAD ERXLNK
	RET

INTTBL:				;INTERRUPT TEST DISPATCH TABLE
	INTSNK			;INTTYPE=0 - INTERRUPT SINK TEST
	INTSEQ			;INTTYPE=1 - INTERRUPT SEQUENCE TEST
	INTPAT			;INTTYPE=2 - INTERRUPT PATTERN TEST
	INTECH			;INTTYPE=3 - INTERRUPT ECHO TEST

	PAGE
	SUBTTL INTSNK - INTERRUPT SINK TEST

;HERE TO PERFORM THE IDEAL INTERRUPT SINK TEST

INTSNK:				;ENTRY FROM DISPATCH TABLE
	STKVAR <MSGLN>		;STORAGE FOR MESSAGE LENGTH
	CALL GTMSGL		;GO GET MESSAGE LENGTH
	MOVEM T1,MSGLN		;SAVE IT FOR USE IN LOOP

INTSN1:				;HERE TO SEND EACH MESSAGE
	LOAD T1,LCBSTS		;GET LINK STATUS
	TXNN T1,MO%CON		;CONNECTED NOW ?
	RET			;NO, RETURN BAD

	MOVE T1,MSGLN		;RESTORE MESSAGE LENGTH
	CALL SNDPAT		;GO SEND MESSAGE
	RET			;RETURN ON SEND ERROR
	SKIPE TIMEUP		;TIME EXPIRED ?
	JRST INTDON		;YES, GO TO DONE ROUTINE
	MOVEI T1,IDELAY		;NO, DELAY BEFORE NEXT INTERRUPT MESSAGE
	CALL SLEEP
	SKIPE TIMEUP		;TIME EXPIRED ?
	JRST INTDON		;YES, GO TO DONE ROUTINE
	JRST INTSN1		;KEEP GOING UNTIL TIME EXPIRES

	PAGE
	SUBTTL INTSEQ - INTERRUPT SEQUENCE TEST

;HERE TO PERFORM INTERRUPT SEQUENCE TEST

INTSEQ:				;ENTRY FROM DISPATCH 
	STKVAR <MSGLN>		;STORAGE FOR MESSAGE LENGTH
	CALL GTMSGL		;GO GET MESSAGE LENGTH
	MOVEM T1,MSGLN		;SAVE IT FOR USE IN LOOP

;TOP OF LOOP TO SEND EACH MESSAGE

INTSE1:
	LOAD T1,LCBSTS		;GET LINK STATUS
	TXNN T1,MO%CON		;CONNECTED NOW ?
	RET			;NO, RETURN BAD

	CALL UPDCNT		;GO UPDATE COUNT FIELD
	MOVE T1,MSGLN		;RESTORE MESSAGE LENGTH
	CALL SNDSEQ		;GO SEND MESSAGE
	RET			;RETURN ON SEND ERROR
	SKIPE TIMEUP		;TIME EXPIRED ?
	JRST INTDON		;YES, GO TO DONE ROUTINE
	MOVEI T1,IDELAY		;NO, DELAY BEFORE NEXT INTERRUPT MESSAGE
	CALL SLEEP
	SKIPE TIMEUP		;TIME EXPIRED ?
	JRST INTDON		;YES, GO TO DONE ROUTINE
	JRST INTSE1		;KEEP GOING

	PAGE
	SUBTTL INTPAT - INTERRUPT PATTERN TEST

;HERE TO PERFORM INTERRUPT PATTERN TEST

INTPAT:				;ENTRY
	STKVAR <MSGLN>		;STORAGE FOR MESSAGE LENGTH
	CALL GTMSGL		;GO GET MESSAGE LENGTH
	MOVEM T1,MSGLN		;SAVE IT FOR USE IN LOOP

;TOP OF LOOP TO SEND EACH MESSAGE

INTPA1:
	LOAD T1,LCBSTS		;GET LINK STATUS
	TXNN T1,MO%CON		;CONNECTED NOW ?
	RET			;NO, RETURN BAD

	CALL UPDCNT		;GO UPDATE COUNT FIELD
	MOVE T1,MSGLN		;RESTORE MESSAGE LENGTH
	CALL SNDSEQ		;GO SEND MESSAGE
	RET			;RETURN ON SEND ERROR
	SKIPE TIMEUP		;TIME EXPIRED ?
	JRST INTDON		;YES, GO TO DONE ROUTINE
	MOVEI T1,IDELAY		;NO, DELAY BEFORE NEXT INTERRUPT MESSAGE
	CALL SLEEP
	SKIPE TIMEUP		;TIME EXPIRED ?
	JRST INTDON		;YES, GO TO DONE ROUTINE
	JRST INTPA1		;KEEP GOING

	PAGE
	SUBTTL INTECH - INTERRUPT ECHO TEST

;HERE TO PERFORM INTERRUPT ECHO TEST

INTECH:				;ENTRY
	STKVAR <MSGLN>		;STORAGE FOR MESSAGE LENGTH
	CALL GTMSGL		;GO GET MESSAGE LENGTH
	MOVEM T1,MSGLN		;SAVE IT FOR USE IN LOOP

;TOP OF LOOP TO SEND EACH MESSAGE

INTEC1:
	LOAD T1,LCBSTS		;GET LINK STATUS
	TXNN T1,MO%CON		;CONNECTED NOW ?
	RET			;NO, RETURN BAD

	CALL UPDCNT		;GO UPDATE COUNT FIELD
	MOVE T1,MSGLN		;RESTORE MESSAGE LENGTH
	CALL SNDSEQ		;GO SEND MESSAGE
	RET			;RETURN ON SEND ERROR
	SKIPE TIMEUP		;TIME EXPIRED ?
	JRST INTEC2		;YES, GO FINISH UP
	SETOI T1,		;WAIT UNTIL WE RECEIVE ECHO INTERRUPT MSG
	CALL SLEEP
	SKIPE IEKERF		;ECHO ERROR ON RECEIVED INT MSG ?
	RET			;YES, RETURN BAD CLOSING LINK
	SKIPN TIMEUP		;WAKEUP DUE TO TIME EXPIRED ?
	JRST INTEC1		;NO, KEEP GOING

	PAGE
	SUBTTL INTECH - INTERRUPT ECHO TEST

INTEC2:				;HERE WHEN TIME EXPIRED
	SKIPE IEKERF		;ECHO ERROR ON RECEIVED INT MSG ?
	RET			;YES, RETURN BAD CLOSING LINK
	LOAD T2,LCBIRC		;GET RECEIVE COUNT
	OPSTR <CAMN T2,>,LCBISC	;EQUAL TO SEND COUNT ?
	JRST IEKDON		;YES, WE'RE THROUGH
	MOVEI T1,WAITVI		;WAIT A WHILE
	CALL SLEEP
	SKIPN TIMOUT		;DID WE TIME OUT ?
	JRST INTEC2		;NO, LOOP UNTIL RECEIVE ALL
	PRTERR <INTERRUPT TEST FAILED, ECHO TIMEOUT>,,<$RET> ;YES, JUST RETURN

IEKDON:				;HERE WHEN INTERRUPT ECHO DONE
	CALL INTDON
	JFCL			;IGNORE
	PRTINF <INTERRUPT MESSAGES RECEIVED = >
	HRROI T1,RDBUF		;USE THE DATA BUFFER
	LOAD T2,LCBIRC		;GET NUMBER WE RECEIVED
	MOVX T3,^D10		;IN DECIMAL
	NOUT
	 JSCONT
	HRROI T1,RDBUF
	CALL SNDSTR
	RETSKP

	PAGE
	SUBTTL INTDON - INTERRUPT TEST DONE ROUTINE

INTDON:				;HERE TO PRINT RESULTS OF TEST IF GOOD
	CALL PINTVL
	RETSKP

	PAGE
	SUBTTL GTMSGL - GET MESSAGE LENGTH FROM ARGUMENT BLOCK

;ACCEPTS: NOTHING
;
;RETURNS+1: ALWAYS, T1/ MESSAGE LENGTH

GTMSGL:				;ENTRY POINT
	MOVE T1,ARGPTR		;GET POINTER TO ARGUMENT BLOCK
	MOVE T2,.DTMSG+1(T1)	;GET BYTE 1, MOST SIGINIICANT DIGIT
	LSH T2,^D8		;SHIFT IT TO BYTE 1 POSITION
	MOVE T1,.DTMSG(T1)	;GET BYTE 0, LEAST SIGNIFICANT DIGIT
	ADDI T1,(T2)		;MESSAGE LENGTH IN T1
	RET

	PAGE
	SUBTTL UPDCNT - UPDATE COUNT FIELD IN DTR/DTS INTERRUPT MESSAGE

;ACCEPTS: NOTHING
;
;RETURNS+1: ALWAYS

UPDCNT:				;ENTRY POINT

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
;CONVERT MESSAGE NUMBER TO 8 BIT FORMAT
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

	MOVE T1,[POINT 8,COUNT] ;GET BYTE POINTER TO 4 DIGIT STRING
	LOAD T2,LCBISC		;GET CURRENT INT MSG SEND COUNT
	ADDI T2,1		;BUMP COUNT
	MOVEI T3,4		;FOUR BYTES
	CALL DEP11		;CONVERT INTEGER TO STRING 
	MOVE T2,[POINT 8,COUNT] ;GET BYTE POINTER TO 4 DIGIT STRING
	MOVE T1,STDSEQ		;GET POINTER TO INTERRUPT MESSAGE
	MOVNI T3,4		;FOUR BYTE SEQUENCE NUMBER
	SOUT			;OUTPUT IT
	RET			;RETURN

	PAGE
	SUBTTL DEP11 - DEPOSIT INTEGER INTO STRING IN PDP-11 FORMAT

;DEP11 - CREATES A STRING OF 8 BIT BYTES WITH LEAST SIGNIFICANT BYTE
;	IN BYTE POSITION ZERO

;ACCEPTS:	T1/ 8 BIT STRING POINTER
;		T2/ INTEGER TO CONVERT
;		T3/ BYTE COUNT

DEP11:				;ENTRY POINT
	IDPB T2,T1		;DEPOSIT BYTE IN STRING
	LSH T2,-8		;SHIFT TO NEXT BYTE
	SOJG T3,DEP11		;KEEP GOING UNTIL COUNT IS EXHAUSTED
	RET			;DONE

	PAGE
	SUBTTL SNDPAT - SEND A DTS INTERRUPT MESSAGE PATTERN

;ACCEPTS: T1/ MESSAGE LENGTH

SNDPAT:				;SEND UNSEQUENCED INTERRUPT MESSAGE
	STOR T1,LCBSZI		;STORE SIZE OF INTERRUPT MSG
	MOVE T1,STDINT		;POINT TO STANDARD INTERRUPT MESSAGE
	JRST SNDI2

SNDSEQ:				;SEND SEQUENCED INTERRUPT MESSAGE
	STOR T1,LCBSZI		;STORE SIZE OF INTERRUPT MSG
	MOVE T1,STDSEQ		;POINT TO STANDARD INTERRUPT MESSAGE
	JRST SNDI2

SNDI2:
	STOR T1,LCBPIM		;STORE IN LCB

SNDI4:				;HERE AFTER FAILURE TO RETRY...
	CALL SIMLNK		;GO SEND INTERRUPT MESSAGE
	JRST SNDI3		;FAIL RETURN, SEE WHY

SNDI:
	LOAD T1,LCBISC		;GET COUNT OF INT MSG SENT
	IDIVI T1,INTVLM		;GET COUNT MOD INTERVAL
	CAIN T2,0		;PRINT A MESSAGE ?
	CALL PINTVL		;YES, TELL HOW MANY WE'VE SENT
	RETSKP			;SENT OK, RETURN


;HERE IF ATTEMPT TO SEND INTERRUPT MESSAGE FAILED
; NSP PROVIDES NO MEANS TO DETERMINE WHEN AN INTERRUPT MESSAGE HAS
; BEEN RECEIVED BY THE REMOTE PROCESS AND WE ARE NOT ALLOWED TO SEND
; ANOTHER UNTIL THE FIRST HAS BEEN READ
; THIS IS ANOTHER HOLE IN THE DTR SPEC
; WHAT WE WILL DO CHECK THE REASON WE FAILED TO SEND THE INTERRUPT
; MESSAGE. IF THE REASON IS DUE TO STILL HAVING AN UNACKNOWLEDGED
; INTERRUPT MESSAGE, WE WILL JUST TRY AGAIN....
;SEE IF INTERRUPT MESSAGE IS STILL OUTSTANDING

SNDI3:
	LOAD T1,LCBLER		;GET MONITOR ERROR CODE
	CAIE T1,DCNX14		;STILL OUTSTANDING AT OTHER END ?
	RETBAD LNKERR		;NO, REAL ERROR & RETURN

;NOTE: IT MAY BE DESIRABLE TO ADD CODE TO WAIT FOR SOME PRE-SPECIFIED
; TIME HERE RATHER THAN JUST CONTINUE TO LOOP

	JRST SNDI4		;YES, GO TRY AGAIN

;HERE TO PRINT MESSAGE AT INTERVAL OF MESSAGES

	PAGE
	SUBTTL PINTVL - PRINT INTERVAL MESSAGES SENT

PINTVL:				;ENTRY
	PRTINF <INTERRUPT MESSAGES SENT = >
	HRROI T1,RDBUF		;USE THE DATA BUFFER
	LOAD T2,LCBISC		;GET NUMBER WE SENT
	MOVX T3,^D10		;IN DECIMAL
	NOUT
	 JSCONT
	HRROI T1,RDBUF
	CALL SNDSTR
	RET

	PAGE
	SUBTTL TIMEXP - TIME EXPIRATION ROUTINE

;TIMEXP - INTERRUPT LEVEL ROUTINE TO HANDLE ELAPSED TIME INTERRUPT
;	WHICH SIGNIFIES THE TEST HAS COMPLETED

TIMEXP:				;ENTRY FROM IHTIME

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
; JUST SET A FLAG TO INDICATE TIME IS UP
; CLEAR OUT THE DISPATCH ADDRESS IN LCB
; THEN RETURN
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

	SETOM TIMEUP		;SET FLAG TO SAY TIME EXPIRED
	SETZRO LCBTID		;CLEAR OUT TIME INTERRUPT DISPATCH ADDRESS
	RET

	PAGE
	SUBTTL READIM - READ INTERRUPT MESSAGE

;HERE TO READ INTERRUPT MESSAGE

READIM:				;ENTRY AT INTERRUPT LEVEL
	STKVAR <IMPNTR,IMSIZ,SVPTR> ;STORAGE TO SAVE INTERRUPT MSG POINTER
	LOAD T1,LCBPIM		;GET POINTER TO INTERRUPT MESSAGE
	MOVEM T1,IMPNTR		;SAVE IT
	LOAD T1,LCBSZI		;GET CURRENT SIZE OF INT MSG
	MOVEM T1,IMSIZ		;SAVE IT
	MOVE T1,[POINT 8,IMBUF]	;GET POINTER TO INT MSG RECV BUFFER
	STOR T1,LCBPIM		;PUT IT IN LCB
	CALL RIMLNK		;GO READ INTERRUPT MESSAGE
	RETBAD LNKERR
	LOAD T3,LCBSZI		;GET SIZE WE RECEIVED
	CALL GTMSGL		;GET LENGTH WE SENT
	CAIN T3,(T1)		;EQUAL ?
	JRST READI1		;YES...
	PUSH P,T1		;NO
	PUSH P,T3
	PRTERR <INVALID INTERRUPT MESSAGE LENGTH RECEIVED - >
	POP P,T2
	CALL PRNUMV
	PRTINF <EXPECTED INTERRUPT MESSAGE LENGTH - >
	POP P,T2
	CALL PRNUMV
	JRST READI2
READI1:
	LOAD T1,LCBPIM		;POINT TO INTERRUPT MESSAGE RECEIVED
	MOVEI T2,4		;4 DIGIT SEQUENCE
	CALL LOAD11		;LOAD SEQUENCE NUMBER FROM MESSAGE
	MOVEM T1,SVPTR		;SAVE POINTER
	LOAD T3,LCBIRC		;GET RECEIVE COUNT FROM LCB
	CAMN T2,T3		;ARE THEY EQUAL ?
	JRST READI3		;YES...
	PUSH P,T3		;NO
	PUSH P,T2
	PRTERR <INTERRUPT ECHO SEQUENCE ERROR - >
	POP P,T2		;RESTORE RECEIVED COUNT
	CALL PRNUMV		;PRINT IT OUT
	PRTERR <EXPECTED INTERRUPT MESSAGE SEQUENCE NUMBER - >
	POP P,T2		;RESTORE EXPECTED COUNT
	CALL PRNUMV		;PRINT IT OUT
	JRST READI2
READI3:
	LOAD T3,LCBSZI		;GET LENGTH RECEIVED
	SUBI T3,4		;LESS THE 4 BYTE SEQ NUMBER
	MOVE T1,SVPTR		;RESTORE POINTER
	MOVE T2,STDPAT		;GET POINTER TO STANDARD
	CALL STRCMP		;COMPARE THEM
	PRTERR <INVALID INTERRUPT MESSAGE PATTERN RECEIVED>,,<$GOTO(READI2)>
	MOVE T1,IMPNTR		;RESTORE LCB STUFF
	STOR T1,LCBPIM
	MOVE T1,IMSIZ
	STOR T1,LCBSZI
	RET			;DONE

READI2:				;HERE ON ECHO ERROR DETECTED
	SETOM IEKERF		;SET ECHO ERROR FLAG
	RET

	PAGE
	SUBTTL READAT - READ DATA ROUTINE

;READAT - INTERRUPT LEVEL ROUTINE TO HANDLE DATA AVAILABLE INTERRUPTS
;	FOR INTERRUPT TESTS
;	IF DATA IS AVAILABLE IT READS IT

READAT:				;HERE WHEN DATA IS AVAILBLE
	CALL RLSLNK		;READ LINK STATUS
	RETBAD ERXLNK		;FAILED
	LOAD T1,LCBSTS		;GET STATUS
	TXNN T1,MO%CON		;CONNECTED ?
	JRST INTERR		;NO, GO SAY TEST ERROR
	LOAD T1,LCBJFN		;GET JFN FOR THIS LINK
	SIBE			;ANY DATA RECEIVED ?
	SKIPA			;YES, BUFFER NOT EMPTY, GO READ
	RET			;NO, RETURN WHEN NO MORE BYTES AVAILABLE

;READ DATA RECEIVED ON LINK
; T2 HAS NUMBER OF BYTES AVAILABLE

READA1:				;HERE WHEN DATA IN BUFFER FOR A LINK
	PRTERR <UNEXPECTED DATA RECEIVED>
	STOR   (T2,LCBCSZ)	;STORE NUMBER OF BYTES AVAILABLE
	MOVX T2,.NULIO		;JUST IGNORE ANY DATA WE GET
	STOR   T2,LCBRMB	;STORE BYTE POINTER FOR RECEIVE BUFFER IN LCB
	CALL   RCVLNK		;GO RECEIVE ON LINK
	RETBAD LNKERR		;FAILED, PRINT LINK ERROR, RETURN BAD
	JRST READAT		;GO TRY AGAIN


	PAGE

;HERE WHEN LINK DISCONNECT OCCURS, MEANS WE GOT AN ERROR
; SET FLAG TO SAY ERROR ENCOUNTERED AND LINK CLOSED

INTERR:				;HERE TO CLOSE LINK
	LOAD T1,LCBSTS		;GET STATUS
	PRTDCX <T1>,<INTERRUPT TEST ERROR - >
	RET

	PAGE
	SUBTTL LNKERR - LINK ERROR ROUTINE

LNKERR:				;HERE TO PRINT LINK ERROR ON JSYS FAILURE
	CALL ERXLNK		;PRINT OUT THE JSYS ERROR FOR LINK
	LOAD T1,LCBRSN		;GET NSP REASON CODE
	PRTDCX <T1>,<NSP REASON> ;PRINT OUT THE NSP ERROR TEXT
	RET			;AND RETURN

	PAGE
	SUBTTL STRCMP - STRING COMPARISON ROUTINE
;
;STRCMP - STRING COMPARE FOR ANY BYTE SIZE STRING, STRICTLY EQUAL COMPARE
;	  NO UPPER/LOWER CASE STUFF
;
;ACCEPTS: T1/ BYTE POINTER TO STRING 
;	  T2/ BYTE POINTER TO STING TO COMPARE WITH
;	  T3/ LENGTH TO COMPARE
;
;	CALL  STRCMP
;
;RETURNS+1: STRINGS UNEQUAL, T1,T2/ UPDATED
;	+2: STRINGS EQUAL
STRCMP:				;ENTRY
	STKVAR <STRPT1,STRPT2> ;VARIABLES
	MOVEM  T1,STRPT1	;SAVE POINTER TO FIRST STRING
	MOVEM  T2,STRPT2	;AND SECOND ALSO
STRCM1:				;LOOP THRU HERE FOR EACH BYTE OF STRINGS
	ILDB   T1,STRPT1	;GET BYTE FROM FIRST STRING
	ILDB   T2,STRPT2	;AND BYTE FROM SECOND
	CAME   T1,T2		;COMPARE THEM
	RET			;NOT EQUAL, RETURN +1
	SOJG   T3,STRCM1	;EQUAL, LOOP FOR NEXT BYTE
	MOVE   T1,STRPT1	;RESTORE UPDATED POINTERS
	MOVE   T2,STRPT2
	RETSKP			;DONE, RETURN

	PAGE
	SUBTTL LITERAL POOL AND CONSTANTS

	XLIST
LTPOOL:	LIT			;BEGINNING OF LITERAL POOL
	LIST

TIMEUP:	BLOCK 1			;FLAG FOR TIME EXPIRED

STDSEQ:	POINT 8,DTSQI		;POINTER TO SEQUENCED INTERRUPT MESSAGE

STDPAT:				;STANDARD DATA PATTERN FOR DTR
STDINT:	POINT 8,DTPAI		;POINTER TO STANDARD INTERRUPT MESSAGE

DTSQI:				;SEQUENCED INTERRUPT MESSAGE
	BYTE (8)0,0,0,0		;SEQUENCE NUMBER
DTPAI:				;STANDARD PATTERN
	BYTE (8)"A","B","C","D"
	BYTE (8)"E","F","G","H"
	BYTE (8)"I","J","K","L"
	BYTE (8)"M","N","O","P"

BT8TBL:				;TABLE OF 256 8 BIT BYTES
	TABLE8			;GENERATE THE TABLE

	PAGE
	SUBTTL VARIABLE DATA STORAGE

	VAR

COUNT:	BLOCK 1			;FOUR BYTE COUNT

;ECHO ERROR FLAG

IEKERF:	BLOCK 1			;ECHO ERROR OCCURRED

;LINK CLOSED FLAG

CLOSED:	BLOCK 1

;BUFFER FOR RECEIVED DATA

	MSGSIZ==1000
RDBUF:	BLOCK MSGSIZ
IMBUF:	BLOCK ^D16/4		;BUFFER FOR RECEIVED INT MSG

	END