Google
 

Trailing-Edge - PDP-10 Archives - de-10-omona-v-mc9 - ttdint.mac
There are 6 other files named ttdint.mac in the archive. Click here to see a list.
TITLE TTDINT - DRIVER FOR DTE20 TELETYPES - V4005
SUBTTL	ALLAN WILSON (VERSION 5 BY E. SOCCI)	13 JUN 78

	SEARCH	F,S,DTEPRM

;NOTE:
; IF ANY CHANGES ARE MADE TO DTEPRM THAT THIS MODULE MUST HAVE, UPDATE
; THE FOLLOWING SYMBOL TO THE VERSION OF DTEPRM THAT MUST BE USED
	PRMMIN==015
; THIS WAY, ASSEMBLING THIS MODULE WITH WRONG VERSION OF DTEPRM FOR SOME REASON
; (LIKE FORGETTING TO ASSEMBLE IT) WILL CAUSE ASSEMBLY TO TERMINATE.
; THIS SCHEME DOES NOT CAUSE EXTRA EDITING, SINCE ONLY FILES
; WHICH NEED THE CHANGES NEED PRMMIN TO BE UPDATED. MODULES
; THAT DO NOT NEED A NEW VERSION OF DTEPRM NEED NOT DEMAND IT.

IFL VDTPRM-PRMMIN,<PRINTX ?PLEASE USE LATEST VERSION OF DTEPRM
			PASS2
			END>

IFE FTNET,<PRINTX ? FTNET MUST BE ON FOR TTDINT
		PASS2
		END>

	$RELOC
	$HIGH
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1976,1977,1978 BY DIGITAL EQUIPMENT CORP., MAYNARD, MASS.

XP VTTDNT,4005
	SALL
	ENTRY	TTDINT

TTDINT::
SUBTTL	DISPATCH TABLES

	CPOPJ##				;(-1)
CT0DSP::EATMSG##			;(0)
	EATMSG##			;(1)
	EATMSG##			;(2)
	EATMSG##			;(3)
	CTYLND				;(4)TAKE LINE, CHAR
	EATMSG##			;(5)
	EATMSG##			;(6)
	EATMSG##			;(7)
	EATMSG##			;(10)
	EATMSG##			;(11)
	EATMSG##			;(12)
	EATMSG##			;(13)
	EATMSG##			;(14)
	EATMSG##			;(15)
	EATMSG##			;(16)
	CTYACK				;(17)ACK
	EATMSG##			;(20)
	EATMSG##			;(21)
	EATMSG##			;(22)
	EATMSG##			;(23)
	EATMSG##			;(24)
	CTYAAL				;(25)ACK ALL
	EATMSG##			;(26)
	EATMSG##			;(27)
	EATMSG##			;(30)
	EATMSG##			;(31)
	CPOPJ##				;(-1)
DLSDSP::EATMSG##			;(0)
	EATMSG##			;(1)
	EATMSG##			;(2)
	EATMSG##			;(3)
	DLSLND				;(4)TAKE LINE, CHAR
	EATMSG##			;(5)
	EATMSG##			;(6)
	EATMSG##			;(7)
	EATMSG##			;(10)
	EATMSG##			;(11)
	EATMSG##			;(12)
	EATMSG##			;(13)
	EATMSG##			;(14)
	TTDDWA				;(15)DATASET WAS ANSWERED
	TTDDHU				;(16)DATASET HUNG UP
	DLSACK				;(17)ACK
	EATMSG##			;(20)
	EATMSG##			;(21)
	TTDHLS				;(22)HERE ARE LINE SPEEDS
	EATMSG##			;(23)
	EATMSG##			;(24)
	DLSAAL				;(25)ACK ALL
	EATMSG##			;(26)
	EATMSG##			;(27)
	EATMSG##			;(30)
	EATMSG##			;(31)
;DISPATCH FOR SCNSER COMMUNICATION WITH TTDINT

TTDDSP::PJRST	TTDTYP			;GO TO CHARACTER OUTPUT ROUTINE
	PJRST	TTDDSC			;GO TO DATASET CONTROL ROUTINE
	PJRST	TTDCHK			;GO TO ONCE-A-SECOND ROUTINE
	PJRST	TTDINI			;GO TO INITIALIZATION ROUTINE
	PJRST	TTDCHP			;GO TO ROUTINE TO CHANGE H/W PARAMETERS
	POPJ	P,			;RETURN ON LINE PARAMETER CONTROL CALL
	POPJ	P,			;RETURN ON SET ELEMENT NUMBER CALL
	PJRST	TTDREM			;GO TO PROCESS REMOTE CALL
	PJRST	CPOPJ1##		;ALWAYS SAY ON-LINE


;DTE. UUO FUNCTION 21 - RETURN DL LINE NUMBER FOR GIVEN FE
;CALL WITH T1 = CPU #,,DTE # (REALLY 0,,DTE # SINCE CALLER
;			      WON'T LET NON-ZERO CPU NUMBER
;			      GET THROUGH)

TTDDLN::JUMPN	T1,TTDDL1		;IF NOT CONSOLE FRONT END
	HRLZ	T1,TTDOFS##+0		;KLINIK LINE TO LH (LINE 0 OF TTD GROUP 0)
	HRRI	T1,CTYLIN##		;CTY LINE NUMBER TO RH
	TDO	T1,[.UXTRM,,.UXTRM]	;CONVERT TO IONDX
	JRST	STOTC1##		;AND RETURN VALUE
TTDDL1:	ADD	T1,TTDOFS##+0		;OFFSET BY FIRST TTD LINE
	MOVEI	T1,.UXTRM(T1)		;CONVERT TO IONDX
	JRST	STOTC1##		;GOOD RETURN
SUBTTL	CHARACTER OUTPUT ROUTINE

;ROUTINE TO TYPE A CHAR ON AN ASYNC RSX-20F LINE
;ARGS:	U/LDB ADDRESS
;	T3/DATA
;CALL:	PUSHJ	P,TTDTYP
;	RETURN HERE

TTDTYP:	SKIPGE	LDBLAR##(U)		;ALREADY OVERRUN THE LINE?
	  POPJ	P,			;YES, THROW IT AWAY
	JSP	T4,SAVEJ		;SAVE J AND SET TO RESTORE ON POPJ
	HRRZ	J,LDBSS2##(U)		;SET J TO TTD DTE INDEX FROM LDB
	CONO	PI,PIOFF##		;ALLOW NO INTERRUPTS
	HLRZ	T1,TTDCTR##(J)		;GET "FUNCTION" PART OF DTE COUNTER WORD
	JUMPE	T1,TTDTP1		;IF ZERO, WE MUST START OUTPUT
	CAIE	T1,-1			;POST ROUTINE WANT OUTPUT FOR LINE?
	JRST   [TRO	T3,400		;NO--REMEMBER ZERO BYTE FOR IMAGE OUTPUT
		MOVEM	T3,LDBTTD##(U)	;SAVE CHAR FOR POST ROUTINE TO FIND
		PJRST	ONPOPJ##]	;ALLOW INTERRUPTS AND RETURN
	IDPB	T3,TTDPTR##(J)		;SAVE CHAR IN OUTPUT BUFFER FOR POST ROUTINE
	AOS	TTDCTR##(J)		;COUNT THE CHAR
	PJRST	ONPOPJ##		;ALLOW INTERRUPTS AND RETURN

TTDTP1:	HRLZM	U,TTDCTR##(J)		;MARK OUTPUT ROUTINE BUSY WITH THIS LINE
	CONO	PI,PION##		;INTERRUPTS ARE OK NOW
	AOS	TTDCTR##(J)		;INDICATE SINGLE CHAR TRANSFER
	IDPB	T3,TTDPTR##(J)		;SAVE THIS CHAR IN OUTPUT BUFFER
 	PJRST	TTDSND			;NOW SEND THE CHAR
SUBTTL	POST ROUTINE FOR STRING OUTPUT

;HERE FROM DTESER ON POST CALL FOR STRING OUTPUT

TTDPST:	HRRZ	U,S			;GET SAVED VALUE OF U (LDB ADDRESS)
	HRRZ	J,LDBSS2##(U)		;SET J TO TTD DTE INDEX FROM LDB
	HRRZ	T2,TTDCTR##(J)		;GET SIZE OF STRING SENT
	MOVNS	T2
	ADDM	T2,LDBLAR##(U)		;SAVE UPDATED ALLOCATION REMAINING
	MOVE	T1,TTDPNT##(J)		;GET POINTER TO STRING BUFFER
	MOVEM	T1,TTDPTR##(J)		;SAVE TO USE IF OUTPUT READY
TTDPS1:	SETZM	TTDCTR##(J)		;START STRING CHAR COUNT AT ZERO
	PUSHJ	P,TTDNXT		;FIND NEXT LINE TO DO OUTPUT FOR
	  POPJ	P,			;NOTHING TO DO NOW--RETURN
	HRROS	TTDCTR##(J)		;SIGNAL TTDTYP OUTPUT REQUEST FROM US
	HRRZ	T1,TTDCTR##(J)		;GET CHAR COUNT
	JUMPE	T1,TTDPS3		;IF ZERO, TRY FOR A CHARACTER
TTDPS2:	HRRZ	T1,TTDCTR##(J)		;GET CURRENT CHAR COUNT
	CAMGE	T1,LDBLAR##(U)		;USED REMAINING ALLOCATION YET?
	CAIL	T1,TTDMOS##		;NO--HAVE AS MANY CHARS AS WE WANT?
	JRST	TTDPS4			;YES--SEND WHAT WE'VE GOT
	SKIPL	LDBDCH##(U)		;NO--LINE HAVE OUTPUT IN PROGRESS?
	JRST	TTDPS4			;NO--SEND WHAT WE'VE GOT
TTDPS3:	PUSH	P,U			;SAVE LDB ADDRESS
	LDB	U,LDPLNO##		;SET U TO MONITOR LINE NUMBER
	PUSHJ	P,XMTINT##		;TELL SCNSER WE WANT MORE OUTPUT
	POP	P,U			;RESTORE LDB ADDRESS
	JRST	TTDPS2			;SEE IF WE SHOULD TRY FOR MORE

TTDPS4:	JUMPE	T1,TTDPS1		;IF NO CHARS, LOOK FOR ANOTHER LINE
	HRLM	U,TTDCTR##(J)		;REMEMBER LDB ADDRESS FOR ACTIVE LINE
	; ...				;FALL INTO TTDSND
SUBTTL	ROUTINE TO SEND (INDIRECT) STRING DATA

;ROUTINE TO SEND STRING DATA TO FRONT-END
;ARGS:	U/LDB ADDRESS
;	J/TTD DTE INDEX
;	TTDCTR(J)/COUNT OF CHARS IN INDIRECT STRING
;CALL:	PUSHJ	P,TTDSND
;	RETURN HERE

TTDSND:	PUSHJ	P,SAVE4##		;SAVE P1-P4
	MOVE	P1,ATCPDT##(J)		;SET P1 TO CPU#,,DTE#
	MOVE	P2,[.EMDLS,,EM.IND+.EMSTR] ;OUTPUT INDIRECT STRING TO DLS
	LDB	T1,LDPLNO##		;GET MONITOR LINE NUMBER
	SUB	T1,TTDOFS##(J)		;CONVERT TO TTD LINE NUMBER
	MOVSI	P3,OFSDLS##(T1)		;MAKE LH(P3) THE DLS LINE NUMBER
	HRR	P3,TTDCTR##(J)		;SET P3 TO DLS LINE #,,COUNT
	MOVE	P4,TTDPNT##(J)		;GET POINTER TO INDIRECT STRING
	MOVSI	S,TTDPST		;POST ADDRESS
	HRR	S,U			;REMEMBER LDB ADDRESS
	PUSHJ	P,DTEQUE##		;QUEUE THE REQUEST
	  JFCL				;FAILED--LET ACK ALL RESTART OUTPUT
	POPJ	P,			;RETURN
SUBTTL	ROUTINE TO FIND ACTIVE OUTPUT LINE

;HERE FROM TTDPST TO LOOK FOR AN ACTIVE OUTPUT LINE
;ARGS:	U/LDB ADDRESS
;	J/TTD DTE INDEX
;CALL:	PUSHJ	P,TTDNXT
;	  RETURN HERE IF NO ACTIVE LINE FOUND
;	RETURN HERE IF LINE FOUND, ITS LDB ADDRESS IN U

TTDNXT:	LDB	T2,LDPLNO##		;GET CURRENT MONITOR LINE NUMBER
TTDNX1:	ADDI	T2,1			;STEP TO NEXT LINE
	CAML	T2,TTDLOM##(J)		;LINE STILL WITHIN THIS TTD GROUP?
	MOVE	T2,TTDOFS##(J)		;NO--WRAP AROUND
	HRRZ	T1,LINTAB##(T2)		;GET LDB ADDRESS
	SKIPN	T3,LDBTTD##(T1)		;ANY SAVED CHAR?
	JRST	TTDNX2			;NO
	SETZM	LDBTTD##(T1)		;YES--REMEMBER CHAR TAKEN
	IDPB	T3,TTDPTR##(J)		;SAVE CHAR IN STRING BUFFER
	AOS	TTDCTR##(J)		;COUNT THE CHAR
	JRST	TTDNX3			;SET U AND SKIP RETURN

TTDNX2:	SKIPLE	LDBLAR##(T1)		;HAS LINE REACHED MAXIMUM ALLOCATION?
	SKIPL	LDBDCH##(T1)		;NO--LINE HAVE OUTPUT IN PROGRESS?
	JRST	TTDNX4			;YES/NO
TTDNX3:	HRRZ	U,T1			;YES--SET U TO LDB ADDRESS OF LINE
	PJRST	CPOPJ1##		;SKIP RETURN

TTDNX4:	CAME	T1,U			;BACK TO ORIGINAL LINE?
	JRST	TTDNX1			;NO--TRY NEXT LINE
	POPJ	P,			;YES--RETURN, NOTHING FOUND TO DO
SUBTTL	DATASET CONTROL

;SUBROUTINE TO EXERCISE CONTROL OVER A DATASET
;ARGS:	U/DSCTAB INDEX
;	T3/TRANSACTION CODE
;CALL:	PUSHJ	P,TTDDSC
;	RETURN HERE

TTDDSC:	CAIN	T3,DSTON##		;WANT TO TURN DATASET ON?
	POPJ	P,			;YES--ALREADY DONE BY RSX-20F
	CAIN	T3,DSTOFF##		;WANT TO TURN IT OFF?
	PJRST	TTDHUD			;YES--TELL RSX-20F TO HANG UP DATASET
	CAIN	T3,DSTREQ##		;WANT TO KNOW STATUS?
	MOVEI	T3,DSTNAC##		;YES--TELL SYSINI NOT TO TAKE ACTION
	POPJ	P,			;RETURN

TTDHUD:	JSP	T4,SAVEJ		;SAVE J AND SET TO RESTORE ON POPJ
	HRRZ	J,DSCTAB##(U)		;GET MONITOR LINE NUMBER
	HRRZ	J,LINTAB##(J)		;GET ITS LDB ADDRESS
	HRRZ	J,LDBSS2##(J)		;SET J TO TTD DTE INDEX FROM LDB
	PUSHJ	P,SAVE4##		;SAVE P1-P4
	MOVE	P1,ATCPDT##(J)		;SET P1 TO CPU#,,DTE#
	MOVE	P2,[.EMDLS,,.EMHUD]	;HANG UP DATASET FOR DLS LINE
	HRRZ	P3,DSCTAB##(U)		;GET MONITOR LINE NUMBER
	SUB	P3,TTDOFS##(J)		;CONVERT TO TTD LINE NUMBER
	MOVSI	P3,OFSDLS##(P3)		;SET P3 TO DLS LINE #,,0
	SETZB	P4,S			;NO BYTE POINTER OR POST ROUTINE
	PUSHJ	P,DTEQUE##		;QUEUE THE REQUEST
	  JFCL				;FAILED--JUST IGNORE
	POPJ	P,			;RETURN
SUBTTL	ROUTINE TO CHANGE HARDWARE PARAMETERS

;SUBROUTINE TO SET UP EVERYTHING ACCORDING TO LDB
;ARGS:	U/LDB ADDRESS
;CALL:	PUSHJ	P,TTDCHP
;	RETURN HERE

TTDCHP:	JSP	T4,SAVEJ		;SAVE J AND SET TO RESTORE ON POPJ
	HRRZ	J,LDBSS2##(U)		;SET J TO TTD DTE INDEX FROM LDB
	PUSHJ	P,SAVE4##		;SAVE P1-P4
	MOVEI	T1,LRSXOF##		;GET TTD XOF BIT
	SKIPL	LDBPAG##(U)		;OUTPUT STOPPED (^S)?
	JRST	TTDCH1			;NO--NOT ^S
	TDNE	T1,LDBSS1##(U)		;YES--DID WE KNOW THAT?
	PJRST	TTDSSP			;YES--SET SPEED
	IORM	T1,LDBSS1##(U)		;NO--REMEMBER ^S
	PUSHJ	P,TTDXOF		;SEND XOF MESSAGE FOR LINE
	PJRST	TTDSSP			;SET SPEED

TTDCH1:	TDNN	T1,LDBSS1##(U)		;NOT ^S; DID WE THINK IT WAS?
	PJRST	TTDSSP			;NO--SET SPEED
	ANDCAM	T1,LDBSS1##(U)		;YES--REMEMBER ^Q
	PUSHJ	P,TTDXON		;SEND XON MESSAGE FOR LINE
	; ...				;FALL INTO TTDSSP
SUBTTL	SET LINE SPEEDS

;HERE TO SET SPEEDS FOR RSX-20F FRONT-END LINE
;ARGS:	U/LDB ADDRESS
;	J/TTD DTE INDEX
;CALL:	SAVE P1-P4
;	PUSHJ	P,TTDSSP
;	RETURN HERE

TTDSSP:	MOVEI	S,0			;NO POST ADDRESS OR VALUE TO SAVE
TTDSS1:	MOVE	T3,[POINT ^D16,LDBSS1##(U)] ;POINT TO PLACE IN LDB
	LDB	T1,LDPRSP##		;GET CODE FOR LINE RECEIVE SPEED
	MOVE	T1,TTDSPD(T1)		;CONVERT TO BAUD
	IDPB	T1,T3			;SAVE IN LDB
	LDB	T1,LDPTSP##		;GET CODE FOR LINE TRANSMIT SPEED
	MOVE	T1,TTDSPD(T1)		;CONVERT TO BAUD
	IDPB	T1,T3			;SAVE IN LDB
	MOVEI	T2,1			;ASSUME ONE STOP BIT
	CAIG	T1,^D110		;LESS THAN OR EQUAL TO 110 BAUD?
	MOVEI	T2,2			;YES--SO USE TWO STOP BITS
	MOVE	T1,LDBDCH##(U)		;GET LINE CHARACTERISTICS WORD
	TRNE	T1,LDRDSD##		;DATASET LINE?
	JRST   [MOVEI	T1,LRSRBS##	;YES--GET "REMOTE BIT SENT" BIT
		TDNE	T1,LDBSS1##(U)	;REMOTE BIT ALREADY SENT?
		JRST	.+1		;YES--BACK TO MAIN CODE
		IORM	T1,LDBSS1##(U)	;NO--MARK IT SENT AS OF NOW
		TRO	T2,140000	;SET REMOTE AND AUTO BAUD IN LINE-SPEED ARGUMENT
		JRST	.+1]		;BACK TO MAIN CODE
	IDPB	T2,T3			;STORE ARGUMENT
	MOVE	P1,ATCPDT##(J)		;SET P1 TO CPU#,,DTE#
	MOVE	P2,[.EMDLS,,EM.16B+EM.IND+.EMHLS] ;SET DLS LINE SPEEDS
	LDB	P3,LDPLNO##		;GET MONITOR LINE NUMBER
	SUB	P3,TTDOFS##(J)		;CONVERT TO TTD LINE NUMBER
	MOVSI	P3,OFSDLS##(P3)		;CONVERT TO DLS LINE NUMBER
	HRRI	P3,6			;SIX BYTES OF ARGUMENT
	MOVSI	P4,(POINT ^D16,)	;GET LH OF BYTE POINTER
	HRRI	P4,LDBSS1##(U)		;FILL IN RH
	PUSHJ	P,DTEQUE##		;QUEUE THE REQUEST
	  JFCL				;FAILED--JUST IGNORE
	POPJ	P,			;RETURN



;NOTE:	THE NONSENSE WITH THE LRSRBS BIT IN THE CODE ABOVE IS NECESSITATED
;BY A QUIRK OF THE RSX-20F FRONT-END.  THE REMOTE BIT IN A LINE-SPEED
;MESSAGE SHOULD BE SENT ONLY ONCE; IF IT'S SENT AGAIN AFTER A USER HAS
;DIALED-IN, IT CAUSES THE DATASET TO BE DISCONNECTED.  OTHERWISE, THE REMOTE BIT
;IN A LINE-SPEED MESSAGE COULD ALWAYS BE SET FOR DATASET LINES.
SUBTTL	TAKE LINE SPEEDS FROM FRONT-END

;HERE FROM DTESER WHEN RSX-20F SENDS LINE SPEEDS

TTDILS:	TDZA	S,S			;HERE ON COMPLETION OF INDIRECT TRANSFER
TTDHLS:	MOVSI	S,TTDILS		;HERE ON START OF MESSAGE
	JSP	T4,SETJ			;SET J TO TTD DTE INDEX
	  PJRST	EATMSG##		;FAILED--IGNORE THIS MESSAGE
	HLRZ	T1,P3			;GET DLS LINE NUMBER
	JSP	T4,DLSMON		;CONVERT TO MONITOR LINE NUMBER IN U
	  PJRST	EATMSG##		;OUT OF RANGE--IGNORE THIS MESSAGE
	HRRZ	U,LINTAB##(U)		;GET LDB ADDRESS
	MOVSI	P4,(POINT ^D16,)	;GET LH OF BYTE POINTER
	HRRI	P4,LDBSS1##(U)		;FILL IN RH
	JUMPE	S,TTDIL1		;BRANCH IF HAVE INDIRECT DATA
	MOVEI	P3,6			;WE WANT 6 8-BIT BYTES
	POPJ	P,			;RETURN

TTDIL1:	ILDB	T1,P4			;GET LINE TRANSMIT SPEED IN BAUD
	JSP	T4,FNDSPD		;SET T1 TO CODED SPEED VALUE
	DPB	T1,LDPTSP##		;SAVE IN LDB
	ILDB	T1,P4			;GET LINE RECEIVE SPEED IN BAUD
	JSP	T4,FNDSPD		;SET T1 TO CODED SPEED VALUE
	DPB	T1,LDPRSP##		;SAVE IN LDB
	SETZB	P3,P4			;TELL DTESER WE'RE DONE
	POPJ	P,			;RETURN

;ROUTINE TO FIND CODED VALUE OF LINE SPEED IN BAUD
;ARGS:	T1/SPEED IN BAUD
;CALL:	JSP	T4,FNDSPD
;	RETURN HERE, CODED VALUE IN T1

FNDSPD:	MOVSI	T2,-TTDSTS		;MAKE AOBJN POINTER
	CAME	T1,TTDSPD(T2)		;IS THIS THE SPEED?
	AOBJN	T2,.-1			;NO--TRY NEXT ONE
	SKIPL	T2			;MAYBE--POINTER STILL VALID?
	MOVEI	T2,0			;NO--INVALID SPEED, BUT SAY 0
	HRRZ	T1,T2			;PUT CODE IN T1
	JRST	0(T4)			;RETURN
SUBTTL	LINE SPEED TABLE

;TABLE OF LINE SPEEDS IN BAUD

TTDSPD:	0				;(0) ZERO BAUD
	^D50				;(1) 50 BAUD
	^D75				;(2) 75 BAUD
	^D110				;(3) 110 BAUD
	^D134				;(4)
	^D150				;(5)
	^D200				;(6)
	^D300				;(7)
	^D600				;(10)
	^D1200				;(11)
	^D1800				;(12)
	^D2400				;(13)
	^D4800				;(14)
	^D9600				;(15)
TTDSTS==.-TTDSPD			;SPEED TABLE SIZE
SUBTTL	XOFF/XON (^S/^Q) PROCESSING

;ROUTINE TO SEND XOFF/XON FOR ^S/^Q ON AN RSX-20F LINE
;ARGS:	U/LDB ADDRESS
;	J/TTD DTE INDEX
;CALL:	SAVE P1-P4
;	PUSHJ	P,TTDXXX	WHERE XXX IS XOF OR XON
;	RETURN HERE

TTDXOF:	SKIPA	P2,[.EMDLS,,.EMXOF]	;XOF FOR DLS
TTDXON:	MOVE	P2,[.EMDLS,,.EMXON]	;XON FOR DLS
	MOVE	P1,ATCPDT##(J)		;SET P1 TO CPU#,,DTE#
	LDB	P3,LDPLNO##		;GET MONITOR LINE NUMBER
	SUB	P3,TTDOFS##(J)		;CONVERT TO TTD LINE NUMBER
	MOVEI	P3,OFSDLS##(P3)		;PUT DLS LINE NUMBER IN P3
	SETZB	P4,S			;NO BYTE POINTER OR POST ROUTINE
	PUSHJ	P,DTEQUE##		;QUEUE THE REQUEST
	  JFCL				;FAILED--IGNORE IT
	POPJ	P,			;RETURN
SUBTTL	PROCESS SCNSER ISRREM CALLS

;HERE ON ISRREM CALLS FROM SCNSER
;ARGS:	U/LDB ADDRESS
;	T3/CODE
;WHERE CODE =	1	FOR BUFFER LOW
;		2	FOR CHARACTER NOT STORED
;		3	FOR ^O PROCESSING
;CALL:	PUSHJ	P,TTDREM
;	RETURN HERE

TTDREM:	CAIL	T3,1			;VALIDATE RANGE OF CODE
	CAILE	T3,3			; ...
	POPJ	P,			;OUT OF RANGE--IGNORE
	PJRST	@.(T3)			;VALID--DISPATCH
	EXP	TTDBFL			;BUFFER LOW
	EXP	TTDCNS			;CHARACTER NOT STORED
	EXP	TTDCTO			;CONTROL-O

;TWO ARE NO-OPS

TTDBFL==CPOPJ##
TTDCNS==CPOPJ##

;HERE FOR ^O PROCESSING

TTDCTO:	JSP	T4,SAVEJ		;SAVE J AND SET TO RESTORE ON POPJ
	HRRZ	J,LDBSS2##(U)		;SET J TO TTD DTE INDEX FROM LDB
	SETZM	LDBTTD##(U)		;CLEAR ANY SAVED CHAR IN LDB
	SETZM	LDBLAR##(U)		;SAY LINE IS WAITING FOR ACK
	PUSHJ	P,SAVE4##		;SAVE P1-P4
	MOVE	P1,ATCPDT##(J)		;SET P1 TO CPU#,,DTE#
	MOVE	P2,[.EMDLS,,.EMFLO]	;FLUSH OUTPUT FOR DLS LINE
	LDB	T1,LDPLNO##		;GET MONITOR LINE NUMBER
	SUB	T1,TTDOFS##(J)		;CONVERT TO TTD LINE NUMBER
	MOVEI	P3,OFSDLS##(T1)		;P3 IS DLS LINE NUMBER
	SETZB	P4,S			;NO BYTE POINTER OR POST ROUTINE
	PUSHJ	P,DTEQUE##		;QUEUE THE REQUEST
	  JFCL				;FAILED--IGNORE IT
	MOVEI	T1,LRSXOF##		;TTD XOF BIT
	ANDCAM	T1,LDBSS1##(U)		;PRETEND XON
	PJRST	TTDXON			;TELL CFE
SUBTTL	HANDLE DATASET(S) ANSWERED

;HERE FROM DTESER WHEN A DATASET WAS ANSWERED BY RSX-20F

TTDDWA:	JSP	T4,SETJ			;SET J TO TTD DTE INDEX
	  PJRST	EATMSG##		;COULDN'T--IGNORE THIS MESSAGE
TTDDW1:	SUBI	P3,2			;ACCOUNT FOR TWO BYTES/ARGUMENT
	JUMPL	P3,CPOPJ##		;RETURN WHEN COUNT EXHAUSTED
	ILDB	U,P4			;GET DLS LINE NUMBER
	IBP	P4			;MOVE PAST UNUSED BYTE
	JSP	T4,TTDCDD		;CONVERT DLS LINE # TO DSCTAB INDEX
	  JRST	TTDDW1			;OUT OF RANGE--LOOP FOR NEXT ARGUMENT
	MOVEI	T3,DSTRNG##		;GET CODE FOR PHONE RANG
	PUSHJ	P,DSCREC##		;CALL SCNSER
	MOVEI	T3,DSTON##		;RSX-20F ALREADY HAS DATASET ON
	PUSHJ	P,DSCREC##		;TELL SCNSER
	JRST	TTDDW1			;LOOP FOR NEXT ARGUMENT
SUBTTL	HANDLE DATASET(S) HUNG UP

;HERE FROM DTESER ON DATASET(S) HUNG UP

TTDDHU:	JSP	T4,SETJ			;SET J TO TTD DTE INDEX
	  PJRST	EATMSG##		;COULDN'T--IGNORE THIS MESSAGE
TTDDH1:	SUBI	P3,2			;ACCOUNT FOR TWO BYTES/ARGUMENT
	JUMPL	P3,CPOPJ##		;RETURN IF COUNT EXHAUSTED
	ILDB	U,P4			;GET DLS LINE NUMBER
	IBP	P4			;MOVE PAST UNUSED BYTE
	JSP	T4,TTDCDD		;CONVERT DLS LINE # TO DSCTAB INDEX
	  JRST	TTDDH1			;OUT OF RANGE--LOOP FOR NEXT ARGUMENT
	MOVEI	T3,DSTOFF##		;GET CODE FOR DATASET OFF
	PUSHJ	P,DSCREC##		;TELL SCNSER
	JRST	TTDDH1			;LOOP FOR NEXT ARGUMENT
SUBTTL	RECEIVE LINE DATA FROM RSX-20F

;HERE TO HANDLE CHARACTER DATA FROM RSX-20F
;THIS ROUTINE PROCESSES "MULTIPLEXED" INPUT (DATA,LINE,DATA,LINE,...)

DLSLND:	JSP	T4,SETJ			;SET J TO TTD DTE INDEX
	  PJRST	EATMSG##		;COULDN'T--IGNORE THIS MESSAGE
DLSLN1:	SUBI	P3,2			;DECREMENT COUNT BY 2
	JUMPL	P3,CPOPJ##		;RETURN IF DONE
	ILDB	T3,P4			;GET DATA
	ILDB	T1,P4			;GET DLS LINE NUMBER
	JSP	T4,DLSMON		;CONVERT TO MONITOR LINE NUMBER IN U
	  JRST	DLSLN1			;OUT OF RANGE--LOOP FOR NEXT ARGUMENT
	PUSHJ	P,RECINT##		;CALL SCNSER
	JRST	DLSLN1			;LOOP FOR MORE
SUBTTL	PROCESS NORMAL ACK MESSAGE FOR TERMINALS

;HERE FROM DTESER ON ACK MESSAGE FOR CTY

CTYACK:	SUBI	P3,2			;ACCOUNT FOR TWO BYTES/ARGUMENT
	JUMPL	P3,CPOPJ##		;RETURN WHEN COUNT EXHAUSTED
	ILDB	T1,P4			;GET LINE NUMBER
	IBP	P4			;MOVE PAST UNUSED BYTE
	MOVEI	U,TCONLN##		;GET MONITOR CTY LINE NUMBER
	SKIPN	T1			;IS THIS CTY NUMBER (0) FOR DLS?
	PUSHJ	P,XMTINT##		;YES--CALL SCNSER
	JRST	CTYACK			;LOOP FOR NEXT ARGUMENT



;HERE TO PROCESS ACK MESSAGE FOR DLS LINES

DLSACK:	JSP	T4,SETJ			;SET J TO TTD DTE INDEX
	  PJRST	EATMSG##		;COULDN'T--IGNORE THIS MESSAGE
DLSAC1:	SUBI	P3,2			;DECREMENT COUNT BY 2
	JUMPL	P3,CPOPJ##		;RETURN WHEN COUNT EXHAUSTED
	ILDB	T1,P4			;GET DLS LINE NUMBER
	IBP	P4			;MOVE PAST UNUSED BYTE
	JSP	T4,DLSMON		;GET MONITOR LINE NUMBER IN U
	  JRST	DLSAC1			;OUT OF RANGE--LOOP FOR NEXT ARGUMENT
	HRRZ	T1,LINTAB##(U)		;GET LDB ADDRESS OF LINE
	MOVEI	T2,TTDMLA##		;THIS IS LINE ALLOCATION
	SKIPLE	LDBLAR##(T1)		;THIS LINE WAITING FOR ACK?
	JRST   [MOVEM	T2,LDBLAR##(T1)	;NO, SAY FULL ALLOCATION ANYWAY
		CAIN	U,TCONLN##	;IS IT THE CTY?
		PUSHJ	P,XMTINT##	;YES--TELL SCNSER TRANSMIT DONE
		JRST	DLSAC1]		;LOOP FOR NEXT ARGUMENT
	MOVEM	T2,LDBLAR##(T1)		;SIGNAL LINE ACKED
	PUSHJ	P,XMTINT##		;TELL SCNSER TRANSMIT DONE
	JRST	DLSAC1			;LOOP FOR NEXT ARGUMENT
SUBTTL	ACK ALL PROCESSING FOR RSX-20F TERMINALS

;HERE TO HANDLE ACK ALL MESSAGE FOR DLS LINES

DLSAAL:	JSP	T4,SETJ			;SET J TO TTD DTE INDEX
	  POPJ	P,			;COULDN'T
	PUSHJ	P,SAVE4##		;SAVE SOME REGS
	SETZM	TTDCTR##(J)		;MARK OUTPUT ROUTINE AVAILABLE
	MOVE	T1,TTDOFS##(J)		;GET STARTING LINE NUMBER FOR TTD GROUP
	PUSHJ	P,DLSAA3		;SET THE LINE SPEED FOR THIS LINE
	MOVE	T1,TTDOFS##(J)		;GET STARTING LINE NUMBER AGAIN
DLSAA1:	CAML	T1,TTDLOM##(J)		;STILL IN THIS TTD GROUP?
	  POPJ	P,			;NO--WE'RE DONE
	HRRZ	U,LINTAB##(T1)		;YES--GET LDB ADDRESS
	MOVEI	T2,TTDMLA##		;GET MAX LINE ALLOCATION
	MOVEM	T2,LDBLAR##(U)		;SIGNAL LINE ACKED
	AOJA	T1,DLSAA1		;LOOP FOR NEXT LINE

; HERE ON POST OF SET LINE SPEED

DLSAA2:	JSP	T4,SETJ			;GET TTD DTE INDEX
	  POPJ	P,			;COULDN'T
	HLRZ	T1,P3			;GET LINE NUMBER
	ADD	T1,TTDOFS##(J)		;CONVERT TO SYSTEM LINE NUMBER
	ADDI	T1,1-OFSDLS##		;GO TO NEXT LINE
	CAML	T1,TTDLOM##(J)		;IF NO MORE LINES,
	  POPJ	P,			;THEN DONE
DLSAA3:	MOVE	U,LINTAB##(T1)		;GET LDB ADDRESS
	SETZM	LDBSS1##(U)		;DON'T KNOW LINE SPEEDS
	HRLI	S,DLSAA2		;THEN CALL ME AGAIN
	PJRST	TTDSS1			;GO SET THIS LINE SPEED



;HERE TO HANDLE ACK ALL FOR CTY

CTYAAL:	MOVEI	U,TCONLN##		;GET MONITOR CTY LINE NUMBER
	PJRST	XMTINT##		;TELL SCNSER TRANSMIT DONE
SUBTTL	OTHER CTY ROUTINES

;HERE FOR CTY INITIALIZATION. TURN IRMA CATCHER OFF, SINCE
; RSX20 IS IN THE HABIT OF IGNORING CTY OUTPUT AND WILL GET
; UPSET IF WE SHOVE CHARACTERS DOWN ITS LITTLE THROAT . . .

CT0INI==:CPOPJ##		;NO INITIALIZATION REQUIRED

;HERE FOR CTY OUTPUT
CTYTYO::PUSHJ	P,SKPMPP##	;IS MASTER RUNNING PRIMARY PROTOCOL?
	  PJRST	SPCTYO##	;NO, TYPE OUT WITH SECONDARY PROTOCOL


	PUSHJ	P,SAVE4##	;SAVE ACS
	MOVE	P3,T3		;SAVE CHAR
	PUSHJ	P,SVEPTD##	;GET MASTER ETD ADDRESS
	MOVE	T3,P3		;RESTORE CHAR
	LOAD.	P1,ED.DTN,(F)	;GET DTE NUMBER OF MASTER
	MOVE	P2,[.EMCTY,,EM.IND+.EMSTR] ;OUTPUT STRING TO CTY
	MOVEI	P3,1		;COUNT OF 1
	MOVE	P4,[POINT 8,CTYCHR]	;POINTER TO LITTLE BUFFER
	MOVEI	S,'FOO'		;NO POST ADDRESS, TEST DATA
	MOVE	T1,P4		;GET COPY OF POINTER
	IDPB	T3,T1		;STORE CHAR
	PUSHJ	P,DTEQUE##	;QUEUE UP REQUEST
	  JFCL			;IGNORE ERROR FOR NOW
				; (LET ACK ALL TAKE LINE OUT OF OUTPUT WAIT)
	POPJ	P,		;RETURN

	$LOW
CTYCHR:	BLOCK	1		;PLACE FOR CTY CHARACTER
	$HIGH


CTYLND:	SUBI	P3,2		;ACCOUNT FOR TWO BYTES/ARGUMENT
	JUMPL	P3,CPOPJ##	;RETURN IF COUNT EXHAUSTED
	ILDB	T3,P4		;GET DATA (???)
	IBP	P4		;FIX UP POINTER
	MOVEI	U,TCONLN##	;GET CTY LINE NUMBER
	PUSHJ	P,RECINT##	;CALL SCNSER
	JRST	CTYLND		;LOOP FOR ANY MORE
SUBTTL	ONCE A SECOND ROUTINES

;HERE ONCE A SECOND (CALLED THROUGH ISRCHK DISPATCH)

TTDCHK:	MOVEI	T1,ST.NRL		;GET BIT FOR NO REMOTE LOGINS
	TDNE	T1,STATES##		;REMOTE LOGINS ALLOWED?
	JRST	TTDCK1			;NO--NOT ALLOWED
	SKIPN	TTDADF			;YES--DID WE KNOW THAT?
	POPJ	P,			;YES--RETURN
	SETZM	TTDADF			;NO--REMEMBER IT
	PJRST	TTDAAD			;TELL RSX-20F ALLOWED TO ANSWER DATASETS

TTDCK1:	SKIPE	TTDADF			;NO REMOTE LOGINS ALLOWED--WE THINK THEY WERE?
	POPJ	P,			;NO--RETURN
	SETOM	TTDADF			;YES--REMEMBER NOT ALLOWED
	PJRST	TTDDAD			;TELL RSX-20F DON'T ANSWER DATASETS

	$LOW				;DOWN TO LOW SEGMENT
TTDADF:	EXP	-1			;ANSWER DATASETS FLAG (FOLLOWS ST.NRL
					; IN SYSTEM STATES WORD)
	$HIGH				;BACK TO HIGH SEGMENT
;ROUTINES TO SEND ENABLE/DISABLE DATASETS MESSAGE TO RSX-20F FRONT-ENDS
;CALL:	PUSHJ	P,TTDXXX		WHERE XXX IS AAD OR DAD
;	RETURN HERE

TTDAAD:	TDZA	J,J			;ZERO MEANS ENABLE TO ANSWER DATASETS
TTDDAD:	MOVEI	J,1			;NON-ZERO MEANS DON'T ANSWER DATASETS
	PUSHJ	P,SAVE4##		;SAVE P1-P4
	MOVE	P2,[.EMDH1,,.EMEDR]	;ENABLE/DISABLE DATASETS FOR DH11 LINES
	MOVE	P3,J			;GET APPROPRIATE DATA
	SETZB	P4,S			;NO BYTE POINTER OR POST ROUTINE
	MOVSI	J,-RSXATN##		;MAKE AOBJN POINTER
TTDEDR:	MOVE	P1,ATCPDT##(J)		;GET CPU#,,DTE#
	PUSHJ	P,DTEQUE##		;QUEUE THE REQUEST
	  JFCL				;IGNORE ANY FAILURE
	AOBJN	J,TTDEDR		;LOOP IF MORE FRONT-ENDS
	POPJ	P,			;DONE--RETURN
SUBTTL	INITIALIZATION FOR TTDINT

;HERE ON ISRINI CALL

TTDINI:	SETZM	LDBTTD##(U)		;NO SAVED CHAR
	SETZM	LDBLAR##(U)		;LINE INACTIVE FOR OUTPUT
	MOVEI	T1,LDRSHC##		;BIT TO SUPPRESS IRMA
	IORM	T1,LDBDCH##(U)		;SET IT FOR THIS LINE
	MOVEI	T1,LRSXOF##		;GET RSX-20F ^S BIT
	ANDCAM	T1,LDBSS1##(U)		;CLEAR IT IN LDB
	SETZM	TTDCLR##		;CLEAR FIRST WORD OF TTD STORAGE
	MOVE	T1,[TTDCLR##,,TTDCLR##+1] ;GET BLT POINTER
	BLT	T1,TTDEND##		;CLEAR AREA
	MOVE	T1,[TTDPNT##,,TTDPTR##]	;POINT TO STATIC AND DYNAMIC POINTERS
	BLT	T1,TTDPTR##+RSXATN##-1	;MAKE COPY OF STATIC POINTERS
	POPJ	P,			;RETURN
SUBTTL	COMMON SUBROUTINES FOR TTDINT

;ROUTINE TO SAVE J THEN SET IT TO TTD DTE INDEX
;ARGS:	P1/CPU#,,DTE# (AS SUPPLIED BY DTESER)
;CALL:	JSP	T4,SETJ
;	  RETURN HERE IF UNABLE TO SET INDEX
;	RETURN HERE IF SUCCESSFUL, J SET TO TTD DTE INDEX

SETJ:	PUSH	P,J			;SAVE J
	MOVSI	J,-RSXATN##		;MAKE AOBJN POINTER
	CAME	P1,ATCPDT##(J)		;IS IT THIS ONE?
	AOBJN	J,.-1			;NO--LOOP IF MORE
	JUMPGE	J,JEXIT			;MAYBE--FAIL RETURN IF POINTER INVALID
	TLZ	J,-1			;CLEAR LH(J)
	AOJA	T4,JEXIT		;SKIP RETURN



;ROUTINE TO SAVE J AND RESTORE IT ON EXIT OF MAIN ROUTINE
;CALL:	JSP	T4,SAVEJ
;	RETURN HERE

SAVEJ:	PUSH	P,J			;SAVE J
JEXIT:	PUSHJ	P,(T4)			;FINISH CALLING ROUTINE AND RETURN TO US
	  PJRST	JPOPJ##			;RESTORE J AND NON-SKIP RETURN
	PJRST	JPOPJ1##		;RESTORE J AND SKIP RETURN
;ROUTINE TO CONVERT DLS LINE NUMBER TO MONITOR LINE NUMBER AND RANGE CHECK
;ARGS:	T1/DLS LINE NUMBER
;	J/TTD DTE INDEX
;CALL:	JSP	T4,DLSMON
;	  RETURN HERE IF LINE NUMBER OUT OF RANGE
;	RETURN HERE IF SUCCESSFUL, MONITOR LINE NUMBER IN U

DLSMON:	LOAD.	T2,ED.CTN,(F)		;GET CTY DLS NUMBER
	MOVEI	U,TCONLN##		;ASSUME CTY
	CAMN	T1,T2			;WERE WE RIGHT?
	JRST	1(T4)			;YES--SKIP RETURN
	MOVEI	U,-OFSDLS##(T1)		;NO--MAKE U TTD LINE NUMBER
	ADD	U,TTDOFS##(J)		;CONVERT TO MONITOR LINE NUMBER
	CAML	U,TTDLOM##(J)		;IN RANGE?
	JRST	0(T4)			;NO--NON-SKIP RETURN
	JRST	1(T4)			;YES--SKIP RETURN



;ROUTINE TO CONVERT DLS LINE # TO DSCTAB INDEX AND RANGE CHECK
;ARGS:	U/DLS LINE NUMBER
;	J/TTD DTE INDEX
;CALL:	JSP	T4,TTDCDD
;	  RETURN HERE IF OUT OF RANGE
;	RETURN HERE IF VALID, DSCTAB INDEX IN U

TTDCDD:	SUBI	U,OFSDLS##		;CONVERT DLS LINE # TO TTD LINE #
	ADD	U,TTDDSO##(J)		;GET DSCTAB INDEX
	CAML	U,TTDDOM##(J)		;IN RANGE?
	JRST	0(T4)			;NO--NON-SKIP RETURN
	JRST	1(T4)			;YES--SKIP RETURN
	END