Google
 

Trailing-Edge - PDP-10 Archives - bb-y393c-sm - monitor-sources/ttdzdv.mac
There are 21 other files named ttdzdv.mac in the archive. Click here to see a list.
;Edit 2913 - Fix hung lines problem
; UPD ID= 113, FARK:<4-1-WORKING-SOURCES.MONITOR>TTDZDV.MAC.3,  30-Jul-82 09:33:40 by DONAHUE
;Edit 2638 - Fix edit 2629 to check for -1 explicitly
; UPD ID= 98, FARK:<4-1-WORKING-SOURCES.MONITOR>TTDZDV.MAC.2,  23-Jun-82 11:56:59 by DONAHUE
;Edit 2629 - Check if TTACTL entry is negative
;<4-1-FIELD-IMAGE.MONITOR>TTDZDV.MAC.2, 25-Feb-82 20:50:07, EDIT BY DONAHUE
;UPDATE COPYRIGHT DATE
; UPD ID= 716, FARK:<4-WORKING-SOURCES.MONITOR>TTDZDV.MAC.4,  18-Aug-81 19:29:40 by ZIMA
;Edit 1924 - put edit 1820 in standard form.  No code changes.
; UPD ID= 341, FARK:<4-WORKING-SOURCES.MONITOR>TTDZDV.MAC.3,  16-Dec-80 07:39:07 by DEUFEL
;Edit 1822 - Fix KLINIK modem handling code completely and correctly
; UPD ID= 336, FARK:<4-WORKING-SOURCES.MONITOR>TTDZDV.MAC.2,  16-Dec-80 00:05:09 by DEUFEL
;Edit 1820 - ADD CODE TO DISCONNECT THE JOB ON THE KLINIK LINE IF THE 8080
;TELLS US THAT THE CARRIER IS GONE. REWRITE DATASET HANDLING CODE AND ADD
;AUTOBAUD CAPABILITIES
; UPD ID= 129, FARK:<4-WORKING-SOURCES.MONITOR>TTDZDV.MAC.2,  21-Jul-80 20:17:43 by ZIMA
;Edit 1760 - remove unneeded sendall check preventing TTMSG to CTY.
;<4.MONITOR>TTDZDV.MAC.180,  3-Jan-80 08:10:38, EDIT BY R.ACE
;UPDATE COPYRIGHT DATE
;<4.MONITOR>TTDZDV.MAC.179, 25-Oct-79 15:13:10, EDIT BY ZIMA
;TCO 4.2550 - INSTALL A TERMINAL SPEED ZERO FOR DZ11 LINES BY TURNING
; OFF THE RECEIVER CLOCK.  PRESERVES OUTPUT CHARACTERISTICS SINCE
; THE OUTPUT CANNOT BE TURNED OFF FOR A LINE.
;<4.MONITOR>TTDZDV.MAC.178, 12-Oct-79 09:35:34, Edit by KONEN
;CORRECT CODE SENDING XON WHILE THERE IS ROOM IN THE INPUT BUFFER
;<4.MONITOR>TTDZDV.MAC.177,  5-Oct-79 17:07:29, EDIT BY MURPHY
;MINXOS CHANGED TO MINXON
;<4.MONITOR>TTDZDV.MAC.176,  5-Oct-79 00:36:16, Edit by KONEN
;CALL GETEXA BEFORE DZXOCA
;<4.MONITOR>TTDZDV.MAC.175,  2-Oct-79 09:13:06, Edit by KONEN
;APPLY PARITY IF NEEDED TO XON/XOFF
;<4.MONITOR>TTDZDV.MAC.174, 28-Sep-79 14:03:03, Edit by KONEN
;ALLOW OUTPUT OF XON/XOF OF DZ'S WHEN OUTPUT BUFFER IS EMPTY
;<4.MONITOR>TTDZDV.MAC.173, 19-Sep-79 14:49:53, EDIT BY MURPHY
;CHANGE VECTOR OFFSET NAMES
;<OSMAN.MON>TTDZDV.MAC.1, 10-Sep-79 16:11:45, EDIT BY OSMAN
;TCO 4.2412 - Move definition of BUGHLTs, BUGCHKs, and BUGINFs to BUGS.MAC
;<4.MONITOR>TTDZDV.MAC.171, 24-Aug-79 13:38:11, EDIT BY WEISBACH
;TCO 4.2355 SEND XON OVER DZ LINES ONLY IF LINE  PREVIOUSLY X'D OFF.
;<4.MONITOR>TTDZDV.MAC.170, 11-Mar-79 13:12:43, EDIT BY KONEN
;UPDATE COPYRIGHT FOR RELEASE 4
;<4.MONITOR>TTDZDV.MAC.169, 15-Feb-79 19:06:01, Edit by MCLEAN
;SOTP EXTRANEOUS DZ OUTPUT INTERRUPT FROM HANGING
;<4.MONITOR>TTDZDV.MAC.168,  2-Feb-79 23:40:35, Edit by MCLEAN
;ADD VSFEXO FOR FRONT-END XOFF RECOGNITION	;ENABLE/DISABLE FRONT-END XOFF RECOGNITION

;<4.MONITOR>TTDZDV.MAC.167, 24-Jan-79 00:20:48, Edit by MCLEAN
;FIX XON/XOFF AND OUTPUT TO NON-EX LINE CRASHES
;<4.MONITOR>TTDZDV.MAC.166, 28-Dec-78 22:45:26, Edit by MCLEAN
;ADD VSTPLN	;STOP LINE

;<4.MONITOR>TTDZDV.MAC.165, 13-Dec-78 16:20:51, Edit by MCLEAN
;CORRECT NUMBER OF STOP BITS IN TABLE IT WAS BACKWARDS.
;<2MCLEAN>TTDZDV.MAC.164, 18-Oct-78 22:50:03, Edit by MCLEAN
;<2MCLEAN>TTDZDV.MAC.163, 18-Oct-78 11:46:55, Edit by MCLEAN
;<2MCLEAN>TTDZDV.MAC.162, 14-Oct-78 22:18:05, Edit by MCLEAN
;<2MCLEAN>TTDZDV.MAC.161, 14-Oct-78 22:14:57, Edit by MCLEAN
;<2MCLEAN>TTDZDV.MAC.160, 14-Oct-78 18:07:23, Edit by MCLEAN
;<2MCLEAN>TTDZDV.MAC.159, 13-Oct-78 16:10:51, Edit by MCLEAN
;<2MCLEAN>TTDZDV.MAC.158, 11-Oct-78 00:09:41, Edit by MCLEAN
;<2MCLEAN>TTDZDV.MAC.157, 10-Oct-78 23:52:42, Edit by MCLEAN
;<2MCLEAN>TTDZDV.MAC.156,  7-Oct-78 22:31:18, Edit by MCLEAN
;REMOVE OBFFR FOR SPEED
;<4.MONITOR>TTDZDV.MAC.155,  5-Oct-78 15:50:02, Edit by MCLEAN
;FIX CARNON SO PERM BIT IS CORRECTLY CHECKED

;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,1979,1980,1981,1982 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

	SUBTTL DZ11 DEVICE DEPENDENT CODE FOR SM10


; DZ11 TTY SERVICE MODULE FOR SM10 CONFIGURATIONS

	EXTN <DZCHCT>		;SPECIAL "CLOCK" FOR PI CHECKS

;DEFINITIONS FOR TTDEV FOR DZ TYPE LINES


;DEFINITIONS FOR TT.DZ LINE TYPE
TT%DZI==1B0			;DZ INTERRUPT SERVICE FLAG
MSKSTR TTDZI,TTDEV,TT%DZI

	RESCD

SCDTMZ==^D50			;TIME FOR RING CHECKS
DZTMCK==^D5000/SCDTMZ		;WHEN TO DO PI CHECK
DZCRDL==^D8000			;TIME DELAY FOR CARRIER HANGUP

;VECTOR TABLE FOR DEVICE DEPENDENT ROUTINES

TTDZVT=.
	TTDDLN			;LENGTH OF DYNAMIC DATA FOR THIS TYPE
	-1			;FIRST LINE OF THIS TYPE/-1 NO LINES
	IFIW!DZINIT		;VITBLS -INITALIZATION	;INITIALIZE TABLES AT SYSTEM STARTUP

	IFIW!DZRSTR		;RESTART
	IFIW!TTCOB5		;CLEAR OUTPUT BUFFER
	IFIW!DZSSP2		;SET LINE SPEED
;**;[1924] Change 1820 lines at TTDZVT= +8L	JGZ	18-AUG-81
;**;[1820] Change one line at TTDZVT= +8L	DAD	15-DEC-80
	IFIW!DZRSPD		;[1820] READ TTY SPEED
	IFIW!DZSNT1		;SET NON-TERM STATUS
	IFIW!DZRNT1		;READ NON-TERM STATUS
	IFIW!TTSTO3		;REMOVE CHAR FROM OUTPUT BUFFER
	IFIW!R			;STPAR JSYS
	IFIW!RSKP		;CHECK PHYSICAL LINE
	IFIW!TTXON2		;VXON -XON	;PROCESS XON FROM TERMINAL

	IFIW!TTYDE0		;DEASIGN DYNAMIC DATA
	TRO 1,200		;SET PARITY
	IFIW!STRTO1		;START OUTPUT LINE
	IFIW!DZSXOF		;XOFF
	IFIW!DZSXON		;XON
	IFIW!DZRING		;EMPTY BUFFER
	IFIW!DZ7CX2		;CARRIER ON
	IFIW!DZCX2		;CARRIER OFF
	IFIW!DZHU0		;HANGUP
	IFIW!R			;VXOFF -^S	;PROCESS XOFF FROM TERMINAL

	IFIW!TTC7S1		;NO LOGINS
	IFIW!DZBST		;STORE CHARACTER
	IFIW!DZSND1		;SEND CHARACTER
	IFIW!TTDAL7		;DEALLOCATE LINE
	IFIW!DLSSX2		;BUFFER OVERFLOW
	IFIW!R			;EMPTY BUFFER
	IFIW!DZSNSA		;VTTMSG - ALLOW TTMSG FOR SINGLE LINE	;DO TTMSG FOR ONE LINE?

	IFIW!R			;ENABLE/DISABLE DATASETS
	IFIW!DZCH7D		;PIA ETC CHECKS
	IFIW!R			;30  CLEAR INPUT BUFFER
	IFIW!R			;31  DOBE
	IFIW!R			;32  INPUT GA
	IFIW!TTSET1		;33  SET INIT. VALUES FOR A LINE
	IFIW!TTSBE1		;34  SOBE
	IFIW!TTOBE1		;35  WAKEUP IF OUTPUT BUFFER EMPTY
	IFIW!DZSNSN		;VSNDA1 - ALLOW TTMSG FOR SINGLE LINE	;SENDALL FOR ONE LINE

	IFIW!DZSNDL		;VSNDAL - ALLOW TTMSG FOR ALL LINES	;SENDALL FOR ALL LINES

	JFCL			;VAJWCL - ADJUST WAKEUP CLASS	;ADJUST WAKEUP CLASS

	IFIW!R			;VSTPLN - STOP LINE	;STOP LINE

	IFIW!R			;VSFEXO - ENABLE XOFF RECOGNITION	;ENABLE/DISABLE FRONT-END XOFF RECOGNITION


   IFN <.-TTVTMX>-TTDZVT,<PRINTX %% INVALID DEVICE DEPENDTNT TABLE SIZE>
;
; SEND CHARACTER TO LINE
; CURRENTLY ONLY CTY IN SECONDARY PROTOCOL IS IMPLEMENTED
;WARNING!!! SNEAKY BUT Q2 IS SET UP TO EXTERNAL PAGE ADDRESS OF
;DZ11 IFF TTDZI IS NON-ZERO!!!



DZSND1:	PUSH P,T2
	JN TTDZI,(T2),[	MOVEI T4,0(T3) ;IF DZ INTERRUPT THEN JUST OUTPUT CHARACTER
			SETZRO TTDZI,(T2)
			WRIOB T4,DZTBUF(Q2)
			POP P,T2
			RET]
	DYNST	
	CAME T2,KLILNO		;KLINIK?
	JRST NOTDZK		;NOT KLINIK
	JN KLIOVL,,[	POP P,T2	;BACKUP STILL BUSY
			JRST DZBKUP]
	JN TTXOC,(T2),DZXOC	;XON/OFF REQUESTED?
	STOR T3,KLIOCH		;STORE OUTPUT CHARACTER
	SETONE KLIOVL		;SET VALID
	JRST CTYCOM		;AND DO COMMON STUFF

NOTDZK:CAME T2,CTYLNO
	JRST [	SKIPE DZLNCT	;IF NO DZ LINES MUST RETURN
		SKIPN FEFLG	;SECONDARY PROTOCOL?
		JRST PB2	;NO -- RETURN IT IS NOT LEGAL NOW
		JRST DZPRNC]	;NOT CTY BUT PRIMARY PROTOCOL
	JN CTYOVL,,[	POP P,T2	;RESTORE T2
			JRST DZBKUP] ;AND BACKUP
	JN TTXOC,(T2),DZXOC	;XON/OFF REQUIRED?
	STOR T3,CTYOCH		;SET OUTPUT CHARACTER
	SETONE CTYOVL		;SET VALID CHARACTER AVAILABLE
CTYCOM:	CALL INTETY		;INTERRUPT 8080
	POP P,T2		;RESTORE
	SETONE TTOTP,(T2)	;SET LINE ACTIVE
	RET			;RETURN

DZPRNC:	SUB T2,DZLNOF		;SUBTRACT RESTRICTED LINES
	CAMLE T2,DZLNNO		;LEGAL?
	JRST PB2		;NO IGNORE
	POP P,T2		;RESTORE REGISTER
	MOVEI T4,0(T3)		;SAVE CHARACTER
	
	CALL GETEXL		;GET EXTERNAL PAGE INFO
	SETONE TTOTP,(T2)	;SET LINE ACTIVE
	BSIOB T1,DZTCR(T3)	;LINE NOT ENABLED DO IT AND WAIT FOR INTERRUPT
DZBKUP:	JN TTSAL,(T2),[	MOVNI T3,1	;BACK UP SENDALL
			LOAD T1,TSALP,(T2)
			ADJBP T3,T1	;BACKUP POINTER
			STOR T3,TSALP,(T2) ;RESTORE COUNTER
			INCR TSALC,(T2)	;UPDATE CHARACTER COUNT
			RET]		;RETURN
	MOVNI T3,1		;BACKUP BYTE POINTER
	ADJBP T3,TTOOUT(T2)
	MOVEM T3,TTOOUT(T2)	;RESTORE IT
	AOS TTOCT(T2)		;RESET COUNT
	RET



DZXOC:	JN TTFXF,(T2),DZPRXO	;DO XON
DZPRXF:	MOVEI T4,XOFFC		;GET XOFF CHARACTER
	SKIPA			;COMMON
DZPRXO:	MOVEI T4,XONC		;GET CHARACTER
	SKIPGE CHITAB(T4)	;PARITY NEEDED?
	TXO T4,200		;YES, APPLY IT
	SETZRO <TTXOC>,(T2)	;CLEAR FLAGS
	CAMN T2,KLILNO		;KLINIK?
	JRST [	STOR T4,KLIOCH	;YES STORE IN KLINIK BUFFER
		SETONE KLIOVL	;SET VALID CHARACTER
		JRST DZPRXA]
	STOR T4,CTYOCH		;STORE CHARACTER IN 8080 BUFFER
	SETONE CTYOVL		;SET VALID CHARACTER
DZPRXA:	CALL INTETY		;INTERRUPT 8080
	POP P,T2		;RESTORE T2
	SETONE TTOTP,(T2)	;SET LINE ACTIVE
	JRST DZBKUP		;AND BACKUP
;
DZXOCA:	JN TTFXO,(T2),DZDZXF	;XOFF?
DZDZXO:	MOVEI T4,XONC		;GET CHARACTER
	SKIPA			;COMMON ENTRY
DZDZXF:	MOVEI T4,XOFFC		;GET XOFF CHARACTER
	SKIPGE CHITAB(T4)	;PARITY NEEDED?
	TXO T4,200		;YES, APPLY IT
	SETZRO <TTXOC>,(T2)	;CLEAR FLAGS
	WRIOB T4,DZTBUF(T3)	;WRITE CHARACTER
	RET
; SET/CLEAR NON-TERMINAL STATUS
	SWAPCD

DZSNT1:	STOR T3,TTNTS,(T2)	;SET/CLEAR FLAG
	RET

; READ NON-TERMINAL STATUS

DZRNT1:	LOAD T3,TTNTS,(T2)	;RETURN STATUS
	RET
	RESCD

DZBST:	LOAD T3,TTFBB,(T2)	;GET COUNT
	AOS T3			;INCREASE COUNT OF CHARACTERS IN TTBBUF
	CAIL T3,MAXABC		;OVER RUN (IGNORE IT TOO MANY)
	RET			;YOU HAVE BEEN WARNED
	STOR T3,TTFBB,(T2)	;STORE COUNT
	CAIL T3,MAXBBC		;CHECK FOR MAX BEFORE SHUT OFF
	CALL SNDXOF		;SEND XOFF
	JRST BIGST1		;STORE CHARACTER


DZSXOF:	MOVEI T4,XOFFC		;GET XOFF CHARACTER
	SETONE <TTXOC,TTFXO>,(T2) ;SET XOFF
	SETZRO TTFXF,(T2)
	JRST DZXCM		;GO TO COMMON STUFF

DZSXON:	JE TTFXO,(T2),R		;XON ONLY IF REQUIRED
	PUSH P,T2		;SAVE LINE NUMBER
	CALL STADYN		;CONVERT TO DYNAMIC
	 JRST DZNXN		;FORGET IT
	LOAD T4,TIMAX,(2)	;CAPACITY OF INPUT BUFFERS
	SUBI T4,MINCT1		;LESS AMOUNT BEFORE FORCED WAKEUP
	CAMG T4,TTICT(2)	;BUFFER NOW THAT FULL?
	JRST PB2		;YES, WAIT
	DYNST			;BACK TO STATIC ADDRESS
	SETONE <TTXOC,TTFXF>,(T2)	;SET XON REQUIRED
	SETZRO TTFXO,(T2)	;CLEAR OLD SWITCH
DZNXN:	MOVEI T4,XONC		;GET XON CHARACTER
	POP P,T2		;RESTORE LINE NUMBER
DZXCM:	SKIPGE CHITAB(T4)	;PARITY NEEDED?
	TXO T4,200		;YES, APPLY IT
	CHNOFF DLSCHN		;SET CHANNEL OFF
	CAMN T2,KLILNO		;KLINIK?
	JRST [	JN KLIOVL,,DZCXR	;CHECK TO SEE IF READY
		STOR T4,KLIOCH	;STORE CHARACTER
		SETONE KLIOVL	;SET VALID
		JRST DZXCM1]
	CAME T2,CTYLNO		;CTY?
	JRST DZXDZ		;REAL DZ
	JN CTYOVL,,DZCXR	;CHECK TO SEE IF READY FOR A CHARACTER
	STOR T4,CTYOCH		;SET OUTPUT CHARACTER
	SETONE CTYOVL		;SET VALID
DZXCM1:	SETZRO TTXOC,(T2)	;CLEAR BOTH SINCE ALL IS DONE
	CALL INTETY		;INTERRUPT 8080
DZCXR:	CHNON DLSCHN		;TURN CHANNEL BACK ON
	RET			;AND RETURN

DZXDZ:	PUSH P,T2		;SAVE STATIC ADDRESS
	CALL STADYN		;FIND DYNAMIC STORAGE ADDRESS
	JRST DZDZX		;NOT SETUP YET FORGET IT
	JN TTDZI,(T2),DZDZX	;QUIT IF BUSY (IT WILL GET CLEARED)
	CALL GETEXL		;FIND EXTERNAL PAGE ADDRESS
	SETONE TTOTP,(T2)	;SET LINE ACTIVE
	BSIOB T1,DZTCR(T3)	;REQUEST INTERRUPT
DZDZX:	CHNON DLSCHN
	JRST PB2		;AND QUIT
;DZINIT -- ROUTINE TO INITALIZE DZ11
;DZRSTR -- SAME ROUTINE TO RESTART DZ11

DZINIT:	SAVEAC <Q1,Q2,P1>	;SAVE AN AC
	SETZM CTYINT		;SET ALIAS (FOR NOW IT IS 0) FOR CTY
	MOVE T4,SMTEPT+DZUBN	;FIND THE TRAP VECTORS
	ADDI T4,DZ110V/4	;OFFSET TO INTERRUPT VECTORS
	MOVEI Q2,DZMAX		;FIND THE MAX DZ11
	MOVE T2,[XPCW DZRDIB]	;SET INTERRUPT BLOCK
	MOVE T3,[XPCW DZXINB]	;OUTPUT INTERRUPT BLOCK
	SETZB Q1,P1		;SET POINTER TO CORRECT BLOCK
DZIVLP:	MOVEM T2,0(T4)		;MAKE AN ENTRY IN THE INTERRUPT VECTOR BLOCK
	MOVEM T3,1(T4)		;GET OUTPUT INTERRUPT VECTOR
	ADDI T3,4		;FOUR WORDS PER INTERRUPT BLOCK
	ADDI T4,2		;POINT TO NEXT INTERRUPT BLOCK
	MOVE T1,[MSEC1,,DZRDIN]	;SET UP THE INTERRUPT BLOCK
	MOVEM T1,DZRDIB+3	;SET UP VECTOR ADDRESS
	SETZM DZRDIB+2		;SET FLAGS TO 0
	MOVE T1,[MSEC1,,DZTXIN]	;SET UP OUTPUT INTERRUPT BLOCK
	ADD T1,Q1		;POINT TO CORRECT INTERRUPT INST
	MOVEM T1,DZXINB+3(P1)
	SETZM DZXINB+2+(P1)	;SET FLAGS TO 0
	ADDI Q1,3		;3 INSTRUCTIONS PER LINE
	ADDI P1,4		;4 WORDS PER BLOCK
	SOJN Q2,DZIVLP		;LOOP UNTIL DONE
	MOVE T1,CTYINT		;GET CTY LINE NUMBER
	AOS T1			;MAKE KLINIK CTY+1
	MOVEM T1,KLILNO		;SAVE KLINIK LINE NUMBER
	RET

; RESTART CODE ALSO RUN FOR INITILIZATION IT SETS UP THE INTERRUPT ENABLES

DZRSTR:	SAVEP			;SAVE THE P'S
	MOVSI P1,-DZMAX		;MAXIMUNM NUMBER OF DZ11'S TO HANDLE
	MOVE P2,[DZ11BA]	;GET BASE ADDRESS OF DZ11
DZINLP:	MOVE T1,P2		;ADDRESS OF DZ11
	CALL UBGOOD		;DOES IT EXIST ?
	 JRST DZNOUB		;NO
	MOVEI T1,DZCLR		;INIT THE DZ11
	WRIO T1,DZCSR(P2)	;RESET THE DZ
	MOVSI T2,1		;SET UP LOOP COUNT
DZCLRK:	SOJE T2,[BUG(DZCLRB)]
	TIOE T1,DZCSR(P2)	;WAIT FOR FINISH
	JRST DZCLRK
	MOVEI T1,DZRIEN+DZTIEN+DZMSCN ;SET INTERRUPT ENABLES AND SCANNER
	WRIO T1,DZCSR(P2)	;START DZ11
	ADDI P2,DZMNV		;ADD THE VECTOR SIZE
	AOBJN P1,DZINLP		;AND TRY THE NEXT ONE
DZNOUB:	HRRZM P1,DZLNCT		;SAVE NUMBER OF DZ11'S FOUND
	IMULI P1,10		;COUNT OF LINES
	HRRZM P1,DZLNNO
	MOVE T1,TTLINV+TT.DZ	;FIND THE OFFSET AND KEEP IT HANDY
	MOVE T1,TT1LIN(T1)
	ADDI T1,FELNS		;ADD IN PSEUDO LINES
	MOVEM T1,DZLNOF
	RET			;RETURN

; DZHU0 -- ROUTINE TO SCHEDULE A HANGUP

DZHU0:	SETZ T1,		;T1/ INDICATE DO IT IMMEDIATELY
	MOVE T3,[DZHU2]		;T3/ ROUTINE TO HANGUP THE LINE
	CALL TTQAD		;SCHEDULE HANGUP AS SOON AS POSSIBLE
	RET


; DZHU2 -- ROUTINE TO DO A HANGUP

DZHU2:	JE TTFEM,(T2),R		;RETURN IF NO DATASET
;**;[1820] Insert one line at DZHU2: + 1L	DAD	15-DEC-80
	SETZRO TTCON,(T2)	;[1820] CLEAR CARRIER ON BIT
	SAVET			;SAVE TEMP'S
	CALL GETEXA		;GET EXTERNAL ADDRESS
	BCIOB T1,DZLPR(T3)	;CLEAR LINE ENABLE
	BCIOB T1,DZDTR(T3)	;CLEAR CARRIER
	RET			;RETURN

;DZ7CX2 -- CARRIER ON


;DZCX2 -- CARRIER OFF

DZ7CX2:	SKIPA T3,[TTCON1]	;CARRIER ON
DZCX2:	MOVE T3,[TTCOF]		;CARRIER OFF
	MOVEI T1,DZCRDL		;8 SEC
	CALL TTQAD
	JRST TTCH7


;DZCH7D -- PIA CHECK TO SEE IF INTERRUPTS ENABLES HAVE BEEN LOST
;**;[1924] Change 1820 lines at DZCH7D: +0L	JGZ	18-AUG-81
;**;[1820] Change one line at DZCH7D: +0L	DAD	15-DEC-80
DZCH7D:	MOVEI T1,^D250		;[1820] TIME FOR NEXT CHECK (EVERY .25 SECONDS)
	MOVEM T1,TTYTIM		;TELL SCHEDULER
	SOSLE DZCHCT		;TIME FOR PI CHECK?
	JRST DZRING		;NO. DO RING POLL ONLY THEN
	MOVEI T1,DZTMCK		;YES. SET UP NEXT TIME CHECK
	MOVEM T1,DZCHCT		;AND SET UP "CLOCK"
	CHNOFF DLSCHN		;TURN OFF DLS CHANNEL
	MOVE T1,DZLNCT		;GET LINE COUNTS
	JUMPE T1,DZCH7E		;IF NO DZ'S THEN NO CHECK
	MOVE T2,[DZ11BA]	;GET BASE ADDRESS
	MOVEI T3,DZRIEN!DZTIEN!DZMSCN
DZCH7L:	TION T3,DZCSR(T2)	;CHECK FOR ENABLES
	JRST [	BUG(DZLINT,<<T2,D>>)
		MOVEI T4,377	;SET ALL LINES TO INTERRUPT ASSUMING LOST ONE
		WRIOB T4,DZTCR(T2)
		BSIO T3,DZCSR(T2) ;SET INTERRUPT ENABLES AGAIN
		JRST .+1]
	ADDI T2,DZMNV		;LOOK AT NEXT DEVICE
	SOJN T1,DZCH7L		;TRY NEXT ONE
DZCH7E:	CHNON DLSCHN		;TURN ON CHANNEL

;NOW CHECK FOR RING ON ANY OF THE LINES

DZRING:	MOVE T2,TTLINV+TT.DZ	;GET VECTOR FOR THIS LINE TYPE
	SKIPE DZLNCT		;IF NO DZ LINES FORGET IT
	SKIPGE T2,TT1LIN(T2)	;GET FIRST LINE NUMBER
	RET			;NONE THERE
	MOVN T4,DZLNNO		;FIND COUNT OF LINES
	HRL T2,T4		;GET - NUMBER OF LINES
	ADDI T2,FELNS		;UPDATE FOR CTY AND KLINIK
;**;[1924] Change 1820 lines at DZRNG0: +0L	JGZ	18-AUG-81
;**;[1820] Change one line at DZRNG0: +0L	DAD	15-DEC-80
DZRNG0:	JE TTFEM,(T2),DZRNG2	;[1820] NOT A REMOTE LINE - NO PROCESSING NECESSARY
	PUSH P,T2		;SAVE ARGS
	CALL GETEXA		;GET EXTERNAL PAGE ADDRESS
	TIONB T1,DZRNG(T3)	;CHECK FOR RING
;**;[1820] Delete 30 lines of code and add 73 lines of code at DZRNG0: + 4L	DAD	15-DEC-80
	SKIPA			;[1820] NOT RING
	JRST DZRGON		;[1820] YES, GO DO RING PROCESSING
	TIONB T1,DZCAR(T3)	;[1820] IS CARRIER UP
	JRST DZCROF		;[1820] NO, GO DO CARRIER OFF PROCESSING
	JRST DZCRON		;[1820] YES, GO DO CARRIER ON PROCESSING

DZRNG1:	POP P,T2		;[1820]
DZRNG2:	AOBJN T2,DZRNG0		;[1820] DO THEM ALL
	RET			;[1820] AND DONE


DZRGON:	JN TTCON,(T2),DZRGO1	;[1820] IS CARRIER THOUGHT TO BE ON?
	BSIOB T1,DZDTR(T3)	;[1820] NO, SO SET DTR ON
	SETONE TTCRW,(T2)	;[1820] SET THE CARRIER WAIT BIT ON
	MOVEI T1,^D20000	;[1820] SET THE CARRIER WAIT TIMEOUT TO 20 SECONDS
	MOVE T3,[DZCRTO]	;[1820] INDICATE ROUTINE TO BE CALLED
	CALL TTQAD		;[1820] QUEUE THE REQUEST
	JRST DZRNG1		;[1820] AND CONTINUE SCANNING THE LINES
DZRGO1:	SETZRO TTCON,(T2)	;[1820] CLEAR THE CARRIER ON BIT
	SETZ T1,		;[1820] QUEUE THIS TO RUN ASAP
	MOVE T3,[NTYCOF]	;[1820] INDICATE THE ROUTINE TO BE CALLED
	CALL TTQAD		;[1820] AND QUEUE THE REQUEST TO DETATCH THE JOB
				;[1820] ON THIS LINE
	JRST DZRNG1		;[1820] CONTINUE SCANNING...

DZCRON:	JN TTCRW,(T2),DZCRCW	;[1820] IS THIS LINE WAITING FOR CARRIER?
	JN TTCON,(T2),DZRNG1	;[1820] NO, IS CARRIER SUPPOSED TO BE ON?
	CALL STADYN		;[1820] IS THE LINE ACTIVE?
	  JRST DZRNG1		;[1820] NO SO IGNORE THE CARRIER
	MOVE T2,(P)		;[1820] RESTORE T2 (STADYN CLOBBERED IT)
	SETONE TTCON,(T2)	;[1820] YES, SO SET THE CARRIER BIT ON AGAIN
	JRST DZRNG1		;[1820] AND CONTINUE SCANNING

;[1820] HERE IF A LINE IS IN CARRIER WAIT AND THE CARRIER COMES ON

DZCRCW:	SETZRO TTCRW,(T2)	;[1820] CLEAR THE CARRIER WAIT BIT
	JE TTAUT,(T2),DZCRC1	;[1820] IS THIS AN AUTOBAUD LINE?
	PUSH P,T4		;[1820] SAVE AWAY T4
	MOVE T4,T2		;[1820] GET THE LINE NUMBER
	SUB T4,DZLNOF		;[1820] SUBTRACT THE DZ LINE OFFSET
	ANDI T4,7		;[1820] MASK DOWN TO THE UNIT NUMBER
	HLRZ T1,DZATSP		;[1820] GET THE DEFAULT AUTOBAUD SPEED
	IOR T1,T4		;[1820] ADD IN THE UNIT NUMBER
	WRIO T1,DZLPR(T3)	;[1820] AND SET THE DZ LINE TO 300 FOR AUTOBAUD DETECT
	POP P,T4		;[1820] RESTORE T4
	SETONE TTABW,(T2)	;[1820] PUT LINE INTO AUTOBAUD WAIT STATE
	SETONE TTCON,(T2)	;[1820] SET THE CARRIER ON BIT
	MOVEI T1,^D30000	;[1820] SET TIMEOUT TO 30 SECONDS
	MOVE T3,[DZABTO]	;[1820] THE ROUTINE TO CALL
	CALL TTQAD		;[1820] QUEUE THE TIMEOUT ROUTINE
	JRST DZRNG1		;[1820] AND CONTINUE SCANNING

DZCRC1:	SETONE TTCON,(T2)	;[1820] NOT AN AUTOBAUD LINE SO SET CARRIER BIT ON
	MOVEI T1,^D2000		;[1820] QUEUE A REQUEST FOR 2 SECONDS FROM NOW
				;[1820] (THIS IS SO THE LINE CAN SETTLE)
	MOVE T3,[TTCON1]	;[1820] THE ROUTINE TO START A JOB
	CALL TTQAD		;[1820] QUEUE THE REQUEST
	JRST DZRNG1		;[1820] AND CONTINUE SCANNING

;[1820] HERE IF THE CARRIER FOR A LINE IS OFF

DZCROF:	JE TTCON,(T2),DZRNG1	;[1820] GO AWAY IF THE CARRIER IS SUPPOSED TO BE OFF
	SETZRO TTCON,(T2)	;[1820] CLEAR THE CARRIER ON BIT
	CALL STADYN		;[1820] IS THE LINE ACTIVE?
	  JRST DZCRF1		;[1820] NO, GO QUEUE CARRIER OFF TIMEOUT
	MOVE T1,(P)		;[1820] RESTORT T2 (STADYN CLOBBERED IT)
	JE TTPRM,(T2),DZCRF1	;[1820] IS THE LINE PERMENANT
	JRST DZRNG1		;[1820] JUST CONTINUE SCANNING

DZCRF1:	MOVE T2,(P)		;[1820] RESTORE T2 (STADYN CLOBBERED IT)
	MOVEI T1,^D4000		;[1820] SET UP AN 4 SECOND TIMEOUT
	MOVE T3,[TTCOF]		;[1820] FOR THIS CARRIER OFF TRANSITION
	CALL TTQAD		;[1820] QUEUE IT
	JRST DZRNG1		;[1820] AND CONTINUE SCANNING

;[1820] HERE WHEN WE TIMEOUT FROM DZRGON

DZCRTO:	JE TTCRW,(T2),R		;[1820] HAS CARRIER WAIT BEEN CLEARED FOR THIS LINE?
	SETZ T1,		;[1820] NO, SO JUST HANG UP THE LINE ASAP
	MOVE T3,[DZHU2]		;[1820] THE HANGUP CODE
	CALL TTQAD		;[1820] QUEUE THE REQUEST
	SETZRO TTCRW,(T2)	;[1820] CLEAR THE CARRIER WAIT FLAG
	RET			;[1820] AND EXIT

;[1820] HERE WHEN WE TIMEOUT FROM DXCRCW

DZABTO:	JE TTABW,(T2),R		;[1820] STILL IN AUTOBAUD WAIT?
	MOVE T3,[DZHU2]		;[1820] YES, HANG UP
	SETZ T1,		;[1820] NOW!!!
	CALL TTQAD		;[1820] QUEUE THE REQUEST
	SETZRO TTABW,(T2)	;[1820] CLEAR THE AUTOBAUD WAIT BIT
	SETZRO TTCON,(T2)	;[1820] CLEAR THE CARRIER FLAG
	RET			;[1820] AND EXIT
;READ INTERRUPT ROUTINE

DZRDIN: MOVEM P,DZSAVP		;SAVE A REGISTER
	MOVEI P,DZSVAC		;POINT TO AC SAVE AREA
	BLT P,DZSVAC+16		;SAVE AC'S
	MOVE P,DZPDL		;SET UP STACK
	MOVE Q1,DZLNCT		;FIND THE NUMBER OF LINES
	MOVE Q2,[DZ11BA]	;FIND FIRST EXTERNAL PAGE ADDRESS
	SKIPE FEFLG		;CHECK FOR PRIMARY PROTOCOL
	JRST DZINPP		;YES -- GO DUMP ALL DZ'S
DZCTRD:	RDIO T1,DZRBUF(Q2)	;READ A CHARACTER
	TRNE T1,DZRDVL		;VALID?
	JRST DZCTRD		;LOOP AND TRY FOR ANOTHER
DZNXCL:	SOJE Q1,DZRXIT		;CHECK TO SEE IF ALL DZS DONE
	ADDI Q2,DZMNV		;LOOK AT NEXT DZ TO DUMP ALL CHARACTERS
	MOVEI T1,DZRDVL		;IN THE BUFFERS TO STOP THEIR INTERRUPTING
	TIOE T1,DZRBUF(Q2)	;THIS WILL READ A CHARACTER AND DUMP IT
	JRST .-1		;THIS WILL CAUSE ALL CHARACTERS TO BE DUMPED
	JRST DZNXCL		;GO DO NEXT DZ

DZINPP:	MOVE P1,DZLNOF		;SET UP LINE NUMBER (MUST START AT 1
DZINPL:	RDIO T1,DZRBUF(Q2)	;GET A CHARACTER
	TRNN T1,DZRDVL		;VALID?
	JRST DZNXLN		;NO -- GO TO NEXT LINE
;**;[1820] Added three lines at DZINPL: + 3L	DAD	15-DEC-80
	LOAD T2,DZTXLN,T1	;[1820] GET THE LINE NUMBER
	ADD T2,P1		;[1820] FIND ITS INTERNAL LINE NUMBER
	JN TTABW,(T2),DZABCK	;[1820] IS THE LINE IN THE AUTOBAUD WAIT STATE?
	TRNE T1,DZROVR		;OVER RUN
	BUG(DZOVER,<<T1,D>>)
;**;[1820] Deleted two lines at DZINPL: + 8L	DAD	15-DEC-80
	ANDI T1,377		;MASK TO CHARACTER ONLY
	CALL TTIDON		;GO PUT IN BUFFER
	JRST DZINPL		;GET ANOTHER CHARACTER

DZNXLN:	ADDI P1,10		;8 LINES PER DZ
	ADDI Q2,DZMNV		;LOOK AT NEXT DZ
	SOJN Q1,DZINPL		;CHECK TO SEE IF COUNT DONE
	JRST DZRXIT		;GO TO READ EXIT (DONE)


DZRXIT:	MOVSI P,DZSVAC		;RESTORE ACS
	BLT P,CX		;RESTORE
	MOVE P,DZSAVP		;RESTORE P
	XJEN DZRDIB		;RETURN
;INTERRUPT ROUTINE FOR THE CTY FOR THE KS10

DZCTIN::CLSB DLSCHN		;CLEAR CHANNEL INTERRUPT REQUEST
	MOVEM P,DZSAVP		;SAVE STACK REGISTER
	MOVEI P,DZSVAC		;POINT TO SC SAVE AREA
	BLT P,DZSVAC+16		;SAVE ACS
	MOVE P,DZPDL		;SET UP STACK
;**;[1822] Removed 8 lines of code at DZCTIN: +5L	DAD	16-DEC-80
;**;[1822] Added 18 lines of code at DZCTIN: +5L	DAD	16-DEC-80
	LOAD T1,KLIACT		;[1822] GET THE KLINIK INPUT ACTIVITY BYTE
	JUMPE T1,DZNOKL		;[1822] IF NO ACTIVITY GO ON
	MOVE T2,KLILNO		;[1822] GET THE LINE NUMBER OF THE KLINIK LINE
	CAIN T1,KLICHR		;[1822] INCOMING CHARACTER?
	 JRST [	LOAD T1,KLIICH		;[1822] YES, GO PROCESS IT
		CALL TTIDON		;[1822] PASS THE CHARACTER ON
		JRST DZCTI1 ]		;[1822] AND CONTINUE
	CAIN T1,KLICAR		;[1822] NO, LOST KLINIK CARRIER?
	 JRST [	MOVE T3,[NTYCOF]	;[1822] YES, DISCONNECT THE JOB
		SETZ T1,		;[1822] ASAP
		CALL TTQAD		;[1822] QUEUE THE REQUEST
		JRST DZCTI1 ]		;[1822] AND CONTINUE ON
	CAIE T1,KLIINI		;[1822] NO, A NEW CALL MAYBE?
	 JRST DZCTI1		;[1822] NO, SO PUNT
	MOVE T3,[TTCON1]	;[1822] YES, SO GIVE THE GUY A JOB
	SETZ T1,		;[1822] NOW! THE 8080 SHOULD HAVE A GOOD
				;[1822] SOLID CARRIER BY NOW
	CALL TTQAD		;[1822] QUEUE THE REQUEST
DZCTI1:	SETZM KLIIWD		;[1822] ZAP THE KLINIK INPUT WORD
	CALL INTETY		;INTERRUPT EIGHTY EIGHTY
DZNOKL:	JN KLIOVL,,DZNXT	;OUTPUT VALID?
	MOVE T2,KLILNO		;YES GET LINE NUMBER
	CALL STADYN		;GET DYN ADDR
	JUMPLE T2,DZNXT		;TRY NEXT
	CALL TTSND		;DONE DO NEXT CHARCTER
DZNXT:	JE CTYIVL,,DZNOCT	;CHECK FOR CTY INPUT
	LOAD T1,CTYICH		;PICK UP THE CHACTER
	MOVE T2,CTYLNO		;GET THE CTY LINE NUMBER
	SETZRO CTYIVL		;CLEAR  CHARACTER IN BUFFER FLAG
	CALL TTIDON		;OUTPUT CHARACTER
	CALL INTETY		;INTERRUPT EIGHTY EIGHTY
DZNOCT:	JN CTYOVL,,DZNXIT	;NO CTY
	MOVE T2,CTYLNO		;GET LINE NUMBER
	CALL STADYN		;CONVERT TO DYNAMIC STORAGE
	JUMPLE T2,DZNXIT	;QUIT IF NO DYNAMIC STORAGE
	CALL TTSND		;DO DONE STUFF
DZNXIT:	MOVSI P,DZSVAC		;RESTORE
	BLT P,CX
	MOVE P,DZSAVP
	RET			;RETURN
DZPDL:	IOWD 40,DZISTK		;I/O STACK SIZE
RS (DZISTK,40)			;STACK FOR INTERRUPT SERVICE
RS (DZRDIB,4)			;INPUT INTERRUPT BLOCK
RS (DZXINB,4*^D8)		;INTERRUPT BLOCK FOR OUTPUT
RS (DZSVAC,17)			;SAVE AC FOR READ INTERRUPT
RS (DZSAVP,1)			;SAVE AC 17
RS (DZLNCT,1)			;COUNT OF DZ'S FOUND
RS (DZLNNO,1)			;COUNT OF LINES FOUND
RS (DZLNOF,1)			;OFFSET TO FIRST LINE NUMBER

; NOTE MUST HAVE ONE SET OF 3 INSTRUCTIONS PER DZ11!!!!!!
DZTXIN::DMOVEM P6,DZSVAC+P6	;SAVE REGISTERS
	SETZ P6,0		;POINTER TO WHICH LINE SET
	JRST DZCOMI		;GO TO COMMON INTERRUPT SERVICE
DZTXI1:	DMOVEM P6,DZSVAC+P6
	MOVEI P6,10		;SECOND BLOCK OF 10
	JRST DZCOMI
DZTXI2:	DMOVEM P6,DZSVAC+P6
	MOVEI P6,20
	JRST DZCOMI
DZTXI3:	DMOVEM P6,DZSVAC+P6
	MOVEI P6,30
	JRST DZCOMI
DZTXI4:	DMOVEM P6,DZSVAC+P6
	MOVEI P6,40
	JRST DZCOMI
DZTXI5:	DMOVEM P6,DZSVAC+P6
	MOVEI P6,50
	JRST DZCOMI
DZTXI6:	DMOVEM P6,DZSVAC+P6
	MOVEI P6,60
	JRST DZCOMI
DZTXI7:	DMOVEM P6,DZSVAC+P6
	MOVEI P6,70
;	JRST DZCOMI
;
DZCOMI:	MOVEM P,DZSAVP		;SAVE A REGISTER
	DMOVEM T1,DZSVAC+T1
	DMOVEM T3,DZSVAC+T3
	DMOVEM Q1,DZSVAC+Q1
	MOVE P,DZPDL		;SET UP STACK SIZE
	MOVE Q2,[DZ11BA]	;GET BASE ADDRESS
	ADD Q2,P6		;POINT TO CORRECT ADDRESS
	LSH P6,-1		;FIND RETURN ADDRESS
	DMOVE T1,DZXINB(P6)	;GET RETURN PS/PC
	DMOVEM T1,DZXINB	;STORE IN COMMON RETURN
	LSH P6,1		;GET ADDRESS BACK
	ADD P6,DZLNOF		;SET UP LINE COUNT
DZTNXO:	RDIO T2,DZCSR(Q2)	;READ THE STATUS
	TRNN T2,DZTRDY		;CHECK FOR TRANSMIT DONN
	JRST DZTXIT		;NOT THIS DZ TRY NEXT ONE
	LDB T2,[POINT 3,T2,27]	;PICK UP LINE NUMBER
	MOVNS T2		;GET CORRECT BIT POSITION
	MOVE Q1,BITS+^D35(T2)	;SAVE LINE NUMBER
	MOVNS T2		;BACK THE WAY IT WAS
	ADD T2,P6		;MAKE ABSOLUTE NUMBER
	JN <TTXOC>,(T2),[CALL GETEXA
			 CALL DZXOCA ;DO XON/XOF
			  JRST DZTNXO]
;**;[2629] Change one line at DZTNXO:+11.L	PED	23-JUN-82
	SKIPG T2,TTACTL(T2)	;[2629] NET DYNAMIC STORANE
;**;[2638] Delete 1 line, Add 3 at [2629]+1L	PED	30-JUL-82
	JRST [	CAML T2,[-1]	;[2638] 
		JRST DXTNEX	;[2638] 0 OR -1
		JRST .+1 ]	;[2638] OK
	SETONE TTDZI,(T2)	;SET INTERRUPT FLAG
	CALL TTSND		;DO TTY DONE
	SETZRO TTDZI,(T2)
	JN TTOTP,(T2),DZTNXO 	;DONE?
DXTNEX:	BCIOB Q1,DZTCR(Q2)  	;CLEAR THE ACTIVE BITS
	JRST DZTNXO		;TRY FOR ANOTHER
				;THIS WILL STOP INTERRUPTING DZ AND END OUTPUT

DZTXIT:	DMOVE T1,DZSVAC+T1
	DMOVE T3,DZSVAC+T3
	DMOVE Q1,DZSVAC+Q1
	DMOVE P6,DZSVAC+P6
	MOVE P,DZSAVP		;RESTORE AC
	XJEN DZXINB		;AND RETURN
; SENDALL
	SWAPCD

DZSNDL:	CAME T2,KLILNO
	CAMN T2,CTYINT		;CHECK FOR REAL CTY
	RET			;CAN'T DO THIS LINE
	PUSH P,T2
	SUB T2,DZLNOF		;FIND IF LINE A LEGAL DZ LINE
	CAML T2,DZLNNO		;LGAL? (DZ'S +CTY)
	JRST [	ADD T2,DZLNOF	;PUT LINE NUMBER BACK
		CAME T2,KLILNO	;CHECK FOR KLINIK
		CAMN T2,CTYLNO	;CHECK FOR CTY
		JRST .+1	;YUP ALL OK TO DO SENDALL
		JRST PB2]	;NOPE QUIT
DZCTOK:	POP P,T2		;RESTORE LINE NUMBER
	SKIPE FEFLG		;SECONDARY PROTOCOL?
	RETSKP			;YES RETURN OK
	SETO T2,0		;NO SKIP GROUP
	RETSKP


; SENDALL TO SPECIFIC LINE


;
DZSNSA:
DZSNSN:	CAME T2,KLILNO		;NOT KLINIK YET
	CAMN T2,CTYINT		;CHECK FOR CTY
	RET			;YES NOT THIS ONE
;**;[1760] Deleted one line at DZSNSA: +4L	JGZ	21-JUL-80
	SKIPN FEFLG		;CHECK FOR PRIMARY PROTOCOL
	RET			;NO SEND ALL LEGAL HERE
	PUSH P,T2		;SAVE REGISTER
	SUB T2,DZLNOF		;FIND BEGINNING OF LINES
	CAML T2,DZLNNO		;LGAL? (DZ'S + CTY)
	JRST [	ADD T2,DZLNOF	;PUT LINE NUMBER BACK
		CAME T2,KLILNO	;CHECK FOR KLINIK
		CAMN T2,CTYLNO	;CHECK FOR CTY
		JRST .+1	;YUP DO SENDALL
		JRST PB2]	;NO ON SENDALL
	POP P,T2		;YES
	RETSKP			;RETURN SEND ALL LEGAL

	RESCD
;
	SWAPCD
; SET SPEED FOR A DZ11 LINE
;

DZSSP2:	UMOVE T4,2		;GET FLAGS
	TXNE T4,MO%AUT		;REQUESTING AUTO?
;**;[1820] Deleted one line and added three at DZSSP2: + 2L	DAD	15-DEC-80
	JRST [	TXNE T4,MO%RMT	;[1820] YES. ALSO WANT REMOTE?
		JRST .+1	;[1820] YES. PROCEED THEN
		RET]		;[1820] NO. ILLEGAL REQUEST
	SKIPN DZLNCT		;IF NO DZ LINES CAN'T SET SPEED
	RET
	UMOVE T4,T3		;GET THE SPEED
	HLRZ T1,T4		;CHECK TO SEE BOTH HALF THE SAME
	CAME T2,KLILNO		;NOT KLINIK LINE NUMBER EITHER
	CAMN T2,CTYINT		;CHECK FOR CTY
	RET			;NOT LEGAL ON THIS MACHINE
	CAME T2,CTYLNO		;CHECK TO SEE IF CTY <CAN'T SET THAT ONE)
	CAIE T1,0(T4)		;IF NOT SAME THEN FORGET IT HARDWARE
	RET			;SUPPORTS INPUT/OUTPUT SAME
	NOINT			;SET NOINT
	CHNOFF DLSCHN		;TURN OFF CHANNEL WHILE PLAYING WITH LINE SPEEDS
	JN TTFEM,(T2),DZSSP1	;IF REMOTE DON'T SET PERM SPEED
	XCTU [SKIPGE 2]		;REMOTE REQUESTED?
	JRST [	MOVX T3,SC%OPR!SC%WHL	;CHECK CAPBILITIES
		TDNN T3,CAPENB
		JRST DZSSP1		;NO CAPABILITIES FORGET IT
;**;[1820] Added six lines at DZSSP2: + 22L	DAD	15-DEC-80
		SETONE TTFEM,(T2)	;[1820] SET ONCE ONLY FLAG
		UMOVE T3,2		;[1820] GET THE REMOTE AND AUTOBAUD BITS
		TXNN T3,MO%AUT		;[1820] IS THE LINE TO BE AUTOBAUD
		JRST .+1		;[1820] NO, CONTINUE
		SETONE TTAUT,(T2)	;[1820] YES, SET THE AUTOBAUD BIT
		MOVE T4,[<^D300>B17+<^D300>B35] ;[1820] SET THE DEFAULT SPEED
		JRST .+1]	;AND CONTINUE
	JUMPE T4,[EXCH T4,TTSPWD(T2) ;TREAT SPEED ZERO SPECIALLY, PRESERVE
		  JRST DZSSP1]	; OUTPUT CHARACTERISTICS, TURN OFF INPUT
	MOVEM T4,TTSPWD(T2)	;SAVE TTY SPEED
;**;[1820] Inserted one line at DZSSP1:	DAD	15-DEC-80
DZSSP1:	MOVEM T4,DZSPWD(T2)	;[1820] SET THE DZ11 SPECIFIC SPEED WORD
	HRRZS T4		;SET SPEED IN RIGHT HALF ONLY
	MOVEI T1,DZSPTB		;FIND POINTER TO TABLE POINTER
DZSPLP:	MOVE T3,0(T1)		;GET A TABLE ENTRY
	JUMPE T3,NOLNSP		;NO LINE SPEED FOUND
	CAIE T4,0(T3)		;CORRECT ENTRY?
	AOJA T1,DZSPLP		;NO -- TRY NEXT ONE
	HLRZ T4,T3		;GET LINE SPEED
	MOVE T3,T2		;GET LINE NUMBER
	SUB T3,DZLNOF		;SUBTRACT FRONT-END LINES
	CAML T3,DZLNNO		;CHECK TO SEE IF LEGAL LINE NUMBER
	JRST NOLNSP		;NOPE -- QUIT WHILE AHEAD
	ANDI T3,7		;MASK TO 3 BITS
	IOR T4,T3		;SET UNIT NUMBER
	CALL GETEXA		;GET THE EXTERNAL PAGE ADDRESS OF THIS DZ
;**;[2913] Change 1 line at NOLNSP:-3L	PED	21-FEB-83
	SKIPN DZSPWD(T2)	;SETTING SPEED TO ZERO?
	TRZ T4,DZ1RXO		;YES, FOR DZ HARDWARE TURN OFF RX CLOCK
	WRIO T4,DZLPR(T3)	;SET THE LINE PARAMETER REGISTER
NOLNSP:	CHNON DLSCHN		;ENABLE CHANNEL
	OKINT			;ENABLE INTERRUPTS
	RET			;RETURN
;**;[1820] Added 39 lines at NOLNSP: + 3L	DAD	15-DEC-80
;[1820] ROUTINE TO RETURN SPEED TO A USER
;[1820] IMPLEMENTS THE .MORSP FUNCTION OF MTOPR

DZRSPD:	SETO T3,		;[1820] SET UP THE "INDETERMINATE SPEED" VALUE
	CAME B,KLILNO		;[1820] IS THIS THE KLINIK LINE?
	CAMN T2,CTYLNO		;[1820] NO, IS THIS THE CTY?
	SKIPA			;[1820] YES, SO THE SPEED IS INDETERMINATE
DZRSP1:	MOVE C,DZSPWD(B)	;[1820] GET CURRENT SPEED
	UMOVEM C,C		;[1820] PUT INTO USER SPACE
	SETZ C,			;[1820] CLEAR C
	OPSTR <SKIPE>,TTFEM,(B)	;[1820] A REMOTE LINE?
	TXO C,MO%RMT		;[1820] YES
	OPSTR <SKIPE>,TTAUT,(B)	;[1820] AN AUTOBAUD LINE?
	TXO C,MO%AUT		;[1820] YES
	XCTU [HLLM C,2]		;[1820] PUT IT INTO USER SPACE
	RET			;[1820] AND RETURN
;[1820] HERE WITH A CHARACTER IF A LINE IS IN AUTOBAUD WAIT
;[1820] NOTE THAT Q2 HAS EXTERNAL PAGE ADDRESS

	RESCD

DZABCK:	PUSH P,T3		;[1820] SAVE AN AC
	PUSH P,T4		;[1820] SAVE ANOTHER AC
	ANDI T1,377		;[1820] AND OFF THE EXTRANIOUS GARBAGE
	MOVEI T4,DZABTB		;[1820] POINT TO THE AUTOBAUD TABLE
DZABC1:	HLRZ T3,(T4)		;[1820] GET CHARACTER FROM TABLE
	JUMPE T3,DZABC2		;[1820] IF END OF TABLE THEN QUIT
	CAME T1,T3		;[1820] IS THIS A MATCH?
	AOJA T4,DZABC1		;[1820] NO, BUMP POINTER INTO THE AUTOBAUD TABLE
				;[1820] AND CONTINUE SCANNING
	HRRZ T3,(T4)		;[1820] YES, GET THE OFFSET INTO DZSPTB
	HRRZ T4,DZSPTB(T3)	;[1820] GET THE DECIMAL LINE SPEED
	HRL T4,T4		;[1820] IN BOTH LH AND RH
	MOVEM T4,DZSPWD(T2)	;[1820] AND STORE IT IN THE SPEED WORD
	HLRZ T4,DZSPTB(T3)	;[1820] GET THE SPEED WORD
	MOVE T3,T2		;[1820] GET THE LINE NUMBER
	SUB T3,DZLNOF		;[1820] SUBTRACT THE FRONT-END LINE OFFSET
	ANDI T3,7		;[1820] MASK TO 3 BIT LINE NUMBER
	IOR T4,T3		;[1820] SET UNIT NUMBER
	WRIO T4,DZLPR(Q2)	;[1820] AND SET THE LINE SPEED
	SETZRO TTABW,(T2)	;[1820] CLEAR THE AUTOBAUD WAIT BIT
	MOVE T3,[TTCON1]	;[1820] SET CARRIER ON
	MOVEI T1,^D750		;[1820] SET THE TIMER TO 3/4 SECOND (THIS IS
				;[1820] SO LEFT-OVER CHARACTERS IN THE DZ SILO
				;[1820] GET FLUSHED BEFORE WE START THE JOB.
				;[1820] THIS WILL OCCUR WHEN WE AUTOBAUD AT 110
				;[1820] BAUD.)
	CALL TTQAD		;[1820] SCHEDULE IT
DZABC2:	POP P,T4		;[1820] RESTORE T4
	POP P,T3		;[1820] RESTORE T3
	JRST DZINPL		;[1820] AND GO CHECK FOR MORE CHARACTERS


DZSPTB:	DZ1RXO+DZ1OPA+DZ8BIT+DZ2STP+0,,^D50
	DZ1RXO+DZ1OPA+DZ8BIT+DZ2STP+400,,^D75
	DZ1RXO+DZ1OPA+DZ8BIT+DZ2STP+1000,,^D110
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+1400,,^D134
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+2000,,^D150
;**;[1924] Change 1820 lines at DZSPTB: +5L	JGZ	18-AUG-81
;**;[1820] Change one line at DZSPTB: +5L	DAD	15-DEC-80
DZATSP:	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+2400,,^D300	;[1820] OUR AUTOBAUD SPEED
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+3000,,^D600
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+3400,,^D1200
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+4000,,^D1800
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+4400,,^D2000
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+5000,,^D2400
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+5400,,^D3600
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+6000,,^D4800
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+6400,,^D7200
	DZ1RXO+DZ1OPA+DZ8BIT+DZ1STP+7000,,^D9600
	0,,0			;END OF TABLE
;**;[1924] Change 1820 lines at DZSPTB: +16L	JGZ	18-AUG-81
;**;[1820] Added a 12 line autobaud speed table at DZSPTB: + 16L	DAD	15-DEC-80
;[1820] TABLE OF AUTOBAUD DETECT CHARACTERS AND OFFSETS INTO DZSPTB:
;[1820] THIS TABLE IS SET UP WITH THE MOST COMMON SPEEDS FIRST TO
;[1820] MINIMIZE OVERHEAD.

DZABTB:	015,,5		;[1820] <CR> AT 300 BAUD
	215,,5		;[1820] <CR> AT 300 BAUD
	003,,5		;[1820] <^C> AT 300 BAUD
	203,,5		;[1820] <^C> AT 300 BAUD
	376,,7		;[1820] <ANYTHING> AT 1200 BAUD
	377,,7		;[1820] <ANYTHING> AT 1200 BAUD
	214,,2		;[1820] <CR> AT 110 BAUD
	234,,2		;[1820] <CR> AT 110 BAUD
	174,,2		;[1820] <^C> AT 110 BAUD
	346,,4		;[1820] <CR> AT 150 BAUD
	036,,4		;[1820] <^C> AT 150 BAUD
	0,,0		;[1820] END OF TABLE
;GETEXA -- SUBROUTINE TO FIND THE EXTERNAL PAGE ADDRESS OF 
; THE SPECIFIED DZ11

; CALLING SEQUENCE:
; T2 -- LINE NUMBER
;
;	CALL GETLIN
; T1 -- LINE BIT POSITION (LINE 0=1B35 ETC)
; T3 -- EXTERNAL PAGE ADDRESS OF FIRST REGISTER FOR THIS DZ11
; RETURNS +1 ALWAYS

GETEXA:	PUSH P,T2		;SAVE LINE NUMBER
GETEX1:	SUB T2,DZLNOF		;BACKUP TO POINT TO REAL  NUMBER
	MOVE 3,2		;GET LINE NUMBER
	ANDI T3,777770		;MASK OF LOW ORDER 3 BITS (8 PER DZ)
	ADD T3,[DZ11BA]		;ADD DZ11 BASE ADDRESS
	MOVE T1,T2
	ANDI T1,7		;MASK OFF UNIT
	MOVNS T1
	MOVE T1,BITS+^D35(T1)
	POP P,T2		;RESTORE
	RET

;
;  GETEXL -- SUBROUTINE TO FIND EXTERNAL PAGE AND LINE NUMBER
;
;	CALLING SEQUENCE:
;	B -- DYNAMIC STORAGE ADDRESS
;	CALL GETEXL
;	RETURNS:
;	A -- LINE BIT POSITION (LINE 0=1B35 1,1B34 ETC)
;	C -- EXTERNAL PAGE ADDRESS OF THIS DZ11
;

GETEXL:	PUSH P,T2		;SAVE DYNAMIC ADDRESS
	DYNST			;GET LINE NUMBER
	CALLRET GETEX1		;GET EXTERNAL PAGE ADDRESS