	.TITLE	MAC -- MAIN PROGRAM TO OVERLAY MACRO AND CREF
/
/COPYRIGHT (C) 1975
/DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
/
/THIS SOFTWARE IS FURNISHED UNDER A LICENSE FOR USE ONLY
/ON A SINGLE COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH
/THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS
/SOFTWARE, OR ANY OTHER COPIES THEREOF, MAY NOT BE PRO-
/VIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON
/EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO
/THESE LICENSE TERMS.  TITLE TO AND OWNERSHIP OF THE
/SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.
/
/THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE
/WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COM-
/MITMENT BY DIGITAL EQUIPMENT CORPORATION.
/
/DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY
/OF ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.
	.EJECT
/ EDIT 8		5/1/71	R. MCLEAN
/EDIT 9	03/NOV/75	JMW	DECREASE SPACE FOR STORAGE OF ARGS.
/
 /COPYRIGHT 1971,1972  DIGITAL EQUIPMENT COPRORATION, MAYNARD, MASS.
/
/	MAC IS USED TO CALL MACRO AND CREF AND TO
/		MAINTAIN THE COMMON STORAGE FOR BOTH
/		PROGRAMS
/
/	MACRO IS THE MAIN OVERLAY AND CREF COMES IN AND 
/		PICKS UP THE SYMBOL TABLE LEFT BY
/		MACRO.
/
/
	.GLOBL	FILNMS,MACR15,CREF,SWITCH,PARBUF,IOERR,PKNUMS,INITSW,UPKADS,EXIT,TDVEV
/
ECLA=641000
X10=10
	.IFUND	DAT2
DAT2=14
	.ENDC
	.IFUND	DAT3
DAT3=15
	.ENDC
	.IFUND	DAT10
DAT10=24
	.ENDC
	.IFUND	DAT11
DAT11=17
	.ENDC
	.IFUND	DAT12
DAT12=20
	.ENDC
	.IFUND	DAT13
DAT13=21
	.ENDC
	.IFUND	DAT14
DAT14=22
	.ENDC
/
MAC	CAL	REDPAR	/READ PARAMETERS
	LAC	TDVEV
	SPA		/WAS REQUEST FOR TDV LEGAL?
	JMP	TDVERR	/NO EXIT
MACA	JMS*	MACR15	/ENTER MACRO
	LAC	FSWCH	/SAVE THE F SWITCH FOR CREF
	SAD	FSWCH-5
	JMP	SAVESW
	LAC	FILNMS+3
	DAC	FILNMS
	LAC	FILNMS+4
	DAC	FILNMS+1
	LAC	FILNMS+5
	DAC	FILNMS+2
	CLA		/DON'T SAVE SWITCH IF Z IS SET
SAVESW	DAC	FSWTC
	JMS*	CREF	/ENTER CREF
	LAC	BATCH	/SAVE THE BATCH SWITCH
	DAC	BATCHS
	SZA		/EXIT REQUESTED?
	JMP	MACA	/CREF HAS EXITED -- RE-ENTER MACRO TO SEE IF
	JMP	EXIT	/YES EXIT
			/MORE HAS TO BE DONE
/
FILNMS	.BLOCK	6	/FILENAMES AND PARAMETERS FOR CREF
FSWTC	0		/^^^^MUST FOLLOW FILNMS
BATCH	.BLOCK	12	/^^^^ MUST FOLLOW FSWTC (JMW:009)
SWITCH	.BLOCK	20	/MACRO OPTION SWITCHES (JMW:009)
FSWCH	0		/^^^^ MUST FOLLOW SWITCH
BATCHS	.BLOCK	3		/BATCH SWITCH ^^^ MUST FOLLOW FSWCH ^^^
REDPAR	37		/READ PARAMETERS CAL -- ONCE ONLY CODE -- OVERLAYED
	TDVEV		/EVENT VARIABLE ADDRESS
	PARBUF		/PARAMETER BUFFER
	40		/BUFFER SIZE (WORDS)
PARBUF	.BLOCK	40	/INPUT PARAMETERS
PKNUMS	0	/POINTERS TO BUFFER IN MACRO
UPKADS	0
INITSW	0	/FIRST TIME SWITCH
/
TDVERR	CAL	WRTDVE	/TDV ERROR EXIT MACRO
	CAL	WTFOR
	JMP	EXIT	/EXIT
/
/	I/O ERROR HAS OCCURRED OUTPUT TO USER
/		MAC-I/O ERROR LUN XX EVENT VARIABLE YYYYYY
/
IOERR	0
	TCA		/COMPLEMENT ERROR TO MAKE IT POSITIVE
	LMQ		/SAVE IT IN MQ
	LAW	-6	/DECODE 6 DIGITS
	DAC	PSWCH	/SAVE TEMPORARILY
	LAC	(IOER-1)	/SET UP MESSAGE POINTER
	DAC*	(X10)
DECOD	ECLA!LLS 3	/DECODE MQ - EVENT VARIABLE
	AAC	60	/ADD 60 TO DIGIT
DECODS	SAD	(60)	/IS IT A ZERO?
	JMP	NDECOD	/YES -- SUPPRESS LEADING ZEROES
	PAL		/SAVE AC
	LAC	DECRRA	/SET UP TO JUMP OVER ZERO SUPPRESS
	DAC	DECODS	/SET JUMP
	PLA		/RESTORE AC
DECODR	DAC*	X10	/STORE CHARACTER
	ISZ	PSWCH	/FINISHED?
	JMP	DECOD	/NO DECODE IT
	LAC	(IOERL-1)	/SET UP TO DECODE THE LUN
	DAC*	(X10)
	XCT*	IOERR	/PICK UP THE LUN SLOT
	IDIV		/DIVIDE BY 10 TO FIND DECIMAL LUN
	12
	PAX		/SAVE REMAINDER
	LACQ		/PICK UP QUOTENT
	AND	(17)	/MASK OF NUMBER
	AAC	60	/ADD 60
	DAC*	X10	/STORE IT
	PXA		/PICK UP REMAINDER AGAIN
	AND	(17)	/MASK IT OFF ALSO
	AAC	60	/ADD 60
	DAC*	X10	/STORE IT IN THE MESSAGE
	CAL	WRIOER	/WRITE ERROR ON OUTPUT TTY
	CAL	WTFOR	/WAIT FOR MESSAGE TO COMPLETE
	LAC	(2)	/FORCE TDV TO BE CALLED
	DAC	TDVEV
EXIT	LAC	(DAT2)	/DETACH ALL UNITS AND EXIT
	JMS	DETCHB
	LAC	(DAT3)
	JMS	DETCHB
	LAC	(DAT10)
	JMS	DETCHB
	LAC	(DAT11)
	JMS	DETCHB
	LAC	(DAT12)
	JMS	DETCHB
	LAC	(DAT13)
	JMS	DETCHB
	LAC	(DAT14)
	JMS	DETCHB
	LAC	TDVEV	/REQUEST TDV?
	SAD	(2)
	CAL	REQTDV	/YES
	CAL	(10)	/EXIT
/
DETCHB	0	/EXIT REQUEST
	DAC	DETLUN	/STORE LUN
	DAC	CLOLUN
	CAL	CLOSE	/CLOSE LUN
	CAL	DETACH	/DETACH LUN
	CAL	WTFOR
	JMP*	DETCHB	/RETURN
/
CLOSE	3400	/CLOSE
	0
CLOLUN	0	/LUN FOR CLOSE
/
DETACH	2500	/DETACH REQUEST
	WTFREV	/ EVENT VARIABLE
DETLUN	0	/LUN OF DETACH
/
REQTDV	1	/REQUEST TDV
	0
	.SIXBT	'TDV...'
	0
/
/
NDECOD	CLA		/SUPPRESS PRINTING
DECRRA	JMP	DECODR	/RETURN
/
/
IOERMS	ERMSE-IOERMS+1/2*1000+3
	0
	115	/M
	101	/A
	103	/C
	055	/-
	111	/I
	057	//
	117	/O
	040	/SP
	105	/E
	122	/R
	122	/R
	117	/O
	122	/R
	040	/SP
	114	/L
	125	/U
	116	/N
	040	/SP
IOERL	0	/LUN XX
	0
	040	/SP
IOER	.BLOCK	6	/EVENT VARIABLE
	000	/NULL
	015	/CR
ERMSE	012	/LF
/
TDVMES	TDVEN-TDVMES/2*1000+2
	0
	.ASCII	/MAC-TDV ERR/<15>
TDVEN=.
TDVEV	0	/TDV EVENT VARIABLE
/
WRTDVE	2700
	WTFREV	/EVENT VARIABLE FOR TDV ERR WRITE
	DAT3	/TDV OUTPUT DEVICE
	2	/IOPS ASCII
	TDVMES	/BUFFER POINTER
/
WRIOER	2700	/WRITE I/O ERROR MESSAGE
	WTFREV	/EVENT VARIABLE ADDRESS
	DAT3	/OUTPUT DEVICE
	3	/IMAGE ASCII
	IOERMS	/BUFFER ADDRESS
/
WTFOR	20	/WAIT FOR EVENT VARIABLE
	WTFREV	/EVENT VARIABLE ADDRESS
/
WTFREV	0	/EVENT VARIABLE
/
PSWCH=FILNMS	/TEMP
	.END
