/3 KL8A SERVICE ROUTINE			FOR RTS/8 V2B
/
/
/
/
/
/
/
/
/
/COPYRIGHT  (C)  1976 BY DIGITAL EQUIPMENT CORPORATION
/
/
/
/
/
/
/
/
/
/
/THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE
/AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT
/CORPORATION.  DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/FOR ANY ERRORS THAT MAY APPEAR IN THIS DOCUMENT.
/
/THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FURNISHED TO THE PURCHASER
/UNDER A LICENSE FOR USE ON A SINGLE COMPUTER SYSTEM AND CAN BE COPIED
/(WITH INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR USE IN SUCH
/SYSTEM, EXCEPT AS MAY OTHERWISE BE PROVIDED IN WRITING BY DIGITAL.
/
/DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY FOR THE USE
/OR RELIABILITY OF ITS SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY
/DIGITAL.
/
/
/
/
/
/
/
/
/
/
/	ORIGINALLY WRITTEN BY RICHARD LARY (LATE 1975)

/	CHANGES BY S. RABINOWITZ:

/	28-SEP-76	BROKEN OUT OF EXEC
/			ADDED MULTIPLE KL8A SUPPORT
/	14-DEC-76	ADDED A CDF TO FIX A BUG


/ KL8A SERVICE MODULE
/THIS IS NOT A TASK - RATHER IT IS A MODULE WHICH ALLOWS
/INDEPENDENT TASKS TO CONNECT TO A LINE OF THE KL8A AS
/A PSEUDO-KL8J.

/****************************************
/
/	NO LITERALS PERMITTED!
/
/****************************************

/CONNECT ROUTINE - CALLED VIA

/	CDF CUR
/	CIF 0
/	IOF
/	TAD	(KL8ALINENUMBER^4
/	JMS I	(KL8ACT
/	KEYBOARD INTERRUPT ROUTINE
/	PRINTER INTERRUPT ROUTINE
/	KL8A IOT DEFINITIONS

	IFNDEF KL8A <NOKL8A,_ERROR_>
	IFZERO KL8A <KL0ERR,_ERROR_>
	IFNDEF	KL8ADV	<KL8ADV=40>
	IFNDEF	KLDV2	<KLDV2=KL8ADV+2>
	IFNDEF	KLDV3	<KLDV3=KL8ADV+4>
	KLUD=KL8A-1/3^200	/CAN FIT 3 ADDITONAL KL8A'S PER PAGE
	IFNDEF KL8ACT <KL8ACT=7400-KLUD>

MSIE=	KL8ADV^10+6000
MSAB=	KL8ADV^10+6001
MSRD=	KL8ADV^10+6005
MSCT=	KL8ADV^10+6006
MSCD=	KL8ADV^10+6010
MSLB=	KL8ADV^10+6012
	IFZERO KL8A-2&4000 <
MSIE2=	KLDV2^10+6000
MSAB2=	KLDV2^10+6001
MSRD2=	KLDV2^10+6005
MSCT2=	KLDV2^10+6006
MSCD2=	KLDV2^10+6010
MSLB2=	KLDV2^10+6012
	>
	IFZERO KL8A-3&4000 <
MSIE3=	KLDV3^10+6000
MSAB3=	KLDV3^10+6001
MSRD3=	KLDV3^10+6005
MSCT3=	KLDV3^10+6006
MSCD3=	KLDV3^10+6010
MSLB3=	KLDV3^10+6012
	>

	KL8LOC=45	/MAGIC LOCATION IN EXEC WHICH POINTS TO INTERRUPT
			/SKIP CHAIN FOR KL8A
	*KL8ACT		/MUST BE IN FIELD 0, USUALLY AT 7400

KL8ACT,	0
	JMP	AROUND	/JUMP AROUND POWER FAIL ROUTINE

KL8APF,	0		/KL8A POWER FAIL ROUTINE - MUST BE AT KL8ACT+2
	RDF
	TAD	KLCDIF
	DCA	KLPFRT	/SAVE RETURN FIELD
	JMS	KLINIT	/INITIALIZE INT ENABLES AND VECTOR ADDRESS
KLPFRT,	HLT		/RESTORE RETURN FIELDS
	JMP I	KL8APF
AROUND,	TAD	PKB0CDF	/INDEX INTO DISPATCH TABLE
	DCA	STORP
	RDF
	TAD	KLCDIF
	DCA	KL8ART	/STORE RETURN CDF CIF
	TAD I	KL8ACT	/PICK UP ARGUMENTS
	DCA	INR	/GET INPUT ADDRESS
	ISZ	KL8ACT	/POINT TO SECOND ARGUMENT
	TAD I	KL8ACT	/GET OUTPUT ADDRESS
	DCA	OUTR	/SAVE THEM IN APPROPRIATE SPOTS
	ISZ	KL8ACT	/POINT TO RETURN LOCATION
	JMS	KLINIT	/INITIALIZE THE KL8A
	DCA	.-1	/ONLY ONCE!
	CDF	0	/BUG FIX
	JMS	KLCOMN	/GET INPUT ADDRESS
INR,	0
	TAD	STORP	/GET STORE ADDRESS
	TAD	DIF
	DCA	STORP	/BUMP TO OUTPUT TABLE
	JMS	KLCOMN	/GET OUTPUT ADDRESS
OUTR,	0
KL8ART,	HLT
	ION		/TURN INTERRUPTS BACK ON
	JMP I	KL8ACT	/RETURN

PKB0CDF,KB0+1
DIF,	TT0-KB0-4
KLCOMN,	0
	TAD I	KLCOMN	/GET INPUT INTERRUPT ROUTINE ADR
	CMA
	SNA		/-1 MEANS LEAVE IT ALONE
	JMP	LVKMN
	CMA
	SZA CLA		/ZERO MEANS DISABLE THIS SIDE OF THIS LINE
	TAD	KL8ART	/GET CDF CIF
	JMS	STORE	/STORE CDF CIF OR 0
	TAD I	KLCOMN	/GET ADDRESS AGAIN
	SNA
	TAD	PIGNORE	/IF ZERO SUBSTITUTE THROWAWAY ROUTINE
	JMS	STORE
	SKP
LVKMN,	TAD	L4	/FIXUP 'STORP' AS THIS ROUTINE NORMALLY WOULD
	TAD	STORP
	DCA	STORP
	ISZ	KLCOMN	/SKIP ARGUMENT
	JMP I	KLCOMN	/RETURN
KLINIT,	0		/KL8A INITIALIZE ROUTINE
	MSCD		/INITIALIZE THE KL8A
	CLA IAC
	MSIE		/ENABLE INTERRUPTS
	CLA
	TAD	PKLAD1
	MSLB		/AND LOAD KL8A BRANCH POINTER
	CLA
	IFZERO KL8A-2&4000 <
	MSCD2		/INITIALIZE THE KL8A
	CLA IAC
	MSIE2		/ENABLE INTERRUPTS
	CLA
	TAD	PKLAD2
	MSLB2		/AND LOAD KL8A BRANCH POINTER
	CLA
	>
	IFZERO KL8A-3&4000 <
	MSCD3		/INITIALIZE THE KL8A
	CLA IAC
	MSIE3		/ENABLE INTERRUPTS
	CLA
	TAD	PKLAD3
	MSLB3		/AND LOAD KL8A BRANCH POINTER
	CLA
	>
KLCDIF,	CIF CDF 0
	TAD	PMSAB1	/GET KL8A INTERRUPT DISPATCH INSTRUCTION
	DCA I	KL8LOC	/STORE IT IN THE RTS8 EXEC
	IFZERO KL8A-2&4000 <
	TAD	KL8LOC	/GET ADDRESS OF FIRST DISPATCH LOC
	IAC		/BUMP BY ONE
	DCA	KLTEM	/SAVE IT
	TAD	PMSAB2
	DCA I	KLTEM	/STORE NEXT ONE
	>
	IFZERO KL8A-3&4000 <
	ISZ	KLTEM	/BUMP ONE AGAIN
	TAD	PMSAB3
	DCA I	KLTEM	/STORE IT TOO
	>
	JMP I	KLINIT
PIGNORE,IGNORE
PKLAD1,	KLADR1
PMSAB1,	MSAB
	IFZERO KL8A-2&4000 <
PKLAD2,	KLADR2
PMSAB2,	MSAB2
KLTEM,	0
	>
	IFZERO KL8A-3&4000 <
PKLAD3,	KLADR3
PMSAB3,	MSAB3
	>
L4,	4

STORE,	0		/ROUTINE TO STORE INTO DISPATCH TABLES
	DCA I	STORP
	ISZ	STORP
	ISZ	STORP
	JMP I	STORE

STORP,	KB0+1

IGNORE,	CLA		/MAKE SURE AC CLEAR!
	POSTDS		/DISMISS INTERRUPT
/	KL8A HARDWARE DISPATCH TABLE

	*.&7770+10	/MUST BE ON 8 WORD BOUNDARY!

KLADR1,	JMP	TT0
	JMP	TT1
	JMP	TT2
	JMP	TT3
	JMP	KB0
	JMP	KB1
	JMP	KB2
	JMP	KB3
	IFZERO KL8A-2&4000 <
KLADR2,	JMP	TT02
	JMP	TT12
	JMP	TT22
	JMP	TT32
	JMP	KB02
	JMP	KB12
	JMP	KB22
	JMP	KB32
	>
	IFZERO KL8A-3&4000 <
KLADR3,	JMP	TT03
	JMP	TT13
	JMP	TT23
	JMP	TT33
	JMP	KB03
	JMP	KB13
	JMP	KB23
	JMP	KB33
	>
/KL8A INDIVIDUAL DISPATCH ROUTINES - MUST ALL BE 4 WDS LONG!
/MUST START AT AN EVEN ADDRESS

KB0,	MSRD		/READ CHAR FROM SILO
	CDF CIF 0
	JMP I	.+1
	IGNORE

KB1,	MSRD
	CDF CIF 0
	JMP I	.+1
	IGNORE

KB2,	MSRD
	CDF CIF 0
	JMP I	.+1
	IGNORE

KB3,	MSRD
	CDF CIF 0
	JMP I	.+1
	IGNORE

TT0,	CLA
	CDF CIF 0
	JMP I	.+1
	IGNORE

TT1,	CLA
	CDF CIF 0
	JMP I	.+1
	IGNORE

TT2,	CLA
	CDF CIF 0
	JMP I	.+1
	IGNORE

TT3,	CLA
	CDF CIF 0
	JMP I	.+1
	IGNORE

	IFZERO KL8A-2&4000 <
KB02,	MSRD2		/READ CHAR FROM SILO
	CDF CIF 0
	JMP I	.+1
	IGNORE

KB12,	MSRD2
	CDF CIF 0
	JMP I	.+1
	IGNORE

KB22,	MSRD2
	CDF CIF 0
	JMP I	.+1
	IGNORE

KB32,	MSRD2
	CDF CIF 0
	JMP I	.+1
	IGNORE

TT02,	CLA
	CDF CIF 0
	JMP I	.+1
	IGNORE

TT12,	CLA
	CDF CIF 0
	JMP I	.+1
	IGNORE

TT22,	CLA
	CDF CIF 0
	JMP I	.+1
	IGNORE

TT32,	CLA
	CDF CIF 0
	JMP I	.+1
	IGNORE
	>

	IFZERO KL8A-3&4000 <
KB03,	MSRD3		/READ CHAR FROM SILO
	CDF CIF 0
	JMP I	.+1
	IGNORE

KB13,	MSRD3
	CDF CIF 0
	JMP I	.+1
	IGNORE

KB23,	MSRD3
	CDF CIF 0
	JMP I	.+1
	IGNORE

KB33,	MSRD3
	CDF CIF 0
	JMP I	.+1
	IGNORE

TT03,	CLA
	CDF CIF 0
	JMP I	.+1
	IGNORE

TT13,	CLA
	CDF CIF 0
	JMP I	.+1
	IGNORE

TT23,	CLA
	CDF CIF 0
	JMP I	.+1
	IGNORE

TT33,	CLA
	CDF CIF 0
	JMP I	.+1
	IGNORE
	>
	IFZERO .&7600-7600 <HITMON,_ERROR_>	/OVERFLOWED INTO OS/8
	PAGE

