/
/	COPYRIGHT 1971, DIGITAL EQUIPMENT CORPORATION,
/			MAYNARD, MASSACHUSETTS 01754
/	UTILITY SUBROUTINE PACKAGE
/		VERSION UTILTY.V7A (OCTOBER 26,1971)
/			(VERS. CHG. V07 TO V7A 4/25/77 MH)
/
	ENTRY	OPEN	     /INITIALIZING AND FLAG SETTING ROUTINE
	ENTRY	GENIO
	ENTRY	EXIT		/EXIT TO DISK MONITOR SYSTEM
	ENTRY	ERROR
	ENTRY	CKIO	/USELESS ROUTINE
	OPDEF	KRS	6034
	OPDEF	KCC	6032
	OPDEF	RIF	6224
	OPDEF TADI 1400
	OPDEF DCAI 3400
	OPDEF	JMSI	4400
	OPDEF JMPI 5400
/	CARD READER IOT'S
	OPDEF	RCSE	6672
	OPDEF	RCSP	6671
	OPDEF	RCSF	6631
	OPDEF	RCRA	6632
/LINE PRINTER IOT'S
	OPDEF	LLB	6666
	OPDEF	LSF	6661

	LAP

U17,	17		/*** MUST BE FIRST LOC IN PAGE ***

IOER,	1117
	0522		/"IOER" ERROR
GENIO,	BLOCK 2		/GENERAL INPUT/OUTPUT ROUTINE
	DCA	7	/SAVE ENTRY AC
GENLP,	TAD	7
	RTL
	RTL
	RAL
U200,	AND	U17
	TAD	JMPITB
	DCA	DSPACH	/INDEX JUMP TABLE BY DEVICE NUMBER
	TAD	U200
	KRS
	TAD	UM203
	SNA CLA
	KSF		/CHECK FOR ^C ON TELETYPE
DSPACH,	NOP		/NO ^C - DISPATCH TO I/O ROUTINE
	CALL	0,EXIT

JMPITB,	JMPI	DEVTAB
DEVTAB,	TTYOUT
	HSPOUT
	IOERR
	GENOUT
	TTYIN
	HSRIN
	IOERR
	GENIN
	IOERR
	IOERR
	IOERR
	IOERR
	IOERR
	IOERR
	IOERR
	IOERR

HSPOUT,	PSF
	JMP	GENLP
	TAD	7
	PLS
GENRTN,	CLA
	RETRN	GENIO

HSRIN,	ISZ	T1
	JMP	HSRSF
	TAD	U336	/TIME OUT-PRINT '^'
	TLS
HLP,	KSF
	JMP	HLP
	AND	U200	/GET 200 INTO AC 
	KRS		/READ THE CHAR.
	TAD	UM203
	SZA	CLA	/IS IT CONTROL C?
	KCC		/NO-CLEAR FLAG
	RFC		/USER TYPED-TICKLE RDR-FALL THRU RFC
HSRSF,	RSF
	JMP	GENLP
	DCA	T1
	RRB RFC
	JMP	GENRTN#
U336,	336
T1,	0

UM203,	-203


	PAGE
U377,	377		/MUST BE FIRST LOC IN THIS PAGE
GENIN,	6201
	TADI	IHNDLR
	SNA CLA		/OPEN INPUT FILE?
	JMP	IOERR	/NO
	6202
	JMS I	FICHAR	/GET A CHAR
	JMP	IOERR	/INPUT ERROR
UU200,	AND	U377
GRTN2,	RETRN	GENIO

GENOUT,	6201
	TADI	OHNDLR
	SNA CLA		/OPEN OUTPUT FILE?
	JMP	IOERR	/NO
	6202
	TAD	7	/GET CHAR TO BE OUTPUT
	AND	U377
	JMS I	FOCHAR	/PUT A CHARACTER
	JMP	IOERR	/OUTPUT ERROR
	JMP	GRTN2

IHNDLR,	122		/***ALL THESE LOCATIONS ARE VERY VOLATILE!! ***
FICHAR,	606		/*******
OHNDLR,	121		/*******
FOCHAR,	651		/******************
BATIN,	5400		/**************************
BATOUT,	7400		/**************************
BATVFY,	5600		/**************************
BATVAL,	-2214		/**************************

/
/	INITIALIZING SUBROUTINE CALLED BY FORTRAN
/	CLEARS FLOATING AC AND SETS FLAGS
/
OPEN,	BLOCK	2
	PLS
	RFC
	CALL	0,CLEAR
CDFX,	6201
	DCAI	IHNDLR
	DCAI	OHNDLR		/ZERO DEVICE-INDEPENDENT IO FLAGS
	DCA TTFLAG	/BEGINNING OF LINE
	TADI (7777	/GET BATCH FIELD
	AND (70
	TAD CDFX	/MAKE A CDF
	DCA CDFB
	TADI (7777	/GET BATCH RUNNING BIT
	RAL
	SMA CLA
	JMP IOERR	/BATCH NOT RUNNING
CDFB,	HLT
	TADI BATVFY	/CHECK CRUCIAL LOCATION
	TAD BATVAL	/FOR RL'S INITIALS
	SZA CLA
	JMP IOERR
	TAD CDFB
	IAC		/MAKE A CIF
	DCA CIFB1
	TAD CIFB1
	DCA CIFB2
	RIF		/MAKE A CDF TO HERE
	TAD CDFX
	DCA CDFH
	RETRN	OPEN


TTYIN,
CIFB1,	0		/CIF BATCH
	JMSI BATIN	/GET A CHAR
		JMP TTEOF1	/EOF
	DCA	7	/SAVE KEYBOARD CHAR
	TAD 	7
	TAD (-"$	/IS IT A "$"?
	SZA CLA
	JMP TTFUJ1	/NO
	ISZ TTFLAG	/WAS LAST CHAR <CR>?
	JMP TTYEOF	/YES - EOF
TTFUJ1,	CLA CMA
	DCA TTFLAG	/RESET FLAG FOR NON <CR>
	TAD	7
	TAD	(-215
	SNA CLA
	DCA TTFLAG	/CLEAR FLAG TO INDICATE <CR>
TYRTN,	TAD	7
	JMP	GRTN2	/RETURN WITH CHAR IN AC

TTFLAG,	0		/INITIALLY AT BEGINNING OF LINE

TTYEOF,	6201		/CDF
	TADI (7777	/GET WORD FROM FIELD 0
	RTR
	CLL CML RTL	/SET BIT 10
	DCAI (7777	/REPLACE IT
CDFH,	0		/CDF HERE
TTEOF1,	JMP IOERR	/WHAT TO DO?


TYPE,	0
	TAD	7
CIFB2,	0		/CIF BATCH
	JMSI BATOUT	/SEND A CHAR TO THE BATCH OUTPUT STREAM
	JMPI	TYPE

TTYOUT,	JMS	TYPE
	JMP	GRTN2

IOERR,	CALL	1,ERROR
	ARG	IOER


	PAGE

PMESG,	MESG
MESG,	7777
	7777
	4005
	2222
	1722
	4001
	2440
	1417
	0340
LIT7,	0007

ERROR,	BLOCK 2		/ERROR PROCESSOR
U7600,	7600
	TAD	ERROR
	DCA	TEM1
TEM1,	NOP		/SET DATA FIELD OF "CALL ERROR"
	TADI	ERROR#
	DCA	TEM3
	INC	ERROR#
E60,	CLA CMA CML	/CML IS WINDOW DRESSING
	TADI	ERROR#
	DCA	10
	INC	ERROR#
TEM3,	NOP		/DATA FIELD OF MESSAGE&ENTRY POINT
	DCA	CKIO	/ZERO "FATAL ERROR" FLAG
	TADI	10
	RAL
	SZL		/NON-FATAL BIT ON?
	ISZ	CKIO	/YES - SET "FATAL FLAG" TO NON-FATAL
	CLL RAR		/STRIP NON-FATAL BIT FROM MESSAGE
	DCA	MESG
	TADI	10	/SECOND WORD OF MESSAGE
	DCA	MESG#
	TADI	10
	DCA	TEM1
	TADI	10
	DCA	TEM3	/CALLING ADDRESS
	TAD	PMESG
	DCA	TEM2

ERLP,	TAD I	TEM2
	RTR
	RTR
	RTR
	JMS	PR6BIT
	TAD I	TEM2
	JMS	PR6BIT
	INC	TEM2
	JMP	ERLP

PRLOC,	TAD	TEM1
	RTR
	RTR
	JMS	ERTTY	/PRINT CALLING FIELD
	TAD	(-4
	DCA	TEM2
NUMLP,	TAD	TEM3
	RTL
	RAL
	DCA	TEM3
	TAD	TEM3
	JMS	ERTTY
	ISZ	TEM2
	JMP	NUMLP
	TAD	(215
	DCA	7
	JMS	TYPE
	CLA CLL CMA RTL
	JMS	TYPE
	TAD	CKIO	/GET THE FATAL ERROR FLAG
	SNA CLA		/WHADDOWEDO??
	JMP	EXITX
	RETRN	ERROR	/HE SAYS ITS NON-FATAL - LET HIM HANDLE IT

ERTTY,	0	/DIGIT PRINTING ROUTINE
	RAL
	AND	LIT7
	TAD	E60
	JMS	PR6BIT
	JMP I	ERTTY

PR6BIT,	0		/6BIT TO 8BIT CONVERTOR
	AND	(77
	SNA
	JMP	PRLOC	/MESSAGE OVER
	TAD	(7740
	SPA
	TAD	(100
	TAD	(240
	CALL	0,GENIO	/LOOK FOR ^C WHILE TYPING
	JMP I	PR6BIT

/
/EXIT TO DISK MONITOR SYSTEM
/
EXIT,	BLOCK	2
EXITX,	CALL	0,CKIO
	6203
	JMPI	U7600	/RETURN TO MONITOR

CKIO,	0
TEM2,	0	/DUMMY SUBROUTINE TO WAIT FOR I/O COMPLETE
	RETRN	CKIO


	END

