perm filename PTYFIL.FAI[NEW,AIL] blob sn#408310 filedate 1979-01-08 generic text, type T, neo UTF8
SEARCH HDRFIL
COMPIL(PTY,<PTYGET,PTYREL,PTIFRE,PTOCNT,PTCHRW,PTCHRS
ENTINT <PTOCHS,PTOCHW,PTOSTR,PTYALL,PTYSTR,PTYIN>
ENTINT <PTYLCH,PTYGTL>>
	  ,<SAVE,RESTR,X11,X22,X33,INSET,CAT,STRNGC,GOGTAB,BRKMSK,BKTCHK,.SKIP.,RELEAS,OPEN,OUT,GETCHA,GETCHN,WORDOU,WORDIN,GETSTS>
	  ,<PTY ROUTINES>)
COMMENT ⊗Ptyuuo functions ⊗

	OPDEF	PTYUUO	[711B8]

DSCR PTYUUO FUNCTIONS
CAL SAIL
⊗
COMMENT ⊗
BEGIN "PTYSPC"
INTEGER PROCEDURE PTYGET;
PROCEDURE PTYREL(INTEGER LINE);
INTEGER PROCEDURE PTIFRE(INTEGER LINE);
INTEGER PROCEDURE PTOCNT(INTEGER LINE);
INTEGER PROCEDURE PTCHRS(INTEGER LINE);
PROCEDURE PTOCHS(INTEGER LINE,CHAR);
PROCEDURE PTOCHW(INTEGER LINE,CHAR);
PROCEDURE PTOSTR(INTEGER LINE; STRING INFORMATION);
STRING PROCEDURE PTYALL(INTEGER LINE);
STRING PROCEDURE PTYSTR(INTEGER LINE,BRCHAR);
STRING PROCEDURE PTYIN(INTEGER LINE,BKTBL; REFERENCE INTEGER BRCHAR);

END "PTYSPC"

⊗
	EXTERN SIMIO


HERE (PTYGET)
	SETZM	.SKIP.
	MOVEI	A,0
	PUSHJ	P,GETCHAN
	JUMPL	A,NIX
	MOVE	CHNL,A
	PUSHJ	P,GETCHN
	move	0,errtst(cdb)
	trz	0,40000
	movem	0,errtst(cdb)
	PUSH	P,CHNL
	PUSH	SP,[3]
	PUSH	SP,[POINT  7,[ASCIZ/PTY/]]
	PUSH	P,[0]
	PUSH	P,[2]
	PUSH	P,[2]
	PUSH	P,[dummy]
	PUSH	P,[0,,DUMMY]
	PUSH	P,[0,,EOF]
	PUSHJ	P,OPEN
	JUMPL	a,NIX
	MOVE	A,CHNL
	SETOM	.SKIP.
	popj	p,
NIX:	POPJ	P,

HERE (PTYREL)
	EXCH	A,-1(P)
	PUSH	P,A
	PUSH	P,[0]
	PUSHJ	P,RELEAS
	POP	P,A
	POP	P,A
	JRST	@2(P)

HERE (PTYGTL) PUSH	P,(P)	;ANOTHER COPY OF RETURN ADDRESS.
	MOVE	-2(P)
	CALLI	0,127
	JRST	NSD
	TTCALL	7,0
	MOVEM	-1(P)
	JRST	.+3
NSD:	OUTSTR	[ASCIZ/NO SUCH DEVICE/]
	SETZM	-1(P)
	MOVE	A,-1(P)	;RESULT.
	SUB	P,X33
	JRST	@3(P)	;AND RETURN.

HERE (PTYLCH)
	move	a,-3(p)
	calli	a,127
	outstr	[
asciz/** PTY ERROR- No Pty on channel specified **
/]
	movem	a,-3(p)
	move	0,-4(p)
	movei	a,2
	cail	0,5
	caile	0,7
	skipa
	movei	a,3
	cain	0,13
	movei	a,4
	trne	0,2000
	movei	a,3
	cain	0,16
	movei	a,3
	movs	a,a
	hrri	a,-4(p)
	calli	a,116
	outstr	[
asciz/** PTY ERROR- Trmop. uuo error **
/]
	sub	p,[5,,5]
	jrst	@5(p)

HERE (PTIFRE)
	EXCH	0,-1(P)
	MOVE	CHNL,0
	PUSHJ	P,GETCHN
	MOVN	A,OCOWNT(CDB)
	ADDI	A,120
	POP	P,0
	POP	P,0
	JRST	@2(P)

HERE (PTOCNT)
	EXCH	0,-1(P)
	MOVE	CHNL,0
	PUSHJ	P,GETCHN
	MOVE	A,ICOWNT(CDB)
	POP	P,0
	POP	P,0
	JRST	@2(P)

HERE (PTCHRW)
	PUSH	P,-1(P)
	PUSHJ	P,PTOCNT
	SKIPLE	A
	jrst	wrdn
	PUSH	P,-1(P)
	PUSHJ	P,GETSTS
	TRNE	A,2000
	jrst	wrdn

SLP:	SETO	A,
	WAKE	A,
	JRST	HIBERR
	MOVSI	A,70
	HIBER	A,
	JRST	HIBERR
	HIBER	A,
	JRST	HIBERR
	push	p,-1(p)
	push	p,getsts
	trne	a,2000
	jrst	wrdn
	jrst	slp
HIBERR:	OUTSTR	.+2
	jrst	4,
	ASCIZ/**PTY FUNCTION NOT IMPLEMENTED- HIBER UUO ERROR**/

WRDN:	MOVE	CHNL,-1(P)
	PUSHJ	P,GETCHN
	SETZM	@ENDFL(CDB)
WI:	SOSL	ICOWNT(CDB)
	JRST	WOKI
	XCT	IOIN,SIMIO
	SOSGE	ICOWNT(CDB)
	TDZA	A,A
WOKI:	ILDB	A,IBP(CDB)
	SUB	p,X22
	JRST	@2(P)

HERE (PTCHRS)
	push	p,-1(p)
	pushj	p,ptocnt
	jumpg	a,wrdn
	push	p,-1(p)
	pushj	p,getsts
	trne	a,2000
	jrst	wrdn
	seto	a,
	sub	p,x22
	jrst	@2(p)

HERE (PTOCHS)
	setzm	.skip.
	move	user,gogtab
	move	temp,-1(p)
	pop	p,-1(p)
	PUSH	SP,[1]
	PUSH	SP,TOPBYTE(user)
	IDPB	TEMP,TOPBYTE(user)
	push	p,-1(p)
	pushj	p,ptostr
	push	p,-1(p)
	pushj	p,getsts
	trnn	a,40000
	setom	.skip.
rtn:	sub	p,x22
	jrst	@2(p)

HERE (PTOCHW)
	MOVE	CHNL,-2(P)
	PUSHJ	P,GETCHN
	MOVE	TEMP,-1(P)
	pop	p,-1(p)
	PUSH	SP,[1]
	PUSH	SP,TOPBYTE(CDB)
	IDPB	TEMP,TOPBYTE(CDB)
	jrst	ptostr


HERE (PTOSTR)
	MOVE	USER,GOGTAB
	PUSHJ	P,INSET
	JRST	OUT

HERE (PTYALL)
	PUSHJ	P,SAVE
	MOVE	0,-1(P)	;LINE NUMBER
	MOVE	CHNL,0
	PUSHJ	P,GETCHN
	MOVN	A,OCOWNT(CDB)
	ADDI	A,120
	JUMPE	A,[PUSH SP,[0]
		   PUSH SP,[0]
		   JRST ALLQ]
	MOVEI	A,=450
	ADDM	A,REMCHR(USER)
	SKIPL	REMCHR(USER)
	PUSHJ	P,STRNGC
	PUSHJ	P,INSET
	PUSH	SP,-1(P)	;PTY LINE NUMBER
	PUSH	SP,TOPBYTE(USER)	;AND BYTE POINTER.
	MOVE	CHNL,-1(SP)	;AND ASK FOR ALL THAT IS THERE.
RDIN:	PUSH	P,CHNL
	PUSHJ	P,WORDIN
	SKIPN	EOF
	IDPB	A,(SP)
	SKIPN	EOF
	JRST	RDIN
	MOVEI	B,0
	MOVE	C,(SP)		;BYTE POINTER.
;;#IN# 7-11-72 DCS TOPBYTE INVALIDLY UPDATED (ONE TOO FAR)
SOMMOR:	MOVE	LPSA,C		;LAG BY ONE		#IN#
	ILDB	0,C		;GET CHAR
	JUMPE	0,ALLDUN
	AOJA	B,SOMMOR
ALLDUN:	CAILE	B,=445
	 ERR	 <PTYALL OVERFLOW -- IT JUST CAN'T HAPPEN!!!!>
	HRROM	B,-1(SP)	;SAVE AS RESULT.
	MOVEM	LPSA,TOPBYTE(USER);THIS IS WHERE TO START ENXT ITEM. #IN#
;;#IN#
	SUBI	B,=156		;-ESTIMATE
	ADDM	B,REMCHR(USER)	;AND UPDATE FREE COUTN.
ALLQ:	MOVE	LPSA,X22
	JRST	RESTR

%REDSTR:SKIPE	SGLIGN(USER)
	PUSHJ	P,INSET
	MOVEI	A,=100
	ADDM	A,REMCHR(USER)
	SKIPLE	REMCHR(USER)
	PUSHJ	P,STRNGC
	MOVNI	A,=100
	PUSH	SP,[0]		;NULL STRING IF NOTHING DONE
	PUSH	SP,TOPBYTE(USER)
	POPJ	P,

%FINSTR:	CAIN	TEMP,15	;REMOVE LFD IF CR BROKE IT
;;#PO# ! RHT THIS USED TO BE CDB (=11) & MUNGED 12
;; USE C & D INSTEAD
	PUSH	P,A
	PUSH	P,C
	PUSHJ	P,PTCHRW
	MOVE	D,A
	POP	P,A
%FINS1:	ADDM	A,REMCHR(USER)	;NUMBER NOT USED
	ADDI	A,=100		;NUMBER USED
	HRROM	A,-1(SP)	; AND TO STRING COUNT WORD
	JRST	RESTR

HERE (PTYSTR)
	PUSHJ	P,SAVE
	PUSHJ	P,%REDSTR
;;#PO#
	MOVE	C,-2(P)
	MOVE	B,-1(P)		;BREAK CHAR
	MOVE	LPSA,X33	;# TO REMOVE
;;#PO# (2 LINES)
	PUSH	P,A
%INS1:	PUSH	P,C
	PUSHJ	P,PTCHRW
	MOVE	D,A
	POP	P,A
%INS2:	CAMN	D,B		;BREAK?
	 JRST	 %FINSTR		; YES, ALL DONE
;;#PO#
	IDPB	D,TOPBYTE(USER) ;PUT IT AWAY AND
	AOJA	A,%INS1		; GO BACK FOR MORE

	JRST	%INS2

HERE (PTYIN) PUSHJ	P,SAVE
;;#PO# (2 LINES)
	MOVE	C,-3(P)
	PUSH	P,A
	PUSH	P,C
	PUSHJ	P,PTCHRW
	MOVE	D,A
	POP	P,A
%TYIN:	PUSHJ	P,%REDSTR		;PREPARE STACK,A,STRNGC FOR A STRING
	MOVE	LPSA,[XWD 4,4]		;PREPARE TO RETURN
%TYIN1:	SETZM	@-1(P)		;ASSUME NO BREAK CHAR
	MOVE	X,-2(P)		;TABLE #
	MOVEI	TEMP,-1		;BLOCK MUST BE THERE AND BE INIT'ED
	PUSHJ	P,BKTCHK	;CHECK TABLE #
	 JRST	%FINS1		;ERROR OF SOME SORT
	MOVE	FF,BRKMSK(CHNL)	;GET MASK FOR THIS TABLE
	ADD	CHNL,CDB	;RELOCATE RANGE 1 TO 18
	MOVEI	Z,1		;FOR TESTING LINE NUMBERS
	SKIPN	LINTBL(CHNL)	;DON'T LET TEST SUCCEED IF
	 MOVEI	 Z,0		;WE'RE TO LET LINE NUMBERS THRU
	MOVE	Y,CDB		;BASE OF THIS GROUP
;;#PO# !
	ADD	Y,[XWD D,BRKTBL] ;BRKTBL+RLC(CDB)
	JRST	%TTYN1
;;#PO# !
	PUSH	P,A
%TTYN:	PUSH	P,C
	PUSHJ	P,PTCHRW
	MOVE	D,A
	POP	P,A
%TTYN1:	TDNE	FF,@Y		;BREAK OR OMIT?
	JRST	%TTYSPC		; YES, FIND OUT WHICH
;;#PO# !
%TTYC:	IDPB	D,TOPBYTE(USER)	;PUT IT AWAY
	AOJL	A,%TTYN		;COUNT AND CONTINUE
	JRST	%FINS1		;DONE
%TTYSPC: HLLZ	TEMP,@Y		;WHICH?
	TDNN	TEMP,FF
	JRST	%TTYN		;OMIT
;;#PO# !
	MOVEM	D,@-1(P)
	SKIPN	Y,DSPTBL(CHNL)	;PICK UP DISPOSITION WORD
	JRST	%FINS1		;DONE, NO SAVE
	JUMPL	Y,%TTYAPP	;APPEND
	ERR	<PTYIN: cannot retain break char>,1,%FINS1
;;#PO#
%TTYAPP: IDPB	D,TOPBYTE(USER)	;COUNT THE BREAK CHAR
	ADDI	A,1		;ONE MORE HAPPY CHAR
	JRST	%FINS1
EOF:	0
DUMMY:	200

ENDCOM(PTY)