Google
 

Trailing-Edge - PDP-10 Archives - de-10-omona-v-mc9 - comdev.mac
There are 15 other files named comdev.mac in the archive. Click here to see a list.
TITLE COMDEV -  MONITOR DEVICE DEPENDENT CODE, SYMBOLS, AND DATA - V61141
SUBTTL PART 6 COMDEV.MAC - T. HASTINGS/PH/TWE/DAL	22 AUG 78
	SEARCH	F,S
IFN M.KL10,<
	SEARCH	DTEPRM
>;END IFN M.KL10
	$RELOC
	$LOW



;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1973,1974,1975,1976,1977,1978 BY DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
XP VCOMDV,61141
				;PUT VERSION NUMBER IN GLOB AND LOADER STORAGE MAP


;SEE DATMAN FOR A LISTING OF S.MAC AND F.MAC

REPEAT 0, <
;THE COMDEV SUBPROGRAM CONSISTS OF 6 FILES ASSEMBLED TOGETHER AS ONE SUBPROGRAM
	1. F.MAC -- FEATURE TESTS (OUTPUT OF MONGEN).
	2. S.MAC - THE USUAL SYSTEM SYMBOL DEFINITIONS ASSEMBLED WITH
	EVERY	MONITOR SUBPROGRAM
	3. HDWCNF.MAC -- HARDWARE CONFIGURATION
	4. TTYCNF.MAC -- TERMINAL CONFIGURATION
	5. REMCNF.MAC -- REMOTE CONFIGURATION
	6. COMMON.MAC - THE REST OF THIS PROGRAM WHICH IS THE SAME SOURCE FOR
	ALL	CONFIGURATIONS.  HOWEVER, THE ASSEMBLIES ARE CONDITIONED BY
	SYMBOLS	AND MACROS DEFINED IN 2.

	THE	FOLLOWING SYMBOLS AND TABLES ARE GENERATED BELOW:

	A. CONVERSION SYMBOLS FROM NEW MONGEN(M.XXXX) TO OLD SYMBOLS(XXXXX.N)
	B. TTY AND REMOTE CONVERSION SYMBOLS
	C. MONGEN DEFAULT SYMBOLS
	D. TTY DATA BASE
	E. REMOTE STATION DATA BASE
	F. ALL OTHER DEVICE SPECIFIC CODE AND DATA BASES:
	   (ONLY CODE WHICH CHANGES DEPENDING ON THE CONFIGURATION
	   SHOULD BE IN COMDEV). THE LIBARARY SEARCH FEATURE
	   DETERMINES WHETHER THE CONFIGURATION INDEPENDENT CODE
	   FOR A PARTICULAR DEVICE IS LOADED OR NOT).
	   EXTERNS TO CAUSE LOADING OF PROPER DEVICE MODULE
	   SHOULD BE HERE.
	   THE ONLY DEVICE SPECIFIC STUFF IN COMMON IS THE
	   SYMBOL DEFINITIONS WHICH INCLUDE THE PI ASSIGNMENT VALUE.



LEVEL D DISK SERVICE PARAMETERS:

	ALL	SYMBOLS AND LOCATIONS ARE IN A SEPARATE FILE CALLED
	COMMOD.MAC WHICH IS ALSO ASSEMBLED WITH S AND CONFIG (BUT NOT WITH FEATURS FILES).
	THE	SEPARATE FILE IS FOR TWO REASONS:
	1.  ANTICIPATING MULTIPROCESSING SYSTEMS WHICH SHARE DISKS AND 1 16K MEMORY
	(THE DATA MUST BE IN THE COMMON MEMORY)
	2.  ELIMINATE THE NEED TO ASSEMBLE COMMOD IF NOT A DISK SYSTEM
	(COMMOD.MAC TAKES LOTS OF CORE FOR ITS COMPLICATED MACROS)


		 COMMUNICATIONS SOFTWARE
>
SUBTTL CONVERT MONGEN SYMBOLS
REPEAT 0,<

;THIS SECTION CONVERTS NEW MONGEN SYMBOLS TO OLD MONGEN SYMBOLS
;SO THAT THE REST OF COMMON AND MONITOR CAN STILL USE THE OLD
;SYMBOLS.  THIS WAS DONE RATHER THAN CONVERTING ALL OF THE
;MONITOR TO NEW SYMBOLS FOR TWO REASONS:
; 1.  IT IS EASIER AND FASTER AND LESS LIKELY TO INTRODUCE BUGS, AND
; 2.  IT ALLOWS CUSTOMERS TO USE OLD MONGEN WITH A MINIMUM
;OF TROUBLE: ONLY A FEW EXTRA SYMBOLS MUST BE DEFINED.
;THE MONITOR WILL PROBABLY BE CONVERTED TO THE NEW MONGEN SYMBOLS
;AFTER THE 5.04 RELEASE.  THE ORDER HERE PARALLELS THE OLD
;MONGEN ORDER.

>
XP SYS40N,0		;NEW MONGEN MAKES SWAPPING SYSTEMS ONLY
XP SYS50N,1
XP DSKN,1
XP LOGINN,1

XP APRSN,M.C0SN		;APR SERIAL NUMBER (REALLY PROCESSOR 0)
XP APR0SN,M.C0SN	;PROCESSOR 0 SERIAL NUMBER
XP APR1SN,M.C1SN	;PROCESSOR 1 SERIAL NUMBER
XP CP0P6N,0		;PROCESSOR 0 IS NOT A PDP 6
XP CP1P6N,0		;PROCESSOR 1 IS NOT A PDP 6
XP CP0KAN,M.KA10	;PROCESSOR 0 MAY BE A PDP 10
XP CP1KAN,M.KA10	;PROCESSOR 1 MAY BE A PDP 10
XP CP0KIN,M.KI10	;PROCESSOR 0 MAY BE A KI10
XP CP1KIN,M.KI10	;PROCESSOR 1 MAY BE A KI10
XP CPUN,M.CPU		;NUMBER OF PROCESSORS

XP LEVDN,1		;NEW MONGEN MAKES ONLY LEVEL D DISK SERVICE
XP LEVCN,0
XP CHNN,M.CHN		;NUMBER OF DATA CHANNELS FOR DISKS
	DEFINE	CALLF(CHN),<
XP	C'CHN'FHN,M.C'CHN'FH
>	;END MACRO DEFINITION

	DEFINE CHMFH(CHN),<
	CALLF	(\CHN)
>	;END MACRO DEFINITION

	DEFINE	CALLD(CHN),<
XP	C'CHN'DPN,M.C'CHN'DP
>	;END MACRO DEFINITION

	DEFINE CHMDP(CHN),<
	CALLD	(\CHN)
>	;END MACRO DEFINITION

	DEFINE	CALLM(CHN),<
XP	C'CHN'MDN,0
>
	DEFINE	CHMMF(CHN),<
	CALLM	(\CHN)
>
ZZ==0
ZZF==0
ZZD==0

REPEAT CHNN,<
	CHMFH	(ZZ)
	CHMDP	(ZZ)
	CHMMF	(ZZ)
ZZ==ZZ+1
>

	DEFINE	UNFH(KON,LIST),<
ZZCNT==0
IRP LIST,<
	IFE ZZCNT-KON,<
	XP FH'LIST'UN,M.FH'LIST
	>	;END IFE
ZZCNT==ZZCNT+1
>	;END IRP
>	;END MACRO DEFINITION

REPEAT M.RC10,<
	UNFH	(ZZF,<A,B,C,D,E,F,G,H>)
ZZF==ZZF+1
>

	DEFINE	UNDP(KON,LIST),<
ZZCNT==0
IRP LIST,<
	IFE ZZCNT-KON,<
	XP DP'LIST'UN,M.DP'LIST
	>	;END IFE
ZZCNT==ZZCNT+1
>	;END IRP
>	;END MACRO DEFINITION

REPEAT	M.RP10,<
	UNDP	(ZZD,<A,B,C,D,E,F,G,H>)
ZZD==ZZD+1
>

XP RD10N,M.RC10
XP RP10N,M.RP10
XP RH10NS,M.RH1S
XP RH10NP,M.RHP4
XP RA10N,0		;NO MDF

	DEFINE	SYSDEV,<
	SIXBIT	/DSK/
>
XP JOBN,M.JOB+1
XP PDP10N,M.KA10!M.KI10!M.KL10N
XP PDP6N,MD.P6
XP KT10AN,MD.2RR
XP SEGN,MD.SEG
IFG KT10AN,<XP SEGN,SEGN+JOBN>	;NO. OF SEGS=NO. OF JOBS+NO. HISEGS
XP DDTN,MD.DDT

XP EDITN,0

XP PTRN,M.PTR
XP PTPN,M.PTP
XP PLTN,M.PLT
XP LPTN,M.LPT
XP DLPTN,M.DLPT
XP DCDRN,M.DCDR
XP MOVIEN,MD.MOV
XP CDRN,M.CDR
XP CR10N,MD.C10
XP CDPN,M.CDP
	IFN	FTXTC,<
	IFE	M.XTC,<
XP M.XTL,0>
XP XTCN,M.XTC
>
	IFE	FTXTC,<
	IFN	M.XTC,<
PRINTX	?NO DA28 SUPPORT WITH FTXTC=0
PRINTX	?PROCEEDING ASSUMING NO DA28
XP M.XTC,0
XP M.XTL,0
>
XP XTCN,0
>

XP DISN,M.DIS
XP PENN,M.DIS
XP T340N,M.340
XP TVP10N,M.VP10
XP T30N,0		;NO TYPE 30

DEFINE TDMAC(KON,LIST),<
ZZCNT==0
IRP LIST,<
	IFE ZZCNT-KON,<
	XP DT'LIST'N,M.DT'LIST'
	>	;END IFE
ZZCNT==ZZCNT+1
>	;END IRP
>	;END MACRO DEFINITION

ZZ==0

REPEAT M.TD10,<
	TDMAC (ZZ,<A,B>)
ZZ==ZZ+1
>
IFNDEF M.DTA, <M.DTA==0>
IFNDEF DTAN, <DTAN==0>
IFNDEF M.DTB, <M.DTB==0>
IFNDEF DTBN, <DTBN==0>
XP DTCN,MD.DTC
IFNDEF M.TM10,<XP M.TM10,0>
IFNDEF M.TC10,<XP M.TC10,0>
IFNDEF M.TX01,<XP M.TX01,0>
XP TAPN,M.TM10+M.TC10+M.TX01+M.TM02

XP PTYN,M.PTY

XP TEMP,M.TMP
IFN M.TMP,<
XP TMPN,MD.TWJ
XP TMPLN,MD.TLJ
>
XP SYSCN,M.SYSC
XP LOKN,M.LOK
XP CMNN,M.MGC
XP RTTRPN,M.RTD
XP HPQN,M.HPQ

IFNDEF M.HRSN,<XP M.HRSN,77>
IFNDEF TTXTRA,<XP TTXTRA,0>
XP	TTD28N,M.XTL
IFG M.XTL,<XP M.TLTL,M.TLTL+M.XTL>
XP	M.CTY1,0		;DEFINE M.CTY1 FOR CONVENIENCE
IFN FTMS,<IFG CPUN-1,<IFN FTCTY1,<XP M.CTY1,1>>>	;NOT REALLY CHANGABLE BY MONGEN
				;  M.CTY1=1 MEANS WANT CTY1(CPU1-CTY)
XP	CTYLIN,M.TLTL+M.RTTY+M.CTY1
IFN M.CTY1,<XP CT1LIN,M.TLTL+M.RTTY>
	DEFINE	OPRL(LINE),<
IFIDN <LINE> <CTY>,<SIXBIT /CTY/>
IFIDN <LINE> <CTY1>,<SIXBIT /CTY1/>
IFDIF <LINE> <CTY>,<IFDIF <LINE><CTY1>,<SIXBIT /TTY'LINE/>>
>

	DEFINE CALLM(NAME,LINE),<
NAME'LINE==1
>

	DEFINE TTYMAC(TYPE),<
	XLIST

	DEFINE L(A,B),<
IFB <B>,<IFIDN <A> <CTY>,<
	ZZLINE==CTYLIN
	ZZBEG==CTYLIN
	ZZEND==CTYLIN
>	;END IFIDN
	IFIDN <A> <CTY1>,<
	IFE M.CTY1,<PRINTX %CTY1 IN TTYCNF WHEN FTCTY1 OR FTMS=0>
	IFN M.CTY1,<
	ZZLINE==CT1LIN
	ZZBEG==CT1LIN
	ZZEND==CT1LIN
>>	;END IFN M.CTY1 END IFIDN
	IFDIF <A> <CTY>,<
	IFDIF <A> <CTY1>,<
	ZZLINE==A
	ZZBEG==A
	ZZEND==A
>>	;END IFDIF IFDIF
>	;END IFB
IFNB <B>,<ZZLINE==A
	ZZBEG==A
	ZZEND==B
>	;END IFNB
REPEAT ZZEND-ZZBEG+1,<
	CALLM	(TYPE,\ZZLINE)
ZZLINE==ZZLINE+1
>>	;END REPEAT AND DEFINITION OF L
	MAC'TYPE
	LIST
>	;END DEFINITION OF TTYMAC
	TTYMAC DSD
	TTYMAC TAB
	TTYMAC RMT
	TTYMAC LCP
	TTYMAC HLF
	TTYMAC SLV
	TTYMAC FRM
	TTYMAC INI
	TTYMAC(DIS)	;2741 TERMINALS ATTACHED TO A DC-10
	DEFINE	CALLM(NAME,LINE,VALUE),<
NAME'LINE==VALUE
>

	DEFINE	TTYMAC(TYPE),<
	XLIST

	DEFINE	L(M,N,P),<
IFIDN <M> <CTY>,<
	ZZBEG==CTYLIN
	ZZLINE==CTYLIN
>
IFIDN <M> <CTY1>,<
	ZZBEG==CT1LIN
	ZZLINE==CT1LIN
>
IFDIF <M> <CTY>,<
IFDIF <M> <CTY1>,<
	ZZBEG==M
	ZZLINE==M
>>
IFB <P>,<
	ZZEND==ZZBEG
	ZZVAL==N
>
IFNB <P>,<
	ZZEND==N
	ZZVAL==P
>

REPEAT ZZEND-ZZBEG+1,<
	CALLM	(TYPE,\ZZLINE,ZZVAL)
ZZLINE==ZZLINE+1
>>	;END REPEAT AND DEFINITION OF L
	MAC'TYPE
	LIST
>	;END DEFINITION OF TTYMAC

	TTYMAC	FLC
	
DEFINE	DSASOC,<
	XLIST

	DEFINE	L(M,N,P),<
IFIDN <M> <CTY>,<
	ZZBEG==CTYLIN
	ZZDATA==CTYLIN
>
IFIDN <M> <CTY1>,<
	ZZBEG==CT1LIN
	ZZDATA==CT1LIN
>
IFDIF <M> <CTY>,<
IFDIF <M> <CTY1>,<
	ZZBEG==M
	ZZDATA==M
>>
IFB <P>,<
	ZZEND==ZZBEG
	ZZLINE==N
>
IFNB <P>,<
	ZZEND==N
	ZZLINE==P
>

REPEAT ZZEND-ZZBEG+1,<
	GENLIN	(\ZZDATA,ZZLINE)
ZZDATA==ZZDATA+1
ZZLINE==ZZLINE+1
>>	;END REPEAT AND DEFINITION OF L

	LIST
>	;END DEFINITION OF DSASOC
SUBTTL DEFAULT SYMBOLS
;THE FOLLOWING STANDARD SYMBOLS CAN BE SUPERSEDED BY A CUSTOMER HAVING
; PREVIOUSLY DEFINED THEM ON THE HDWGEN.MAC FILE USING THE MONGEN PROGRAM....
;**********************************************************************
;ADD NEW SYMBOLS AT END SO EASY TO UPDATE MONGEN APPENDIX	      *
;**********************************************************************
IFNDEF XPANDN,<XP XPANDN,0>	;FORCE NO EXPANSION OF MACROS
				; UNLESS XPANDN IS DEFINED NON-ZERO WITH MONGEN


				;SIZE OF MAGTAPE RECORDS (DATA WORDS IN BUFFER)
IFNDEF MTSIZ, <XP MTSIZ,^D128>	;STANDARD == 128 WORDS PER BUFFER

				;SIZE OF LPT BUFFER (NUMBER OF DATA WORDS+2)
IFNDEF LPTSIZ, <XP LPTSIZ,^D27+2> ;STANDARD == 27 WORDS PER LPT BUFFER (132 COL. PRINTER)

IFNDEF	FLCDEF,<XP FLCDEF,1>	;FILLER CLASS CODE TO USE IF NOT SPECIFIED
				;FOR A TTY LINE
IFNDEF TTYALT,<XP TTYALT,0>	;DEFAULT SETTING OF TTY ALTMODE
				; IS NO CONVERSION OF ASCII CODES 175 AND 176 TO 33


;NOTE--IN ORDER TO RESERVE PI-CHANNELS FOR
;NON-STANDARD USAGE, FOR EACH CHANNEL (SAY N)
;DEFINE SYMBOL UNIQN==1 VIA MONGEN.  FOR
;EXAMPLE, TO RESERVE CHANNEL 4, DEFINE
;UNIQ4==1.

;IF IT IS DESIRED TO LEAVE A CHANNEL FREE FOR RTTRP JOB TO USE
;THEN THE APPROPRIATE SYMBOL "RTCH'N" SHOULD BE DEFINED AS 1.
;FOR EXAMPLE:
;IF CHANNEL 2 IS TO FREE FOR RTTRP USE THE DEFINE RTCH2==1 IN MONGEN

IFNDEF MTELOG,<XP MTELOG,-1>	;ZERO TO LOG ALL RECOVERED ERRORS
				;NON-ZERO TO LOG ERRORS THAT REQ'D MORE THAN ONE RETRY
IFNDEF MTDAEM,<XP MTDAEM,10>	;NUMBER OF TIMES PER REEL TO CALL DAEMON
				; FOR MAGTAPE ERROR REPORTS.
IFN FTTLAB,<
IFNDEF MTDLTP,<XP MTDLTP,LT.BLP>	;DEFAULT LABEL TYPE
>

	NDL M.AT01,1		;ASYNCHRONOUS TERMINALS ON FIRST FRONT ENDL
	NDL M.AT02,0		;ON SECOND
	NDL M.AT03,0
	NDL M.AT04,0		;(REPRESENTS POSSIBLE CTYS)

	NDL M.FD01,2		;NUMBER OF FRONT END DEVICES ON FIRST FRONT END
	NDL M.FD02,2		;ON SECOND
	NDL M.FD03,2
	NDL M.FD04,2		;ONE FOR FILE XFER, ONE FOR DDT11
;ADD NEW MONGEN SYMBOLS HERE
SUBTTL COMPUTE SPECIAL SYMBOLS

;PERFORM TRANSLATION FROM HARDWARE TO SOFTWARE DESIGNATION
; FOR ALL DISK SYMBOLS

IFN DSKN,<
	FHDN==RD10N
	DPCN==RP10N
	MDFN==RA10N
	FSDN==RH10NS
	RPXN==RH10NP
>
IFE DSKN, <
	FHDN==0
	DPCN==0
	MDFN==0
	FSDN==0
	RPXN==0
>

IFN LEVDN,<
ALLDSK=FHDN+DPCN+MDFN+FSDN+RPXN	;ALLDSK = THE TOTAL # OF DSK KONTROLLERS IN THE SYSTEM
				; IF YOU ADD ANOTHER KONTROLLER TYPE YOU MUST
				; INCLUDE THE # OF KONTROLLERS OF THAT TYPE HERE
>

;DEFINE THE PARAMETERS WHICH CONTROL THE TYPE OF SYSTEM

XP FTDISK,-DSKN			;10/40D OR 10/50S
XP FTSWAP,-SYS50N		;10/50S
XP FTLOGIN,-DSKN		;PUT FTLOGIN IN SO LOADER WILL COMPLAIN
				; IF DIFFERENT IN OTHER FILES
SUBTTL TERMINAL DATA BASE
;THE FOLLOWING SECTION DESCRIBES THE TELETYPE LINES,GLOBALS, AND
;DATA STRUCTURES OF THE MONITOR.

;THE FOLLOWING ARE SUPPLIED BY MONGEN


;M.DC10	=NUMBER OF DC10'S
;M.DC68	=NUMBER OF DC68'S
;M.DC76 =NUMBER OF DC76'S

;M.D7KN =NUMBER OF LINES ON DC76 K
;M.68LK	=NUMBER OF LINES ON DC68 K
;M.TTGK	=NUMBER OF LINES ON DC10 K
;M.DSGK	=NUMBER OF DC10E'S ON DC10 K
;M.TLTL	=TOTAL LOCAL TTY LINES

;THE FOLLOWING MAY BE SUPPLIED FOR LINTAB, WHERE THE LINE NUMBER
; IS CONCATENATED ON THE END (0 IN THIS CASE):

;DSD0 MEANS LINE 0 IS A DATASET LINE
;TAB0 MEANS LINE 0 HAS HARDWARE TABS
;RMT0 MEANS LINE 0 IS A REMOTE LINE, BUT NOT A DATASET.
;HLF0 MEANS LINE 0 IS HALF-DUPLEX (XMTED CHARS WILL BE RCVD)


;ALSO A MACRO IS DEFINED FOR DC10E-CONTROLLED DATASETS, WHICH
;DEFINES THE CORRESPONDENCE BETWEEN THE DC10E CONTROL LINE NUMBER
;(WHICH CONTROLS THE DATASET ENABLES, RINGING, ETC) AND THE
;CORRESPONDING DC10B LINE NUMBER (I.E., TTYN AS THE SYSTEM SEES
;IT). FOR EXAMPLE, FOR A SYSTEM WITH TWO DATASETS CONTROLLED
;BY DC10E LINES 27 AND 26, AND WITH DATA ON TTY17 AND TTY16 RESPECTIVELY,
;	DEFINE DSASOC <
;		GENLIN 27,17
;		GENLIN 26,16
;	>

;THE FOLLOWING ARE USED IN THE PREDEFINED LINE TABLES

DEFINE LINMAC (BITS) <
IRP BITS,<
LINMC1 (BITS,\LIN)
>
		LIN==LIN+1
>
DEFINE LINMC1 (B,N) <
B'N==1
>
;THE FOLLOWING GLOBALS ARE USED IN VARIOUS ROUTINES SUCH AS
;ONCE,SCNSER,DLSINT,BTHINT,ETC.


XP SCNN,JOBN+TTXTRA		;NUMBER OF TTY DDBS TO BE BUILT
XP HGHLIN,M.TLTL		;HIGHEST LINE ON SCANNERS, BEFORE TCONLN
IFG M.CTY1 ,<XP CT1LIN,HGHLIN+M.RTTY>	;CPU1 CTY (CTY1)
IFE M.CTY1,<XP CT1LIN,-1>;	;IF DON'T WANT CTY1 MAKE SURE CT1LIN IS ILLEGAL

XP TCONLN,HGHLIN+M.RTTY+M.CTY1	;LINE NUMBER FOR CTY (NOT ON SCANNER)
XP CTYLDB,LINTAB+TCONLN		;ADR. OF WORD CONTAINING CTY LDB
				; USED TO PRINT ON CTY (AS OPPOSED TO OPR)
				; WHEN NOT USING INTERRUPTS

XP DL0MXD,<10*M.TTG0>-1		;HIGHEST DC10 LINE WHICH IS REAL DATA
XP DL0MXL,<10*M.DSG0>+DL0MXD	;HIGHEST LINE ON DC10 (MAY BE DC10E)
XP DL0OFS,0			;OFFSET FROM LINTAB TO HARDWARE
XP DL1MXD,<10*M.TTG1>-1		;NUMBER OF DATA LINES ON DC10 #1
XP DL1MXL,<10*M.DSG1>+DL1MXD	;HIGHEST LINE ON DC10 #1
XP DL1OFS,<10*M.TTG0>		;ADD TO GO FROM HARDWARE TO LINTAB
XP CC0OFS,DL1OFS+<M.TTG1*10>	;OFFSET TO GET TO CCI0
XP CC1OFS,CC0OFS+M.68L0		;OFFSET TO GET TO CCI1
XP D70OFS,CC1OFS+M.68L1		;OFFSET FOR FIRST DC76
XP D71OFS,D70OFS+M.D70N		;OFFSET FOR SECOND DC76
XP D72OFS,D71OFS+M.D71N		;OFFSET FO THIRD DC76
XP D73OFS,D72OFS+M.D72N		;OFFSET FOR FOURTH DC76
XP D74OFS,D73OFS+M.D73N		;OFFSET FOR FIFTH DC76
XP D75OFS,D74OFS+M.D74N		;OFFSET FOR SIXTH DC76
XP D76OFS,D75OFS+M.D75N		;OFFSET FOR SEVENTH DC76
XP D77OFS,D76OFS+M.D76N		;OFFSET FOR EIGHT DC76
XP TTDLAL,D77OFS+M.D77N		;OFFSET FOR ALL TTD (RSX-20F) LINES
XP KLNKLN,TTDLAL		;FIRST TTD LINE IS THE KLINIK LINE
XP NETOFS,TTDLAL+M.TTDN		;OFFSET TO NETWORK TTY'S
XP D28OFS,NETOFS+M.RTTY		;OFFSET FOR DA28 LINES
XP DSCOF0,DL0MXD+1		;NUMBER TO SUBTRACT FROM LINE # TO
				; GET DCSTAB INDEX FOR DC10#0
XP DSCOF1,DL1MXD+1-<DL0MXL-DL0MXD> ;DITTO FOR DC10 #1

IFG <PTYN -^D511>,<PRINTX 512. OR MORE PTY'S EXCEEDS FIELD OF DDB>
XP TTPLEN,TCONLN+PTYN+1		;LENGTH OF TRANSLATOR TABLE
				;INCLUDES ALL SCNANNERS, CTY, AND PTY'S
IFG <TTPLEN -^D511>,<PRINTX MORE THAN 511. TTYS+PTYS EXCEEDS FIELD OF DDB>
XP PTYOFS,TCONLN+1		;OFFSET FOR PTY-DRIVEN TTY'S
;DEFINE ALL DL10 SYMBOLS

	DLX.CK(0)		;MACRO DEFINED IN S.MAC

IFN FTTYPE!DLX.44,<
IFE FTTYPE,<
	PRINTX	?DEFINING A DC44 REQUIRES FTTYPE TO BE ON
	PRINTX	?M.DC44 HAS BEEN TURNED OFF
PDP11N=PDP11N-DLX.44
M.DC44=0			;NUMBER OF MONGEN

DLX.44=0			;ACTUAL NUMBER
>>	;END OF IFN FTTYPE!DLX.44

IFN FTDAS78!DLX.78,<
IFE FTDAS78,<
	PRINTX	?DEFINING A DAS78 REQUIRES FTDAS78 TO BE ON
PDP11N=PDP11N-DLX.78
DLX.78=0			;ACTUAL NUMBER
>>	;END OF IFN FTDAS78!DLX.78

IFE <DLX.78-PDP11N>,<DLXWIN=0>

IFN <DLX.78-PDP11N>,<EXTERN DLXWIN>
XP MTTYLN,-TTPLEN
XP MLTTYL,-SCNN
IFN PTYN,<
IFE FTPTYUUO,<
	PRINTX ? MONITOR WITH PTY'S SHOULD HAVE FTPTYUUO==-1
>>

IFN FTKL10,<		;KL-10'S HAVE KLINIK LINE
DEFINE KLNCNF(N),<
DSD'N==1		;; KLINIK LINE IS ALWAYS A DATASET
>
KLNCNF(\KLNKLN)		;DEFINE KLINIK LINE CONFIGURATION PARAMETERS
>; END IFN FTKL10
;SCANNER ENTRY POINTS AND BIT DEFINITIONS

EXTERNAL SCNSER				;SCANNER SERVICE ENTRY POINT
INTERNAL LINTAB

LINTAB:		;LINE CHARACTERISTICS BITS (NOT CLEARED ON SYSTEM STARTUP)

;TELETYPE LINE CHARACTERISTICS (LH OF LINTAB)
;USED BY SCNSER

XP TTVRMT,40			;REMOTE LINE
XP TTVHLF,100			;HALF DUPLEX LINE (DC10C OR TWX)
XP TTVINI,200			;RUN INITIAL CUSP
XP TTVDSD,400			;DATASET DATA LINE
XP TTVDIS,1000			;2741 TERMINALS ON A DC-10 INTERFACE
XP TTVNFC,2000			;NO FREE CRLF AT 72 COLUMNS
XP TTVFRM,4000			;FORM FEED IN HARDWARE
XP TTVLCP,10000			;LOCAL COPY, BUT NOT HALF DUPLEX
XP TTVTAB,20000			;TAB HARDWARE (8 COLUMNS PER)
XP TTVLCT,40000			;LOWER CASE TRANSLATE TO UPPER
XP TTVSLV,100000		;SLAVE TTY
XP TTVFLC,200000		;TWO BITS OF FILLER CLASS CODE
;NOW DEFINE THE LINE TABLE FOR EACH TTY'S CHARACTERISTICS
;USING THE INFO FROM MONGEN, AND DATA FROM TTYTAB AREA.

DEFINE GENLIN(LIN,LINN)<
IFE LINN-<LINN/30>*30,<PAGE>
ZZ=0

.GNLN(LIN,RMT)
.GNLN(LIN,HLF)
.GNLN(LIN,INI)
.GNLN(LIN,DSD)
.GNLN(LIN,DIS)
.GNLN(LIN,NFC)
.GNLN(LIN,FRM)
.GNLN(LIN,LCP)
.GNLN(LIN,TAB)
.GNLN(LIN,LCT)
.GNLN(LIN,SLV)
.GNLN(LIN,FLC)

	XWD	ZZ,0		;LINE LIN
LINN=LINN+1
>

DEFINE .GNLN (N,BIT) <
IFDEF BIT'N,<ZZ=ZZ+BIT'N*TTV'BIT>
IFIDN <BIT><FLC>,<IFNDEF BIT'N,<ZZ=ZZ+FLCDEF*TTV'BIT>>
>

LINTAB:	LIN=0
XALL
REPEAT TTPLEN,<GENLIN(\LIN,LIN)>
IFN FTMODM,<

;NOW THE DATASET CONTROLLER INFO FOR ANY DC10E'S

INTERNAL DSCTAB


;CONSTRUCT THE DATASET CONTROLLER TABLE

DEFINE GENLIN(CON,DATA)<

ZZ==0
IFLE <CON-DL0MXD>,<ZZ==1>
IFG <CON-DL0MXL>,<ZZ==1>
IFG <DATA-DL0MXD>,<ZZ==1>		;CHECK RANGE OF ARGUMENT

IFN ZZ,<PRINTX ? SPECIFICATION ERROR - DSCTAB>
IFE ZZ,<
DSA'CON==1
DSB'CON==DATA
>
>

IFG M.DSG0,<
DSASOC
MACCR0			;INVOKE THE MACRO
>
DSCTAB:
	.INDEX==DL0MXD+1
DEFINE GENLIN(N)<
ZZ==0
IFDEF DSA'N,<IFN DSA'N,<ZZ==DL0OFS+DSB'N>>
	EXP	ZZ		;DATA SET N
.INDEX==.INDEX+1
>
XALL
REPEAT <DL0MXL-DL0MXD>,<GENLIN(\.INDEX)>

IFDEF	MACCR1,<	;ONLY IF 2 DC10'S
	
DEFINE GENLIN(CON,DATA)<

ZZ==0
IFLE <CON-DL1MXD>,<ZZ==1>
IFG <CON-DL1MXL>,<ZZ==1>
IFG <DATA-DL1MXD>,<ZZ==1>		;CHECK RANGE OF ARGUMENT

IFN ZZ,<PRINTX ? SPECIFICATION ERROR - DSCTAB>
IFE ZZ,<
DSA'CON==1
DSB'CON==DATA
>
>

DSASOC
MACCR1			;INVOKE THE MACRO
	.INDEX==DL1MXD+1
DEFINE GENLIN(N)<
ZZ==0
IFDEF DSA'N,<IFN DSA'N,<ZZ==DL1OFS+DSB'N>>
	EXP	ZZ		;DATA SET N
.INDEX==.INDEX+1
>
XALL
DSCTB1:REPEAT <DL1MXL-DL1MXD>,<GENLIN(\.INDEX)>
> ;END IFNDEF MACCR1

ZZ==CC0OFS
	XP DSCNDX,<.-DSCTAB>
	XP CC0DSO,CC0OFS-<<M.TTG0+M.TTG1>*10>+DSCNDX
	XP CC1DSO,CC1OFS-<<M.TTG0+M.TTG1>*10>+DSCNDX
	XP D70DSO,D70OFS-<<M.TTG0+M.TTG1>*10>+DSCNDX
	XP D71DSO,D71OFS-<<M.TTG0+M.TTG1>*10>+DSCNDX
	XP D72DSO,D72OFS-<<M.TTG0+M.TTG1>*10>+DSCNDX
	XP D73DSO,D73OFS-<<M.TTG0+M.TTG1>*10>+DSCNDX
	XP D74DSO,D74OFS-<<M.TTG0+M.TTG1>*10>+DSCNDX
	XP D75DSO,D75OFS-<<M.TTG0+M.TTG1>*10>+DSCNDX
	XP D76DSO,D76OFS-<<M.TTG0+M.TTG1>*10>+DSCNDX
	XP D77DSO,D77OFS-<<M.TTG0+M.TTG1>*10>+DSCNDX
	XP TTDDAL,TTDLAL-<<M.TTG0+M.TTG1>*10>+DSCNDX
REPEAT M.68L0+M.68L1+M.D70N+M.D71N+M.D72N+M.D73N+M.D74N+M.D75N+M.D76N+M.D77N+M.TTDN,<	EXP ZZ
ZZ==ZZ+1
>
	MDSLN==:DSCTAB-.
> ;END FTMODM

;THE FOLLOWING SLIDING SCALE DEFINES THE LENGTH OF THE TTY FREE LIST

IFNDEF TTCHKN,<IFL TTPLEN-10,<XP TTCHKN,11*TTPLEN>>
IFNDEF TTCHKN,<IFL TTPLEN-20,<XP TTCHKN,10*TTPLEN>>
IFNDEF TTCHKN,<IFL TTPLEN-40,<XP TTCHKN,7*TTPLEN>>
IFNDEF TTCHKN,<XP TTCHKN,6*TTPLEN>

XP TTCHKS,4				;CHUNK SIZE

IFG XTCN,<		;GENERATE TABLE FOR DA28 POOL
TTLTAB::BLOCK	TTD28N		;KON,,UNIT
XP MTTD28,-TTD28N		;MINUS # OF DA28 LINES
>

INTERN SYSPDL
SYSPDL:	BLOCK	40		;UNTIL FIND A BETTER PLACE FOR IT
IFNDEF MDSLN,<MDSLN==:0>
;THE TTY COMMAND MAP HAS 1 BIT PER LINE ARRANGED 32 BITS PER WORD
;THUS LINE 0 IS BIT 0 OF WORD 0, LINE 37(8) IS BIT 31 OF WORD 0,
; LINE 40(8) IS BIT 0 OF WORD 1, AND SO ON.
TTMAPN==<TTPLEN/^D32>+1
CMDMAP::BLOCK	TTMAPN		;TTY COMMAND BIT MAP

;TTYCMD IS CALLED ON EVERY CLOCK TICK TO LOOK FOR A COMMAND. IF THERE
; IS A COMMAND WAITING IT CALLS COMCON TO PROCESS IT. COMCON IN TURN
; CALLS TTFCOM WHICH SCANS CMDMAP TO FIND THE COMMAND.  THE ENTIRE
; PROCESS IS VERY FAST AND IS NOT ERROR PRONE.
	$HIGH
TTYCMD::	;HERE TO TEST FOR A COMMAND
	ZZ==0
REPEAT TTMAPN,<
	SKIPE	CMDMAP+ZZ	;ANY COMMANDS IN THIS GROUP?
	PJRST	COMMAND##	;YES--CALL COMCON
	ZZ==ZZ+1
	XLIST
>;END REPEAT
	LIST
	POPJ	P,0

XP TTCMPT,-TTMAPN	;AOBJN POINTER TO COMMAND MAP
TTDALT::	;XCTED IN SCNSER TO SET TTY ALT DEFAULT
IFE TTYALT,<
	IORM	T1,LDBPAG##(U)	;NORMAL DEFAULT IS TTY NO ALT
>
IFN TTYALT,<
	ANDCAM	T1,LDBPAG##(U)	;IF LOTS OF 33S AND 35S
>
	$LOW
	SUBTTL	DTESER DATA BASE GENERATION

IFN FTKL10,<
	.XCREF
;GENERATE FRONT END DEVICE BLOCKS

	FEDGEN

;GENERATE HEADER FOR COMM REGION

	ETHEAD

;GENERATE COMM REGION ITSELF

	ETREGN

;GENERATE DTE CONTROL BLOCKS

	ETDGEN

;GENERATE TABLE OF CORRESPONDENCE BETWEEN CPU#,DTE# AND DTE CONTROL BLOCKS
	XALL
	.CREF
	ETDTBX

;TABLE FOR MASTER DTE CONTROL BLOCK ADDRESS FOR EACH CPU

DTEMAS::BLOCK	M.CPU
;USEFUL MACROS FOR DTE DEPENDENT DATA BASE

DEFINE	RSX20F	<

	N10==0				;;INDEX FOR -10 CPU #
	REPEAT	CPUN,<			;;DO FOR EACH CPU ON SYSTEM
		RSXCPU	\N10		;;CALL CPU MACRO
		N10==N10+1		;;STEP TO NEXT CPU
	>
>


DEFINE	RSXCPU	(C)	<

   IFDEF M.'C'DTE,<			;;DO ONLY IF DTE(S) ON THIS CPU
	N11==1				;;INDEX FOR -11 CPU (DTE) #
	REPEAT	M.'C'DTE,<		;;DO FOR ALL DTE'S
		RSXDTE	\C,\N11		;;CALL CURRENT DTE MACRO
		N11==N11+1		;;STEP TO NEXT -11 (DTE)
	>
   >
>
>
	SUBTTL	NETWORK SYMBOLS FOR NON-NETWORK SYSTEMS

IFE M.NET,<			;IF MONGEN ANSWER IS NO THEN DEFINE SYMBOLS
NODE.U==:CPOPJ##		;ILLEGAL UUO
TSTNET==:CPOPJ##		;NO NETWORK DEVICES
GENNET==:CPOPJ##
NET2ND==:CPOPJ##
HOST.U==:CPOPJ##
SRCNDB==:CPOPJ##
NETCTC==:CPOPJ##
ZAPNET==:CPOPJ##
STBSCA==:CPOPJ##
D85DSC==:ECOD4##
RDA$IN==:CPOPJ##
CDR$IN==:CPOPJ##
NETRTY::0			;NO NETWORK TTYS
NDBNNM==:0			;NO STATION BLOCKS
NETDSP==:0			;NO SERVICE ROUTINE
STBOPR::PUSH	P,U		;SAVE LDB
	MOVE	U,OPRLDB##	;GET CENTRAL (ONLY) OPR LDB
	LDB	T1,LDPLNO##	;GET LINE NUMBER
	PJRST	UPOPJ##		;RESTORE AC AND RETURN.
>;END IFE M.NET
IFE M.RDX,<
	TSTRDX==:CPOPJ##
>;END M.RDX

IFE M.RJOB,<
	TSTTSK==:CPOPJ##
>


IFN M.KL10&FTNET,<
IFE M.NET*M.D87S,<
NCLUP==:CPOPJ##
NCLDWN==:CPOPJ##
NCLDSP==:EATDSP##
>>
IFE <M.NET!M.DAS78>,<	;INCLUDE IF NO NETWORKS AND NO DAS78'S
WHERE==:CPOPJ
LOCATE==:CPOPJ
>	;END IFE <M.NET!M.DAS78>

IFN M.NET!M.DC76,<		;ANY IBM 2741 FE SUPPORT
	$HIGH
;SUBROUTINE EXEINX - RETURN AN INDEX TO THE GOLF BALL NUMBER
;CALL	MOVEI	T3,BALL NUMBER(BINARY)
;	PUSHJ	P,ELEINX
;RETURN	CPOPJ			;NOT IN THE TABLE
;	CPOPJ1			;FOUND T2=INDEX
ELEINX::MOVSI	T2,-ELELEN	;SIZE OF TABLE
	CAME	T3,ELETAB(T2)	;MATCH
	AOBJN	T2,.-1		;NO--LOOP FOR MORE
	JUMPGE	T2,CPOPJ##	;EXIT IF NOT FOUND
	PJRST	CPOPJ1##	;GOOD RETURN
	RADIX	10
ELETAB::EXP	029,087,938,963,987,988
	RADIX	8
ELELEN==.-ELETAB
	$LOW
>;END M.NET!M.DC76

	SUBTTL	EXTERNAL PROCESSOR DEFINITIONS
	IFN	FTXTC,<
	IFN	M.XTC,<


XP	MX11BF,^D129	;MAXIMUM PDP-11 IMAGE BINARY BUFFER SIZE
DEFINE	XTCDEF	(X),<
	IFNDEF	XT'X'S,<XT'X'S==420+X*10>
	IFNDEF	XT'X'C,<XT'X'C==424+X*10>
XP	XKBSKP,400450

XT'X'INT:: CONSO	XT'X'C,XKBSKP	;EXTERNAL PROCESSOR INTERRUPT?
	 JRST	.-1		;NO, GO DOWN THE SKIP CHAIN
	JSR	XT'X'SAV##	;SAVE ALL THE AC'S
	PUSHJ	P,SAVE4##	; ..
	JSP	W,XTCINT##	;CALL XTCSER

XP	XTCCHN,XT'X'CHN##

DEFINE	XTLNK	(A) <
	IFN	A-XTCN,<
XKBKDB::!EXP	XKB'A'		;LINK TO NEXT KDB
>
	IFE	A-XTCN,<
XKBKDB::!EXP	0		;NO MORE KDB'S
>
>
XP	XKBINT,<XT'X'INT-.>

Z=X+1
XKB'X::	PHASE	0		;BEGIN CONTROLLER DATA BLOCK
XKBNAM::!XWD	'EPA'+X,0	;EP NAME
	 XTLNK	\Z		;LINK TO NEXT KDB
XKBUDB::!BLOCK	21		;SPACE FOR LINKS TO UDBS
XTSCNO::!CONO	XT'X'S,(T1)
XTCCNO::!CONO	XT'X'C,(T1)
XTSCNI::!CONI	XT'X'S,T1
XTCCNI::!CONI	XT'X'C,T1
XTSDTI::!DATAI	XT'X'S,T1
XTCDTI::!DATAI	XT'X'C,T1
XTCDTO::!DATAO	XT'X'C,T1
XTSDTO::!DATAO	XT'X'S,T2
XTCBSY::!CONSZ	XT'X'C,20
XKBLOK::!EXP	-1		;INTERLOCK
XKBDDB::!BLOCK	1		;POINTER TO DDB WAITING FOR INTRPT
XKBIUN::!BLOCK	1		;POINTER TO UDB WAITING FOR INTERRUPT
XKBDAC::!BLOCK	1		;INFO FROM LAST CONI DAC
XKBDAS::!BLOCK	1		;INFO FROM LAST CONI DAS
XKBTIM::!BLOCK	1		;COUNTER FOR TIMEOUT
XKBIOW::!BLOCK	1		;IOWD FOR DAC OR PNTR TO IOLIST
XKBCUR::!BLOCK	1		;CUR PNTR TO IOLIST (KI10 ONLY)
XKBGRB::!Z			;0 IF FREE 1 IF GRABBING
				;CONTROL -1 IF GRABBED
XKBPAC::!BLOCK	1		;# OF PSEUDO ACTIVE DDB'S ON THIS
				; CONTROLLER
XKBREQ::!BLOCK	1		;OLDEST JOB # REQUESTING USE OF UDB
XKBMBF::!BLOCK	<MX11BF*3>/2	;MONITOR BUFFER
	DEPHASE

>
	ZZ=0
	IFE	XTCN,<
XTUUO==:CPOPJ			;NO XTUUO IF NO XTCSER
XTKLDB==:CPOPJ			;ALSO NO DDB KILLER
XTCTTY::AOS	(P)		;DOUBLE SKIP
	JRST	CPOPJ1##
XTCTYP==:CPOPJ
>

	IFN	XTCN,<EXTERN XTCSER>	;LOAD XTCSER IF NEEDED

	REPEAT	XTCN,<
	 XTCDEF	(\ZZ)
	 ZZ=ZZ+1
>
>>	;;END OF FTXTC FEATURE
SUBTTL MAGTAPE DATA BASE FOR TAPSER

IFG TAPN,<

	EXTERNAL	TAPSER,TAPUUO

;SOME GENERALLY USEFUL MACROS

DEFINE	CALUNI (Y,EMACR) <
	..UNI==0
	REPEAT M.MT'Y,<
	  GENUNI (Y,\..UNI,EMACR)
	  ..UNI==..UNI+1>
>
DEFINE	TM2UNI(Y,EMACR) <
	X==0
	..UNI==0
	REPEAT M.MT'Y'U,<
	TM2UN2(Y,\X,EMACR)
		X==X+1>
>

DEFINE TM2UN2(Y,Z,EMACR) <
	REPEAT M.MT'Y'Z,<
	  GENUNI(Y,\..UNI,EMACR)
	  ..UNI==..UNI+1>
	..UNI==..UNI+10-M.MT'Y'Z
>


DEFINE	UNIMAC (A,B) <
	..U'A'B>

DEFINE	CHNMAC (Z) <
	CHN'Z'CB##>

DEFINE	GENDDB (X,Y) <

MT'X'DDB::
	<SIXBIT	/MTA0/>+<X+OFFSET>_^D18	;(0)  DEVNAM
	DVCMDA!<^D5*HUNGST>,,MTSIZ+1  ;(1)  DEVCHR
	0			;(2)  DEVIOS
	TPMDSP##		;(3)  DEVSER
	1023,,154403+BYTBIT	;(4)  DEVMOD
	0			;(5)  DEVLOG
	0			;(6)  DEVBUF
	R,,0			;(7)  DEVIAD
	R,,0			;(10) DEVOAD
	;;BITS 0-13 ARE USED FOR FRAME-COUNT
	0			;(11) DEVSTS
	.TYMTA!DEPLEN,,Y*DEPEVM	;(12) DEVSTA
	0			;(13) DEVXTR
	;BITS 22-30 = NUMBER OF INPUT BUFFERS
	0			;(14) DEVEVM
	0			;(15) DEVPSI
	0			;(16) DEVESE
	0			;(17) DEVHCW
	0			;(20) DEVJOB (6.02 AND LATER)
	PHASE	DEVLSD
TDVUDB::!			;LH = UDB PNTR
TDVKDB::! ..U'X'0,,MT'X'KDB	;RH = KDB PNTR (PRIME CONTROLLER)
TDVSTS::! 0			;UNIT STATUS INFO
TDVIOR::! 0			;IORB TO WAIT FOR
TDVSUL::! 0			;SAVED USER UPPER LIMIT
TDVSLL::! 0			;SAVED USER LOWER LIMIT
TDVSVM::! 0			;SAVED M FOR DUMP MODE
TDVREM::! 0			;REMAINDER FOR MODE 16
	DEPHASE
XP MT'X'DDS,.-MT'X'DDB		;SIZE OF DDB
>	;END GENDDB MACRO
;MACRO TO GENERATE A KDB

DEFINE	GENKDB (X,KMACR) <

MT'X'INT::
	CONSO	MT'X'S,0	;INTERUPT INSTRUCTION
	JRST	.-1
	JSR	MT'X'SAV##	;SAVE ACS
	JSP	W,TAPINT##
XP TKBCSO,MT'X'INT-.		;OFFSET OF CONSO INSTR FROM KDB
MT'X'KDB:: PHASE 0
TKBNAM::! SIXBIT /MT'X/
TKBCNT::! 0			;(1) NUMBER OF RECORDS DONE ON THIS OPERATION
TKBKDB::! IFE <X-TAPN+1>,<0>	;(2) LINK TO NEXT KDB
	  IFN <X-TAPN+1>,<MTLINK (\<X+1>)>
IFN M.MT'X'T-4,<
TKBIUN::! -M.MT'X,,MT'X'KDB+TKBUDB ;(3) INITIAL UNIT AOBJN PNTR
TKBCUN::! -M.MT'X,,MT'X'KDB+TKBUDB ;(4) CURRENT UNIT AOBJN PNTR
>
IFE M.MT'X'T-4,<
TKBIUN::! -M.MT'X'U*10,,MT'X'KDB+TKBUDB
TKBCUN::! -M.MT'X'U*10,,MT'X'KDB+TKBUDB
>
TKBDSP::! MT'X'DSP		;(5) KONTROLLER DISPATCH
TKBSTS::! 0			;(6) KONTROLLER STATUS
				;(RH) CONSECUTIVE OPS REMAINING
TKBICP::!			;(7) PNTR TO ICPC/ CHL INFO
	  IFE M.MT'X'T,<MTALOC##>	;PI CHL FOR TM10A
	  IFE <M.MT'X'T-1>,<
		$LOCW*2+LOCOCW##
		$LOCW==$LOCW+1>	;TM10B
	IFE M.MT'X'T-2,<
		$LOCW*2+LOCOCW##
		$LOCW==$LOCW+1>	;TC10C
	  IFE M.MT'X'T-3,<
		$LOCD*4+LOCODW##
		$LOCD==$LOCD+1>	;DX10 TYPE
	  IFE M.MT'X'T-4,<
		IFE M.T2'X'T,<
		$LOCW*2+LOCOCW##
		$LOCW==$LOCW+1>	;TM02 ON RH10
		IFN M.T2'X'T,<
		RH2IOC##+4*<M.T2'X'T-1>;TM02 ON RH20 # N
		>
		>
TKBTIM::! 0			;(10) TIMER FOR SPACING OPS
TKBCDB::! IFE M.MT'X'T,<0>	;(11) PNTR TO CHL IF NOT TM11A
	  IFN M.MT'X'T,<CHNMAC(\M.MT'X'C)>
TKBJOB::! 0			;(12) JOB NUMBER OF MAINT-MODE OWNER
				; TKBJOB MUST IMMEDIATELY PRECEDE TKBCCL
TKBCCL::! BLOCK	5		;(13) CHNL CMD LIST
TKBERB::! BLOCK 4		;(21) IORB FOR ERROR RECOVERY
IFE M.TM02,<
TKBUDB::! ..UNI==0
IFN M.MT'X'T-4,<
	REPEAT M.MT'X,<
	  UNIMAC (X,\..UNI)
	  ..UNI==..UNI+1>
	BLOCK ^D8-M.MT'X	;ALLOW FOR 8 MAX UNITS
>
>
IFG M.TM02,<

IFN M.MT'X'T-4,<BLOCK 5>
IFE M.MT'X'T-4,<
TT2CO1::!CONO MT'X'S,(T1)
TT2CI2::!CONI MT'X'S,T2
TT2CO3::!CONO MT'X'S,(T3)
TT2DI2::!DATAI MT'X'S,T2
TT2DO2::!DATAO MT'X'S,T2
>
TKBUDB::! ..UNI==0
IFE M.MT'X'T-4,<
	TT2CDB (X)
>
IFN M.MT'X'T-4,<
	REPEAT M.MT'X,<
	  UNIMAC (X,\..UNI)
	  ..UNI==..UNI+1>
	BLOCK ^D8-M.MT'X	;ALLOW FOR 8 MAX UNITS
>
>
	KMACR(X)		;KONTROLLER DEPENDENT DATA
	DEPHASE
>

DEFINE	MTLINK (X) <MT'X'KDB>
;MACRO TO GENERATE ALL TAPE INFO

DEFINE	GENTAP (KON) <

	EXPNDK	(KON)		;DEFINE 7 TRACK UNITS AND 6250 BPI UNITS

IFLE <M.MT'KON'T-1>,<		;ALL TM10S
	MT'KON'DSP=TMXDSP##
	EXTERN	TMXKON
	DOTM10(KON,M.MT'KON'T)	;GEN FOR APPROPRIATE TYPE
>
IFE <M.MT'KON'T-2>,<		;TC10C
	MT'KON'DSP=TCXDSP##
	EXTERN TCXKON
	MT'KON'S==%TC10S	;TC10 STATUS REG
	CALUNI(KON,ETCMAC)	;GEN UNITS
	GENKDB(KON,KTCMAC)	;GE KDB
		BYTBIT==0_BYTMOD
	GENDDB(KON,1)		;DDB PROTOTYPE
	%TC10S==%TC10S+4	;ADVANCE TO NEXT TC10C
>
IFE <M.MT'KON'T-3>,<		;TX01
	MT'KON'DSP=TX1DSP##
	EXTERN TX1KON
	MT'KON'S==%DX10S	;DX10 STATUS REG
	CALUNI(KON,ETXMAC)	;GEN UNITS
	GENKDB(KON,KTXMAC)	;GEN KDB
		BYTBIT==1_BYTMOD
	GENDDB(KON,1)		;DDB PROTOTYPE
	%DX10S==%DX10S+4	;ADVANCE TO NEXT DX10
	IFE <%DX10S-230>,<%DX10S==034>
				;TM02
>
IFE <M.MT'KON'T-4>,<
	MT'KON'DSP==TM2DSP##
	EXTERN	TM2KON
	IFE M.T2'KON'T,<
	MT'KON'S==%TM02S
	>
	IFN M.T2'KON'T,<
	MT'KON'S==540+4*<M.T2'KON'T-1>
	>
	TM2UNI(KON,ET2MAC)
	GENKDB(KON,KT2MAC)
		BYTBIT==1_BYTMOD
	GENDDB(KON,1)
	OFFSET==OFFSET+M.MT'KON'U-1
	IFE M.T2'KON'T,<
	%TM02S==%TM02S+4
	>
	IFE <%TM02S-300>,<%TM02S==360>
>>

DEFINE DOTM10 (KON,TYP) <
	MT'KON'C==%TM10S	;TM10 COMMAND REG
	MT'KON'S==%TM10S+4	;TM10 STATUS REG
	CALUNI(KON,ETMMAC)	;GEN UNITS
	GENKDB(KON,KTMMAC)	;GEN KDB
		BYTBIT==0_BYTMOD
	GENDDB(KON,TYP)		;GEN DDB PROTOTYPE FOR UNIT 0
	%TM10S==%TM10S+10	;ADVANCE TO NEXT UNIT
>
;MACRO TO INSERT TM02 UNITS INTO TKBUDB
DEFINE	TT2CDB(X) <
	..UNI==0
	Y==0
	REPEAT M.MT'X'U,<
	   TM2INS(X,\Y)
		Y==Y+1>
>

DEFINE TM2INS(X,Z) <
	REPEAT M.MT'X'Z,<
	  UNIMAC(X,\..UNI)
	  ..UNI==..UNI+1>
	BLOCK ^D8-M.MT'X'Z
	..UNI==..UNI+^D8-M.MT'X'Z
>
;MACROS TO FIGURE OUT WHICH UNITS ARE 7 TRACK OR CAPABLE OF 6250 BPI

DEFINE	EXPNDK	(K) <
	..X=7
	MACKN'K (K)
	..X=6
	MACK6'K (K)>

DEFINE	KN (A,B,C<0>) <
    IFIDN <B>,<ALL>,<TKREP (\..X,A,0,M.MT'A)>
    IFDIF <B>,<ALL>,<TKREP (\..X,A,B,C)>
>

DEFINE	TKREP	(X,A,B,C) <
    IFE C,<DEF'X (A,\B)>
    IFN C,<
	..UNI==B
	REPEAT <C-B+1>,<
	    DEF'X (A,\..UNI)
	    ..UNI==..UNI+1>
    >
>

DEFINE	DEF7 (K,U) <XP M.M7'K'U,1>

DEFINE	DEF6 (K,U) <XP M.M6'K'U,1>
;MACRO TO GENERATE A UDB

DEFINE	GENUNI(Y,U,EMACR) <

..U'Y'U::! PHASE 0
TUBNAM::! SIXBIT /MT'Y'U/	;(0) UNIT NAME
TUBKDB::! 0,,MT'Y'KDB		;(1) PNTR TO OWNING KONTROLLERS
TUBADR::! 0,,U			;(2) UNIT ADDRS ON KONTROLLER
TUBAKA::! 0			;(3) LH = UNIT ADDRS (CURRENT)
				;    RH = CURRENT KONTROLLER
TUBDDB::! 0			;(4) PNTR TO DDB'S
TUBCUR::! 0			;(5) POINTER TO CURRENT DDB
IFDEF M.M7'Y'U,<..X==TUCDR7##>	;7 TRACK TAPE
IFNDEF M.M7'Y'U,<		;NOT 7 TRACK TAPE
    IFLE <M.MT'Y'T-1>,<..X==TUCDR8##>	;TM10 9 TRACK
    IFE <M.MT'Y'T-2>,<..X==TUCDR6##>	;TC10C 800/1600 BPI
    IFE <M.MT'Y'T-3>,<
	IFNDEF M.M6'Y'U,<..X==TUCDR6##>	;TU70 800/1600 BPI
	IFDEF M.M6'Y'U,<..X==TUCDR5##>	;TU72 1600/6250 BPI
    >
    IFE <M.MT'Y'T-4>,<..X==TUCDR6##>	;TM02 800/1600 BPI
>
TUBCNF::!			;(6) CONFIG INFO (RH)
TUBSTS::!..X+M.MT'Y'T		;    UNIT STATUS (LH)
TUBQUE::! 0			;(7) QUEUE PNTR FOR IORB'S
TUBERR::! 0			;(10) ERROR RECOVERY INFO
TUBRID::! 0			;(11) REELID (DAEMON KNOWS ABT THIS AREA)
TUBFIL::! 0			;(12) # OF FILES FROM BOT
TUBREC::! 0			;(13) # OF RECORDS FROM EOF
TUBCRD::! 0			;(14) # CHARS READ SINCE UNLOAD
TUBCWR::! 0			;(15) # CHARS WRITTEN SINCE UNLOAD
TUBSRE::! 0			;(16) SOFT READ ERRORS
TUBHRE::! 0			;(17) HARD READ ERRORS
TUBSWE::! 0			;(20) SOFT WRITE ERRORS
TUBHWE::! 0			;(21) HARD WRITE ERRORS
TUBTME::! 0			;(22) TOTAL MEDIA ERRORS SINCE UNLOAD
TUBCLE==:.-1			;     END OF AREA TO CLEAR
TUBTDE::! 0			;(23) TOTAL DEVICE ERRORS SINCE RELOAD
TUBTUN::! 0			;(24) TOTAL UNLOADS
TUBTRY::! 0			;(25) RETRIES TO RESOLVE ERROR
TUBCCR::! 0			;(26) CHAR CNT ON LAST REC
TUBPBE::! 0			;(27) POSITION BEFORE ERROR
				;     FILE,,RECORD
TUBFES::! 0			;(30) FINAL ERROR STATE WORD
TPCHMX==:.-TUBRID		;     MAX ARG ALLOWED FOR MTACHR UUO
TUBCHR::! 0			;(31) STATISTICS FOR MTCHR. UUO
TUBDDA::! BLOCK TUBTME-TUBRID+1	;SHADOW AREA FOR DAEMON
TUBDDE==:.-1			;END OF SHADOW AREA (DAEMON KNOWS ABT)
IFN FTKI10!FTKL10&FTRDBACK,<
TUBCNI::! 0			;ERROR STATUS FOR NEXT RECORD
>
IFN FTTLAB,<
TUBMSG::! XWD	TLMSIZ,.IPCTL##	;LENGTH,,FUNCTION CODE FOR LABEL MESSAGE
TUBPHY::! 0			;PHYSICAL NAME FOR LABEL PCS
TUBLBL::!			;LABEL STATUS WORD
IFNDEF M.M7'Y'U,<MTDLTP>
IFDEF M.M7'Y'U,<LT.BLP>
TLMSIZ==.-TUBMSG
TUBRFM::!0			;RECORD FORMAT (FOR LABELS ONLY)
TUBRCC::!0			;RECORD SIZE (FOR LABELS ONLY)
TUBBKL::!0			;BLOCK SIZE (FOR LABELS ONLY)
TUBEXP::!0			;EXPIRATION DATE (FOR LABELS ONLY)
TUBPRT::!0			;PROTECTION (FOR LABELS ONLY)
TLPMAX==:.-TUBRFM
>
	EMACR(Y)		;GENERATE ERROR INFO BLOCK
	DEPHASE
>
;SPECIFIC MACROS FOR VARIOUS CONTROLLERS

IFG M.TM10,<

DEFINE ETMMAC (X) <
TUBIEP::! -2,,TTMICC		;(30) INITIAL ERROR PNTR
TUBFEP::! -2,,TTMFCC		;(31) FINAL ERROR PNTR
TTMICC::! 0		;LAST ERROR INITIAL CONI MTC
TTMICS::! 0		;LAST ERROR INITIAL CONI MTS
TTMFCC::! 0		;LAST ERROR FINAL CONI MTC
TTMFCS::! 0		;LAST ERROR FINAL CONI MTS
>

DEFINE KTMMAC (X) <
TTMCOC::! CONO MT'X'C,(T1)
TTMCOS::! CONO MT'X'S,(T1)
TTMCIC::! CONI MT'X'C,T1
TTMCIS::! CONI MT'X'S,T1
TTMDOS::! DATAO MT'X'S,T1
TTMDIC::! DATAI MT'X'C,T1
TTMBLK::!
	IFE M.MT'X'T,<BLKI MT'X'C,(<BLKO MT'X'C,>)>
	IFN M.MT'X'T,<0>
TTMCHE::! 0		;-1 IF CHANNEL DETECTED ERROR
TTMJSR::! IFN M.MT'X'T,<0>	;JSR FOR TM10A BLKI/O STOP
	  IFE M.MT'X'T,<JSR MT'X'KDB+TTMEND
TTMEND::! 0			;HERE AT END OF DATA XFER
	  CONO 	MT'X'S,1	;STOP TAPE
	  JEN	@MT'X'KDB+TTMEND ;DISMISS INTERUPT
> ;;; END IF3 MT'X'T
> ;;; END DEFINE KTMMAC
> ;;; END IFG M.TM10

IFG M.TX01,<

DEFINE ETXMAC (X) <
TUBIEP::! -^D20,,TTXIST		;(30) INITIAL ERROR PNTR
TUBFEP::! -^D20,,TTXFST		;(31) FINAL ERROR PNTR
TTXIST::! BLOCK	^D19	;LAST ERROR INITIAL STATUS
TTXISE::! BLOCK	1	;LAST WORD IN INTIAL STATUS
TTXFST::! BLOCK ^D20	;LAST ERROR FINAL STATUS
>

DEFINE KTXMAC (X) <
TTXCOS::! CONO	MT'X'S,(T1)
TTXCIS::! CONI	MT'X'S,T1
TTXDOS::! DATAO	MT'X'S,T2
TTXDIS::! DATAI	MT'X'S,T2
TTXTMP::! BLOCK	1		;TEMP LOC FOR DX10
>
>	;;; END IFG M.TX01
IFG M.TC10,<
DEFINE ETCMAC (X) <
TUBIEP::! -1,,TTCICS		;(30) INITIAL ERROR PNTR
TUBFEP::! -1,,TTCFCS		;(31) FINAL ERROR PNTR
TTCICS::! 0			;LAST ERROR INITIAL STATUS
TTCFCS::! 0			;LAST ERROR FINAL STATUS
>

DEFINE KTCMAC (X) <
TTCCOS::! CONO MT'X'S,(T1)
TTCCIS::! CONI MT'X'S,T1
TTCDOS::! DATAO MT'X'S,T1
TTCDIS::! DATAI MT'X'S,T1
>
>	;;; END IFG M.TC10

IFG M.TM02,<
DEFINE ET2MAC (X) <
TUBIEP::! -16,,TT2ICS
TUBFEP::! -16,,TT2REG
TT2ICS::! BLOCK 16
TT2REG::! BLOCK 16
>
DEFINE KT2MAC (X) <
TT2UVA::!0			;TEMP LOC FOR READ-BACKWARDS
>
>	;;END IFG M.TM02
;NOW GENERATE THIS WHOLE MESS

%TM10S==340		;INITIAL TM10 CONTROLLER DEVICE CODE
%DX10S==220		;INITIAL DX10 CONTROLLER DEVICE CODE
%TC10S==724		;INITIAL TC10 CONTROLLER DEVICE CODE
%TM02S==270+4*<M.RH1P+M.RH1S>
IFG <%TM02S-274>,<%TM02S==%TM02S+60>
IFNDEF	TAPTIM,<XP TAPTIM,^D60>	;MAX TIME TO SKIP 10 RECORDS
XP	DSETIM,^D270		;MAX TIME TO DO DATA SECURITY ERASE

IFNDEF NOISE,<XP NOISE,^D12>  ;NOISE RECORD LENGTH IN BYTES
IFNDEF MQUANT,<XP MQUANT,^D10> ;CONSECUTIVE RECORDS
XP	NOISEW,NOISE/4

..KON==0		;INITIATE LOOP
OFFSET==0
$LOCW==ALLDSK		;FIRST AVAILABLE CHL PNTR
$LOCD==0		;DX10 CHL PNTR
TAPDST==:.

REPEAT TAPN,<
	GENTAP(\..KON)	;DO A CONTROLLER
	..KON==..KON+1	;ADVANCE TO NEXT
>
TAPDEN==:.-1

;RANDOM BYTE PNTRS INTO DATA STRUCTURE

PMTCRC::POINT 9,TUBCHR(U),26	;LAST 9TK CRC (NRZI)
PMTNCR::POINT 3,TUBCHR(U),29	;BYTE RESIDUE OF LAST WORD
PBUFRM::POINT 14,DEVOAD(F),13

>	;;;; END OF IFG TAPN
IFE TAPN,<	;;;; GLOBAL DUMMIES

XP	TPMCTT,CPOPJ
XP	TAPMIN,CPOPJ
XP	TAPSEC,CPOPJ
XP	UTAPOP,CPOPJ
XP	MTARID,CPOPJ
XP	MTACHR,CPOPJ
XP	TPFREE,CPOPJ
XP	TPMIN,CPOPJ
XP	MTAPE0,CPOPJ

TPMSIL::JRST	CPOPJ1##

XP	TDYDN1,0
XP	TPKINI,0
XP	TUBQUE,0
XP	TDVKDB,0
XP	TUYKTP,0
XP	TKBUDB,0
XP	TKBDSP,0
XP	TKBCDB,0
XP	TKBKDB,0
XP	TDVUDB,0
XP	NOISEW,0
XP	TUC7TK,0
XP	TUBDDB,0
XP	TUBCNF,0
XP	PBUFRM,0

>	;;; END IFE TAPN
IFE M.TX01,<
TTXCOS::
TTXCIS::JFCL		;DUMMY'S
CCHJGO==:0
>
IFE M.TM10,<
TTMCIC::
TTMCIS::
TTMCOC::JFCL	;DUMMY'S
>

IFE M.TM02,<
TT2CO1::
TT2CI2::JFCL
>
IFE M.TC10,<
TTCCOS::
TTCCIS::JFCL
>
;DECTAPE ENTRY POINT AND BIT DEFINITIONS

SAVN==1		;OLD FORMAT DECTAPE SYSTEMS NO LONGER SUPPORTED BY DEC.
		; MONGEN NO LONGER ASKS THE DECTAPE FORMAT QUESTIONS.

	IFG	M.DTA!M.DTB, <EXTERNAL DTASRN>	;TD10 WITH NEW FORMAT
	IFG	DTCN, <
	IFG	SAVN, <EXTERNAL DTCSRN>	;556 WITH NEW FORMAT
	IFE	SAVN, <EXTERNAL DTCSRO>	;556 WITH OLD FORMAT
>
	IFG	M.DTA!M.DTB, <		;DEFINE SYMBOLS IF PDP-10 DECTAPES (TD10)
>
	IFG	DTCN, <		;DEFINE SYMBOLS IF PDP-6 DECTAPES (556)
	INTERNAL DCLOC,DCLOC1,DCON,DCOFF,DCIN,DCOUT
		DCLOC==40+2*DCTCHN	;EVEN DC PI CHANNEL LOC
		DCLOC1==DCLOC+1		;NEXT LOCATION
		DCBIT==1
		REPEAT 7-DCTCHN, <DCBIT==DCBIT*2>
		DCON==2000+DCBIT	;TURN DC PI CHANNEL ON
		DCOFF==1000+DCBIT	;TURN DC PI CHANNEL OFF
		DCIN==4010+DCTCHN	;SET DATA CHANNEL FOR INPUT
		DCOUT==3410+DCTCHN	;SET DATA CHANNEL FOR OUTPUT
>

;DEFINE SAVE MODE AND EXTENSION FOR OLD OR NEW FORMAT

	INTERNAL SAVDMP
	IFE	SAVN, <
		SAVDMP==<SIXBIT /   DMP/>	;EXTENSION FOR SAVED FILES == "DMP"
>
	IFN	SAVN, <
		SAVDMP==<SIXBIT /   SAV/>	;EXTENSION FOR SAVED FILES == "SAV"
>

	IFE	M.DTA!M.DTB,<
;IF NO DECTAPES, SATISFY GLOBALS BY DEFINING DUMMIES
	INTERNAL DTASEC,DTADDB,DTXINI,DSCON,LVFLAG,USEWRD,DCONS,KONEND,DTADSP
	DTASEC==CPOPJ
	DTADDB==CPOPJ		;THIS WORKS BECAUSE SYSINI DOES A   MOVEI W,DTADDB##
	DTXINI==0		;              FOLLOWED BY AN       XCT DTXINI##(W)
	DSCON==0
	LVFLAG==0
	USEWRD==0
	DCONS==0
	DTADSP==0
>
DAC=320		;CONTROL DEVICE NUMBER
DAS=DAC+4	;CONTROL STATUS NUMBER
IFG	M.DTA,<
SUBTTL INTERRUPT HEAD FOR DTA
			;FLAGS LEVEL CODE
;CONTROL DEPENDENT PORTION OF DECTAPE SERVICE
DEFINE CDC (C,B) <
	INTERN	C

C=.-DTADDB	;RELATIVE LOCATION WITHIN CONTROL BLOCK
	B>
INTERNAL DTADDB,DTADDS,DADINT,DTAINT,DTADIR,DTXDDB

;MODEL DEVICE DATA BLOCK
DTXDDB=.-DTADDB

DTADDB:	SIXBIT	/DTA0/		;(0) - DEVNAM
	XWD	DVCMDA!<^D6*HUNGST>,200  ;(1) - DEVCHR
	0			;(2) - DEVIOS
	EXP	DTADSP##	;(3) - DEVSER
	XWD	1107,154403	;(4) - DEVMOD
	0			;(5) - DEVLOG
	0			;(6) - DEVBUF
	XWD	R,0		;(7) - DEVIAD
	XWD	R,0		;(10) - DEVOAD
	0			;(11) - DEVSTS
	XWD	.TYDTA,0	;(12) - DEVSTA
	0			;(13) - DEVXTR
	0			;(14) - DEVEVM
	0			;(15) - DEVPSI
	0			;(16) - DEVESE
	0			;(17) - DEVHCW
	0			;(20) - DEVJOB
	0			; - DEVFIL
	0			; - DEVEXT
	0			; - FSTBLK
	DTADIR+DTADDB		; - DLOC
	0			; - IBLK
	0			; - OBLK
	0			; - DISPAD
	0			; - DMPLST
	0			; - SVDWRD
	0			; - DJOTOP
	0			; - DJOBOT
	0			; - BADCOM



DTADIR==.-DTADDB
	BLOCK	200
	XP	DTADDS,.-DTADDB
;DATA LEVEL CODE...CHANNEL 1 OR 2 USUALLY

DADINT:	CONSO	DAS,1		;DATA INTERRUPT FOR THIS CONTROL?
	JRST	.		;NO- PROCEED DOWN CHAIN
	SKIPN	DTAUSE		;EXPECTING AN INTERRUPT?
	JRST	DADINT+1	;NO, IGNORE IT

	SKIPE	DADSRC		;ARE WE SEARCHING FOR BLOCK NUMBERS?
	JRST	DASRCH		;YES
DAIOWD:	BLKI	DAC,DTAPNT	;EXECUTE BLKI OR BLKO FOR THIS UNIT
	JRST	DADTHR		;POINTER RAN OUT
DADCTN:	JFCL			;GOING REVERSE?
	JEN	@DADCHL##	;NO- DISMISS DECTAPE DATA CHANNEL A
	SOS	DTAPNT		;YES- DECREMENT POINTER
	SOS	DTAPNT		;TWICE
	JEN	@DADCHL##	;DISMISS THE INTERRUPT
DADTHR:	SKIPE	DADDMP		;DUMP MODE POINTER RAN OUT?
	JRST	DADMPA		;YES- ADVANCE POINTER
DADFNS:	CONO	DAS,770001	;SEND OUT FUNCTION STOP IF THROUGH
	JEN	@DADCHL##	;DISMISS INTERRUPT

DADSRC:	CDC	DTXSRC,0;SET NEGATIVE WHEN READING BLOCK NUMBERS

;HERE WHEN READING BLOCK NUMBERS AT DATA INTERRUPT LEVEL

DASRCH:	MOVEM	W,DTASVC	;SAV W
DACCNC:	CONI	DAC,W		;READ FLAGS REGISTER
	HRLZS	W		;PUT MOST FLAGS INTO LEFT HALF
	HRRI	W,DTADDB	;POINT TO THIS CONTROL BLOCK
	JRST	SRCH##		;DO THE SEARCH
DADXIT:	MOVE	W,DTASVC	;RESTORE W
	JEN	@DADCHL##	;DISMISS THE INTERRUPT

DADMPA:	MOVEM	W,DTASVC	;SAVE W
	HRRZI	W,DTADDB	;POINT TO CONTROL A
	JRST	DMPADV##	;PROCESS THE EXHAUSTED BLKI/O

	XP	DTSFNS,DADFNS-DTADDB
	XP	DXDINT,DADINT-DTADDB
	XP	DXIOWD,DAIOWD-DTADDB
	XP	DXDCTN,DADCTN-DTADDB
DACNUM:	CDC	DXCNUM,<<DAC>B11>;CONTROL NUMBER

	XP	DTXXIT,DADXIT-DTADDB
	XP	DTXCNC,DACCNC-DTADDB
;FLAGS LEVEL INTERRUPT HEAD...
DTAINT:	CONSO	DAS,770000	;INTERRUPT FOR THIS CONTROL?
	JRST	.		;NO- PROCEED DOWN CHAIN
	SKIPN	DTAUSE
	JRST	DTAINT+1
	JSR	DTASAV##	;YES- SAV ACCUMULATORS FOR THIS LEVEL
	CDC	DXCCNT,<CONI DAC,T1>;READ FLAGS INTO T1
	CDC	DTSCNI,<CONI DAS,T4>;READ STATUS INTO T4
	HRLZI	W,(T1)		;PUT FLAGS (RH) INTO W (LH)
	HRRI	W,DTADDB	;ADDRESS OF CONTROL DEPENDANT BLOCK
	JRST	DTXINT##	;TO NON-CONTROL DEPENDANT SECTION

	CDC	DTSCN2,<CONI DAS,T1>;STATUS REGISTER INTO T1

;CONSTANTS REQUIRED FOR EACH CONTROL...
	CDC	BFPNTR,<IOWD 200,DABUF+1>
DTAUSE:	CDC	USEWRD,0
	CDC	ADRPRG,0
DTAPNT:	CDC	PNTR,0
	CDC	TEMP,0
	CDC	DISTNC,0
	CDC	BLOCK,0
	CDC	QUANTM,0
	CDC	DSCON,0
	CDC	RVERS,0
	CDC	ERRCNT,0
	CDC	FNDTMP,0
	CDC	IOWRIT,0
	CDC	TURNCT,0
	CDC	BLKWRD,0
	CDC	LVFLAG,0
DTASVC:	0
	CDC	BLKCNT,0
	CDC	SVPNTR,0
	CDC	USPNTR,0
	CDC	DIRCTN,0
	DTABUF=.-DTADDB
DABUF:	CDC	BUF,<BLOCK 200>		;A CONTROL MONITOR BUFFER
	CDC	DTXCON,<CONO DAC,(T1)>	;CONDITIONS OUT - A CONTROL A
	CDC	DTXSTP,<CONO DAC,400000>	;STOP SELECTED TAPE
	CDC	DTXTRN,<CONO DAC,DTTURN##>	;TURN SELECTED TAPE AROUND
	CDC	DTSCO2,<CONO DAS,2(T4)>
	CDC	DTSENJ,<CONO DAS,670000>	;ENABLE JOB DONE

	CDC	DTXREQ,D1REQ##		;ADDRESS OF REQUEST COUNT FOR THIS CONTROL
	CDC	DTXWAT,D1WAIT##		;WAIT ROUTINE
	CDC	DTXFRE,D1FREE##		;FREE-UP ROUTINE
DADDMP:	CDC	DTXDMP,0		;SET TO -1 WHEN READING IN DUMP MODE
	XP	DTXIOG,.-DTADDB
	CONO	DAC,DTBOTH##(T2)	;START UP DECTAPE
	CONO	DAS,770000		;ENABLE INTERRUPT CONDITIONS
	POPJ	P,			;RETURN
	CDC	DTXSF,<CONSZ DAC,100000>	;SKIP IF GOING FORWARD
	CDC	DTXDSL,<CONO DAC,410000>	;STOP AND DESELECT TAPE
	CDC	DTXDST,<CONO DAC,10000>		;DESELECT TAPE
	CDC	DTXSTO,<CONO DAC,430000(T1)>	;STOP AND DESELECT
	CDC	DTXTR2,<CONO DAC,230200(T1)>	;TURN TAPE, SEARCH FOR BLOCKS
	CDC	DTXINI,<CONO DAC,0>	;SHUT DOWN CONTROL
	CDC	DTXDTI,<DATAI DAC,T1>	;READ A BLOCK NUMBER

	XP	DCONS,.-DTADDB
>	;END IFG M.DTA CONDITIONAL

DBC=330		;CONTROL DEVICE NUMBER
DBS=DBC+4	;CONTROL STATUS NUMBER
IFG M.DTB,<
SUBTTL INTERRUPT HEAD FOR DTB
	INTERNAL	DTBDDB,DTBDDS,DBDINT,DTBINT,DTBDIR
			;FLAGS LEVEL CODE

;CONTROL DEPENDANT PORTION OF DECTAPE SERVICE
DEFINE CDC (C,B) <
	INTERN	C
C=.-DTBDDB	;RELATIVE LOCATION WITHIN CONTROL BLOCK
	B>

;MODEL DEVICE DATA BLOCK
DTXDDB=.-DTBDDB
DTBDDB:	SIXBIT	/DTB0/		;(0) - DEVNAM
	XWD	DVCMDA!<^D6*HUNGST>,200  ;(1) - DEVCHR
	0			;(2) - DEVIOS
	EXP	DTADSP##	;(3) - DEVSER
	XWD	1107,154403	;(4) - DEVMOD
	0			;(5) - DEVLOG
	0			;(6) - DEVBUF
	XWD	R,0		;(7) - DEVIAD
	XWD	R,0		;(10) - DEVOAD
	0			;(11) - DEVSTS
	XWD	.TYDTA,0	;(12) - DEVSTA
	0			;(13) - DEVXTR
	0			;(14) - DEVEVM
	0			;(15) - DEVPSI
	0			;(16) - DEVESE
	0			;(17) - DEVHCW
	0			;(20) - DEVJOB
	0			; - DEVFIL
	0			; - DEVEXT
	0			; - FSTBLK
	DTBDIR+DTBDDB		; - DLOC
	0			; - IBLK
	0			; - OBLK
	0			; - DISPAD
	0			; - DMPLST
	0			; - SVDWRD
	0			; - DJOTOP
	0			; - DJOBOT
	0			; - BADCOM
DTBDIR==.-DTBDDB
	BLOCK	200
	XP	DTBDDS,.-DTBDDB

;DATA LEVEL CODE...CHANNEL 1 OR 2 USUALLY

DBDINT:	CONSO	DBS,1		;DATA INTERRUPT FOR THIS CONTROL?
	JRST	.		;NO- PROCEED DOWN CHAIN
	SKIPN	DTBUSE
	JRST	DBDINT+1
	SKIPE	DBDSRC		;ARE WE SEARCHING FOR BLOCK NUMBERS?
	JRST	DBSRCH		;YES
DBIOWD:	BLKI	DBC,DTBPNT	;EXECUTE BLKI OR BLKO FOR THIS UNIT
	JRST	DBDTHR		;POINTER RAN OUT
DBDCTN:	JFCL			;GOING REVERSE?
	JEN	@DBDCHL		;NO- DISMISS DECTAPE DATA CHANNEL A
	SOS	DTBPNT		;YES- DECREMENT POINTER
	SOS	DTBPNT		;TWICE
	JEN	@DBDCHL##	;DISMISS THE INTERRUPT
DBDTHR:	SKIPE	DBDDMP		;IN DUMP MODE?
	JRST	DBDMPA		;YES
DBDFNS:	CONO	DBS,770001	;SEND OUT FUNCTION STOP IF THROUGH
	JEN	@DBDCHL		;DISMISS INTERRUPT

DBDSRC:	CDC	DTXSRC,0;SET NEGATIVE WHEN READING BLOCK NUMBERS

;HERE WHEN READING BLOCK NUMBERS AT DATA INTERRUPT LEVEL

DBSRCH:	MOVEM	W,DTBSVC	;SAV W
DBCCNC:	CONI	DBC,W		;READ FLAGS REGISTER
	HRLZS	W		;PUT IN LEFT HALF OF W
	HRRI	W,DTBDDB	;POINT TO THIS CONTROL BLOCK
	JRST	SRCH##		;DO THE SEARCH
DBDXIT:	MOVE	W,DTBSVC	;RESTORE W
	JEN	@DBDCHL		;DISMISS THE INTERRUPT

DBDMPA:	MOVEM	W,DTBSVC	;SAVE W
	HRRZI	W,DTBDDB	;ADDRESS OF THIS CONTROL BLOCK
	JRST	DMPADV##	;PROCESS THE EXHAUSTED BLKI/O

	XP	DTSFNS,DBDFNS-DTBDDB
	XP	DXDINT,DBDINT-DTBDDB
	XP	DXIOWD,DBIOWD-DTBDDB
	XP	DXDCTN,DBDCTN-DTBDDB
DBCNUM:	CDC	DCXNUM,<<DBC>B11>;DECTAPE CONTROL B DEVICE NUMBER


	XP	DTXXIT,DBDXIT-DTBDDB
	XP	DTXCNC,DBCCNC-DTBDDB
;FLAGS LEVEL INTERRUPT HEAD...
DTBINT:	CONSO	DBS,770000	;INTERRUPT FOR THIS CONTROL?
	JRST	.		;NO- PROCEED DOWN CHAIN
	SKIPN	DTBUSE
	JRST	DTBINT+1
	JSR	DTBSAV##	;YES- SAV ACCUMULATORS FOR THIS LEVEL
	CDC	DXCCNT,<CONI DBC,T1>;READ FLAGS INTO T1
	CDC	DTSCNI,<CONI DBS,T4>;READ STATUS INTO T4
	HRLZI	W,(T1)		;PUT FLAGS (RH) INTO W (LH)
	HRRI	W,DTBDDB	;ADDRESS OF CONTROL DEPENDATNT BLOCK
	JRST	DTXINT##	;TO NON-CONTROL DEPENDANT SECTION

	CDC	DTSCN2,<CONI DBS,T1>;READ STATUS REGISTER INTO T1

;CONSTANTS REQUIRED FOR EACH CONTROL...
	CDC	BFPNTR,<IOWD 200,DBBUF+1>
DTBUSE:	CDC	USEWRD,0
	CDC	ADRPRG,0
DTBPNT:	CDC	PNTR,0
	CDC	TEMP,0
	CDC	DISTNC,0
	CDC	BLOCK,0
	CDC	QUANTM,0
	CDC	DSCON,0
	CDC	RVERS,0
	CDC	ERRCNT,0
	CDC	FNDTMP,0
	CDC	IOWRIT,0
	CDC	TURNCT,0
	CDC	BLKWRD,0
	CDC	LVFLAG,0
DTBSVC:	0
	CDC	BLKCNT,0
	CDC	SVPNTR,0
	CDC	USPNTR,0
	CDC	DIRCTN,0
	DTBBUF=.-DTBDDB
DBBUF:	CDC	BUF,<BLOCK 200>		;A CONTROL MONITOR BUFFER
	CDC	DTXCON,<CONO DBC,(T1)>	;CONDITIONS OUT - A CONTROL A
	CDC	DTXSTP,<CONO DBC,400000>	;STOP SELECTED TAPE
	CDC	DTXTRN,<CONO DBC,DTTURN>	;TURN SELECTED TAPE AROUND
	CDC	DTSCO2,<CONO DBS,2(T4)>
	CDC	DTSENJ,<CONO DBS,670000>	;ENABLE JOB DONE

	CDC	DTXREQ,D2REQ##		;ADDRESS OF REQUEST COUNT FOR THIS CONTROL
	CDC	DTXWAT,D2WAIT##		;WAIT ROUTINE
	CDC	DTXFRE,D2FREE##		;FREE-UP ROUTINE
DBDDMP:	CDC	DTXDMP,0		;NON-ZERO FOR DUMPMODE I/O
	XP	DTXIOG,.-DTBDDB
	CONO	DBC,DTBOTH(T2)		;START UP DECTAPE
	CONO	DBS,770000		;ENABLE INTERRUPT CONDITIONS
	POPJ	P,			;RETURN
	CDC	DTXSF,<CONSZ DBC,100000>	;SKIP IF GOING FORWARD
	CDC	DTXDSL,<CONO DBC,410000>	;STOP AND DESELECT TAPE
	CDC	DTXDST,<CONO DBC,10000>		;DESELECT TAPE
	CDC	DTXSTO,<CONO DBC,430000(T1)>	;STOP AND DESELECT
	CDC	DTXTR2,<CONO DBC,230200(T1)>	;TURN TAPE, SEARCH FOR BLOCKS
	CDC	DTXINI,<CONO DBC,0>	;SHUT DOWN DECTAPE CONTROL
	CDC	DTXDTI,<DATAI DBC,T1>	;READ A BLOCK NUMBER
EXTERN	D1REQ,D2REQ
	XP	DCONS,.-DTBDDB
>	;END IFG M.DTB CONDITIONAL

KONEND:			;END OF KONTROLLER DATA BLOCKS
INTERN	DLOC,FSTBLK,IBLK,OBLK,DISPAD,DMPLST,SVDWRD
INTERN	DJOTOP,DJOBOT,BADCOM,KONEND


;DDB MAGIC CELLS
FSTBLK==DEVPPN
DLOC==FSTBLK+1	;LH==BLOCK# DURING DEAD RECKONING,RH==ADDRESS OF DIR
IBLK==FSTBLK+2	;LH==INDEX OF INPUT FILE(1-27),RH==BLOCK# TO READ NEXT
OBLK==FSTBLK+3
DISPAD==FSTBLK+4
DMPLST==FSTBLK+5
SVDWRD==FSTBLK+6
DJOTOP==FSTBLK+7
DJOBOT==FSTBLK+10
BADCOM==FSTBLK+11
	CDR2==154		;DEVICE SELECTION CODE FOR SECOND CDR

	IFG	CDRN, <

SUBTTL PROTOTYPE DEFINITION FOR CARD READER DEVICE DATA BLOCKS

DEFINE	CDRDDB	(N) <

	INTERN	CR'N'DDB

CR'N'SV1==CR'N'SAC##+F		;DEFINE F SAVE LOCATION

CDRCON==.-CR'N'DDB
CR'N'INT::CONSO	CR'N,0		;(-4) SKIP IF INTERRUPT FOR THIS READER
	  JRST	.-1		;(-3) NOT HERE, CONTINUE DOWN THE CHAIN
	  MOVEM	F,CR'N'SV1	;(-2) SAVE F IN CHANNEL SAVE AREA
	  JSP	F,CDRINT	;(-1) SET F TO DDB ADDRESS AND SERVICE INTERRUPT
CR'N'DDB:
CR'N'NAM:
	CRNAM=SIXBIT/CDR/
	IFE	CDRN+DCDRN-1,<CRNAM>	;(0) PHYSICAL DEVICE NAME
	IFN	CDRN+DCDRN-1,<CRNAM+<20+$CRNUM>B23> ;(0) PHYSICAL DEVICE NAME
	XWD	2*HUNGST,	;(1) DEVICE CHARACTERISTICS
CDRIOS==.-CR'N'DDB
	0			;(2) DEVIOS
	CDRDSP			;(3) LH=DDB LINK, RH=CDR DISPATCH TABLE
	XWD DVCDR+DVIN,14403	;(4) DEVICE CHARACTERISTICS
	0			;(5) LOGICAL DEVICE NAME (DEVLOG)
	0			;(6) BUFFER HEADER ADDRESSES
CDRIAD==.-CR'N'DDB
	XWD	R,0		;(7) ADDRESS OF CURRENT INPUT BUFFER
CDRPTR==.-CR'N'DDB
	XWD	R,0		;(10) BYTE POINTER TO CURRENT INPUT BUFFER
CDRSTS==.-CR'N'DDB
CR'N'STS: 0			;(11) LATEST CONI STATUS BITS
	XWD .TYCDR!.SPCDR,0	;SPOOLED CDR
	0			;DEVXTR
	0			;DEVEVM
	0			;DEVPSI
	0			;DEVESE
	0			;DEVHCW
	0			;DEVJOB
CDRCTR==.-CR'N'DDB
	0			;BYTE COUNTER FOR IDPB'S INTO USER'S BUFFERS
CDRCHK==.-CR'N'DDB
	0			;CHECK SUM OF CURRENT INPUT BINARY CARD
CDRCNT==:.-CR'N'DDB
	0			;# OF CARDS READ
CDRADR==.-CR'N'DDB
	0			;USER'S JOBDAT ADDRESS
CDRCOL==.-CR'N'DDB
	0			;COLUMN COUNT ON CURRENT CARD
IFN	FTCDRSI, <
	INTERN CDRSUP
CDRSUP==.-CR'N'DDB		;BLKI POINTER TO USER'S BUFFER
CR'N'SUP: 0			; FOR SUPER IMAGE MODE INPUT
	>
CDRMIS==.-CR'N'DDB
	0			;FLAG =-1 IF MISSED DATA ON CURRENT CARD
CDRSPU==.-CR'N'DDB		;COUNT OF SPURIOUS END-OF-CARD FLAGS
	0			; TO CHECK ON POSSIBLE HARDWARE PROBLEM
CDRSV2==.-CR'N'DDB
	0			;SAVE LOCATION FOR U
IFN FTCDRSI,<
INTERN CDRBKI
CDRBKI==.-CR'N'DDB
	BLKI	CR'N,CR'N'SUP
>
CDRCNO==.-CR'N'DDB
	CONO	CR'N,(U)
CDRCSO==.-CR'N'DDB
	CONSO	CR'N,(U)
CDRCSZ==.-CR'N'DDB
	CONSZ	CR'N,(U)
CDRDTI==.-CR'N'DDB
	DATAI	CR'N,U
CDRRDY==.-CR'N'DDB
	EXTERN	IDRDY
	CONSO	CR'N,IDRDY	;SKIP IF DATA READY
CDRRTR==.-CR'N'DDB
	EXTERN	NOTRDY
	CONSZ	CR'N,NOTRDY	;SKIP IF READY TO READ
CDRSVE==.-CR'N'DDB
CR'N'SVE: 0			;ROUTINE TO SAVE AC'S
	MOVE	F,CR'N'SV1	;RESTORE F
	JSR	CR'N'SAV##	;SAVE AC'S AND ESTABLISH P
	MOVEI	F,CR'N'DDB	;SET UP DDB ADDRESS
	JRST	@CR'N'SVE	;AND RETURN
CDREX1==.-CR'N'DDB
	MOVE	F,CR'N'SV1	;RESTORE F
	JEN	@CR'N'CHL##	;AND DISMISS INTERRUPT
CRFCON==.-CR'N'DDB
CF'N'INT::CONSO	CR'N,0		;SKIP IF CDR FLAG
	JRST	.-1		;NOT THIS, CONTINUE DOWN SKIP CHAIN
	JSR	CF'N'SAV##	;SAVE AC'S
	MOVEI	F,CR'N'DDB	;SET UP F
	JRST	CRFINT##	;AND SERVICE INTERRUPT
IFN	FT5UUO, <
CRXSTS==.-CR'N'DDB
	INTERN	CRXSTS
	CONI	CR'N,CR'N'STS
	>

	INTERN	CDRCNO,CDRCOL,CDRCON,CDRCSO,CDRCSZ,CDRCTR,CDRRDY
	INTERN	CDRADR,CDRDTI,CDRIAD,CDRIOS,CDRMIS,CDRPTR,CDRSPU
	INTERN	CDRSV2,CDRSVE,CDREX1,CDRCHK,CDRRTR
	INTERN	PCDRAS,PCDRBI,PCDRsi,crfcon
	>

	EXTERN	CDRSRX,CDRINT,CDRDSP


	IFNDEF	CR0,<CR0==CR>	;DEFINE STANDARD MNEMONIC DEFINITIONS
	IFNDEF	CR1,<CR1==CDR2> ; BUT ALLOW FOR OVERRIDE

	$CRNUM==0		;TEMPORARY SYMBOL USED FOR MACRO EXPANSION

	REPEAT	CDRN,	<

	CDRDDB	\$CRNUM
	$CRNUM==$CRNUM+1

	>
>

IFG DCDRN, <				;ONLY NEED THIS IF FRONT-END CARD READERS

DEFINE	DCRDDB	(D,U,X) <

FC'X'DDB::
	CRNAM=SIXBIT/CDR/
	CRNAM+<20+$CRNUM>B23		;(0) DEVNAM
	XWD	2*HUNGST,		;(1) DEVCHR
	0				;(2) DEVIOS
	DCRDSP				;(3) LH=DDB LINK, RH=DISPATCH TABLE
	XWD	DVCDR+DVIN,14403	;(4) DEVMOD
	0				;(5) DEVLOG
	0				;(6) DEVBUF
	0				;(7) DEVIAD
	0				;(10) DEVPTR
	0				;(11) DEVSTS
	XWD .TYCDR!.SPCDR,0		;(12) DEVSPL
	0				;(13) DEVXTR
	0				;(14) DEVEVM
	0				;(15) DEVPSI
	0				;(16) DEVESE
	EXP	3B11			;(17) DEVHCW
	0				;(20) DEVJOB
	0				;(21) DEVCTR
DCRDUX==:.-FC'X'DDB
	XWD	U,D			;(22) LINE NUMBER,,DTE INDEX
CDRCNT==:.-FC'X'DDB
	0				;(23) CARD COUNT
DCRBUF==:.-FC'X'DDB
	BLOCK	^D40			;(24) BUFFER FOR READING A CARD
>
	EXTERN	DCRSER,DCRDSP


DEFINE	RSXDTE	(C,D)	<
	ZZ=0
  REPEAT M.CR'C'D,<
	DCRDDB	\N,\ZZ,\<$CRNUM-CDRN>
	ZZ=ZZ+1
	$CRNUM=$CRNUM+1
  >
	N==N+1
>


	$CRNUM=CDRN			;START NUMBERING DCB'S AT CDRN
	N==0				;DTE INDEX STARTS AT 0

	RSX20F				;GENERATE THE FRONT END READER DDB'S
>	;END IFN DCDRN

IFN	M.KL10,<
IFE DCDRN,<FCRDSP==:EATDSP##>
>	;END IFN M.KL10
;IF THERE ARE REMOTE OR LOCAL READERS, CERTAIN BYTE POINTERS
;  AND THE CHARACTER TRANSLATION TABLES MUST BE DEFINED.

IFN CDRN+M.RCDR+DCDRN,<

IFN M.KA10,<ZZ==R>
IFN M.KI10!M.KL10,<ZZ=0>
XP PCDRAS,700+ZZ		;ASCIZ BYTE POINTER
XP PCDRBI,1400+ZZ		;BINARY AND IMAGE BYTE POINTER
XP PCDRSI,4400+ZZ		;SUPER IMAGE BYTE POINTER

;THE CHARACTER TRANSLATION TABLES:

	$HIGH
CRCVPT::XWD	350700+T2,CRCVTB
	XWD	260700+T2,CRCVTB
	XWD	170700+T2,CRCVTB
	XWD	100700+T2,CRCVTB

;CODE CONVERSION FOR THE 029 KEYPUNCH
;THE FOLLOWING EQUIVALENCES ARE ARTIFICIALLY DEFINED

;029 KEYTOP	;ASCII 35	;ASCII 37
;CENT		[		[
;0-8-2		]		]
;VERT BAR	^		HAT = L.C. VERT BAR
;UNDERBAR	_		UNDERBAR
;NEGATION	\		TILDE = L.C. NEGATION

	;CHARACTERS	;ZONE/DIGITS
CRCVTB:	ASCII	/ 123/		;N/N-3
	ASCII	.0/ST.		;0/N-3
	ASCII	/-JKL/		;11/N-3
	ASCII	/HI[./		;12,8/N-3
	ASCII	/&ABC/		;12/N-3
	ASCII	/QR]$/		;11,8/N-3
	ASCII	/YZ\,/		;0,8/N-3
	ASCII	/89:#/		;8/N-3
	ASCII	/4567/		;N/4-7
	ASCII	/UVWX/		;0/4-7
	ASCII	/MNOP/		;11/4-7
	ASCII	/<(+!/		;12,8/4-7
	ASCII	/DEFG/		;12/4-7
	ASCII	/*);^/		;11,8/4-7
	ASCII	/%_>?/		;0,8/4-7
	ASCII	/@'="/		;8/4-7

;CODE FOR THE 026 KEYPUNCH A LA H HYMAN

	ASCII	/ 123/		;N/N-3
	ASCII	.0/ST.		;0/N-3
	ASCII	/-JKL/		;11/N-3
	ASCII	/HI?./		;12,8/N-3
	ASCII	/+ABC/		;12/N-3
	ASCII	/QR:$/		;11,8/N-3
	ASCII	/YZ;,/		;0,8/N-3
	ASCII	/89_=/		;8/N-3
	ASCII	/4567/		;N/4-7
	ASCII	/UVWX/		;0/4-7
	ASCII	/MNOP/		;11/4-7
	ASCII	/)]<!/		;12,8/4-7
	ASCII	/DEFG/		;12/4-7
	ASCII	/*[>&/		;11,8/4-7
	ASCII	/("#%/		;0,8/4-7
	ASCII	/@^'\/		;8/4-7
	$LOW
>	;END OF IFN RCDRN+M.RCDR

;CARD PUNCH ENTRY POINT

	IFG	CDPN, <
	EXTERNAL CDPSER		;ENTRY POINT
CP10D::	EXP	M.CP1D		;1 IF CP10D, 0 IF CP10A
>



;-------DK10 BITS

RTC==	070	;DEVICE ASSIGNMENT
		;CONO BITS
DK.OSO==1B23	;SET COUNT OVERFLOW
DK.OCO==1B31	;CLEAR COUNT OVERFLOW
DK.OSD==1B24	;SET DONE
DK.OCD==1B32	;CLEAR DONE
DK.OSU==1B28	;SET USER TIME
DK.OCU==1B27	;CLEAR USER TIME
DK.OON==1B30	;TURN CLOCK ON
DK.OOF==1B29	;TURN CLOCK OFF
DK.OIC==1B25	;INCREMENT CLOCK(IF OFF)
DK.OCC==1B26	;CLEAR CLOCK(COUNTER,DONE,OVF.,USER,PIA)
		;CONI BITS
DK.IO== 1B31	;OVERFLOW FLAG (INTERRUPT)
DK.ID== 1B32	;DONE FLAG (INTERRUPT)
DK.IU== 1B28	;USER TIME
DK.ION==1B30	;CLOCK ON
DK.IXS==1B26	;EXTERNAL SOURCE
;PROTOTYPE DK10 DDB

RTCNUM==M.RT0+M.RT1		;# OF DK10'S

XP C0RTC,0			;ASSUME NO DK10 ON CPU0
XP C1RTC,0			;ASSUME NO DK10 ON CPU1
IFG M.RT0,<XP C0RTC,RT0DDB>
IFG M.RT1,<XP C1RTC,RT1DDB>

;HIGH PRECISION TIME ACCOUNTING

XP C0RTD,0			;ASSUME NO HIGH PRECISION ACCOUNTING ON CPU0
XP C1RTD,0			;ASSUME NO HIGH PRECISION ACCOUNTING ON CPU1
IFN M.RTCA,<		;HIGH PREC TIME ACCOUNTING?
	XP C0RTD,C0RTC
	XP C1RTD,C1RTC
>

DEFINE	RTCDDB	(N,DEVCOD)<

	INTERN	RTCINI,RTCTIM

RT'N'SVF==RT'N'SAC##+F		;DEFINE SAVE LOC. FOR F
RT'N'SVT==RT'N'SAC##+T1		;SAVE LOC. FOR T1
RT'N==DEVCOD			;DEFINE DEVICE CODE
RT'N'DTI==:(DATAI RT'N,)	;DATAI FOR EXTERNAL USE (E.G. RT'N'DTI##,,ADDR)


;----	INITIALIZATION ROUTINE (JSR RTCINI(F))
RT'N'INI:	0
	CONO	RT'N,DK.OCC	; CLEAR THE CLOCK
	DATAO	RT'N,RT'N'PRD	; SET PERIOD
	CONO	RT'N,DK.OON+RT'N'CHN## ; & START CLOCK
	JRST	@RT'N'INI

;----	EXIT ROUTINE (JRST RTCXIT(F))
RT'N'XIT:CONO	RT'N,DK.OCO+DK.OCD+RT'N'CHN##  ;CLEAR IRP.
	MOVE	F,RT'N'SVF	; RESTORE F & T1
	MOVE	T1,RT'N'SVT
	JEN	@RT'N'CHL##	; & DISMISS

;----	INTERRUPT ROUTINE
RT'N'INT::CONSO	RT'N,DK.IO+DK.ID	; INTERRUPT FOR THIS DK10 (OVERFLOW OR DONE?)
	JRST	.-1		; NO
	MOVEM	F,RT'N'SVF	; YES - SAVE F & T1
	MOVEM	T1,RT'N'SVT
	JSP	F,RTCINT##	; LOAD F WITH DDB ADDR & GO TO IRP. ROUTINE

;	DEFINE SOME DISPLACMENTS RELATIVE TO DDB
XP RTCINI,RT'N'INI-.
XP RTCXIT,RT'N'XIT-.

RT'N'DDB::
XP RTCNAM,.-RT'N'DDB		;(0) PHYSICAL NAME
	SIXBIT/RTC'N/
XP RTCPRD,.-RT'N'DDB		;(1) PERIOD (10 USEC UNITS)
RT'N'PRD:	^D100000
XP RTCTIM,.-RT'N'DDB		;(2) TIME (10 USEC UNITS) UPDATED EVERY IRP.
RT'N'TIM::	0
XP RTCSON,.-RT'N'DDB		;(3) SKIP IF DK10 ON
	CONSO	RT'N,DK.ION
XP RTCSNO,.-RT'N'DDB		;(4) SKIP IF NOT OVERFLOW
	CONSZ	RT'N,DK.IO
XP RTCDAI,.-RT'N'DDB		;(5) READ CLOCK INTO T1
	DATAI	RT'N,T1
XP RTCLGT,.-RT'N'DDB		;(6) LAST VALUE RETURNED BY GETIME
	0
>	;DEFINE RTCDDB



;GENERATE DK10 DDB'S

IFG M.RT0,<RTCDDB(0,70)>	;CPU0 CLOCK

IFG M.RT1,<RTCDDB(1,70)>	;CPU1 CLOCK

IFE M.RTC,<			;IF NO DK10'S STILL DEFINE SOME SYMBOLS
XP RTCTIM,0			;FOR SETIME (SYSINI) SO WON'T GET
XP RTCINI,0			;UNDEFINED GLOBALS.
>
;DISPLAY AND LITE PEN

	IFG	DISN, <
	IFN	T30N!TVP10N, <DIS==134>
	EXTERNAL DISSER,PENLOC,DISIN1,EXIT1,EXIT0,DISBKO,DISNX1
	INTERNAL ENDCHK
	INTERNAL PENINT,SETCON,DISCNO,DISCNA,DISCZA,BLKLIT,DISTST
XP DISJSR,DISBLK##+1		;DIS JSR LOCATION IN LOWER CORE
XP ONDIS,DISBTH##+100
XP NONDIS,DISBTH##
XP OFFDIS,0
XP DISPON,2000+DISBIT##		;CONO PI, TURNS DIS PI CHANNEL ON
XP DISPOF,1000+DISBIT##		;CONO PI, TURNS DIS PI CHANNEL OFF


DISCON:

IFN T340N, <EXP ONDIS

DISBSY==77
XP PENON,7400

SETCON:	CONO	DIS,100		;PARAMETER MODE
	JRST	DISIN1

PENINT:	CONSO	DIS,0		;CHECK FOR CONI FLAGS
	JRST	PENINT		;THIS WILL BE PART OF THE LINKED INTERRUPT CHAIN.
	CONSZ	DIS,400		;STOP FLAG UP
	JRST	STPFLG		;YES
	CONSZ	DIS,2000	;PEN FLAG UP
	DATAI	DIS,PENLOC	;YES-STORE CURRENT LITE PEN LOCATION
	CONO	DIS,NONDIS	;CLEAR FLAGS
	JEN	@PENCHL##	;& DISMISS

;"STPFLG" SERVICES STOP FLAGS (DISPLAY PROGRAMMED) BY DOING A CLOSE ON THE DISPLAY

STPFLG:	JSR	PENSAV
	JRST	DISDSP+DCL	;DO A CLOSE

EXTERN DISDSP

ENDCHK:	TRNN	T1,-1
	JRST	EXIT1
	JRST	EXIT0
>	;END OF IFN T340N
IFE T340N, <Z

DISBSY==20000
PENON==10000

SETCON:	MOVEI	T1,PENCHN##	;SET UP CONO WORD
	ASH	T1,3		;WITH PROPER CHANNEL ASSIGNMENTS
	ADDI	T1,DISCHN##
IFN T30N!TVP10N, <TRO T1,4300>	;SET DISPLAY READY BIT & BRIGHTNESS = 3.
	MOVEM	T1,DISCON
	JRST	DISIN1

PENINT:	CONSO	DIS,0		;CHECK FOR CONI FLAGS
	JRST	PENINT		;THIS INSTRUCTION CHANGED TO LINK IN INTERRUPT CHAIN.
	DATAI	DIS,PENLOC	;CLEAR PEN INTERRUPT
	MOVEM	T1,PENLOC	;SAVE AC T1
	MOVE	T1,DISBKO	;GET ABSOLUTE ADDRESS OF NEXT DATA ELEMENT
	SUB	T1,DISREL	;MAKE RELATIVE
	HRRZS	T1		;CLEAR OUT GARBAGE IN LH
	EXCH	T1,PENLOC	;SAVE ADDRESS IN PENLOC
	JEN	@PENCHL##

EXTERN DISREL

ENDCHK:	JUMPE	T1,EXIT1	;END OF LIST?
	TRNE	T1,-1		;NO, CHANGE INTENSITY COMMAND?
	JRST	EXIT0		;NO
	MOVSS	T1		;YES, LH HAS USER CONO BITS
	DPB	T1,INPNT	;DEPOSIT FOR CONO
	CONO	DIS,@DISCON	;SET NEW INTENSITY
	JRST	DISNX1
INPNT:	IFN	TVP10N, <POINT 2,DISCON,28>
	IFN	T30N, <POINT 3,DISCON,29>
>	;END OF IFE T340N

	EXTERN	DISSTS
DISCNA:	CONO	DIS,@DISCON
DISCZA:	CONSZ	DIS,@DISCON
BLKLIT:	BLKO	DIS,DISBKO
DISCNO:	CONO	DIS,OFFDIS
IFN FT5UUO,<
	INTERN DISCNI
DISCNI:	CONI	DIS,DISSTS
>
DISTST:	CONO	DIS,DISCHN##
>	;END OF IFG DISN
	IFG	LPTN, <

;PROTOTYPE DEFINITION FOR LINE PRINTER DEVICE DATA BLOCKS

LPTDON==100

DEFINE	LPTDDB (N) <

	XLIST				;TURN OFF LISTING DURING EXPANSION

	INTERN	LP'N'DDB


LP'N'SV1==LP'N'SAC##+F		;DEFINE F SAVE LOCATION

LPTCON==.-LP'N'DDB
LP'N'INT::CONSO LP'N,0			;(-4) SKIP IF INTERRUPT FOR THIS LPT
	  JRST .-1			;(-3)  GO TO NEXT SKIP CHAIN ELEMENT
	  MOVEM F,LP'N'SV1		;(-2) SAVE F IN CHANNEL SAVE AREA
	  JSP F,LPTINT		;(-1) SET UP DDB ADDRESS AND BRANCH
LP'N'DDB:
LP'N'NAM: 
	LPNAM=SIXBIT /LPT/
	IFE	LPTN+DLPTN-1, <LPNAM>	;( 0) PHYSICAL DEVICE NAME
	IFN	LPTN+DLPTN-1, <LPNAM+<20+$LPNUM>B23>	;( 0) PHYSICAL DEVICE NAME
	<XWD <6*HUNGST>,<N>B23+LPTSIZ>+<M.LP'N'L>B0  ;( 1) DEVICE CHARACTERISTICS
					; HUNG TIME IS 63 SECS (CODE 6)
	  0				;( 2) DEVICE I/O STATUS
	  XWD 0,LPTDSP			;( 3) LH=DDB LINK, RH=DSP TABLE ADDR.
LPTMOD==1_A+1_AL+1_I			;LPT LEGAL MODES
	  XWD DVOUT+DVLPT,LPTMOD	;( 4) DEVICE CHARACTERISTICS
	  0 				;( 5) LOGICAL DEVICE NAME
	  0				;( 6) BUFFER HEADER ADDRESSES
LPTPTR==.-LP'N'DDB
LP'N'PTR: 0				;( 7) BLOCK OUTPUT POINTER
	  XWD R,0			;(10) CURRENT OUTPUT BUFFER ADDRESS
LP'N'STS:	0			;(11) DEVICE STATUS WORD
	XWD	.TYLPT!.SPLPT!DEPLEN,0	;SPOOLED LPT, VAR BUFS, DON'T DEADVANCE
	0				;DEVXTR
	0				;DEVEVM
	0				;DEVPSI
	0				;DEVESE
	0				;DEVHCW
	0				;DEVJOB
LPTCH==.-LP'N'DDB
	  EXP LP'N'BTH##		; INTERRUPT CHANNEL ASSIGNMENTS
LPTSVE==.-LP'N'DDB
	  MOVE F,LP'N'SV1		; RESTORE F, SAVE AC'S
	  JSR LP'N'SAV##		;  AND ESTABLISH P
	  MOVEI F,LP'N'NAM		; SET UP DDB ADDRESS AND RETURN
	  JRST LPTNXT			;  TO COMMON INTERRUPT HANDLER
LPTEX1==.-LP'N'DDB
	  MOVE F,LP'N'SV1		; RESTORE F AND
	  JEN @LP'N'CHL##			;  DISMISS INTERRUPT
LPTSV2==.-LP'N'DDB
	  0				; SAVE LOCATION FOR U
LPTDAP==.-LP'N'DDB
	  0				;PLACE TO BUILD AOBJN POINTER
					;TO ERROR BLOCK
LPTDAE==.-LP'N'DDB
	  BLOCK	4			;SYSERR BLOCK
					; THE REST OF THE DDB CONTAINS
LPTDNO==.-LP'N'DDB
	  CONSZ LP'N,CI%SKE##		;  THE ACTUAL I/O INSTRUCTIONS
LPTDNZ==.-LP'N'DDB
	  CONSO	LP'N,CI%SKE##
LPTCSO==.-LP'N'DDB
	  CONSO LP'N,(U)		;  USED BY THE COMMON SERVICE
LPTCSZ==.-LP'N'DDB
	  CONSZ LP'N,(U)		;  ROUTINE TO CONTROL A LINE
LPTCNI==.-LP'N'DDB
	  CONI  LP'N,U		;  PRINTER. THEY ARE EXECUTED
LPTCNO==.-LP'N'DDB
	  CONO  LP'N,(U)		;  BY MEANS OF AN XCT INSTRUCTION
LPTDTO==.-LP'N'DDB
	  DATAO LP'N,(U)		;  INDEXED TO THE PROPER DDB
LPTBKO==.-LP'N'DDB
	  BLKO  LP'N,LP'N'PTR		;
LPTPAG==.-LP'N'DDB
	0			;PAGE COUNTER WORD
IFN FT5UUO,<
LPXSTS==.-LP'N'DDB
	INTERN	LPXSTS
	CONI	LP'N,LP'N'STS	; DEVICE STATUS WORD CONI

>
	INTERN	LPTCON,LPTPTR,LPTCH,LPTSVE,LPTEX1,LPTSV2,LPTPAG
	INTERN	LPTCSO,LPTCSZ,LPTCNI,LPTCNO,LPTDTO,LPTBKO
	INTERN	LPTDNO,LPTDNZ,LPTDAP,LPTDAE
	LIST				;TURN LISTING BACK ON AFTER EXPANSION

>;END DEFINE OF LPTDDB
>;END IFG LPTN
IFN M.KL10,<				;FRONT END CDR'S ON KL10'S ONLY
   IFG DLPTN,<

;PROTOTYPE DEFINITION FOR RSX-20F LINEPRINTER DEVICE DATA BLOCKS

DEFINE	DLPDDB	(D,U,X,Y)	<

	XLIST				;TURN OFF LISTING DURING EXPANSION

	INTERN	FL'Y'DDB		;"FL" IS FOR RSX-20F LPT 

;HARDWARE CHARACTERISTICS DEFAULTS

   IFNDEF M.LP'X'L,<M.LP'X'L==:0>	;PRINTER IS UPPER-CASE
   IFNDEF M.LP'X'P,<M.LP'X'P==:0>	;NO PAGE COUNTER
   IFNDEF M.LP'X'V,<M.LP'X'V==:1>	;DAVFU
   IFNDEF M.LP'X'C,<M.LP'X'C==:0>	;64-CHAR SET
   IFNDEF M.LP'X'T,<M.LP'X'T==:3>	;RSX20F PRINTER
   IFNDEF M.LP'X'N,<M.LP'X'N==:0>	;NO CHAR SET NAME

FL'Y'DDB:
FL'Y'NAM:
	LPNAM=SIXBIT/LPT/
	IFE DLPTN+LPTN-1,<LPNAM>	;(0) PHYSICAL DEVICE NAME
	IFN DLPTN+LPTN-1,<LPNAM+<20+$LPNUM>B23> ;(0) PHYSICAL DEVICE NAME
	<XWD <5*HUNGST>,LPTSIZ>+<M.LP'X'L>B0	;(1) DEVICE CHARACTERISTICS
					;HUNG TIME IS 63 SECONDS
	0				;(2) DEVICE I/O STATUS
	XWD	0,RLPDSP		;(3) DDB LINK,,DSP TABLE ADDRESS
DLPMOD==1_A+1_AL+1_BYTMOD		;LEGAL MODES
	XWD	DVOUT+DVLPT,DLPMOD	;(4) DEVICE CHARACTERISTICS
	0				;(5) LOGICAL DEVICE NAME
	0				;(6) BUFFER HEADER ADDRESSES
	0				;(7) OUTPUT POINTER
	XWD	R,0			;(10) CURRENT OUTPUT BUFFER ADDRESS
	0				;(11) DEVICE STATUS WORD
	XWD	.TYLPT!.SPLPT!DEPLEN,0	;SPOOLED LPT, VAR BUFS, DON'T DEADVANCE
	0				;DEVXTR
	0				;DEVEVM
	0				;DEVPSI
	0				;DEVESE
	BYTE (1) M.LP'X'L, M.LP'X'P, 0 (3) M.LP'X'V, M.LP'X'C, M.LP'X'T (6) 0 (18) M.LP'X'N
					;DEVHCW
	0				;DEVJOB
	0				;COUNT OF OUTPUT CHARS
DLPDUX==.-FL'Y'DDB
	XWD	U,D			;UNIT # ON FRONT-END,,DLP DTE INDEX
DLPMLA==.-FL'Y'DDB
	0				;MAXIMUM LINE ALLOCATION
DLPRLA==.-FL'Y'DDB
	0				;REMAINING LINE ALLOCATION
DLPSNT==.-FL'Y'DDB
	0				;NUMBER OF WORDS ALREADY SENT
	INTERN	DLPDUX,DLPSNT,DLPMLA,DLPRLA

	LIST				;TURN LISTING BACK ON AFTER EXPANSION

>;END DEFINE OF DLPDDB

	EXTERNAL DLPSER,RLPDSP

>;END IFG DLPTN
>;END IFN KL10
SUBTTL	GENERATION OF LPT AND DLP DDB'S

   IFG LPTN,<
		EXTERNAL LPTSER, LPTNXT, LPTINT, LPTDSP

		LPT2==234		;DEVICE SELECT CODE FOR SECOND LPT
		IFNDEF LP2, <LP2==LPT3>

		IFNDEF LP0, <LP0==LPT>	;DEFINE STANDARD MNEMONIC DEFINITIONS
		IFNDEF LP1, <LP1==LPT2>	; BUT ALLOW FOR OVERRIDE
		LPT3==230		;DEVICE SELECTION CODE FOR THIRD LPT
   >;END IFG LPTN



DEFINE	RSXDTE	(C,D)	<

   IFG M.LP'C'D,<			;;DO ONLY IF AT LEAST ONE LPT ON DTE
	$LPUNT==0			;;UNIT STARTS AT ZERO FOR EACH DTE
	REPEAT	M.LP'C'D,<		;;DO FOR EACH LPT ON DTE
		DLPDDB	\$DTNDX,\$LPUNT,\$LPNUM,\<$LPNUM-LPTN>
					;;GENERATE DDB
		$LPUNT==$LPUNT+1	;;STEP TO NEXT UNIT ON DTE
		$LPNUM==$LPNUM+1	;;STEP TO NEXT UNIT FOR SYSTEM
	>
	$DTNDX==$DTNDX+1		;;STEP TO NEXT DTE
   >
>

IFN	M.KL10,<
IFE DLPTN,<DLPDSP==:EATDSP##>
>;END IFN M.KL10
IFG LPTN+DLPTN,<

		$LPNUM==0		;TEMPORARY SYMBOL USED TO FACILITATE
					; MACRO GENERATION

		REPEAT LPTN, <

			LPTDDB \$LPNUM
			$LPNUM==$LPNUM+1
		>



IFN DLPTN,<
		$DTNDX==0			;DTE INDEX FOR MACRO STARTS AT 0
		RSX20F				;GENERATE DDB'S FOR RSX-20F LPT'S


>;END IFN DLPTN
>;END IFG LPTN+DLPTN
	IFG	PLTN, <
;PROTOTYPE DEFINITION FOR CALCOMP PLOTTER DEVICE DATA BLOCKS

DEFINE	PLTDDB (N) <
	XLIST			;TURN OFF LISTING DURING EXPANSION
	INTERN	PL'N'DDB

PL'N'SV1==PL'N'SAC##+F		;DEFINE F SAVE LOCATION

PLTCON==.-PL'N'DDB
PL'N'INT::CONSO	PL'N,0		; SKIP IF INTERRUPT FOR THIS PLT
	JRST	.-1		; GO TO NEXT SKIP CHAIN ELEMENT
IFN FT5UUO,<
	CONI	PL'N,PL'N'STS >	;SAVE PLOTTER STATUS
	SOSGE	PL'N'CTR	;OUTPUT CHARACTERS LEFT?
	JRST	PL'N'IN2	;NO
	MOVEM	T1,PL'N'SV1	;SAVE T1 IN CHANNEL SAVE AREA
	ILDB	T1,PL'N'PTR	;GET NEXT CHARACTER
PLTDTO==.-PL'N'DDB
	DATAO	PL'N,T1		;SEND TO PLOTTER
	MOVE	T1,PL'N'SV1	;RESTORE T1 AND
	JEN	@PL'N'CHL##	;  DISMISS INTERRUPT

PL'N'IN2:JSR	PL'N'SAV##	;SAVE AC'S
	JSP	F,PLTNXT##	;SET UP F, GO TO PLOTTER SERVICE

PL'N'DDB:
PL'N'NAM:
	PLNAM==SIXBIT /PLT/
	IFE PLTN-1,<PLNAM>		; ( 0) PHYSICAL DEVICE NAME
	IFN PLTN-1,<PLNAM+<20+$PLNUM>B23>; ( 0) PHYSICAL DEVICE NAME
	XWD	HUNGST*4,^D36	;( 1) XWD (HUNG TIMEOUT),(BUFFER SIZE)
				; CODE 4 - HUNG TIME=15 SECONDS
	0			;( 2) DEVICE IO STATUS
	XWD	0,PLTDSP##	;( 3) LH=DDB LINK; RH=DSP TABLE ADDR.
PLTMOD==1_A+1_AL+1_I+1_IB+1_B		;PLOTTER LEGAL MODES
	XWD	DVOUT,PLTMOD	;( 4) XWD (OUTPUT DEV), (MODES)
	0			;( 5) LOGICAL DEVICE NAME
	0			;( 6) BUFFER HEADER ADDRESSES
PLTPTR==.-PL'N'DDB
PL'N'PTR:	0		;( 7) OUTPUT BYTE POINTER
	XWD	R,0		;(10) CURRENT OUTPUT BUFFER ADDRESS
PL'N'STS:	0		;(11) DEVICE STATUS WORD
	XWD	.TYPLT!.SPPLT,0	;(12) SPOOLED PLT
	0			;(13) DEVXTR
	0			;(14) DEVEVM
	0			;(15) DEVPSI
	0			;(16) DEVESE
	0			;(17) DEVHCW
	0			;(20) DEVJOB
PL'N'CTR:	0		;OUTPUT BYTE COUNTER
PLTCH==.-PL'N'DDB
	PL'N'CHN##		; INTERRUPT CHANNEL

PLTCNO==.-PL'N'DDB
	CONO	PL'N,(T1)	;XCT'D FROM PLTSER

	INTERN	PLTCON,PLTDTO,PLTCH,PLTCNO,PLTPTR
	LIST			;TURN ON LISTING AFTER EXPANSION
>	;END OF PLTDDB MACRO DEFINITION
	EXTERNAL	PLTSER

	PLT2==144		;2ND PLOTTER DEVICE CODE
	IFNDEF	PL0,<PL0==PLT>	;DEFINE STANDARD MNEMONIC DEFINITIONS
	IFNDEF	PL1,<PL1==PLT2>	;  BUT ALLOW FOR OVERRIDE

	$PLNUM==0		;TEMPORARY SYMBOL USED TO FACILITATE
				;  MACRO GENERATION
	REPEAT	PLTN,<
		PLTDDB	\$PLNUM
		$PLNUM==$PLNUM+1
	>
>	;END OF "IFG PLTN"
;PAPER TAPE READER ENTRY POINT AND MASK

	IFG	PTRN, <EXTERNAL PTRSER	;SAME ROUTINE FOR PDP-6 AND PDP-10 READER
	INTERNAL PTRMSK
		IFG PDP10N, <PTRMSK==0>		;MASK==0 IF PDP-10 READER
		IFE PDP10N, <PTRMSK==777777>	;MASK==777777 FOR PDP-6 READER
>


;PAPER TAPE PUNCH ENTRY POINT

	IFG	PTPN, <EXTERNAL PTPSER>

IFN M.KA10,<ZZ==R>
IFN M.KI10!M.KL10,<ZZ==0>

INTERN	PASCII,PIMAGE,PIMTTY,PBYTMD

PASCII==700+ZZ
PIMAGE==4400+ZZ
PIMTTY==1000+ZZ
PBYTMD==1000+ZZ


;PSEUDO TTY ENTRY POINT

	IFE	PTYN, <INTERNAL PTYPE,PTMNMZ,PTYOW,PTMNMD,PTYLST,PTYDSP
PTYPE:PTMNMZ:PTYOW:PTMNMD:	HALT CPOPJ	;HALT IF SCNSER CALL PTY ROUTINES
PTYDSP==0					; BECAUSE NONE LOADED
PTYLST==0					;SATISFY GLOBOL IN SYSINI
;IF NO PTY'S, SATISFY GLOBALS
	INTERN	CTLJOB,UJBSTS
CTLJOB==CPOPJ
UJBSTS==CPOPJ
;IF NO PTY'S, JOB CAN NEVER BE CONTROLLED BY PTY, SO
; SUBSTITUTE THIS DUMMY SUBROUTINE FOR CTLJB
INTERN CTLJB,CTLJBD
CTLJBU::SETZM	U		;NO LDB
CTLJB:
CTLJBD:	MOVNI	T1,1
	POPJ	P,
>
	IFG	PTYN, <
	EXTERNAL PTYSER			;LOAD PTY SERVICE ROUTINE
>
	IFN	FTTYPE,<
;DEFINITION FOR DC44 FRONT END
;FIRST PROTOTYPE DDB'S ARE GENERATED
;NEXT A TABLE DC40TB IS GENERATED WITH A WORD FOR
;EACH DC44 DEVICE . THE DEVICE DATA BLOCK ADDRESS
;WILL BE STORED IN THIS TABLE BY THE LINKSR CODE
;THE ENTRY IS FOUND BY SUBTRACTING THE VALUE NTT
;FROM THE COMTEX LINE NUMBER
;THE WORD DEVCTR CONTAINS THE FOLLOWING INFORMATION:
;1. THE LEFT HALF CONTAINS THE DL-10 PORT NUMBER
;2. THE RIGHT HALF THE COMTEX LINE NUMBER
	LALL
	WTY0N==0
	WTY1N==1
	WTY2N==0
	WTY3N==0
	DEFINE DDB(MNEM,PORT,DISP,IOTYP,HNG),<
	IFN	MNEM'PORT'N,<
	ENTRY	MNEM'PORT'DD,MNEM'PORT'DS
	EXTERN	DISP
MNEM'PORT'DD:
	SIXBIT	/MNEM/
	XWD	HUNGST*HNG,41	;;HUNG TIME IS 63 SECONDS FOR 5000 CHARACTERS

	EXP	0,DISP
	XWD	IOTYP,407	;IMAGE,PIM,ASCII AND ASCIL
	EXP	0,0
	XWD	R,0
	EXP	0,0
	XWD	.TY'MNEM+DEPLEN,DEPEVM
	EXP	0,0
	XWD	PORT,0		;DEVCNTR UNUSED COMMON WILL INSERT LINE NUMBER
	EXP	0,0,0,0,0,0
MNEM'PORT'DS=.-MNEM'PORT'DD
>	;;END OF IFN CONDITION
>
INTYP==DVPTR+DVIN
OUTYP==DVPTP+DVOUT

	DEFINE	GENDDB(PORT)
<	IFN	TYPNU'PORT,<
	DDB	PAR,PORT,TYIDSP,INTYP,6
	DDB	PCR,PORT,TYIDSP,INTYP,6
	DDB	PAP,PORT,TYODSP,OUTYP,6
	DDB	LPC,PORT,TYODSP,OUTYP,6
	DDB	PCP,PORT,TYODSP,OUTYP,6
	DDB	WTY,PORT,TYIDSP,INTYP,0
>	;;END OF IFN ....
>	;;END OF GENDDB MACRO

ZZZ==0
	IFN	M.DC44,<
	REPEAT	8,<
	GENDDB(\ZZZ)
ZZZ==ZZZ+1
>	;;END OF REPEAT
>	;;END OF IFN

;THE FOLLOWING TABLE CORRESPONDS TO THE LINTAB TABLE OF
;SCNSER AND TYPMAX TO THE VARIABLE TCONLN
;TYPMAX IS THE MAXIMUM NON TERMINAL LINE ON A DC44 FRONT END
;INDEXING OF DC44TB WITH THE COMTEX LINE NUMBER GIVES THE
;DDB ADDRESS OF A COMTEX LINE

TPSMAX::	EXP	TYPNUM		;MONGEN VALUE

;FOR EACH FRONT END A DC44TB IS GENERATED

	DEFINE	DC44TB(PORT)
<DC4'PORT'TB::
	BLOCK	TYPNU'PORT
>	;END DEFINE DC44TB
ZZZ=0
	REPEAT	8,<
	DC44TB(\ZZZ)
ZZZ=ZZZ+1
>	;;END OF REPEAT 4,

>	;;END OF FTTYPE CONDITION

SUBTTL	STORAGE AND SYMBOL GENERATION FOR RSX-20F DEVICES



   IFN FTKL10,<;DO THIS STUFF ONLY FOR KL CPU'S

;DEFINE SYMBOLS AND STORAGE FOR RSX-20F ASYNC TERMINALS

	$HIGH				;THIS PART INTO THE HIGH SEGMENT

   IFNDEF OFSDLS,<OFSDLS==:1>		;OFFSET FOR TTD TO DLS LINES

;THE FOLLOWING SYMBOL IS CURRENTLY AN ABSOLUTE CONSTANT.  THE
; VALUE NOW IS INTENTIONALLY SMALL SO ALL (128) FRONT-END LINES CAN BE
; HANDLED WITHOUT EXCEEDING BUFFER SPACE AVAILABLE IN THE FRONT-END.  THE
; SYMBOL VALUE SHOULD PROBABLY BE CALCULATED AT ASSEMBLY TIME AS
; A FUNCTION OF THE NUMBER OF LINES ACTUALLY PRESENT.

   IFNDEF TTDMLA,<TTDMLA==:^D16>	;DEFAULT MAXIMUM LINE ALLOCATION FOR RSX-20F TERMINALS


DEFINE	RSXDTE	(C,D)	<

   IFG M.AT'C'D,<XWD C,D-1>
>

ATCPDT::RSX20F				;MAKE TABLE WITH ONE ENTRY FOR EACH
					; RSX20F FRONT-END SUPPORTING ASYNC
					; TERMINALS
RSXATN==:.-ATCPDT			;NUMBER OF SUCH FRONT-ENDS


DEFINE	RSXDTE	(C,D)	<

   IFG M.AT'C'D,<POINT 8,TT'C'D'BF>
>

TTDPNT::RSX20F				;POINTERS TO EACH DTE'S OUTPUT STRING AREA


DEFINE	RSXDTE	(C,D)	<

   IFG M.AT'C'D,<
	EXP	$TTOFS
	$TTOFS==$TTOFS+M.AT'C'D
   >
>
	$TTOFS==TTDLAL			;INITIALIZE SYMBOL USED IN FOLLOWING MACRO
TTDOFS::RSX20F				;TABLE OF TTD LINE TABLE OFFSETS


DEFINE	RSXDTE	(C,D)	<

   IFG M.AT'C'D,<
	$TTOFS==$TTOFS+M.AT'C'D
	EXP	$TTOFS
   >
>

	$TTOFS==TTDLAL			;INITIALIZE SYMBOL USED IN FOLLOWING MACRO
TTDLOM::RSX20F				;TABLE OF MAXIMUM LINTAB OFFSETS


DEFINE	RSXDTE	(C,D)	<

   IFG M.AT'C'D,<
	EXP	$TTOFS
	$TTOFS=$TTOFS+M.AT'C'D
   >
>

	$TTOFS==TTDDAL			;INITIALIZE SYMBOL USED IN FOLLOWING MACRO
TTDDSO::RSX20F				;TABLE OF TTD DSCTAB OFFSETS


DEFINE	RSXDTE	(C,D)	<

   IFG M.AT'C'D,<
	$TTOFS==$TTOFS+M.AT'C'D
	EXP	$TTOFS
   >
>

	$TTOFS==TTDDAL			;INITIALIZE SYMBOL USED IN FOLLOWING MACRO
TTDDOM::RSX20F				;TABLE OF MAXIMUM DSCTAB OFFSETS


	$LOW				;DOWN TO LOW SEGMENT FOR FOLLOWING ITEMS

TTDCLR::				;START OF AREA CLEARED BY TTDINI
TTDCTR::BLOCK	RSXATN			;COUNTS OF CHARS IN CURRENT OUTPUT STRINGS
TTDPTR::BLOCK	RSXATN			;DYNAMIC POINTERS TO BUILD OUTPUT STRINGS

   IFNDEF TTDMOS,<TTDMOS==:^D16>	;DEFAULT LENGTH OF MAXIMUM OUTPUT STRING

DEFINE	RSXDTE	(C,D)	<

   IFG M.AT'C'D,<
TT'C'D'BF: BLOCK <TTDMOS+3>/4
   >
>

	RSX20F				;BUFFER AREA FOR DTE OUTPUT STRINGS

TTDEND==:.-1				;END OF AREA CLEARED BY TTDINI
   ; ... STILL IN FTKL10 CONDITIONAL

	$HIGH				;BACK TO HIGH SEGMENT
IFG DLPTN,<

;DEFINE STORAGE AND SYMBOLS FOR LINEPRINTERS ON RSX-20F FRONT-ENDS

   IFNDEF DLPMLA,<DLPMLA==:^D140>	;DEFAULT MAXIMUM LINE ALLOCATION FOR RSX-20F LINEPRINTERS


DEFINE	RSXDTE	(C,D)	<

   IFG M.LP'C'D,<XWD	C,D-1>
>

LPCPDT::RSX20F				;MAKE TABLE WITH ONE ENTRY FOR EACH
					; RSX-20F FRONT-END SUPPORTING LINEPRINTERS
RSXLPN==:.-LPCPDT			;NUMBER OF SUCH FRONT-ENDS

LPDTDV::				;TABLE TO CONVERT FROM CPU #, DTE #,
					;AND UNIT NUMBER TO DDB ADDRESS

DEFINE	LPCPDT	(C)	<
  IFN M.'C'DTE,<Z @LP'C'DTE(P1)>	;INDEX OFF DTE NUMBER
  IFE M.'C'DTE,<Z>			;NO DTE'S ON THIS CPU
>

	ZZ==0
REPEAT CPUN,<
	LPCPDT	\ZZ
	ZZ==ZZ+1
>

DEFINE	RSXDTE	(C,D)	<
  IFE D-1,<LP'C'DTE:>
  IFN M.LP'C'D,<Z @LP'C'D'DV(T1)>	;INDEX OFF LINE NUMBER
  IFE M.LP'C'D,<Z>			;NO LINE PRINTERS THIS DTE
>

	RSX20F				;GENERATE DTE TABLE

DEFINE	RSXDTE	(C,D)	<
  IFN M.LP'C'D,<
    LP'C'D'DV:
    REPEAT M.LP'C'D,<
	DLPDDB	\ZZ
	ZZ==ZZ+1
    >
REPEAT	<2-M.LP'C'D>,<
	Z
>
  >
>

DEFINE	DLPDDB	(X) <FL'X'DDB>

	ZZ==0

	RSX20F				;GENERATE THE DDB ADDRESS TABLE
>;END IFG DLPTN
   ; ... STILL IN FTKL10 CONDITIONAL

IFN DCDRN,<

	$HIGH

;DEFINE SPECIAL TABLES FOR RSX20F CARD READERS


DEFINE	RSXDTE	(C,D)	<
	XWD	C,D-1
>

CRCPDT::RSX20F				;CORRESPONDENCE TABLE BETWEEN
					;DTE INDEX AND CPU#,,DTE # FOR
					;DTESER

CRDTDV::				;TABLE TO CONVERT FROM CPU #, DTE #,
					;AND UNIT NUMBER TO DDB ADDRESS

DEFINE	CRCPDT	(C)	<
  IFDEF M.'C'DTE,<Z @CR'C'DTE(P1)>	;INDEX OFF DTE NUMBER
  IFNDEF M.'C'DTE,<Z>			;NO DTE'S ON THIS CPU
>

	ZZ==0
REPEAT CPUN,<
	CRCPDT	\ZZ
	ZZ==ZZ+1
>

DEFINE	RSXDTE	(C,D)	<
  IFE D-1,<CR'C'DTE:>
  IFN M.CR'C'D,<Z @CR'C'D'DV(T1)>	;INDEX OFF LINE NUMBER
  IFE M.CR'C'D,<Z>			;NO CARD READERS THIS DTE
>

	RSX20F				;GENERATE DTE TABLE

DEFINE	RSXDTE	(C,D)	<
  IFN M.CR'C'D,<
    CR'C'D'DV:
    REPEAT M.CR'C'D,<
	DCRDDB	\ZZ
	ZZ==ZZ+1
    >
  >
>

DEFINE	DCRDDB	(X) <FC'X'DDB>

	ZZ==0

	RSX20F				;GENERATE THE DDB ADDRESS TABLE


>;END IFN DCDRN
>;END IFN FTKL10
SUBTTL COMMON CODE FOR PDP11 HANDLING
;CODE COMMON TO ALL PDP-11S, WHATEVER THEIR APPLICATION.

IFN PDP11N,<
	DLMAP
	$HIGH

;SUBROUTINE TO PROCESS THE COMMAND:
;	.SET NOMESSAGE PDP11 N
;CALL WITH:
;	PUSHJ	P,D76SIL
;	RETURN HERE OR JRST COMERA
D76SIL::PUSHJ	P,DECIN##	;READ A DECIMAL NUMBER
	  JRST	D76SIP		;NO NUMBER ASSUME ZERO
	  CAIA			;ILLEGAL CHARACTER MAYBE
	  JRST	D76SIP		;OK GOT A DIGIT
	CAIE	T3,"*"		;WILD CARD
	JRST	COMERA##		;NO, ERROR
	MOVEI	T2,7		;YES, SET SIL ON ALL PDP11'S
	PUSHJ	P,D76SIA	;CONTINUE
	  JFCL			;IGNORE IF NOT THERE
	SOJGE	T2,.-2		;CONTINUE
	POPJ	P,		;RETURN
D76SIP:	PUSHJ	P,D76SIA	;GO SILENCE THIS 76
	  JRST	COMERA		;LOST, GIVE ERROR
	POPJ	P,		;RETURN

D76SIA:	SKIPL	T2		;.LT. 0 IS WRONG.
	CAIL	T2,10		;SKIP IF PORT .LT. 8
	POPJ	P,		;INVALID PORT #
IFN M.DAS78,<
	CAILE	T2,M78HPO##	;SEE IF THIS PORT EXISTS ON A DAS78
	JRST	D76SI1		;NO, TRY OTHER 11'S.
	SKIPE	T1,M78BAT##(T2)	;IF A DAS78 THEN
	JRST	D76SI0		; ALL SET
>;END IFN M.DAS78
D76SI1:	SKIPE	T1,DLXBAT##(T2)	;IF NO KNOWN PORT OR
	SKIPN	T1,DLXWIN(T1)	; NO WINDOW ASSIGNED THEN
	POPJ	P,		; COMPLAIN
D76SI0:	SKIPG	DWN(T1)		;IS THE PDP11 DOWN?
	SETOM	DWN(T1)		;YES--TURN OFF THE MESSAGE
	JRST	CPOPJ1##		;RETURN
	$LOW
>	;END OF IFN PDP11N
IFN <PDP11N-DLX.78>,<
SUBTTL DL10 ERROR REPORTING STORAGE AND ROUTINE

IFN FTDAEMON,<
;ROUTINE TO GET ERROR STATUS AND CALL DAEMON FOR AN ERROR
;ON EITHER A DC76 OR A DC75.
;ARGUMENTS	T1=PORT # OF 11 WITH ERROR
DLB==60	;DEVICE CODE FOR DL10
DLC==64	;DEVICE CODE FOR DL10

DLBREG==3	;NUMBER OF HIGHEST CONI DLB, WE DO 
DLBEDT==0	;VALUE OF R FOR DATAI DLB, WE WANT TO SAVE

	$HIGH
DL10EL::
	MOVEM	T1,DLEPRT	;SAVE THE PORT OF THE 11 WITH ERROR
	MOVE	T2,DLXNMT(P2)	;GET NAME
	MOVEM	T2,DLEPGM	;SAVE
	HRLZ	T2,DLXTYP##(P2)
	MOVEM	T2,DLESTS
	MOVE	T2,DLXWIN##(P2)
	MOVE	T2,HLT(T2)
	HRRM	T2,DLESTS
	CONI	DLC,DLCCNI	;GET THE DLC CONI
	DATAI	DLC,DLCDTI	; AND DATAI
	MOVEI	T1,DLBREG	;GET NUMBER OF REGS TO SAVE OF DLB
DLBLUP:	DPB	T1,[POINT 2,DLBDTO,5]	;PUT REG INTO DATAO
	DATAO	DLB,DLBDTO	;AND DO DATAO SO CONI GETS RIGHT REG
	CONI	DLB,DLBCNI(T1)	;GET THIS DLB CONI
	CAIN	T1,DLBEDT	;IS THIS THE DATAI WE WANT?
	DATAI	DLB,DLBDTI	;YES, GET IT
	SOJGE	T1,DLBLUP	;AND LOOP BACK FOR NEXT REG
	MOVEI	T1,.ERDLE	;GET CODE FOR ERROR RPT UUO
	HRLI	T1,DLEBLK	;AND ADDRESS FOR DAEMON TO LOOK AT
	PJRST	DAEEIM##	;AND GO WAKE DAEMON

	$LOW
DLBDTO:	XWD	1,0	;BITS FOR DATAO DLB,
DLEBLK:-DLELEN,,DLEPRT	;AOBJN POINTER FOR ERROR BLOCK
DLEPRT:	BLOCK	1	;PORT OF 11 WITH ERROR
DLCCNI:	BLOCK	1	;CONI DLC AT ERROR
DLCDTI:	BLOCK	1	;DATAI DLC AT ERROR
DLBCNI:	BLOCK	4	;BLOCK FOR CONI DLB'S
DLBDTI:	BLOCK	1	;DATAI DLB WITH R=0 AT ERROR
DLEPGM:	BLOCK	1	;SIXBIT PROGRAM NAME
DLESTS:	BLOCK	1	;HALT STATUS
DLELEN==.-DLEPRT

>	;END OF FTDAEMON


IFE FTDAEM,<

DL10EL==CPOPJ

>
;CAL11. UUO
	$HIGH

CALL11::PUSH	P,T1		;SAVE USER'S ARG
	HRLOI	P2,377777	;ASSUME PRIV. JOB.
	PUSHJ	P,PRUSET##	;SKIP IF PRIV.
	  TLO	P2,400000	;NOT PRIV.
	POP	P,T1		;RESTORE USER'S ARG
	HRR	M,T1		;GET USER'S AC
	HLRE	T3,T1		;GET COUNT
	JUMPLE	T3,ECOD7##	;.LE. ZERO ARGS NOT ENOUGH!
	PUSHJ	P,GETWDU##	;GET FUNCTION CODE INTO T1
	SOJL	T3,ECOD7##	;ERROR CODE 7: NOT ENUF ARGS
	HLRZ	P1,T1		;COPY PDP11 NUMBER
	HRRZS	T1		;AND CLEAR IT FROM T1
	CAIL	P1,10		;REASONABLE PDP-11 NUMBER?
	JRST	ECOD3##		;NO, ERROR CODE 3.
	SKIPN	W,DLXBAT##(P1)	;IS THERE A BASE FOR THIS 11?
	  JRST	ECOD3##		;NO, INVALID PDP-11 NUMBER
	SKIPN	P1,DLXWIN(W)	;GET WINDOW ADDRESS
	PJRST	ECOD3##		;NO GOOD THIS PDP11
	SKIPN	T2,DLXCAL##(W)	;GET CAL11. TABLE POINTER
	MOVE	T2,[XWD CAL11L,CAL11D] ;NONE, USE DEFAULT
	HLRZ	T4,T2		;GET LENGTH OF TABLE
	CAML	T1,T4		;FUNCTION TOO LARGE?
	  JRST	ECOD2##		;YES, ERROR CODE 2.
	ADD	T2,T1		;NO, POINT TO TABLE ENTRY
	MOVE	T1,0(T2)	;PICK UP ENTRY
	AND	T1,P2		;CLEAR SIGN BIT IF PRIV
	JUMPL	T1,ECOD1##	;IF STILL SET, NEED PRIV.
	PUSHJ	P,0(T1)		;GO DO FUNCTION
	POPJ	P,		;NON-SKIP RETURN
	PJRST	CPOPJ1##	;SKIP RETURN

;TABLE FOR CAL11. UUO IF THERE IS NO SERVICE ROUTINE

CAL11D:	XWD	400000,ECOD2##	;(0) DEPOSIT
	XWD	400000,ECOD2##	;(1) EXAMINE
	XWD	400000,ECOD2##	;(2) QUEUE A MESSAGE
	XWD	0,CAL11N	;(3) RETURN NAME
	XWD	0,CAL11S	;(4) UP/DOWN STATUS
CAL11L==.-CAL11D

CAL11N::MOVE	T1,DLXNMT##(W)	;RETURN NAME
	JRST	STOTC1		;SKIP RETURN

CAL11S::SKIPG	DLXDWN##(P1)	;RETURN PDP-11 STATUS
	TDZA	T1,T1		;DOWN
	MOVEI	T1,1		;UP
	JRST	STOTC1##

;COME HERE ONCE A SECOND.

DLXSEC::PUSHJ	P,SAVE3##	;SAVE P1-P3
	MOVSI	P1,-10		;AOBJN POINTER
D76SC1:	SKIPN	P2,DLXBAT##(P1)	;GET BASE ADDRESS OF THIS PDP11
	JRST	D76S1L		;NO.
	SKIPN	P3,DLXWIN##(P2)	;HAS IT A WINDOW?
	JRST	D76S1L		;NO WINDOW IS NO GOOD
IFN M.PSI&<M.KI10!M.KL10>,<
	MOVSI	T1,200001	;KA10 INTERRUPTS
	XCT	DLXDAO##(P2)	;BASE ADDRESS
>
	SKIPG	DLXDWN##(P3)	;IS THIS PDP11 UP?
	JRST	D76NTR		;NO.
	SKIPN	DLXHLT##(P3)	;YES, IS IT HALTED?
	JRST	D76S2L		;NO.
D76DWN:	SKIPG	DLXDWN##(P3)	;DO I THINK THE PDP11 IS UP?
	JRST	D76S1L		;NO.
	XCT	DLXCLR##(P2)	;YES, CLEAR ITS ENABLE.
	SETZM	DLXDWN##(P3)	;AND MARK IT DOWN.
	XCT	DLXPRG##(P2)	;DO ANY NECESSARY CLEAN UPS
IFN FTDAEM,<
	MOVE	T1,P1		;GET PORT #
	PUSHJ	P,DL10EL	;LOG ERROR
>
	MOVSI	T1,(JFCL)	;DISABLE ITS SERVICE ROUTINE
	MOVEM	T1,DLXINI##(P2)
	SETZM	DLXCAL##(P2)
	MOVEM	T1,DLXPRG##(P2)
D76S1L:	AOBJN	P1,D76SC1	;TRY NEXT PDP11.
	POPJ	P,		;NO MORE, ALL DONE.

D76S2L:	AOS	T1,DLXOK##(P3)	;COUNT THE "OK" COUNTER
	CAIL	T1,^D10		;IS THE PDP11 STILL OK?
	JRST	D76DWN		;NO, IT HAS GONE DOWN.
	JRST	D76S1L		;YES, GO ON TO NEXT PDP11.

;COME HERE IF A PDP11 IS NOT RUNNING.

D76NTR:	XCT	DLXCNI##(P2)	;CONI DLC,T1
	MOVEI	T2,22220	;PORT ENABLE BITS
	ANDCM	T2,T1		;T2 GETS A 1 FOR EACH PDP11
				;  NOT ENABLED
	LSH	T2,-1		;MOVE TO INTERRUPT BIT
	AND	T2,T1		;1 FOR EACH PDP11 LOADED BUT NOT
				;  YET STARTED.
	AND	T2,DLXMSK##(P2)	;MASK OFF BITS FOR OTHER PDP11S
	JUMPE	T2,D76S1L	;JUMP IF NOT OUR PDP11
	SETZM	DLXOK##(P3)	;NOT CRASHED YET
	SETZM	DLXHLT##(P3)	;NOR HALTED
	SETZM	TTP(P3)		;CLEAR THE Q'S
	SETZM	TTG(P3)		;CLEAR THE Q'S
	SETZM	TEP(P3)		;CLEAR THE Q'S
	SETZM	TEG(P3)		;CLEAR THE Q'S
	SETZM	DLXCEU##(P2)	;NO CAL11. USER
	MOVSI	T1,767760	;BUILD SIX BIT DL10 BYTE POINTER
	HRRI	T1,DLXNMT##(P2)	;INTO DL10 BASE TABLE
	SETZM	(T1)		;ZAP OLD NAME
	MOVEM	T1,DLXNAM##(P3)	;STORE POINTER TO NAME
	MOVEI	T1,2		;KILL IF NO RESPONSE IN 2 SEC
	MOVEM	T1,DLXDWN##(P3)	; BY MARKING PDP11 AS UP
	MOVE	T1,[PUSHJ P,D76CKN] ;CHECK NAME ON INTERRUPT
	MOVEM	T1,DLXINI##(P2)
	XCT	DLXSWA##(P2)	;SET WINDOW ADDRESS
	XCT	DLXENB##(P2)	;ENABLE PORT
	JRST	D76S1L		;WAIT FOR INTERRUPT

;COME HERE ON NEXT DL10 INTERRUPT FOR THIS PDP11.

D76CKN:	SKIPN	T1,DLXNMT##(W)	;NAME SPECIFIED YET?
	POPJ	P,		;NO.
IFN M.DC75,<
	CAMN	T1,[SIXBIT /DC75/] ;YES, DC75?
	JRST	D75III##	;YES, START UP DC75.
>
IFN M.DC76,<
	CAMN	T1,[SIXBIT /DC76/] ;NO, DC76?
	JRST	D76III##	;YES, START UP DC76.
>
	POPJ	P,		;NO, IGNORE IT.

;COME HERE ONCE A MINUTE.

D76MIN::SKIPGE	DEBUGF##	;DEBUGGINH
	POPJ	P,		;YES, NO MESSAGE
	PUSHJ	P,SAVE3##	;SAVE P1-P3
	MOVSI	P1,-10		;MAXIMUM NUMBER OF PORTS
D76MLP:	SKIPE	P2,DLXBAT##(P1)	;IS THIS PDP11 DEFINED?
	SKIPN	P3,DLXWIN##(P2)	;YES, HAS IT A WINDOW?
	JRST	D76MNX		;NO, LOOK AT NEXT PDP11
	SKIPE	DLXDWN##(P3)	;IS IT UP OR SILENCED?
	JRST	D76MNX		;YES.
	HRRZ	U,OPRLDB##	;NO, PRINT MESSAGE ON OPR'S TTY
	PUSHJ	P,INLMES##
	ASCIZ	/
%%PDP-11 number /
	MOVE	T1,DLXEPN##(P3)	;ELEVEN PORT NUMBER
	PUSHJ	P,RADX10##	;PRINT THAT OUT
	SKIPE	DLXHLT##(P3)	;HALTED?
	JRST	D76HLT		;YES.
	PUSHJ	P,INLMES##	;NO, JUST SAY NOT UP.
	ASCIZ	/ is not running.
/
	JRST	D76MNX		;CHECK NEXT PDP11

;COME HERE IF THE PDP11 IS ACTUALLY HALTED.

D76HLT:	PUSHJ	P,INLMES##
	ASCIZ	/ halted at /
	MOVE	T1,DLXHLT##(P3)	;GET HALT PC (OR STOP CODE)
	PUSHJ	P,OCTPNT##	;TYPE IT OUT
	PUSHJ	P,INLMES##	;END WITH A DOT
	ASCIZ	/.
/
D76MNX:	AOBJN	P1,D76MLP	;CHECK THE REST OF THE PDP11S
	POPJ	P,		;DONE THEM ALL--RETURN.

	$LOW
>	;END OF IFN PDP11N
SUBTTL	LOCATE & WHERE COMMAND/UUOS

IFE M.NET,<
	$HIGH
NODE.C::
HOST.C::
NETASG::
IFE M.DAS78,<
CLOCAT::
CWHERE::
>	;END IFE M.DAS78
	MOVSI	T1,JLOG		;IF NOT
	TDNN	T1,JBTSTS##(J)	;LOGGED IN
	DPB	T1,PJOBN##	;DON'T LEAVE GHOST JOB
	JSP	T1,ERRMES##	;CAN'T DO THESE IF NO NETWORK
	ASCIZ	/no network software
/
	$LOW
>	;END IFE M.NET .IF M.NET=0 & M.DAS78 #0, ONLY 1 LABEL, NETASG
	; IF BOTH=0, 3 LABELS

IFN	M.NET!M.DAS78,<
	$HIGH

;LOCATE COMMAND TO PLACE A JOB AT A REMOTE STATION SITE

CLOCAT::PUSHJ	P,CTEXT1##	;GET THE ARGUMNET IN SIXBIT
	SKIPN	T1,T2		;COPY TO T1
	JRST	LOCTHS		;NO ARGUMNET
	PUSHJ	P,CVTOCT##	;TRY TO CONVERT TO OCTAL
	  MOVE	T1,T2		;CAN'T-GET THE NAME BACK
	JUMPE	T1,LOCLOC	;YES CENTRAL SITE NUMBER
LOCLC1:
IFN	M.NET,<
	PUSH	P,T1		;SAVE THE ARG
	PUSHJ	P,SRCNDB##	;SEARCH FOR THE NODE BLOCK
>;END IFN M.NET
	  JRST	LOCNOT		;DOES NOT EXIST
IFN	M.NET,<
	POP	P,(P)		;RESTORE THE STACK
	HLRZ	T1,NDBNNM##(W)	;YES, GET THE NODE NUMBER
	HRRZM	T1,JBTLOC##(J)	;LOCATE HIM WHERE HE WANTS
	PUSHJ	P,TYPNDB##	;TYPE THE NODE NAME
	JSP	T1,CONMES##	;EXIT TO COMDEV
	ASCIZ	/ Located/
>;END IFN M.NET

LOCTHS:	LDB	T1,PDVSTA##	;GET STA NUMBER OF CONTROL TTY
	JRST	LOCLC1		;AND GO LOCATE HIM

LOCLOC:	MOVE	T1,JBTLOC##	;GET CENTRAL SITE NUMBER
	JRST	LOCLC1		;AND GO LOCATE HIM THERE

LOCNOT:
IFN	M.NET,<
	POP	P,T1		;RESTORE THE ARG
>;END IFN M.NET
	CAIG	T1,77		;IS IT A NUMBER
IFN	M.NET,<
	JUMPG	T1,LOCNO1	;YES, WILL ALLOW THE LOCATE TO HAPPEN
	HRRZ	T1,NRTUNN##	;NO, UNDEFINE NETWORK NODE
>;END IFN M.NET
	IFE	M.NET,<
	JUMPGE	T1,LOCNO1	;YES, WILL ALLOW THE LOCATE TO HAPPEN
	HRRZI	T1,[ASCIZ \Undefined Node\]	;NO, UNDEFINDED NODE
>;END IFE M.NET
	PJRST	ERRMES##	;TYPE IT

LOCNO1:	HRRZM	T1,JBTLOC##(J)	;STORE THE LOCATION
	PUSHJ	P,INLMES##	;TYPE A MESSAGE
	ASCIZ	/NODE(/
	HRRZ	T1,JBTLOC##(J)	;GET THE NUMBER
	PUSHJ	P,PRTDI8##	;PRINT THE NUMBER
	PUSHJ	P,INLMES##	;AND A COMMENT
IFN	M.NET,<
	ASCIZ	/)	Located but OFF-LINE
/
>;END IFN M.NET
IFE	M.NET,<
	ASCIZ	/)	Located
/
>;END IFE M.NET
	POPJ	P,		;RETURN
;WHERE COMMAND - SIMILAR TO WHERE UUO
;THE LOCATION OF A DEVICE IS TYPED ON THE USER'S TTY

CWHERE::SKIPN	JBTADR##(J)	;ANY CORE ASSIGNED
	PUSHJ	P,GETMIN##	;NO, GET SOME CORE
	JUMPE	R,DLYCM##	;DELAY THE COMMAND
	PUSHJ	P,SAVCTX##	;SAVE THE CONTEXT OF THE JOB
	PUSHJ	P,CTEXT1##	;GET FIRST ARG = SIXBIT DEV NAME
	PUSH	P,T2		;SAVE 6 BIT
	PUSHJ	P,FNDSTA##	;GET OUR STATION
	POP	P,T2		;GET 6 BIT NAME
	MOVE	T1,T2		;INTO T1
	PUSH	P,U		;SAVE U
	PUSHJ	P,DVCNSG##	;SEARCH FOR PHYSICAL DEV NAME
	JRST	NOTDV1##	;PRINT "NO SUCH DEVICE"
	PUSHJ	P,FNDDEV	;FIND LOCATION
IFN M.NET,<
	MOVE	U,(P)
>
IFN	M.DAS78,<
IFN	M.NET,<
	LDB	T2,[POINT 6,DEVSTA(F),9]	;GET TYPE OF DEVICE
	CAIN	T2,.TYD78/.TYEST	;IS IT A DAS78?
	JRST	WCMD78		;YES.
>;END IFN M.NET
>;END IFN M.DAS78
IFN	M.NET,<
	PUSHJ	P,SRCNDB##	;SEARCH FOR THE NDB
	  MOVEI	W,NETNDB##	;USE THE LOCAL MODE
	PUSHJ	P,TYPNDB##	;TYPE THE NODE INFO
	PUSHJ	P,PRSPC##
	MOVE	T2,DEVNAM(F)
	PUSHJ	P,PRNAME##
	MOVSI	T1,DVTTY	;CHECK FOR A TTY
	TDNN	T1,DEVMOD(F)	;IS IT
	JRST	[MOVEI T1,ASSCON!ASSPRG ;IS IT IN USE
		 TDNN T1,DEVMOD(F) ;SHIP IF SO
		 PUSHJ P,ZAPNET##  ;NO,FREE DDB
		 PJRST UPOPJ##]	;AND EXIT
	PUSHJ	P,INLMES##	;TYPE OUT
	ASCIZ	/ LINE # /
	MOVE	U,DDBLDB##(F)	;YES, GET THE LDB
	LDB	T1,LDPLNO##	;GET THE LOCAL LINE NUMBER
	MOVEI	T2,LDRREM##	;NETWORK LINE
	TDNN	T2,LDBDCH##(U)	;CHECK A BIT
	JRST	CWHER1		;LOCAL LINE
	HLRZ	T2,LDBREM##(U)	;GET THE NDB POINTER
	JUMPE	T2,[POP	P,U
		PUSHJ	P,INLMES##	;NOT CONNECTED
		ASCIZ	/ NOT CONNECTED /
		POPJ	P,]		;RETURN
	LDB	T1,LDPRLN##	;CONNECT NETWORK LINE
CWHER1:	POP	P,U		;RESTORE THE LDB
	PJRST	PRTDI8##	;TYPE ^T
>;END IFN M.NET

IFN	M.DAS78,<
WCMD78:	POP	P,U		;RESTORE LDB
	PUSHJ	P,INLMES##	;PRINT THE MESSAGE
	ASCIZ	\NODE	\
IFN	M.NET,<
	MOVE	T2,STANAM##	;CENTRAL STATION NAME
	PUSHJ	P,PRNAME##	;PRINT CENTRAL NAME
>;END IFN M.NET
	MOVEI	T3,"("		;LEFT PAREN
	PUSHJ	P,COMTYO##	;TYPE IT
	LDB	T1,PDVSTA##	;GET STATION #
	PUSHJ	P,PRTDI8##	;PRINT IT
	PUSHJ	P,INLMES##	;
	ASCIZ	\) \		;
	MOVEI	T1,CONFIG##	;SYSTEM NAME
	PUSHJ	P,CONMES##	;PRINT IT
	PUSHJ	P,PRSPC##	;SPACE
	MOVEI	T1,SYSDAT##	;DATE
	PJRST	CONMES##	;
>;END IFN M.DAS78

;ROUTINE TO FIND LOCATION OF A DEVICE
;RETURN WITH T1=LOCATION
FNDDEV::LDB	T1,PDVSTA##	;GET DDB LOCATION
	MOVSI	T2,DVTTY	;SEE IF
	TDNN	T2,DEVMOD(F)	; TTY
	POPJ	P,		;NO.
	MOVE	U,DDBLDB##(F)	;YES, SET UP U
	PJRST	FNDSTA##	;AND COMPUTE FROM LDB

;WHERE UUO
;IF AC CONTAINS 0 TO 17 THE CALLER WANTS THE LOCATION OF THE DEVICE
;INITED ON THE CHANNEL NUMBER SPECIFIED IN AC. LH(AC) = STA STATUS BITS
;IF AC IS GREATER THAN 17 IT IS ASSUMED TO BE A SIXBIT DEVICE NAME
;THAT THE CALLER WISHES TO KNOW THE STATION OF. LH(AC) = STA STATUS BITS

WHERE::	CAMN	T1,[SIXBIT/OPR/]	;IS IT AN OPR
	JRST	[HRRZ	T1,JBTLOC##(J)	;YES, GET THE JOB LOCATION
		PJRST	STOTC1##]	;RETURN LOCATION OF THE JOB
	PUSHJ	P,DVCNSG##	;SEARCH FOR DEVICE OR CHANNEL
	  JRST RTZER##		;NONE--RETURN ERROR AS 0.
	PUSHJ	P,FNDDEV	;GET STATION NUMBER
	JUMPN	T1,WHER1	;USE IT IF NON ZERO
IFN	M.DAS78,<
	LDB	T2,[POINT 6,DEVSTA(F),9]	;GET TYPE OF DEVICE
	CAIE	T2,.TYD78/.TYEST	;IF DAS78 DEV LEAVE IT 0
>;END IFN M.DAS78
	 MOVE	T1,JBTLOC##	; OTHERWISE USE CENTRAL SITE NUMBER
WHER1:
IFN FTSPL,<
	SKIPN	DEVCHR(F)	;IF A "FAKE" DDB,
	HRRZ	T1,JBTLOC##(J)	;TELL WHERE JOB IS
>
IFN	M.DAS78,<
	IFN	M.NET,<
	LDB	T2,[POINT 6,DEVSTA(F),9]	;GET DEVICE TYPE
	CAIE	T2,.TYD78/.TYEST	;SKIP IF DAS78 DEVICE
>;END IFN M.NET
	IFE	M.NET,<
	JRST	STOTC1##	;STATUS BITS TO 0 AND RETURN
>;END IFE M.NET
>;END IFN FTDAS78
IFN	M.NET,<
	CAMN	T1,JBTLOC##	;CENTRAL SITE?
	JRST	STOTC1##	;YES, STATUS BITS ALL ZERO.
	PUSHJ	P,SRCNDB##	;FIND THE NODE BLOCK
	  JRST	RTZER##		;DOES NO EXIST
	HLRZ	T1,NDBNNM##(W)	;GET THE NODE NUMBER
	HLL	T1,SCBSTS##(W)	;GET THE STATUS BITS
	JRST	STOTC1##	;STORE T1 IN USER'S AC
>;END IFN M.NET

;LOCATE UUO (CALLI 62)
;PLACES THE CALLER AT THE DESIRED STATION SITE
;CALL: AC HAS STATION NUMBER TO LOCATE AT

LOCATE::SKIPN	F,TTYTAB##(J)	;POINT TO JOB'S TTY
	JRST	LOCAT3		;NONE.
	CAME	T1,[EXP -1]	;IF ARG IS -1...
	JRST	LOCAT3		;NO
	LDB	T1,PDVSTA##	;PUT JOB WHERE TTY IS
	JRST	LOCAT2		;LOCATE THE JOB
LOCAT3:	JUMPE	T1,LOCAT1	;0 IMPLIES LOCAL NODE
	CAILE	T1,77		;IS THE STATION IN RANGE
	POPJ	P,		;NO, ERROR RETURN
LOCAT2:	HRRZM	T1,JBTLOC##(J)	;LOCATE JOB
	JRST	CPOPJ1##	;GIVE GOOD RETURN

LOCAT1:	MOVE	T1,JBTLOC##	;CENTRAL LOCATION
	JRST	LOCAT2		;PUT HIM THERE.

	$LOW

>;END IFN M.NET!M.DAS78

	$LIT

IFNDEF FTCMBTH,<COMEND:	END>