	.title	XON -- Resume output to a Non-Keyboard Terminal
	.ident	"V1.0"
	.nlist	bex,me
	.enabl	lc
	.sbttl	Author's Credits
 
;	Author:		Henry Tumblin
;			The Jackson Laboratory Computer Service
 
;	Date:		July 14,1978
 
;	Version:	1.0
 
;	Residence:	DB1:[1,20]XON.MAC,XON.CMD
 
;	For:		Systems
 
;	Core Requirements:  @1-K
 
;	Machine/System:	PDP-11/70 - IAS V2.0
 
;	Type/Language:	Main/Assembler(MACRO)
 
;	Indirect Command File:  XON.CMD
 
;	Abstract:	This program was originally developed by Andy Putnins
;			of DEC software services. This program will plant
;			a CONTROL-Q(XON) in the terminal handler on the
;			behalf of a non-keyboard terminal whose output
;			has been suspended by XOFF(CONTROL-S), such as with
;			an LA180S. 
;
;	Edits:	
 
;	Date	By	Reason
;    ---------	------	----------------------------------------------------
;    14-Jul-78	HRT	Added feature to allow the user to type the
;			terminal number to plant a Control-Q in, instead
;			of it being hard-wired into the program.
 
;	Example:  PDS> XON TT12:
;


	.sbttl	Tell the assembler which libmacs to use

	.mcall	GMCR$,EXIT$S,DIR$,QIOW$
  
	.sbttl	Define the GMCR DPB and Buffer
 
GMCR:	GMCR$		;SET UP COMMAND BUFFER
WRITE:	QIOW$	IO.WVB,1,1,150,,,<ERR1,ERR1S,40>
DEVUN:	.byte	0	;buffer for terminal number 
ERR1:	.ASCII	"XON -- Bad command string or bad terminal number"
	err1s=.-err1
	.even

	.sbttl	Start mainline code

;	This section will get an MCR command line and
;	determine which terminal to plant a Control-Q in.
;	The syntax is strict - there must be a terminal specified
 
start:	DIR$	#GMCR		;GET COMMAND LINE
	CMP	#9.,@#$DSW	;SEE IF TOO MANY CHARACTERS TYPED
	BLO	ERR		;LOS - THEN ERROR CONDITION
	MOV	#GMCR+8.,R0	;SET POINTER TO TT #
	CLR	R1
	CALL	$COTB		;CONVERT TO ASCII
	MOVB	R1,DEVUN	;STORE THE DEVICE #
	BEQ	ERR
	BR	ARND		;OF NO ERROR, THEN RETURN
 
ERR:	DIR$	#write	
	JMP	EXIT		;AND LEAVE
ARND:	MOV	.PUDBA,R0	;GET POINTER TO FIRST PUD

;	Scan PUD for terminal
;
LOOP:	CMP	#"TT,U.DN(R0)	;Is device a TT?
	BNE	10$		; no - continue
	CMPB	DEVUN,U.UN(R0)	;Unit number match??
	BEQ	Found		;yes
10$:	ADD	#U.SZ,R0	;point to next PUD
	CMP	R0,.PUDEA	;At end yet??
	BLO	loop		;NO - keep looking
EXIT:	EXIT$S
;
;	Found it - Simulate a received XON
;
;
FOUND:	MOV	U.DA(R0),R4	;Get terminal Table Entry @
	BEQ	EXIT		;never init'd by TT handler
	MOVB	#CH.XON,R5	;Plant XON (^Q)
	MOV	@#PSW,-(SP)	;save processor status
	MOVB	#M$$PRI*40,@#PSW	;raise priority to ISR level
	CALL	RCHAR		;simulate a receive interrupt
	CALL	..enb0		;restore PSW
	BR	EXIT
	.end	start
