/7 CONCISE OS8 BATCH PROCESSOR		7-JUN-1978
/
/
/
/
/
/
/
/
/
/COPYRIGHT  (C)  1975,1977,1978 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.
/
/
/
/
/
/
/
/
/
/
/EF,RL,SR

/ABSTRACT---
/BATCH IS THE INITIALIZING PROGRAM FOR THE OS/8 BATCH
/PROCESSING MONITOR. TO SET UP A BATCH RUN, TYPE
/	.R BATCH
/BATCH WILL CALL THE COMMAND DECODER TO OBTAIN ITS
/PARAMETERS AND INPUT FILE LOCATION.

	VERSON=	10



/	BATCH SWITCHES:

/C	BATCH FROM CARDS
/E	IGNORE KMON, CD, AND CCL ERRORS
/H	HUSH (SUPPRESSES $JOB, #END, AND ECHOING)
/P	BATCH FROM PAPER TAPE
/Q	QUIET - NO BATCH LOG
/T	FORCE BATCH LOG TO TELETYPE
/U	UNATTENDED
/6	USE 026 CARD CODES (ONLY IF /C)


/MAINTENANCE RELEASE CHANGES BY S.R. ON 1-AUG-75:

/1.	CHANGED VERSION NUMBER TO 6
/2.	INCORPORATED V5A PATCH SEQ # 1 APR-75 DSN
/	ALLOWS BATCH TO PASS ALTMODE TO KBM
/3.	INCORPORATED V5B PATCH SEQ #2 17-JULY-75 WSN
/	SLOWS BATCH DOWN WHEN READING FROM CARDS
/4.	ALLOW BATCH TO IGNORE NULLS FROM BATCH STREAM
/	(PATCH TO BE PUBLISHED IN DSN.)
/5.	SET BATCH SO THAT IT RESTORES OLD SOFTWARE CORESIZE
/	UPON NORMAL TERMINATION.

/CHANGES BY S.R. ON 3-FEB-77:

/1.	ADDED HUSH SWITCH (/H)
/2.	SAVED REST OF 7777 AROUND BATCH
/3.	FIXED BUG CONCERNING MANUAL HELP NEEDED
/4.	ALLOWED CORE IMAGE TO BE PRESERVED AFTER BATCH TERMINATION

/8-DEC-77 CHANGES:

/1.	PUT IN SYMBIONT SUPPORT
/2.	LENGTHENED LPT WAIT LOOP (FOR LA180'S)
/3.	MADE /T MUCHO OVERRIDE LPT TEST
/4.	BATCH LPT LOG CONVERTS L.C. TO U.C.
/	TO INHIBIT CONVERSION, PATCH LOC 6400 FROM A -40 TO A 0
/5.	DON''T RESTORE EXTENDED DATE BITS IN 07777
/6.	MORE FIXES TO MANUAL INTERVENTION REQUIRED MESSAGE BUG
/7.	BATCH OUTPUT ROUTINE IGNORES NULLS
/SYSTEM DEPENDENT PARAMETERS

	AMFLAG=17	/ALTMODE FLAG FOR KBM
	CDREC=51	/COMMAND DECODER
	KMREC=7		/KEYBOARD MONITOR
	BUFFER=3000
	JSW=7746	/JOB STATUS WORD
	DCB=7760	/DEVICE CONTROL BLOCK
	MTWO=CLA CLL CMA RAL
	MTHREE=CLA CLL CMA RTL
	SYSTEM=7607
	MPARAM=7643
/********************************************
	KEYMON=403
	BEGLN=1000
	PRINT=200
	XGLINE=1200
	BATCH=35	/REFERS TO KEYBOARD MONITOR!!!!!!!
	BCHGO=46	/THEY MUST!!!!! BE CORRECT!!!!!!
	CBATCH=4571	/CONTENTS OF LOC "BATCH" IN KEYBOARD MONITOR
/*******************************************
	CDOVER=326
	CDBEGLN=1200	/CD BUFFER AREA
	ANALYZ=202	/CD ANALYSIS
	TYPE=1367	/ERROR OUTPUT ROUTINE
	CGLINE=1002
	TT=21		/THESE REFER TO CD ASSEMBLY***VOLATILE***
	DVICE=43	/IF CD OR MAIN OS/8 ASSEMBLY CHANGES,
	DEFALT=42		/V3D NOT NEEDED
	LKUPSW=245	/V3D IF CONTENTS=0, IN SPECIAL MODE
	OUTSW=41	/THESE VALUES MUST BE ALTERED ALSO.
	NAMECT=31
	DEV1=33
	RESTRT=676
/********************************************
	ORIGIN=5400
	PSKF=6661	/LE8 IOT'S
	PCLS=6666
	RCRA=6632	/CARD READER IOT'S
	RCSE=6672
	RCSD=6671
	RCSF=6631
	RCRD=6674
/*****************************
	BOSCCL=07777
/BATCH USES CERTAIN SYSTEM WORDS AS FLAGS AND STATUS
/INDICATORS. THEY ARE:

/LOC. 07777. THIS IS USED AS THE BATCH IN PROGRESS FLAG.
/BIT 1 IS BATCH IN PROGRESS. (BIP) =1 MEANS BATCH IS ON
/BITS 6-8 HOLD THE FIELD WHERE BATCH IS SITTING
/BIT 10 IS USED BY BAT: TO SIGNAL IT HAS READ A DOLLAR SIGN
/BIT 11 IS USED BY THE COMMAND DECODER TO SIGNAL BATCH NOT THERE

/THE JOB STATUS WORD USES BIT 3 AS AN INDICATOR AS TO
/WHETHER THE BATCH MONITOR IS CURRENTLY IN CORE. =1 MEANS
/THAT THE BATCH SYSTEM NEED NOT BE RE-READ.

/BOSSW IS A FLAG WORD INTERNAL TO THE BATCH MONITOR.
/IT IS SET UP DURING BATCH INITIALIZATION.
/BIT 0: 1 IF USE OF PTR IS PROHOBITED DURING RUN
/BIT 1: 1 IF LPT OR TTY LISTINGS ARE TO BE SPOOLED
/BIT 2: 1 IF KMON AND CD ERRORS ARE NON-FATAL
/BIT 10: 1 IF LP08 IS OUTPUT DEVICE
/BIT 11: 1 IF OPERATOR IS NOT PRESENT

/IF SYS IS INPUT, LOCATIONS 7774 AND 7775 IN THE TOP FIELD
/ARE USED AS POINTERS TO THE CORRECT DATA BLOCK ON THE
/SYSTEM DEVICE. THE BUFFER IS RE-READ WHENEVER THE
/BATCH MONITOR MUST BE RE-READ.

	SPLNUM=	7776	/SPOOL SEQUENCE NUMBER
	SYCNT=	7775	/CHARACTER COUNT IN BUFFER
	SYBLKN=	7774	/SYSTEM DEVICE BLOCK NUMBER

/IF SPOOLING IS USED, LOC. N7776 IS USED TO HOLD THE
/XX IN 'BTCHXX.TM'.

/BATCH INITIALIZER PAGE 0
	*0

	VERSON
	CIF 30
	JMP .-1

	*16
XR1,	0
XR2,	0
TEMP,	0
TEMP2,	0
COUNT,	0
BOSCTL,	1101	/CONTROL WORD TO READ/WRITE BOS
CDFTOP,	0
TOPCDF,	HLT		/CDF TO TOP FIELD
	JMP I	CDFTOP
T1,	0
T2,	0
	PAGE
START,	SKP
	JMP	BCHAIN	/IF CHAINED TO
	JMS I (GETCOR	/DETERMINE CORE SIZE; PUT IN 7777
BATASK,	CIF 10
	JMS I	[200
	5
	0211		/.BI ASSUMED EXT
	SKP
BCHAIN,	JMS I	(GETCOR
	DCA I	[BOSSW
	CDF 10
	TAD I	[MPARAM+1
	AND	(4	/GET /V SWITCH
	SNA CLA		/IS IT ON?
	JMP	.+3	/NO
	JMS I	[MESSG
	VERMSG		/PRINT BATCH VERSION NUMBER
	CDF 10
	TAD I	(7620
	DCA	T1	/GET STARTING BLOCK
	TAD I	(7617
	SNA
	JMP	NOTSYS	/NO FILE - BATCH FROM PTR OR CDR
	AND	[17
	TAD	(MPARAM+3	/POINT INTO HANDLER TABLE
	DCA	T2
	TAD I	T2
	CLL
	TAD	[200	/IS THE DEVICE SYS OR CORESIDENT WITH SYS?
	SNL CLA
	JMP I	(INDERR	/NO
	TAD I	T2	/GET DEVICE HANDLER ENTRY POINT
	CDF 0
	DCA I	(SYSINH	/STORE AS BATCH INPUT HANDLER
	JMS	CDFTOP
	TAD	T1
	DCA I	(SYBLKN
	TAD	(-601
	DCA I	(SYCNT	/SET UP PARAMETERS FOR INPUT FILE
	CDF 0
	TAD	(SYSIN-1
	JMP	STODEV	/INPUT DEV = SYS

NOTSYS,	TAD I	(MPARAM
	RTL		/GET C FLAG IN SIGN BIT
	SMA CLA
	JMP	NOTCDR
	JMS I	(CHANGE	/SET 026/029 CARD CODE
	TAD	(CDR-1
	JMP	STODEV	/INPUT DEV = CDR
NOTCDR,	TAD I	[MPARAM+1
	AND	(400
	CDF 0
	SNA CLA
	JMP	BATASK	/NO INPUT SPECIFIED
	STL RAR
	DCA I	[BOSSW	/PTR INPUT FLAG
	TAD	(PTR-1
STODEV,	JMS I	(MVINSB	/MOVE THE PROPER ROUTINE INTO THE BATCH MONITOR
	CDF 10
	TAD I	[MPARAM+1
	CDF 0
	AND	(210		/GET /Q AND /U SWITCHES
	CLL RTL
	RTL
	RAL		/ /Q INTO LINK
	SZA CLA
	ISZ I	[BOSSW	/SET UNATTENDED BIT IF /U SPECIFIED
	SNL
	JMP	.+3	/NO /Q
	TAD	(NULOUT-TTYOUT	/EIGHTY-SIX THE BATCH LOG
	JMP	NOLPT/SET LPT MODE SO $MSG WILL ECHO
	CDF 10
	TAD I	[MPARAM+1
	CDF 0
	AND	(20	/CHECK /T SWITCH
	CLL CIA
	SZL CLA
	JMS I (LPTTST	/OTHERWISE, CHECK OUT FOR LINE PRINTER
NOLPT,	TAD (TTYOUT-BOSLPT	/NO LPT
	TAD (BOSLPT	/HE HAS A LPT
	DCA I	(OUTPUT	/SET OUTPUT DEVICE TO TTY OR LPT OR NULOUT
	TAD I (OUTPUT
	TAD (-BOSLPT
	SNA CLA
	STL RTL
	TAD I	[BOSSW
	DCA I	[BOSSW	/AND SET FLAG
	CDF 10
	TAD I	[7600
	CDF 0
	SNA
	JMP I	(CONT	/NO SPOOLING
	AND	[17
	DCA	T1
	TAD	T1
	TAD	(DCB-1
	DCA	T2
	CDF 10
	TAD I	T2
	CDF 0
	JMP I	(SPCONT
	PAGE
SPCONT,	SMA CLA
	JMP	BADSPL
	TAD	T1
	DCA I	(SPLDEV
	STL RTR
	TAD I	[BOSSW
	DCA I	[BOSSW
CONT,	JMS I (EOPTN	/CHECK FOR /E SWITCH
	TAD (BATPTR	/SET POINTER TO BATCH.SV
	DCA FILPTR
	CLA IAC		/DO LOOKUP ON SYS
	CIF 10
	JMS I [200
K2,	2
FILPTR,	BATPTR
	0		/WHO CARES ABOUT THE LENGTH?
	JMP NOBACH	/BATCH FILE NOT FOUND
	TAD I K7777	/PUT IN FIELD OF BOS
	AND (70
	TAD (CDF 0
	DCA CDFBOS
	TAD (201
	JMS I [SYS	/READ AND ALTER KEYBOARD MON.
	BUFFER
	KMREC
			/GET RECORD # OF BOS
	JMS I [VERTST	/GET VERSION OF MONITOR
	TAD (EOINIT
	AND (7400
	CLL RTL
	RTL
	RAL
	TAD K2
	TAD FILPTR
	DCA BOSREC	/WE WILL RE-WRITE BOS LATER
	TAD BOSREC	/ALTER KEYBOARD MONITOR
	DCA I (BUFFER+BATCH+3	/RECORD #
	TAD CDFBOS
	AND (70		/ALTER CONTROL WORD
	TAD BOSCTL
	DCA I (BUFFER+BATCH+1
	TAD BOSREC-1
	DCA I (BUFFER+BATCH+2
	CLA CLL CML RTL
	TAD CDFBOS
	DCA I (BCHGO+BUFFER	/JMP TO CORRECT FIELD
	TAD (BOS	/START ADD. OF MONITOR
	DCA I (BCHGO+BUFFER+2	/ENTRY POINT
	TAD (4200	/RE-WRITE KEYBD. MON.
	JMS I [SYS
	BUFFER
	KMREC
	TAD (201	/READ IN COMMAND DECODER
	JMS I [SYS
	BUFFER		/AND INSERT BOS RECORD
	CDREC
	TAD CDFBOS	/NOW FILL IN THE COMMAND DECODER
	DCA I (TT+BUFFER
	TAD (CDBOS
	DCA I (DVICE+BUFFER	/ALLOW CD TO CHECK BATCH VALIDITY
	TAD I (CDBOS
	CIA		/STORE COMPLEMENT ALSO
	DCA I (OUTSW+BUFFER
	CLL CML RTL	/CREATE CIF CDF BATCH
	TAD CDFBOS
	DCA I (NAMECT+BUFFER
	TAD (CDBOS
	DCA I (DEV1+BUFFER
	TAD (4200
	JMS I [SYS	/RE WRITE CD.
	BUFFER
	CDREC
	JMS I (SETH	/SET HUSH IF /H SPECIFIED
	CLA CLL CML RAR
	TAD BOSCTL
	JMS I [SYS	/INPUT POINTERS SET UP.
	ORIGIN&7400
BOSREC,	HLT
	CLA CLL CML RTR	/BATCH IN PROGRESS
	JMS I [INCOR
K7777,	7777
	CLA STL RAR	/4000
	DCA I (DOLFLG	/SET FOR INITIAL $JOB
	JMS I (MOVE	/PUT IMAGE OF BOS INTO HIGH CORE
	ORIGIN-7600
	ORIGIN
CDFBOS,	HLT
	ORIGIN
	TAD	(0160	/SET SPOOL FILENAME TO BTCHA0
	JMS	CDFTOP
	DCA I (SPLNUM
BATRET,	CIF CDF 0
	JMP I [7605

NOBACH,	JMS I [MESSG	/BATCH.SV NOT THERE
	NBATCH
	JMP	BATRET
BADSPL,	JMS I [MESSG
	SPLERR
	JMP I (BATASK
INDERR,	JMS I	[MESSG
	NODEV
	JMP I	(BATASK
	PAGE
MESSG,	0		/MESSAGE PRINTING ROUTINE
	CLA
	CDF 0
	JMS I [CRLF	/GENERATE CARRIAGE RET., LINE FEED
	TAD I MESSG	/ADDRESS OF ERROR MESSAGE
	ISZ MESSG	/POINT TO RETURN
	DCA TEMP
MCONT,	TAD I TEMP	/GET TEXT CHARACTERS IN AC
	CLL RTR
	RTR
	RTR
	JMS PCHAR	/PUNCH IT
	TAD I TEMP
	JMS PCHAR	/SECOND OF TWO.
	ISZ TEMP	/NEXT TEXT WORD
	JMP MCONT	/CONTINUE

PCHAR,	0		/ROUTINE TO UNPACK AND PRINT TEXT
	AND [77
	SNA		/0 TERMINATES THE LIST
	JMP	MSGXIT	/UNCLEAN RETURN, BUT WHO CARES?
	TAD (-37	/SEPARATE DIGITS FROM ALPHAS
	SNA
	JMP	PCRLF	/_ IS SPECIAL CHAR
	SPA 
	TAD (100	/MAKE IT ALPHABETIC
	TAD (237
	JMS I (TTYOUT
	JMP I PCHAR
MSGXIT,	TSF
	JMP	MSGXIT
	JMP I	MESSG

PCRLF,	JMS I	[CRLF
	JMP I	PCHAR
LZERO=0
GETCOR,	0		/ONCE ONLY ROUTINE TO DETERMINE CORE SIZE
	TAD I (BOSCCL	/GET CORE-SIZE WORD
	RTL		/PUT BATCH IN-PROGRESS BIT IN LINK
	SZL CLA		/ARE WE RUNNING BATCH FROM A BATCH JOB?
	JMP AAA		/YES, DON'T TOUCH ORIGINAL CORE SIZE
	TAD I (BOSCCL	/NO, GET OLD SOFTWARE CORE SIZE
	AND (7177	/BUT DON'T SAVE EXTENDED DATE BITS
	DCA I (OLDCOR	/SAVE CURRENT SOFTWARE CORE SIZE
AAA,	TAD I (BOSCCL	/GET BATCH CTL WD
	AND (70		/IT MIGHT ALREADY CONTAIN THE ANSWER
	SZA
	JMP	STOCOR
	TAD [7607
	DCA LZERO
CHUG,	CDF 10
	TAD K
	DCA I (LZERO
K10,	10
	TAD LZERO
	CIA
	TAD [7607
	SZA CLA
	JMP DUN
	TAD I (LZERO
	NOP
	CIA
	TAD K
	SZA CLA
	JMP DUN
	TAD [10
	TAD CHUG
	DCA CHUG
	ISZ K
	JMP CHUG-2
	CLA CMA
DUN,	CIF CDF 0
	TAD K
	TAD K10
	CLL RTL		/STORE HIGHEST FIELD # INTO 7777
	RAL
STOCOR,	DCA INCOR
	TAD INCOR
	TAD (-10	/TEST FOR AT LEAST 12 K
	SPA SNA
	JMP NOCORE
	TAD (-60	/LIMIT TO FIELD 6, SO AS NOT
	SNA CLA		/TO DISTURB ROM IN F. 7
	TAD (-10
	TAD INCOR
	DCA INCOR
	TAD	INCOR
	TAD	(CDF
	DCA	TOPCDF
	TAD I (BOSCCL
	AND (7707	/V3D
	TAD INCOR
	DCA I (BOSCCL
	TAD	INCOR
	TAD	(201
	DCA I	(SYCNTL
	TAD	TOPCDF
	DCA I	(BOSCDF
	JMP I GETCOR
NOCORE,	CLA
	JMS I [MESSG
	COR8
	JMP I [7600
K,	-10

INCOR,	0		/INCLUSIVE OR ROUTINE. USE THE 
	DCA TEMP	/FOLLOWING:
	TAD I INCOR	/A .OR. B= .NOT. A .AND. B +A
	DCA TEMP2
	TAD TEMP
	CMA
	AND I TEMP2
	TAD TEMP
	DCA I TEMP2
	ISZ INCOR
	JMP I INCOR
	PAGE
PTR,	0		/HI SPEED READER HANDLER
	RDF		/** MOVED TO 5400 IN BATCH FIELD **
	TAD	PCDIF0
	DCA	PTRRET
	JMS I PTRDOL	/CHECK FOR $ INSERTION
	JMP PTRISZ	/YES
	DCA	PTIMER
	JMS I TCTRLC
	RFC
PTM2,	RSF
	JMP PTMER
	TAD PTR200	/FORCE PARITY ON
	RRB
PTRISZ,	ISZ PTR
PTRRET,	HLT
	JMP I PTR
PCDIF0,	CDF CIF 0
TCTRLC,	CTRLC

PTMER,	AND I	0
	AND I	0
	ISZ	PTIMER
	JMP PTM2	/TIMES OUT IN 16 MS.
	JMP PTRRET
PTIMER,	0
PTR200,	200
PTRDOL,	GETDOL
/SYS PERFORMS I/O TO SYSTEM DEVICE. THE CALLING SEQUENCE
/CONFORMS TO THAT OF THE STANDARD OS/8 CALL SEQUENCE, EXCEPT
/THAT WE HAVE ONE ERROR RETURN FROM THE ROUTINE, NOT A LOT
/OF SEPARATE ERROR RETURNS.

SYS,	0
	DCA SYCTL	/AC HAD CONTROL WORD
	TAD I SYS
	DCA SYBUFF	/BUFFER FOR TRANSFER
	ISZ SYS
	TAD I SYS
	DCA SYREC	/RECORD OF TRANSFER
	ISZ SYS
	CIF 0
	JMS I (SYSTEM
SYCTL,	HLT
SYBUFF,	HLT
SYREC,	HLT
	SKP CLA
	JMP I SYS
	JMS I (PRMESG
	SERMSG
	JMP I	(BATRET

BATPTR,	FILENAME	BATCH.SV
CHANGE,	0		/ROUTINE TO ALTER CARD TABLE
	CDF 10
	TAD I (MPARAM+2
	CDF 0
	AND (10		/GET /6 SWITCH
	SZA CLA		/IF IT IS SPECIFIED,
	TAD (C026-C029	/USE DEC 026 CARD CODES,
	TAD (C029	/OTHERWISE USE DEC 029 CODES
	DCA XR1		/ADDDRESS OF CORRECT LIST
	TAD (CLST-1
	DCA XR2		/THE LOCS. THAT GET ALTERED
	TAD [-15
	DCA COUNT	/13 ENTRIES.
	TAD I XR2
	DCA CHPTR
	TAD I XR1
	DCA I CHPTR	/ALTER TABLE IN MONITOR.
	ISZ COUNT
	JMP .-5
	JMP I CHANGE
CHPTR,	0

CLST,	CDT+5		/ADDRESSES OF CARD CONVERSION LOCS.
	CDT+6
	CDT+7
	CDT+15
	CDT+16
	CDT+17
	CDT+25
	CDT+26
	CDT+27
	CDT+30
	CDT+35
	CDT+36
	CDT+37

C026=.-1
	7735		/CODES FOR 026 CARDS
	4076
	0774;3314;1002;0305;3204;1273;3606;1341;3716;1175
	3401

C029=.-1
	3203;4007;3502;7514;0577;3637;0104;1211;3374;0641;7316;3410
	1376

SETH,	0		/SET HUSH
	CDF 10
	TAD I (MPARAM	/LOOK AT A-L SWITCHES
	AND (20		/IN PARTICULAR, LOOK AT /H BIT
	CDF 0
	DCA I (HUSH	/SAVE THIS BIT
	JMP I SETH

	PAGE
BILEN=	0		/INITIALIZE MAX INPUT ROUTINE LENGTH

SYSIN,	0		/INPUT FROM SYSTEM DEVICE
	RDF		/** MOVED INTO 5400 IN BATCH FIELD **
	TAD	SYCDIF
	DCA	SYSRET
SYSIN4,	JMS I SYSDOL	/CHECK FOR $ INSERTION
	JMP SYSISZ	/YES
	TAD BLOK	/RE-READ BUFFER?
	SZA CLA
	JMP SYGETC	/NO. STILL THERE
	TAD I PSYBLKN
	DCA BLOK
	TAD I PSYCNT
IOSYS,	DCA SYCHCN	/RESTORE CHARACTER COUNT
	CIF 0
	JMS I	SYSINH	/READ THE BLOCK
SYCNTL,	0
BTBUF,	ORIGIN-400
BLOK,	0
	JMP I	PSYIERR
	TAD BTBUF	/SET BUFFER POINTER.
	DCA WPTR	/NOW DETERMINE FROM COUNT WHICH WORD
	TAD SYS601	/WAS INTERRUPTED. WHEN AC GOES NEG.,
	TAD SYCHCN	/WE ARE AT PROPER 2 WORD GROUP.
GWDLP,	TAD SYSM3	/THEN WE FORM A JMP TO CORRECT WORD
	SPA
	JMP GEWD
	ISZ WPTR	/SKIP 2 WORDS
	ISZ WPTR
	JMP GWDLP
GEWD,	TAD SYS3	/FORM A JMP CHARX, X=1,2,3
	TAD JMPDOT
	DCA JMPCH	/SET UNPACK SWITCH
SYGETC,	ISZ JMPCH	/NORMAL CHAR. FETCH
	ISZ SYCHCN	/NEED NEW BLOCK?
JMPDOT,	JMP JMPCH	/NO
	ISZ BLOK	/YES. NEXT BLOCK
	TAD SYM601
	JMP IOSYS	/READ IT.
JMPCH,	JMP JMPCH	/3 WAY SWITCH
	JMP ICHAR1	/FIRST OF 3
	JMP ICHAR2	/SECOND
	TAD JMPDOT
	DCA JMPCH	/RESET 3 WAY SWITCH
	JMS I	PCTRLC
	TAD I WPTR	/NOTE THAT WE CAN'T DESTROY WPTR BY
	AND SY7400	/BY DOING ISZ'S UNTIL THE 3RD CHAR.
	CLL RTR		/THAT IS BECAUSE IF WE ARE BROKEN
	RTR		/UP, WE CAN ONLY POINT TO THE 2 WORD
	DCA	SYTEMP	/GROUP AS A WHOLE.
	ISZ WPTR
	TAD I WPTR
	AND SY7400
	CLL RTL
	RTL
	RAL
	TAD	SYTEMP
	ISZ WPTR	/BUMP TO NEXT GROUP
	JMP CHCOM
ICHAR2,	CLA IAC
ICHAR1,	TAD WPTR
	DCA	SYTEMP	/THIRD CHAR NEEDS WPTR!
	TAD I	SYTEMP
CHCOM,	AND SYS177
	DCA	SYTEMP
	TAD SYCHCN
	DCA I PSYCNT
	TAD BLOK
	DCA I PSYBLKN
	TAD	SYTEMP	/CHECK FOR ^Z
/	SNA		/V3C
/	JMP SYSISZ	/RETURN NULL AS NULL
	TAD SYSM32
	SZA
	JMP CHOUT	/NOPE. OK
	TAD SYEXT	/^Z. DISABLE INPUT
	DCA SYSIN4
SYEXT,	JMP SYSRET
CHOUT,	TAD SYS232
SYSISZ,	ISZ SYSIN
SYSRET,	HLT		/CDF CIF RETURN FIELD
	JMP I SYSIN

SYCHCN,	0
WPTR,	0
SYSCHR,
SYTEMP,	0
PSYBLK,	SYBLKN
PSYCNT,	SYCNT
SYSINH,	0	/GETS ADDRESS OF INPUT HANDLER (7607 OR CO-RES)
PSYIER,	SYIERR
SYS601,	601
SYM601,	-601
SYSM3,	-3
SYS3,	3
PCTRLC,	CTRLC
SY7400,	7400
SYS177,	177
SYSM32,	-32
SYS232,	232
SYCDIF,	CDF CIF 0
SYSDOL,	GETDOL

	IFZERO .-SYSIN-BILEN&4000	<BILEN=.+1-SYSIN>
	PAGE
/CARD READER HANDLER. BUFFERS AN ENTIRE CARD IN THE LINE BUFFER.
/ON END OF CARD, WE CAST OUT EXTRANEOUS SPACES IN THE BUFFER

CDR,	0
	RDF
	TAD	CCDIF0
	DCA	CDRRET
	JMS I CDRDOL	/CHECK FOR $ INSERTION
	JMP CDRISZ	/YES
	ISZ CHCNT	/STILL CHARACTERS IN BUFFER?
	JMP GETCH	/YES.
NEWCRD,	TAD PLNBUF
	DCA CDRPTR	/NO. READ A NEW CARD
CSLCT,	JMS I	CCTRLC
	RCSE		/SELECT A CARD
	JMP CSLCT
RDNEXC,	DCA CTIMER
RDCOLM,	RCSF		/WAIT FOR DATA
	JMP EOC		/AND CHECK FOR END OF CARD
	RCRA
	CLL RAR		/TRANSLATE INTERNAL INTO ASCII
	TAD PCDT
	DCA CTEMP
	TAD I CTEMP
	SZL		/LEFT OR RIGHT?
	JMP .+4
	RTR;RTR;RTR
	AND CDR77
	TAD CDR240
	ISZ	CDRPTR
	DCA I CDRPTR
	ISZ CHCNT	/CAN'T SKIP
EOC,	RCSD		/CARD DONE?
	JMP TIME	/NO - CHECK TIMEOUT
	TAD CHCNT	/GET REAL NUMBER OF CHARACTERS
	CMA
	DCA CHCNT
CHKSPC,	TAD I	CDRPTR
	TAD CDM240
	SNA CLA
	JMP SPCIG
	ISZ	CDRPTR
CDCR,	TAD CDR215	/INSERT END OF LINE MARKER
	DCA I	CDRPTR
	TAD PLNBUF
	DCA CDRPTR
GETCH,	ISZ	CDRPTR
	TAD I CDRPTR
CDRISZ,	ISZ CDR
CDXIT,	RCRD		/CLEAR CARD DONE FLAG
CDRRET,	HLT
	JMP I CDR

SPCIG,	CLA CMA		/BACK UP ONE CHAR
	TAD	CDRPTR
	DCA	CDRPTR
	ISZ CHCNT	/IF SKIP, IT'S A BLANK LINE
	JMP CHKSPC
	JMP CDCR

TIME,	AND I 0	/CHECK TIME OUT - FIRST DELAY A WHILE
	TAD CDM240	/V3C
	DCA TIME	/TIME OUT A LOT
	ISZ TIME
	JMP .-1
	ISZ CTIMER
	JMP RDCOLM
	DCA CHCNT
	JMP NEWCRD	/CARD HUNG - WAIT FOR READER READY
CCDIF0,	CDF CIF 0
CHCNT,	-1
PLNBUF,	LINBUF-1
CCTRLC,	CTRLC
PCDT,	CDT
CDR77,	77
CDR240,	240
CDM240,	-240
CDR215,	215
CDRPTR,	0
CTEMP,	0
CTIMER,	0
CDRDOL,	GETDOL

	IFZERO	.-CDR-BILEN&4000	<BILEN=.+1-CDR>
LPTTST,	0		/SKIP IF BATCH-TYPE LINE PRINTER AVAILABLE
	TAD	(240
	PCLS		/PRINT AN INNOCUOUS BLANK
	CLA
/	AND I	0
/	AND I	0	/FLAG COMES UP IN UNDER 10 MICROSECONDS
/	AND I	0
/	AND I	0
/	AND I	0
/	AND I	0	/(ACTUALLY, FOR AN LA180 IT TAKES A BIT LONGER)
/	AND I	0
	ISZ	WAIT
	JMP	.-1	/WAIT A LOT
	PSKF		/WELL?
	JMP I	LPTTST	/NO WAY!
	CLA IAC		/DON'T BE FOOLED - COULD STILL BE AN ANALEX
	6654		/LOAD ANALEX BUFFER
	SNA CLA
	JMP	ANALEX	/IF IOT CLEARED AC, ITS AN ANALEX
	TAD	(215
	PCLS		/CLEAR LINE BUFFER BY PRINTING CR
	PSKF
	JMP	.-1
	CLA
	ISZ	LPTTST
	JMP I	LPTTST	/TAKE SKIP RETURN

ANALEX,	6652		/CLEAR FLAGS
	6662		/CLEAR BUFFER
	JMP I	LPTTST	/TAKE NO LPT RETURN

WAIT,	0
	PAGE
NBATCH,	TEXT /BATCH.SV NOT FOUND ON SYS:/
COR8,	TEXT /INSUFFICIENT MEMORY FOR BATCH RUN/
BADMON,	TEXT /WRONG OS8 MONITOR/
NODEV,	TEXT /DEV NOT IMPLEMENTED_/
SPLERR,	TEXT /ILLEGAL SPOOL DEVICE_/
VERMSG,	TEXT	/BATCH /
	*.-1
	VERSON+2660	/"VN"
	TEXT	/B_/
VERTST,	0
	TAD I (BUFFER+BATCH	/SHOULD BE 4562 IN V3
	TAD (-CBATCH
	SNA CLA
	JMP I VERTST
	JMS I [MESSG
	BADMON
	JMP I [7600

MVINSB,	0
	DCA	XR1	/ADDR OF INPUT ROUTINE
	TAD	(BATIN-1	/ADDR OF PLACE IN BATCH MONITOR
	DCA	XR2
	TAD	(-BILEN
	DCA	BMVCNT
	TAD I	XR1
	DCA I	XR2
	ISZ	BMVCNT
	JMP	.-3	/MOVE ROUTINE UP
	JMP I	MVINSB
BMVCNT,	0

EOPTN,	0		/CHECK FOR /E OPTION
	CDF 10
	TAD I (MPARAM
	CDF 0
	AND (200	/ISOLATE E SWITCH
	SNA CLA
	JMP I EOPTN	/NOT ON
	TAD (1000
	JMS I (INCOR	/OR 1000 INTO BOSSW
	BOSSW
	JMP I EOPTN

	EOINIT=.
	PAGE
	FIELD 0		/DUMP PAGE 0 LITERALS HERE
	*ORIGIN		/THIS CODE ACTUALLY EXECUTES IN TOP FIELD!

BATIN,	ZBLOCK	BILEN	/BATCH INPUT ROUTINE GOES HERE

END,	TAD I (HUSH
	SZA CLA
	JMP BKILL	/SUPPRESS #END WHEN HUSHED
	JMS I (PRMESG
	EOBMSG
BKILL,	CDF 10
	STA
	TAD I (7700	/V3D
	DCA I (7700	/ALLOWS CORE IMAGE TO BE PRESERVED ACROSS BATCH
	JMP I (MORKIL

SETJSW,	0		/ROUTINE TO SET JOB
	TAD (7377	/STATUS WORD TO INDICATE THAT
	CDF 0		/BATCH IS STILL IN CORE
	AND I (JSW
	TAD (400
	DCA I (JSW
	JMS I (CDFRST	/RESTORE TRUE DATA FIELD
	JMP I SETJSW

	PAGE
/THIS IS THE ACTUAL BATCH MONITOR. THIS ENTRY IS FOR THE
/INTERFACE WITH THE KEYBOARD MONITOR.

BATVFY,	2214		/** THIS LOCATION IS VERIFIED BY BAT: **

BOS,	CDF 0		/SEE IF CD FOUND AN ERROR
	TAD I (BOSCCL	/IF BIT 11 SET, IT DID.
	CLL RAR
	CLA
	TAD I (BOSCCL	/RESTORE IT.
	AND M2		/ERASE IT
	DCA I (BOSCCL
	JMS I (CDFRST	/RESTORE DATA FIELD
	SZL CLA
	JMP	CDERR
	JMS I (KMLINK	/LINK I/O OF BOS AND K.M.
BOSSB,	TAD OUTPUT
	DCA BOUTDV	/SET MESSAGES
	JMS I (GLINE	/READ LINE OF INPUT
	TAD HUSH
	SZA CLA
	JMP BOSRE	/DON'T ECHO LINES WHEN HUSHED
	TAD I (LINBUF
	TAD (-"$
	SNA CLA
	TAD I (LINBUF+1
	TAD (-"J	/DON'T ECHO $JOB CARD HERE
	SNA CLA
	TAD I (LINBUF+2
	TAD (-"O
	SZA CLA
	JMS I (ECHO	/BUT ECHO ANY OTHER LINE
BOSRE,	TAD I (LINBUF	/ENTER HERE FROM CD IF KM COMMAND SEEN
	DCA I (BNAM	/GET THE FIRST CHAR ON THE LINE
	TAD DOLFLG	/DO WE NEED $?
	SMA CLA
	JMP I (NXPRG	/NO. LOOK FOR . OR /
	TAD I (BNAM	/SEE IF WE HAVE IT
	TAD (-"$
	SZA CLA
	JMP BOSSB	/NOT YET.
	JMP I (KMDOLR	/SEE IF IT'S $JOB

CDERR,	JMS I	(PRMESG
	CDEMSG
	JMP	BOS
/HERE TO ECHO $JOB CARD

DOLECH,	TAD HUSH
	SZA CLA
	JMP HUSH2	/DON'T ECHO $JOB WHEN HUSHED
	TAD (214
	JMS OUTCHR
	TAD I (BOSSW
	CLL RTR		/ECHO A PAGE OF $JOBS TO LPT ONLY
	SNL CLA		/IS LPT OUTPUT?
	JMP DOLEC2
	TAD (-36	/YES
	DCA DOLFLG
	TAD (212
	JMS OUTCHR	/SPACE DOWN TO MIDDLE OF PAGE
	ISZ DOLFLG
	JMP .-3		/REPLACE NEXT THREE LOCS IF CENTRONIX PRINTER:
	JMS I (ECHO	/216
	JMS I (ECHO	/TAD .-1
	JMS I (ECHO	/JMS OUTCHR	/PRINT LARGE CHARS
	JMS I (ECHO
DOLEC2,	TAD (214
	JMS OUTCHR
	JMS I (ECHOT	/PUT $JOB TO TTY IF NEEDED
	JMS I (CRLF
HUSH2,	DCA DOLFLG
	JMP BOSSB

GETDOL,	0		/ROUTINE TO PUT BACK ANY $ READ BY BAT:
	CDF 0
	TAD I (BOSCCL	/GET BATCH CONTROL WORD
	CLL RTR
	SZL CLA		/TEST BIT 10
	JMP GOTDOL	/ITS ON - MUST PUT IN A $
	JMS I (CDFRST	/NO - SET DF TO THIS FIELD
	ISZ	GETDOL
	JMP I GETDOL	/TAKE SKIP RETURJ
GOTDOL,	CLL STA RTL		/7775
	AND I (BOSCCL
	DCA I (BOSCCL	/REMOVE THE BIT
	TAD ("$
	JMP I GETDOL	/TAKE NON-SKIP RETURN WITH $ IN AC
GETCOM,	JMS I	(MOVE
	-112		/PUT BUFFER INTO KEYBOARD MON.
	LINBUF+1
	CDF 0
	BEGLN
	TAD I (AMODE	/V3C GET BATCH ALTMODE FLAG
	SZA CLA
	STL RAL		/SET KBM ALTMODE FLAG IF NECESSARY
	CIF CDF 0
	DCA I (AMFLAG	/IT'S IN FIELD 0
	JMP I .+1	/AND GO PROCESS IT
	KEYMON+1
M2,	-2

OUTCHR,	0
	JMS I	BOUTDV
	JMP I	OUTCHR

BOUTDV,	TTYOUT
OUTPUT,	0
DOLFLG,	0		/$ SLEW FLAG - NEGATIVE IF SLEW
HUSH,	0		/NON-0 MEANS HUSHED (/H)
	PAGE
BOSSW,	0		/BATCH STATUS FLAG.
MSG,	0
	TAD I (DOLFLG	/IF $JOB SLEW SET, DON'T PAUSE
	SPA CLA
	JMP I MSG
	TAD BOSSW	/NO ECHO IF TTY IS OUTPUT
	CLL RTR
	SZL CLA
	JMS I (ECHOT
	TAD BOSSW	/IS OPERATOR AVAILABLE?
	CLL RAR
	SZL CLA
	JMP I MSG	/NO. CONTINUE
	TAD (207
	JMS I (TTYOUT
	KCC		/WAIT A WHILE
	JMS I (TTY
	JMP I MSG

TESTB,	0		/TEST ROUTINE. TEST LIST AGAINST BNAM
	TAD I TESTB
	DCA PRMESG	/# ELEMENTS IN LIST
TSTB2,	ISZ TESTB	/POINT TO ELEMENT
	TAD I TESTB
	ISZ TESTB
	TAD I	(BNAM	/TEST IT
	SNA CLA
	JMP TSBOVR	/A MATCH
	ISZ PRMESG
	JMP TSTB2
	ISZ TESTB
	JMP I TESTB	/NO MATCH
TSBOVR,	TAD I TESTB
	DCA TESTB
	JMP I TESTB

OLDCOR,	0		/V3C HOLDS OLD SOFTWARE CORE SIZE WORD
			/MUST HAVE ADDRESS .GT. 6000
PRMESG,	0		/MESSAGE PRINTER
	DCA TESTB	/SET FOR NO SKIP ON ISZ
	TAD I PRMESG	/INDEX INTO MESSAGE LIST
	DCA	PRTEMP
	JMS I (CRLF
	TAD	("#	/BATCH ERROR SIGNAL
	JMS I (OUTCHR
PRMSG2,	TAD I	PRTEMP
	CLL RTR;RTR;RTR
	JMS PNCH
	TAD I	PRTEMP
	JMS PNCH
	ISZ	PRTEMP
	JMP PRMSG2	/CYCLE UNTIL A 0
PNCH,	0
	AND (77
	SNA
	JMP PRTTY	/COULD BE OPTIMIZED
	TAD	(240
	AND	(77
	TAD	(240
	JMS I (OUTCHR
	JMP I PNCH


PRTTY,	JMS I	(CRLF
	ISZ TESTB	/PUT IT ON TTY, TOO
	CLA CLL CML RTL	/+2  SKIPPED IF SECOND TIME THROUGH
	AND BOSSW	/SEE IF LP08 IS OUTPUT
	SNA 
	JMP PRMOUT	/ALREADY ON TTY
	AND TESTB	/CALL WITH AC=1 MEANS NO TTY OUTPUT
	SZA CLA
	JMP PRMOUT
	TAD (TTYOUT
	DCA I	(BOUTDV	/SET TTY
	CLA CMA		/SET TESTB TO SKIP
	JMP PRMESG+1
PRMOUT,	TAD I (OUTPUT	/RESTORE OUTPUT
	DCA I	(BOUTDV
	ISZ PRMESG	/SKIP ARGUMENT
	JMP I PRMESG
KMLINK,	0		/LINK BATCH AND KEYBOARD I/O.
	RIF
	TAD BCDIF0	/SETUP A JUMP IN KEYBOARD.
	DCA KMLST
	TAD KMLST	/AND ANOTHER FOR PRINT ROUTINE
	DCA KMLST2
	JMS I (MOVE	/PUT NEW CODE INTO KEYBOARD
	-3
	KMLST
	CDF 0
	PRINT+1		/THIS IS OUTPUT LINK
	JMS I (MOVE	/NOW INPUT LINK.
	-3
	KMLST2
	CDF 0
	XGLINE+1
	JMP I KMLINK

/** NEXT 3 WORDS LOAD INTO "PRINT+1" IN KEYBOARD MONITOR **

KMLST,	CIF CDF 0	/ALTERED AT RUN-TIME
	PRINT+3&177+5600	/ALLOWS TALKING THRU BATCH
	BOSPRT

/** NEXT 3 WORDS LOAD INTO "XGLINE+1" IN KEYBOARD MONITOR **

KMLST2,	CIF CDF 0
	XGLINE+3&177+5600	/"JMP I .+1"
	BOS

BCDIF0,	CIF CDF 0
PRTEMP,	0
NXPRG,	JMS TESTB	/SEE IF WE HAVE . OR /
	-4
	-".;GETCOM
	-"/;BOSSB
	-"$;KMDOLR
	-"*;BOSSB	/ERRONEOUS CD CARD.
	JMP I (KJOB
	PAGE
GLINE,	0		/LINE COLLECTION ROUTINE
	TAD (LINBUF-1
	DCA GLPTR
GET,	JMS I (BATIN	/GO TO SPECIFIED INPUT DEVICE
	JMP EOF		/TIME-OUT OR FATAL
	DCA BNAM
	JMS I (TESTB	/TEST FOR SPECIAL CHARS.
	-5
	-215;CARROT
	-212;GET	/IGNORE LINE FEEDS.
	-214;GET	/IGNORE FORM FEEDS
	-337;BKAROW	/CD DOESN'T LIKE _, ONLY <
	-200;GET	/IGNORE BLANKS (NULLS) V3C
	TAD BNAM
	SKP
BKAROW,	TAD ("<
	ISZ	GLPTR
	DCA I	GLPTR
	TAD	GLPTR
	TAD (-LINBUF-110	/OVERFLOW BUFFER?
	SPA CLA
	JMP GET		/NOT YET.
CARROT,	TAD I	GLPTR	/GET LAST CHAR INPUT
	TAD	(-244	/$?
	SZA CLA
	JMP	NALTMD	/NO
	TAD I	GLPTR	/GET $
	SKP
NALTMD,	ISZ	GLPTR	/BUMP TO NEXT CHAR IF NO ALTMODE
	DCA	AMODE	/STORE ALTMODE FLAG
	DCA I	GLPTR	/CLEAR END CHAR IN BUFFER
	TAD I	(LINBUF
	SNA CLA		/WAS LINE NULL?
	JMP	GLINE+1	/YES - IGNORE
	JMP I GLINE

EOF,	KCC		/HANG ON INPUT ACTION
	JMS I (PRMESG	/INDICATE FAILURE
	INPMSG
	JMS I (TTY	/WAIT FOR INPUT
	JMP GET		/AND RETURN

AMODE,	0
GLPTR,	0
/DOLRD INTERPRETS $ CARDS

DOLRD,	0
	TAD (LINBUF	/GET THE NAME OF THE $ COMMAND
	DCA BLPTR
	DCA BNAM
GWRD2,	ISZ	BLPTR
	TAD I	BLPTR
	SNA
	JMP NOCMD	/FUNNY..NOTHING THERE!
	TAD (-240	/IGNORE LEADING SPACES
	SNA
	JMP GWRD2
	TAD (-240	/NOT A SPACE. TAKE WHATEVER IT IS.
	AND (77
	CLL RTL;RTL;RTL
	DCA BNAM	/KEYBOARD MON. WILL EXAMINE IT.
	ISZ	BLPTR
	TAD I	BLPTR
	AND (77
	TAD BNAM
	DCA BNAM
NOCMD,	TAD BNAM
	SNA CLA
	JMP I	(KJOB
	JMS I (TESTB	/TEST IT
	-3
	-0516;END	/$END CARD
	-1523;MSGST	/$MSG CARD IMAGE
	-1217;JOB	/$JOB CARD
DLCRUD,	ISZ DOLRD	/$CRUD
JOB,	TAD I DOLRD
	DCA DOLRD
	JMP I	DOLRD

MSGST,	JMS I	(MSG	/PRINT MESSAGE
	JMP	DLCRUD	/TREAT LIKE CRUD

CDOLLR,	JMS	DOLRD
	CDKBD		/$JOB
	CDGET		/$OTHER

KMDOLR,	JMS	DOLRD
	DOLECH		/$JOB
	BOSSB		/$OTHER

BLPTR,	0
BNAM,	0
/HERE FROM CD WHEN DONE TO ANALYZE CD AREA

CDRENT,	CDF 0
	TAD I (LKUPSW	/GET THE DEFAULT EXTENSION
	JMS I (CDFRST	/SET CURRENT DF
	JMS I (CDSCN	/SCAN CD LINE
	KCC
	TCF		/CLEAR FLAGS JUST LIKE CD WOULD
	CDF CIF 0
	JMP I (CDOVER+3	/RESUME CD AT TERMINATION CODE
	PAGE
LCONV,	-40		/PATCH TO 0 TO ALLOW OUTPUTTING LC TO LPT

CDT,	0021;2223;2425;2627;3031;3203;4007;3502
	2017;6364;6566;6770;7172;7514;0577;3637
	1552;5354;5556;5760;6162;0104;1211;3374
	0641;4243;4445;4647;5051;7316;3410;1376

TTYOUT,	0		/TESTS AC FOR FORM FEED
	TAD (-214
	SNA
	JMP TFORM	/GENERATE LINE FEEDS
	TAD (214
	JMS TTYPE
	JMP I TTYOUT
TFORM,	TAD (-4
	DCA TCOUNT
	TAD (212
	JMS TTYPE
	ISZ TCOUNT
	JMP .-3
	JMP I TTYOUT
TCOUNT,	0

NULOUT,	0
	CLA		/DEEP-SIX THE CHARACTER
	JMS I (CTRLC
	JMP I NULOUT
TTYPE,	0		/TELETYPE OUTPUT STUFF
	TLS
	TSF
	JMP .-1
X200,	CLA
	JMS I	(CTRLC
	JMP I TTYPE

BOSPRT,	JMS ERHDR	/PRINT MESSAGE
	CIF CDF 0
	JMP I (PRINT+10

CDFRST,	0
BOSCDF,	HLT
	JMP I CDFRST

ERHDR,	0		/ERROR HEADER ROUTINE
	DCA CDFRST	/SAVE CHARACTER
	TAD I (DOLFLG	/FIRST ENTRY?
	SZA CLA
	JMP .+3		/NO.
	TAD	("#	/ERROR PROMPT
	JMS I (OUTCHR
	TAD I (BOSSW	/GET BATCH FLAGS WORD
	CMA
	AND (1000	/SET $ SLEW FLAG NEGATIVE IF NO /E,
	STL RTL		/NON-ZERO IN ANY CASE
	DCA I (DOLFLG
	TAD CDFRST
	JMS I (OUTCHR
	JMP I ERHDR

CRLF,	0
	TAD (215
	JMS I (OUTCHR
	TAD (212
	JMS I (OUTCHR
	JMP I CRLF

BOSLPT,	0		/BATCH LINE PRINTER ROUTINE
	DCA BOSTMP
	TAD BOSTMP
	AND (177
	TAD (40
	AND X200
	SZA CLA
	TAD LCONV	/CONVERT LOWER CASE TO UPPER CASE
	TAD BOSTMP
	PCLS
	CLA
	JMS I (CTRLC
	PSKF
	JMP .-2
	JMP I BOSLPT
MORKIL,	CDF 0
	TAD I (BOSCCL
	AND (600	/GET (POSSIBLY NEW) EXTENDED DATE BITS
	JMS CDFRST
	TAD I (OLDCOR
	CIF CDF 0
	DCA I (BOSCCL	/RESTORE WORD
	JMP I (7605
BOSTMP,	0
	PAGE
/ERROR MESSAGES

CDEMSG,	TEXT /MONITOR OVERLAYED/
INPMSG,	TEXT /INPUT FAILURE/
BADMSG,	TEXT /BAD LINE. JOB ABORTED/
SERMSG,	TEXT /SYS ERROR/

LINBUF,	ZBLOCK	113

	PAGE
BATABT,	JMS I (CDFRST	/THIS CODE IS HERE FOR CCL!
	TAD I (BOSSW	/GET BATCH SWITCHES
	CMA
	AND (1000	/IF /E FLAG IS UP CCL ERRORS ARE NON-FATAL,
	CLL RTL
	JMP CDKILX	/OTHERWISE WE SHOULD ABORT BATCH ON THEM

CDGET,	JMS I (GLINE	/READ INPUT
	TAD I (HUSH
	SNA CLA		/DON'T ECHO CD LINES IF HUSHED
	JMS I (ECHO
	TAD (LINBUF-1
	DCA CDGPTR
	TAD I (DOLFLG	/$JOB FLAG UP?
	SPA CLA
	JMP CDKBD	/SLEW UNTIL $JOB
	ISZ	CDGPTR
	TAD I CDGPTR
	DCA I	(BNAM
	JMS I (TESTB	/TEST PROMPT CHAR.
	-4
	-"*;CDLINE	/* IS OK
	-"/;CDGET	/REMARK
	-"$;CDOLLR
	-".;CDKBD	/RECALL KEYBOARD MON.
KJOB,	JMS I (PRMESG
	BADMSG		/ILLEGAL CHARACTER
CDKILL,	STL CLA RAR	/4000
CDKILX,	DCA I (DOLFLG	/ABORT TO NEXT $JOB
	JMS I (SETJSW	/MARK BATCH IN CORE
	CIF CDF 0
	JMP I .+1
	7605		/RESTART.

CDKBD,	CIF	0
	JMS I	(SYSTEM
	1000
	0
	KMREC
SYIERR,	SKP CLA
	JMP	.+4
	JMS I	(PRMESG
	SERMSG
	HLT
	JMS I (SETJSW	/MARK BATCH IN CORE
	JMS I (KMLINK	/LINK TO NEW KEYBOARD
	TAD (BOSRE	/WE WANT TO RETAIN OLD LINE
	CIF CDF 0
	DCA I (BCHGO+2
	JMP I (BEGLN+1

CDGPTR,	0
CDLINE,	JMS I (MOVE	/PUT LINE INTO CD
	-112
	LINBUF+1
	CDF 0
	CDBEGLN
	TAD I	(AMODE
	CDF 10
	SZA CLA		/CHECK WHETHER ALTMODE TERMINATED LINE
	STL RAR		/IT DID - SET CD ALTMODE FLAG
	DCA I	(MPARAM-1
	CIF CDF 0
	JMP I .+1
	ANALYZ

DEVKIL,	JMS I (PRMESG
	PTRMSG
	JMP	CDKILL

HLPMSG,	TEXT /MANUAL HELP NEEDED/
PTRMSG,	TEXT /ILLEGAL INPUT DEVICE/
EOBMSG,	TEXT /END BATCH/
SPLMSG,	TEXT /SPOOL TO FILE /
	*.-1
BCHFIL,	TEXT	/BTCHA0/
	PAGE
/SUBROUTINE TO ANALYZE CD AREA - ENTER FROM ANY FIELD
/WITH DEFAULT EXTENSION IN AC

CDSCN,	0
	TAD (-5200
	SZA
	TAD (5200	/THIS MAY INTRODUCE A BUG WHILE FIXING ONE - STAN -
	DCA EXT		/SAVE EXTENSION
	RDF
	TAD (CDF CIF 0
	DCA CDSCRT	/SAVE RETURN FIELD
	TAD (7600
	DCA CDTEMP	/LOOK AT CD AREA
	MTHREE
	DCA CDCNT
CDSCAN,	JMS I (CDFRST
	TAD I (BOSSW
	CLL RTL
	CDF 10
	SZL CLA		/IS SPOOLING ENABLED
	TAD I CDTEMP	/AND IS THERE AN OUTPUT?
	AND (17
	SNA
	JMP NCKSPL	/NO - DON'T LOOK
	TAD (DCB-1	/CHECK FILE OR NON-FILE STATUS
	DCA CDTMP2
	TAD I CDTMP2	/SPOOL NON-FILE DEVICES
	SPA CLA
	JMP NCKSPL	/FILE STRUCTURED OUTPUT
	TAD I CDTEMP
	AND (7760
	TAD SPLDEV	/RESET CD AREA
	DCA I CDTEMP
	ISZ CDTEMP	/POINT TO FILENAME AREA
	JMS I	(CDFRST
	TAD I (SPLNUM
	AND (11
	CIA
	TAD (11
	SNA CLA
	TAD (66
	IAC
	TAD I (SPLNUM
	DCA I	(BCHFIL+2
	JMS I (MOVE
	-4
	BCHFIL
	CDF 10
CDTEMP,	0		/76XX
	JMS I (PRMESG	/PRINT FILENAME
	SPLMSG
	TAD I	(BCHFIL+2	/SET NEW FILENAME
	DCA I (SPLNUM
	CLA CMA
NCKSPL,	TAD CDTEMP
	TAD (5
	DCA CDTEMP
	TAD EXT
	SNA CLA
	JMP CDSCRT	/YES - LOOK NO MORE
	ISZ CDCNT
	JMP CDSCAN	/KEEP LOOKING
CDX1,	TAD (-11	/SCAN INPUT AREA
	DCA CDCNT
	TAD (7617
	DCA CDPTR	/PICK UP MANUAL INPUTS.
INPSCN,	CDF 10
	TAD I CDPTR
	SNA		/ANY INPUTS?
	JMP CDSCRT	/3 GUESSES!
	AND (17
	TAD (DCB-1	/GET DEVICE IDENTIFIER
	DCA CDTMP2
	TAD I CDTMP2
	AND (770
	JMS I	(CDFRST
	SNA
	JMP	RBELL	/TELETYPE INPUT - CHECK OPERATOR
	TAD	(-10
	SZA CLA
	JMP	CDX3	/OK INPUT DEVICE
	TAD I	(BOSSW
	SPA CLA		/PTR: INPUT - IS BATCH FROM PTR?
	JMP I	(DEVKIL	/YES - ILLEGAL
RBELL,	TAD I (BOSSW	/OPERATOR AVAILABLE?
	CLL RAR
	SZL CLA
	JMP I	(DEVKIL	/NO. ABORT THE JOB
	TAD (207
	JMS I (TTYOUT
	JMS I (PRMESG
	HLPMSG		/MANUAL INTERVENTION REQUIRED.
	JMS I (CRLF
	JMP CDSCRT
CDX3,	CLA CLL CML RTL
	TAD CDPTR
	DCA	CDPTR
	ISZ CDCNT
	JMP INPSCN
CDSCRT,	HLT
	JMP I CDSCN	/RETURN TO CALLER

SPLDEV,	0		/GETS SPOOL DEVICE #
EXT,	0
CDPTR,	0
CDCNT,	0
CDTMP2,	0
	PAGE
/THIS ROUTINE IS NOT REFERENCED FROM BATCH-
/IT PROVIDES A WAY FOR A USER TO OUTPUT MESSAGES
/TO THE BATCH LOG DEVICE

BATOUT,	0		/CALLABLE FROM ANY FIELD
	DCA	CTRLC	/WITH CHARACTER IN AC
	RDF
	TAD CDCF0	/GET CDF CIF TO CALLING FIELD
	DCA BATORT
	JMS I (CDFRST	/CDF TO CURRENT FIELD
	TAD CTRLC
	SZA
	JMS I (OUTCHR	/OUTPUT THE CHARACTER
BATORT,	HLT
	JMP I BATOUT
/ENTER HERE FROM COMMAND DECODER WHEN CD CALLED

CDBOS,	RIF		/FILL IN CIF CDF N
	TAD CDCF0	/TO LINK CD AND BOS
	DCA CDLST1
	TAD CDLST1
	DCA CDLST2
	TAD CDLST2
	DCA CDLST3
	JMS MOVE
CM3,	-3
	CDLST1
	CDF 0
	TYPE+1		/LINK ERROR PRINTOUT TO BOS

	JMS MOVE
	-3
	CDLST2
MCDF0,	CDF 0
	CGLINE		/LINK INPUT TO BOS

	JMS MOVE
	-3
	CDLST3
	CDF 0
	CDOVER		/EXIT FROM LINE ANALYSIS
CDCF0,	CIF CDF 0
	JMP I	.+1
	RESTRT+1	/START UP CD

/** THESE 3 WORDS LOAD INTO "TYPE+1" IN THE COMMAND DECODER **
CDLST1,	CIF CDF 0
	TYPE+3&177+5600	/"JMP I .+1"
	CDPRT

/** THESE 3 WORDS LOAD INTO "CGLINE" IN THE COMMAND DECODER **
CDLST2,	CIF CDF 0
	CGLINE+2&177+5600	/"JMP I .+1"
	CDGET		/RETURN TO CDGET AFTER ZEROING CD AREA

/** THESE 3 WORDS LOAD INTO "CDOVER" IN THE COMMAND DECODER **
CDLST3,	CIF CDF 0
	CDOVER+2&177+5600	/"JMP I .+1"
	CDRENT
CTRLC,	0		/CHECK FOR ^C
	KRS
	AND (177
	TAD CM3
	SNA CLA
	KSF
	JMP I CTRLC
	JMP I .+1
	BKILL

ECHOT,	0		/ECHOES LINE ON TTY
	TAD (TTYOUT	/SET TTY AS OUTPUT
	DCA I	(BOUTDV
	JMS ECHO	/ECHO IT
	JMS I (CRLF
	TAD I (OUTPUT
	DCA I	(BOUTDV	/RESET OUTPUT
	JMP I ECHOT

TTY,	0
	KSF
	JMP .-1
	JMS CTRLC
	KCC
	JMP I TTY

ECHO,	0		/ECHO INPUT LINE
	TAD (LINBUF-1
	DCA EPTR
ECHO2,	ISZ	EPTR
	TAD I EPTR
	SNA
	JMP ECO3
	JMS I (OUTCHR
	JMP ECHO2
ECO3,	TAD I	(AMODE	/NEED $ PRINTED?
	SZA
	JMS I (OUTCHR	/YES
	JMS I (CRLF
	JMP I ECHO
MOVE,	0
	RDF
	TAD MCDF0
	DCA MVIPUT
	TAD I MOVE
	DCA MVTMP	/COUNT
	ISZ MOVE
	CLA CMA
	TAD I MOVE
	DCA MVPT1	/INPUT STUFF
	ISZ MOVE
	TAD I MOVE
	DCA MVOPUT	/OUTPUT FIELD
	ISZ MOVE
	CLA CMA
	TAD I MOVE
	DCA MVPT2
	ISZ MOVE
MVIPUT,	HLT
	ISZ	MVPT1
	TAD I	MVPT1
MVOPUT,	HLT
	ISZ	MVPT2
	DCA I	MVPT2
	ISZ MVTMP
	JMP MVIPUT
	JMS I (CDFRST
	JMP I MOVE

MVTMP=	CTRLC

MVPT1,	0
MVPT2,	0
EPTR,	0

CDPRT,	JMS I (ERHDR
	CIF CDF 0	/LINK BACK TO CD
	JMP I .+1
	TYPE+10
	PAGE

	FIELD 0
	*200
	$$$$$$$$$$
