	.TITLE	WITS
/
/   5 JUN 74 (PDH) ALLOW LOCAL RETRIEVAL & SENDING OF FILES
/  14 MAR 73 - AUTOMATIC SIGN-ON
/   1 MAR 73 - PAUL HENDERSON - FIRST SUCCESS
/
/  PROGRAM TO USE BD50 IN ORDER TO MAKE THE PDP-9 APPEAR AS A
/  BUFFERED TERMINAL TO TALK TO WITS ON THE 360/75.
/
DKI=1
DKO=2
TTI=4
BDI=5
BDO=6
PD=10
AUTO12=12
AUTO13=13
/
	.IODEV	DKI,DKO,TTI,BDI,BDO,PD
/
	.GLOBL	FILENM
/
WITS	.INIT	TTI,0,SIGNON
	.INIT	BDI,0,WITS	/INITIALIZE ALL DEVICES
	.INIT	BDO,1,WITS
	.INIT	PD,1,WITS
/
	.WRITE	PD,2,INITAL,0	/TELL USER WHO WE ARE
	.READ	BDI,3,IMAGE,3	/BEGIN INPUT FROM 360/75
ICMD	.READ	TTI,2,LINE,34	/ALSO BEGIN COMMAND INPUT
MAIN	JMS	BDREAD
	NOP
	JMS	TTREAD		/MAIN LOOP JUST CIRCULATES
	NOP
	JMP	MAIN
/
SIGNON	.WRITE	PD,2,AUTO,0     /ANNOUNCE WE ARE IN AUTOMATIC SIGNON
	DZM	BDCHAR		/CLEAR CHARACTER READ, IN CASE OF 'DC3'
SENDCR	.WRITE	BDO,2,CR,0      /SEND CR TO 360/75
	JMS	BDREAD
	NOP
WAIT1	JMS	BDREAD
	JMP	WAIT1
	SAD	(23		/END OF OUTPUT?
	SKP
	JMP	WAIT1		/NO.  READ NEXT CHARACTER
	.WRITE	PD,2,PASSWD,0   /DISPLAY HASP ACCOUNT NUMBER
	.WRITE	BDO,2,PASSWD,0  /LOG IN
/
WAIT2	JMS	BDREAD
	JMP	WAIT2
	SAD	(23
	SKP
	JMP	WAIT2
	.WRITE	PD,2,PAGE,0     /SET UP PAGE SIZE & READY ID FOR
	.WRITE	BDO,2,PAGE,0    /THE PDP-9
/
WAIT3	JMS	BDREAD
	JMP	WAIT3
	SAD	(23
	SKP
	JMP	WAIT3
	.WRITE	PD,2,TABS,0
	.WRITE	BDO,2,TABS,0
	JMP	ICMD
	.EJECT
/
/  SUBROUTINE TO READ SINGLE CHARACTER FROM 360/75, DISPLAY IT
/  ON THE DISPLAY, AND PERFORM SPECIAL FUNCTION WHEN
/  DC3 <23> IS ENCOUNTERED.
/
/  CALLING SEQUENCE:
/
/	JMS	BDREAD
/	(RETURN IF INPUT NOT COMPLETE)
/	(RETURN WITH CHARACTER JUST READ IN AC)
/
BDREAD	XX
	.WAITR	BDI,BDBUSY      /HAS CHARACTER BEEN RECEIVED?
	LAC	IMAGE+2
	AND	(177		/GET CHARACTER & TRIM TO 7-BITS
	SAD	(177
	JMP	READB		/IGNORE DELETE
	SNA
	JMP	READB		/IGNORE NULL CHARACTERS
	DAC	BDCHAR		/SAVE CHARACTER
	ISZ	BDREAD		/INCREMENT RETURN ADDRESS
	SAD	(23		/ DC3 ?
	JMP	DC3
	ALSS	13		/LEFT JUSTIFY CHARACTER
	XOR	(175*20         /ALT MODE IN 2ND CHARACTER
BDWRT	DAC	PDLINE+2
	.WRITE	PD,2,PDLINE,0   /DISPLAY CHARACTER
READB	.READ	BDI,3,IMAGE,3   /READ NEXT CHARACTER
BDBUSY	LAC	BDCHAR		/LEAVE WITH CHARACTER IN AC
	JMP*	BDREAD
/
DC3	LAC	(23*200+10*20+17	/  <23><10><175>
	JMP	BDWRT
	.EJECT
/  SUBROUTINE TO READ A COMPLETE LINE IN IOPS ASCII FROM THE
/  CONTROL TELETYPE, DISPLAY IT ON THE 340C, AND SEND IT
/  TO THE 360/75.  IF THE FIRST CHARACTER IN THE LINE IS
/  ALT MODE, IT IS INTERPRETED AS A REQUEST FOR 'ATTENTION',
/  AND THE APPROPRIATE SEQUENCE IS INITATED.
/
/  CALLING SEQUENCE:
/
/	JMS	TTREAD
/	(RETURN IF INPUT NOT COMPLETE)
/	(RETURN WHEN INPUT COMPLETE)
/
TTREAD	XX
	.WAITR	TTI,TTBUSY
	774000
	AND	LINE+2
	SAD	ALT		/IF 1ST CHARACTER IS ALTMODE,
	JMP	ATTN		/PRESENT ATTENTION
	LAW	-42
	DAC	MOVCNT		/WE WILL MOVE LINE TO OUTPUT BUFFER
	LAC	(LINE-1
	DAC*	(AUTO12
	LAC	(BDLINE-1
	DAC*	(AUTO13
	LAC*	AUTO12
	DAC*	AUTO13		/MOVE LINE
	ISZ	MOVCNT
	JMP	.-3
	ISZ	TTREAD		/INCREMENT RETURN ADDRESS
	.WRITE	PD,2,BDLINE,0   /DISPLAY LINE
	LAW	774000
	AND	BDLINE+2	/ GET 1ST CHARACTER
	SAD	LPAREN		/ IS IT  '(' ?
	JMP	COMAND		/ YES.  FIND OUT WHAT COMMAND IT IS.
	.WRITE	BDO,2,BDLINE,0  /SEND LINE TO 360/75
READT	.READ	TTI,2,LINE,34   /READ NEXT COMMAND LINE
TTBUSY	JMP*	TTREAD
	.EJECT
ATTN	.WRITE	PD,2,ATTEN,0    /SHOW THAT WE ARE PRESENTING ATTENTION
	.WRITE	BDO,3,NULLS,0   /SEND ATTENTION CODE TO 360/75
	JMP	READT
/
ATTEN	AT-.*400+2
	0
	.ASCII	'*** ATTENTION ***'<15>
AT=.
/
NULLS	2003; 0; 0; 0
	.EJECT
COMAND	LAC	BDLINE+2	/ VALIDATE COMMAND
	SAD	.PUT
	JMP	PUT		/ COMMAND WOULD APPEAR TO BE 'PUT'
	SAD	.GET
	JMP	GET		/ PERHAPS 'GET'
/
/  SPACE FOR FUTURE COMMANDS
/
INVALC	.WRITE	PD,2,NOCMD,0	/ '**INVALID  LOCAL COMMAND'
	JMP	READT		/ RE-ENTER NORMAL SEQUENCE
/
PUT	LAC	BDLINE+3	/ VALIDATE LAST HALF OF COMMAND
	SAD	.PUT+1
	SKP
	JMP	INVALC		/ INVALID LOCAL COMMAND
	JMS*	FILENM
	BDLINE+4
	NAME
	LAC	NAME+2
	SNA
	LAC	SRC		/ DEFAULT EXTENSION IS 'SRC'
	DAC	NAME+2
/
	.INIT	DKI,0,SIGNON
	.FSTAT	DKI,NAME	/ DOES FILE EXIST?
	SNA
	JMP	NOFILE		/ NO.  COMPLAIN ABOUT IT.
	.SEEK	DKI,NAME	/ OPEN REQUESTED FILE
/
WAITP1	JMS	BDREAD		/ FIND OUT IF WE CAN SEND
	NOP
	SAD	(23		/ IS IT 'PROCEED' CHARACTER?
	SKP
	JMP	WAITP1		/ NO.  WAIT LONGER.
	.WRITE	BDO,2,AUETC,0	/ 'AU ETC'
	LAC	(LINE1
	DAC	M01
	DAC	M02		/ SET UP BUFFER ADDRESSES
	DAC	M03
	LAC	(LINE2
	DAC	M04
READ1	.READ	DKI,2,LINE1,34	/ READ FIRST LINE OF FILE.
M02=READ1+2
	.READ	TTI,2,LINE,34	/ READ NEXT COMMAND LINE
/
WAITP2	JMS	BDREAD		/ MUST WAIT UNTIL 360/75 READY
	JMP	WAITP2
	SAD	(23
	JMP	WAITIN
	.WAITR	TTI,WAITP2
	LAW	774000
	AND	LINE+2		/ CHECK 1ST CHARACTER
	SAD	ALT		/ IS IT PSEUDO 'ATTENTION' ?
	JMP	READT		/ END 'PUT' ON 'ATTENTION'.
	JMP	WAITP2
WAITIN	.WAIT	DKI		/ WAIT FOR INPUT
	LAC*	M03
	AND	(7
	SAD	(5		/ EOF?
	SKP
	SAD	(6		/ EOM?
	JMP	INPEND		/ END OF INPUT
READ2	.READ	DKI,2,LINE2,34	/ READ NEXT LINE
M04=READ2+2
WRITE1	.WRITE	PD,2,LINE1,0	/ PUT LINE ON DISPLAY
M01=WRITE1+2
WRITE2	.WRITE	BDO,2,LINE1,0	/ SEND LINE TO 360
M03=WRITE2+2
	LAC	M04
	DAC	M02		/ SWAP M04 & M03
	LAC	M03
	DAC	M04
	LAC	M02
	DAC	M01
	DAC	M03
	JMP	WAITP2
/
INPEND	.CLOSE	DKI
	.WRITE	PD,2,ENDAU,0	/ "** END OF 'PUT'"
	.WRITE	BDO,2,CR,0	/ CARRIAGE RETURN TO GET OUT OF 'AUTOLINE'
	JMP	READT
/
NOFILE	.WRITE	PD,2,NOFIL,0	/ 'FILE NOT FOUND'
	JMP	READT		/RE-ENTER MAIN LOOP
/
AUETC	AU-.*400+2; 0; .ASCII 'AU ETC'<15> ;AU=.
ENDAU	EA-.*400+2; 0; .ASCII "** END OF 'PUT'"<15> ;EA=.
NOCMD	NC-.*400+2; 0; .ASCII '** INVALID LOCAL COMMAND'<15> ;NC=.
NOFIL	NF-.*400+2; 0; .ASCII '** FILE NOT FOUND'<15> ;NF=.
/
/
/
/
GET	JMP	INVALC		/ RESERVED FOR COMMAND 'GET'
/
/
/
LINE1	.BLOCK	42; .ASCII <15>
LINE2	.BLOCK	42; .ASCII <15>
	.EJECT
CR	C-.*400+2
BDCHAR
	.ASCII	<15>
C=.
/
ALT	.ASCII	<175> ; .LOC .-1
LPAREN	.ASCII	'('   ; .LOC .-1
.PUT	.ASCII	'(PUT '
.GET	.ASCII	'(GET '
NAME	.BLOCK	3
SRC	.SIXBT	'SRC'
/
PASSWD	PW-.*400+2
	0
	.ASCII	'T0657FIELD.EN,PDP9'<15>
PW=.
/
PAGE	PA-.*400+2
	0
	.ASCII	'PAGE-NOPROMPT FOLD=80;CONTROL RID=NONE;'
	.ASCII	'TABSET'<15>
PA=.
/
TABS	TA-.*400+2
	0
	.ASCII	<11>'T'<11>'T'<11>'T'<11>'T'<11>'T'
	.ASCII	<11>'T'<11>'T'<11>'T'<11>'T'<15>
TA=.
/
IMAGE	.BLOCK	3
PDLINE	2002; 0; 0; 500000	/LAST WORD CONTAINS 2ND HALF OF <175>
BDLINE	.BLOCK	42
LINE	.BLOCK	42
/
INITAL	IL-.*400+2
MOVCNT
	.ASCII	<13>'PDP-9 BUFFERED WITS TERMINAL.  '
	.ASCII	'WAIT FOR 360/75'<15>
IL=.
/
AUTO	AU-.*400+2
	0
	.ASCII	'*** AUTOMATIC INITIALIZATION ***'<15>
AU=.
/
	.END	WITS
