	.TITLE COPYRIGHT
/
/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
/
/COPYRIGHT 1972,73 DEC, MAYNARD, MASS.
/
/EDIT #007	V5A	FEB. 15, 73
/	008	SEP 24, 73	CTL P RESTART + GET TASK CODE FROM PIREX
/	009	S.KRISH	26-OCT-73	SENTCB ROUTINE MOVED TO RESIDENTPORTION
/	010	S.KRISH	30-OCT-73	GENERAL FIXUP OF ALL PROBLEMS
/	011	S.KRISH	1-NOV-73	*****E ERROR MESSAGE BUG FIX
/	012	SK	6-DEC-73	4K,12K LOCAL MEMORY BUG FIX
/					OF INTERFACE
/	013	SK	14-JUN-74	1. FIX OUT OF TAPE BUG
/	014	BR	15-JULY-74	FIX API ON/OFF PROBLEM
/	015	BR	18-JUNE-75	XVM UPGRADE
/	016	BR	16-JULY-75	CHECK FOR MAC11 SIZE VS LMSZ
/					REMOVE NEED FOR ASM PARAM
/	017	MJH	20-AUG-75	DISCLAIMER
/	018	BLR	21-AUG-75	FIX BAD PARAM ERROR MESSAGE
/	019	BLR	17-SEP-75	TURN PREFETCH OFF
/	020	BLR	18-SEP-75	BOSS COMPATABILITY
/	021	BLR	11_NOV_75	FIX EXTENSION BUG
/
/
/
/THIS IS THE MACRO-11 INTERFACE THAT RUNS UNDER XVM/DOS IN
/CONJUNCTION WITH PIREX ON THE UC15.  IT WORKS EXACTLY SIMILAR
/TO THE MACRO-15, EXCEPT THAT MACRO DEFINITION FILE & PARAMETER
/FILE INPUT ARE NOT PERMITTED.  THESE HAVE TO BE PRESENT IN THE
/ASSEMBLED PROGRAM. CURRENT IMPLEMENTATION PERMITS ONLY THE
/'B' AND 'L' OPTIONS.
/COMMUNICATION BETWEEN THE INTERFACE AND THE MACRO-11 RUNNING UNDER
/THE 11 PROCESSOR IS THROUGH "TCMB11".  BOTH OPERATE AS A COOPERATIVE
/SEQUENTIAL PROCESSES. IN SHORT THEY MONITOR THE EVENT VARIABLES(EV)
/WHICH INDICATE THE NATURE OF THE ACTION AND BY WHOM IT WAS REQUESTED.
/MACRO-11 AND THE INTERFACE WILL ALWAYS RUN IN BANK 1.
/
/
/	20000	*************************
/		*			*
/		*			*
/	23263	*************************
/		*			*
/		*			*
/		*	MACRO-11	*
/		*			*
/		*			*
/		*			*
/		*************************
/		*			*
/	35760	*************************
/		*			*
/		*	MACINT		*
/		*			*
/		*			*
/		*			*
/		*************************
/		*			*
/	37637	*************************
/		*	BOOT		*
/		*************************
/
/
/
/
/TCBM11 EVENT VARIABLE(EV) CODE:	0 NO ACTION
/					POS. & NON ZERO, ACTION REQ BY 11(4=EOF)
/					NEG., ACTION REQ. BY 15
/
/
/
	.TITLE TASK CONTROL BLOCKS
	.ABS
	.LOC	15760
TCBM11=.
M11SW=.+4
BEV=.+5
LEV=.+10
MEV=.+13
SEV=.+16
SBCNT=.+17
SADD=.+20
	.LOC 16001
.SCOM=100
IPFH=701764			/IPF OFF INSTRUCTION FOR XVM SYSTEMS (BR-019)
/CONNECT TCB
/
/ SAME FORMAT AS TCBM11
/
TCBCON	0	/0. WORD
	601	/1.
CONEV	0	/2.
	0	/3.
	0	/4
	0	/5.
	23263	/6.
	0	/7.
	0	/10.
	0	/11.
	.TITLE RESTART/SHUT DOWN MACRO-11
/
/
CHKDNE	LAW -1	
	SAD ENDPRC		/DONE?
	SKP			/TES.
	JMP WAITEV		/NO. CONTINUE
	LAC MEV		/EOF REACHED. WAIT FOR 11 TO FINISH
	SAD (4		/11 DONE??
	SKP		/YES. PROCEED
	JMP WAITEV		/NO. WAIT UNTIL IT IS DONE
	.CLOSE -12
	.CLOSE -11
	LAC M11SW		/BIN OUT REQ. ??
	AND (100000
	SZA			/SKIP LEADR IF NO
	JMS LEADR		/PUNCH LEADER
	ISZ MACSW		/ RESTART MACRO-11?
	JMP REST		/YES. INITIALIZE AND RESTART.
	LAC MACTCD			/NO. DISCONNECT MACRO 11
	DAC CONEV+1
	LAC (TCBCON+20000
	JMS SENTCB
BYE	.EXIT
/
/
ENDP1	.CLOSE -11
	.INIT -11,0,REST+20000
	LAC EXTSAV
	DAC FEXTSN
	.SEEK -11,FILNAM+20000
	CLC
	DAC PASSW
	LAC	(2		/SET HEADER IN PDP-11 ASCII BUFFER
	DAC	BUF3+1
	DZM MEV
	.TITLE IDENTIFY & PROCESS I/O REQUEST
/
WAITEV	CLA
	SAD BEV
	SKP
	JMP BINOUT
	SAD LEV
	SKP
	JMP LSTOUT
	SAD MEV
	SKP
	JMP MESOTR
	SAD SEV
	JMP WAITEV+1
	LAC (40000
	SAD SEV			/EOF REACHED?
	JMP WAITEV		/YES. LOOP
SRCITR	JMS READIN		/READ NEXT RECORD OF SOURCE LINE
	DAC UPKAD		/STORE ADDRESS OF NEXT CHAR (RETURNED IN AC)
	LAC (BUF3+20003
	DAC PK11PT
	JMS PK1511
	LAC BYTCNT		/SET UP HEADER WORDS
	DAC BUF3+2
	LAC EOFSW		/EOF REACHED?
	SAD MIN1
	SKP		/YES.
	CLA!SKP		/NO
	LAC (40000		/SET EOF CODE IN EV
	DAC SEV
	JMP WAITEV
/
MESOTR	LAC MEV			/CHECK IF 11 IS DONE?
	SAD (4
	JMP CHKDNE+6			/YES. CLEAN UP AND EXIT
	SAD (20000
	JMP ENDP1
	JMS MESOUT
	DZM MEV
	JMP CHKDNE
/
LSTOUT	LAC (BUFAD3+20001		/UNPACK 11 ASCII
	DAC TEMP1
	LAC LEV+1
	JMS UNPACK
	JMS WRIM12		/.WRITE -12
	DZM LEV
	JMP CHKDNE
/
BINOUT	LAC BEV+1		/GET BUFFER ADDRESS
	CLL!RAR		/CONVERT TO WORD ADDRESS
	TAD MEMOFS		/RELOCATE & BUMP TO BYTE COUNT
	DAC TEMP		/SAVE IT
	LAC* TEMP		/GET BYTE COUNT
	AAC 4			/INCLUDE HWD'S
	DAC* TEMP		/STORE IN BUFFER
	TCA		/GET 2'S COMPLEMENT
	DAC PPFCNT		/SAVE IT
	LAC TEMP		/BUMP TO BYTE COUNT
	TAD MIN1
	DAC TEMP
	LAC (1			/SET HD WD '1'
	DAC* TEMP
	DZM CHKSUM		/RESET CHECK SUM
	DBI		/DISABLE API BREAKS (BR-016)
	IOF		/INTS OFF
PNCLP	LAC* TEMP
	JMS PUNCH
	LAC* TEMP
	RAL
	SWHA
	JMS PUNCH
	IDX TEMP
	JMP PNCLP
PUNCH	0		/PUNCH CHAR
	JMS	PUNCHD	/PUNCH DATA ON TAPE
	TAD CHKSUM		/GET CHECK SUM
	DAC CHKSUM		/SAVE IT
	ISZ PPFCNT
	JMP* PUNCH
	TCA			/GET 2'S COMPLEMENT OF CHECK SUM
	AND (377		/GET 8 BIT LSB'S
	JMS	PUNCHD	/PUNCH DATA
	ION			/TURN PI ON
	EBI		/ALLOW API AGAIN (BR-016)
	DZM BEV
	JMP CHKDNE
/
PUNCHD	0
	DAC	TEMP2	/TEMP SAVE DATA
	IORS		/CHECK PUNCH STATUS
	AND	L400	/OUT OF TAPE
	SZA
	JMP	IOPS4	/YES. REPORT
	LAC	TEMP2
	PSA		/PUNCH ALPHA-NUMERIC(ALL 8 BITS)
	PSF		/DONE?
	JMP	.-1	/NO. LOOP
	PCF		/YES. CLEAR FLAG
	JMP*	PUNCHD	/EXIT
/
LEADR	0
	DBI		/DISABLE API BREAKS (BR-016)
	IOF		/INTS OFF
	DZM CHKSUM		/RESET CHKSUM
	DZM PPFCNT		/RESET BYTE COUNT
	LAW -500		/SET UP LEADER PUNCH COUNT
	DAC PPLDRC
	CLA
PPLDLP	JMS PUNCHD		/PUNCH LEADER
	ISZ PPLDRC		/DONE??
	JMP PPLDLP		/NO.
	ION
	EBI		/ALLOW API AGAIN (BR-016)
	JMP* LEADR		/YES.
	.TITLE ROUTINE TO CONVERT PACKED 11 ASCII TO IMAGE ASCII
/
/THIS ROUTINE UTILIZES  SUBROUTINE UN11A 
/CALLING SEQUENCE:	11 ASCII BUFFER ADDRESS IN AC
/		 IMAGE ASCII IN BUF1
/		INITIALIZE 'TEMP1' TO .WRITE CAL BUFFER ADDRESS
UNPACK	0
	CLL!RAR			/CONVERT TO WORD ADDRESS
	TAD MEMOFS		/RELOCATE & BUMP TO BYTE COUNT
	DAC TEMP
	LAC* TEMP		/GET BYTE COUNT
	TCA			/GET 2'S COMPLEMENT
	DAC UN11CT		/INITIALIZE UN11A CHAR. COUNT
	DAC* TEMP1		/STORE IN .WRITE CAL
	LAC* TEMP		/GET BYTE COUNT
	AND (777		/CLEAR JUNK
	IAC
	CLL!RAR			/CONVERT TO WPC
	IAC			/INCLUDE HHWP
	SWHA			/LEFT JUSTIFY WPC
	AAC 3			/INCLUDE IMAGE ALPHA CODE
	DAC BUF1		/STORE IN BUFFER HEADER WORD
	DZM BUF1+1		/CLEAR CHKSUM
	LAC TEMP
	IAC
	DAC UN11PT		/SET UN11A PTR
	LAC (BUF1+20002
	DAC UN11BA		/SET UN11A BUFFER POINTER
	LAW -2
	DAC UN11SW		/SET UN11A BYTE SW
	JMS UN11A		/GET 11 ASCII CHARACTER
	LAC (BUFEND+20000		/ZERO REMAINING WORDS IN BUFFER
	SAD UN11BA		/BUFFER FULL?
	JMP* UNPACK		/YES.
	TCA			/NO.
	TAD UN11BA
	DAC TEMP
	IDX UN11BA
ZELOOP	DZM* UN11BA
	IDX UN11BA
	ISZ TEMP
	JMP ZELOOP
	
	JMP* UNPACK		/DONE, RETURN
	.TITLE SHIFTERS/UTILITIES
/
/
RIGHT4	0
	RTR; RTR
	JMP* RIGHT4
/
LEFT8	0
	JMS LEFT4
	JMS LEFT4
	JMP* LEFT8
/
LEFT4	0
	RTL; RTL
	JMP* LEFT4
/
/
SETBT3	0
	CLA!CLL
	IAC
	JMS RIGHT4
	JMP* SETBT3
/
	.TITLE OTHER ROUTINES
/
/ROUTINE THA WAITS FOR 'MEV' IN TCBM11 TO BE NON-ZERO
WTMEV	0
	LAC MEV
	SZA
	SKP
	JMP .-3
	JMP* WTMEV
/
/ROUTINE TO OUTPUT MESSAGES TO DAT -3 ON 15.
/ADDRESS OF MESSAGE BUFFER TAKEN FROM 'MEV+1' IN TCBM11
MESOUT	0
	LAC (BUFAD1+20001		/SET WORD COUNT INDIRECT POINTER
	DAC TEMP1		/FOR UNPACK
	LAC MEV+1		/GET BUFFER ADDRESS
	JMS UNPACK
	LAC (BUF1+20000		/GET .WRITE CAL BUFFER ADDRESS
	JMS WRITM3		/WRITE TO DAT -3
	JMP* MESOUT
/
/THIS ROUTINE UNPACKS IOPS 5/7 ASCII LINE INTO 11 ASCII
/USES 'GETCHR' AND 'PK11A' ROUTINES
/CALLING SEQUENCE:	SET UPKAD TO 15 ASCII BUFFER ADDRESS
/			SET PK11PT TO 11 ASCII BUFFER ADDRESS
/
PK1511	0
	CLL
	DZM BYTCNT		/RESET PK11A BYTE COUNT
	LAC (1
	DAC PKNUM		/RESET GETCHR 5/7 COUNTER
	LAW -2			/RESET PK11A BYTE SW
	DAC PK11SW
	JMS GETCHR		/GET NEXT CHAR FROM LINE
	SAD (15
	JMP .+3
	JMS PK11A
	JMP .-4			/NO.LOOP
	JMS PK11A
ENDLIN	LAC (12			/APPEND ASCIZ
	JMS PK11A
	JMP* PK1511
/
/THIS ROUTINE PACKS CHAR IN AC INTO PACKED 11 ASCII (7 BITS RIGHT
/ JUSTIFIED IN EACH BYTE.)
/CALLING SEQUENCE	SET PK11SW TO -2
/			SET PK11PT TO 11 ASCII BUFFER ADDRESS
/			CHAR TO BE PACKED IN AC
PK11A	0
	ISZ PK11SW		/WHICH POSITION?
	JMP LOWBYT		/LOW BYTE
HIBYT	JMS LEFT8		/HIGH BYTE
	AND (77400		/CLEAR JUNK
	XOR* PK11PT
	DAC* PK11PT
	IDX PK11PT
	LAW -2
	DAC PK11SW
	JMP LOWBYT+2
LOWBYT	AND L177		/CLEAR JUNK
	DAC* PK11PT
	IDX BYTCNT		/INCREMENT BYTE COUNT
	JMP* PK11A
/
SENTCB	0
	SIOR
	JMP	.-1
	LIOR			/ISSUE REQUEST
	AAC+2			/BUMP TO REV
	DAC	TMP1
	LAC*	TMP1
	SAD	(1		/REV=1?
	JMP*	SENTCB
	JMP	.-3
/
	.TITLE LITERALS/CONSTANTS
/
/
/
L177	177
L7	7
MACTCD	0
L10	10
TEMP	0
PKNUM	0
UPKAD	0
L170	170
TMP	0
CHRHLD	0
UN11PT	0
UN11SW	0
UN11CT	0
UN11BA	0
TMP1	0
TEMP2	0
B	102
L	114
CHRCT3	0
ENDPRC	0
EOFSW	0
HDWD	021002
MACSW	0
PK11PT	0
PK11SW	0
BYTCNT	0
TEMP1	0
EXTSAV	0
PASSW	0
PPFCNT	0
CHKSUM	0
PPLDRC	0
MEMOFS	0		/PDP-11 LOCAL MEMORY OFFSET FACTOR (BR-016)
L400	400		/LIT'RAL (BR-016)
L200	200		/LIT'RAL (BR-016)
SCOM4	.SCOM+4		/ENABLES WORD (BR-016)
SIOR=706001
LIOR=706006
IDX=ISZ
PSA=700204
PSF=700201
PCF=700202
RPL=705512
IOF=700002
EBI=705521
DBI=705522
ION=700042
ISA=705504
	.TITLE READ WRITE ROUTINES AND BUFFERS
/
/CALLING SEQUENCE:	BUFFER ADDRESS IN AC
WRITM3	0
	DAC BUFAD1		/SET BUFFER ADDRESS FOR CAL
	CAL+3*1000 -3&777	/.WRITE CAL TO DAT -3
	11
BUFAD1	XX
	XX			/WORD COUNT SET UP
	.WAIT -3
	JMP* WRITM3
/
READM2	0
	DAC .+3			/SET UP BUFFER ADDRESS FOR CAL
	CAL+2*1000 -2&777	/.READ CAL TO DAT -2. IOPS ASCII
	10
	XX
	777121			/MAXM. OF 80 CHARS
	.WAIT -2
	JMP* READM2
/
READIN	0
	LAC HDWD		/SET UP HEADER
	DAC BUF2
	DZM BUF2+1
	.READ -11,2,BUF2+20000,256	/READ SRC INPUT
	LAC BUF2
	AND (7
	SAD (5			/EOF?
	SKP		/YES. PROCESS LAST BLOCK
	JMP READS2		/NO.
MIN1	LAW -1 		/SET EOF SW
	DAC	EOFSW
	SAD PASSW		/PASS 1?
	DAC ENDPRC		/NO. PASS 2. SET END ASSEMBLY SW
	LAC (40002		/SET EOF SW IN 11 ASCII BUFFER
	DAC BUF3+1
READS2	LAC (BUF2+20002
	JMP* READIN
/
WRITM2	0
	DAC .+3			/SET UP BUFFER ADDRESS FOR CAL
	CAL+2*1000 -3&777	/.WRITE CAL TO DAT -2. IOPS ASCII(BR-021)
	11
	XX
	-40			/32. DECIMAL WORDS, 80 CHARS
	.WAIT -3		/(BR-021)
	JMP* WRITM2
WRIM12	0
	CAL+3*1000 -12&777	/IMAGE ASCII, DAT -12
	11			/.WRITE
BUFAD3	BUF1+20000
	XX			/WC SET UP
	.WAIT -12
	JMP* WRIM12
/
/
/IOPS ASCII BUFFER
BUF1	XX			/HEADER WORD SETUP
	0
	.BLOCK 214		/UP TO 140 CHARS (IN CASE OF LP)
BUFEND=.-1
/
FILNAM	XX		/INPUT FILE NAME (.SIXBIT)
	XX
FEXTSN	XX		/INPUT FILE EXTENSION (.SIXBIT)
/
	.TITLE GET CHAR FROM 15 ASCII BUFFER
/
/CALLING SEQUENCE:	DZM PKNUM
/		SET UPKAD TO POINT TO 15 ASCII BUFFER
/THIS ROUTINE UNPACKS CHARS, FROM IOPS 5/7 ASCII WORD PAIRS
/AND LEAVES THEM IN AC AND IN CHRHLD
/GLEANED FROM MACRO-15.
GETCHR	0
	LAC PKNUM		/PKNUM = 1,2,3,4, OR 5
	TAD	(JMP JMPTBL-1
	DAC .+2
	LAC* UPKAD
	0			/JMP TO CHAR 1-5
JMPTBL	JMP CHR1
	JMP CHR2
	JMP CHR3
	JMP CHR4
	JMP CHR5
CHR1	JMS LEFT8
	JMP GETEND
CHR2	JMS RIGHT4
	JMP GETEND
CHR3	RTL
	RAL
	AND L170
	DAC TMP			/SAVE LEFTMOS 4 BITS
	ISZ UPKAD
	LAC* UPKAD		/PICK REMAINING BITS OF CHAR
	JMS LEFT4
	AND L7			/GET RIGHTMOST 3 BITS
	XOR TMP
	JMP GETEND+1
CHR4	JMS RIGHT4
	JMS RIGHT4
	JMP GETEND
CHR5	RAR
	ISZ UPKAD		/UPDATE FOR NEXT 5/7 PAIR
	DZM PKNUM		/RESET CHARNUMBER
GETEND	AND L177
	DAC CHRHLD		/SAVE FOR LATER
	ISZ PKNUM
	JMP* GETCHR		/EXIT WITH CHAR IN AC
/
/ROUTINE TO GET NEXT NON-BLANK CHAR.  USES GETCHR
GTNCHR	0
	JMS GETCHR
	SAD (40			/SPACE?
	JMP .-2			/YES. GET NEXT CHAR
	JMP* GTNCHR
	.TITLE IOPS 11 ASCII UNPACKING ROUTINE
/
/CALLING SEQUENCE:	LOC	JMS UN11A
/		RETURN	LOC+1		IF MORE CHARS PRESENT
/			LOC+2		IF NONE PRESENT
/		SET UN11CT TO 2'S COMPLEMENT OF TOTAL BYTE COUNT
/		SET UN11PT TO ADDRESS OF 11 ASCII STRING
/		SET UN11SW TO -2
UN11A	0
	LAC* UN11PT		/GET LOW BYTE
	JMS CHAR		/EXTRACT CHAR & STORE IN 15 BUFFER
	LAC* UN11PT		/GET HIGH BYTE
	CLL!RAL
	SWHA		/RIGHT JUSTIFY CHAR
	JMS CHAR
	IDX UN11PT		/POINT TO NEXT WORD IN 11 BUFFER
	JMP UN11A+1		/LOOP
CHAR	0
	AND L177		/GET CHAR 
	SAD (13			/VT?
	LAC (175		/YES CHANGE TO ALT (DOS-11)
	DAC* UN11BA		/STORE IN BUFFER
	IDX UN11BA		/POINT TO NEXT WORD IN 15 BUFFER
	ISZ UN11CT		/INCREMENT BYTE COUNT
	JMP* CHAR		/NOT YET DONE. RETURN
	LAC (175
	DAC* UN11BA
	JMP* UN11A		/DONE. EXIT TO CALLER
INTBDY=.
	.TITLE START MACRO-11
/
/
REST1	LAC MACTCD		/CTL 'P' RESTART. DISCONNECT & CONNECT MAC11
	DAC CONEV+1
	LAC (TCBCON+20000
	JMS SENTCB
	LAC MACTCD
	XOR L400
	DAC CONEV+1
	LAC (TCBCON+20000
	JMS SENTCB
	.CLOSE	-11		
	.CLOSE	-12
REST0	LAC (TCBM11+20000	/RUN MACRO-11!!!!!
	SIOR
	JMP .-1
	LIOR
REST	IPFH		/TURN PREFETCH OFF TO IMPROVE SPEED (BR-019)
	DZM	BEV	/INITIALIZE ALL EV'S (BR-019)
	DZM LEV
	DZM SEV
	DZM	EOFSW		/RESET EOF SW
	DZM ENDPRC		/RESET END OF ASSEMBLY SWITCH
	DZM PASSW		/RESET PASS 1 SW
	LAC (2		/RESET EOF SW IN 11 ASCII BUFFER
	DAC BUF3+1
	DZM MEV		/RESET MEV
P2	JMS	WTMEV		/WAIT FOR MACRO-11 TO IDENTIFY
	JMS MESOUT	/ SAY HELLOW
	DZM MEV		/HOLD ON FOR >
	JMS WTMEV
	JMS MESOUT	/INDICATE READY TO PROCESS 'CS'(>)
READCS	LAC (BUF1+20000	/GET INPUT BUFFER ADDRESS
	JMS READM2	/READ CS
	.TITLE COMMAND STRING PROCESSOR
/INPUT COMMAND STRING IS CHECKED FOR LEGALITY. IF FOUND LEGAL THE
/PRESENCE OF SOURCE FILE UNDER THE CURRENT 'UIC' IS VERIFIED.
/IF COMMAND STRING IS FOUND ILLEGAL A '?' IS TYPED AND CSP
/IS RESTARTED(INDICATED BY'>'TYPOUT). IF FILE NOT FOUND/NAME ERROR
/IT IS REPORTED.
	LAC (BUF1+20002	/SET 'GETCHR' BUFFER POINTER
	DAC UPKAD
	LAC (1
	DAC PKNUM	/RESET 'GETCHR' 5/7 COUNTER
	JMS GTNCHR	/GET NEXT NON BLANK CHAR
	SAD B		/'B' OPTION?
	JMP BINYES	/YES
	SAD L		/'L' OPTION?
	JMP LSTYES	/YES
	SAD (137	/PLAIN ASSEMBLY?
	SKP		/YES
	JMP BADCS	/BAD CS REPORT
	DZM M11SW	/INDICATE PLAIN ASSEMBLY IN TCBM11
	JMP SWEND	/PROCESS FILE NAME
/
BINYES	JMS SETBT3	/INDICATE IN TCBM11
	DAC M11SW
	JMS GTNCHR	/GET NEXT NON-BLANK CHAR
	SAD L		/'L' OPTION ALSO?
	JMP BOTH	/YES
	SAD (137	/BIN ONLY?
	JMP SWEND	/YES. PROCESS FILE NAME
/
BADCS	LAC (QUESTM+20000	/GET MESSAGE BUFFER ADDRESS
	JMS WRITM2
	LAC*	(.SCOM+52	/GET BOSS WORD (BR-020)
	SPA			/SKIP IF NOT IN BOSS MODE (BR-020)
	JMP	BYE		/EXIT IF BOSS MODE ERROR (BR-020)
	LAC (REIDTY+20000	/PRINT '>' ON CONCOLE DEVICE
	JMS WRITM2
	JMP READCS	/GO REREAD CE
/
LSTYES	JMS SETBT3	/INDICATE IN TCBM11
	RAR
	DAC M11SW
	JMS GTNCHR	/GET NEXT NON-BLANK CHAR
	SAD B		/'B' ALSO?
	JMP BOTH	/YES
	SAD (137		/'L' ONLY?
	JMP SWEND	/YES. PROCESS FILE NAME
	JMP BADCS	/BAD CS REPORT
/
BOTH	LAC (140000	/INDICATE IN TCBM11
	DAC M11SW
	JMS GTNCHR
	SAD (137		/_??
	SKP		/YES.
	JMP BADCS		/NO. COMPLAIN
/
/THE FILE NAME IS NOT CHECKED FOR LEGALITY. UP TO 6 CHAR FILE NAME
/AND 3 CHAR EXTENSION SEPARATED BY SPACE(S) IS PERMITTED.
/PRESENCE OF INPUT FILE IS VERIFIED BY .FSTAT. IF NOT FOUND/NAME TOO
/LONG IT IS REPORTED
SWEND	LAW -11		/SET FILE NAME+EXTENSION CHAR COUNT
	DAC CHRCT3
	DZM FILNAM	/RESET FILENAME
	DZM FILNAM+1
	LAC SRCEXT	/SET DEFAULT EXTENSION (SRC)
	DAC FEXTSN
	LAC (EXTSN+20000	/PROCESS EXTENSION WHEN SPACE FOUND
	DAC TEMP
	CLL
	JMS GTNCHR	/GET NEXT NON-BLANK CHARACTER
	JMS LEFT8	/LEFT JUSTIFY
	JMS LEFT4
	AND (770000	/CLEAR JUNK
	DAC FILNAM
	ISZ CHRCT3	/INCREMENT CHR COUNT
	JMS FILCHR	/GET NEXT CHR IN FILE NAME
	JMS LEFT4	/SHIFT LEFT 6
	RTL
	XOR FILNAM
	AND (777700	/CLEAR JUNK
	DAC FILNAM	/STORE IN FILE NAME
	JMS FILCHR
	XOR FILNAM
	DAC FILNAM
	JMS FILCHR
	JMS LEFT8
	JMS LEFT4
	AND (770000	/CLEAR JUNK
	DAC FILNAM+1
	JMS FILCHR
	JMS LEFT4
	RTL
	XOR FILNAM+1
	AND (777700	/CLEAR JUNK
	DAC FILNAM+1
	JMS FILCHR
	XOR FILNAM+1
	DAC FILNAM+1	/NEXT CHAR MUST BE SPACE
	JMS	FILCHR		/FILCHR HANDLES NON SPACE (BR-021)
	JMP	BADFNM		/NON SPACE,NON CR,NON ALT IS BAD (BR-021)
EXTSN	LAW -3		/3 CHAR EXTENSION ONLY
	DAC CHRCT3
	LAC (FILCHR+20004	/DO NOT IGNORE SPACE
	DAC TEMP
	JMS GTNCHR
	SAD (15	/CR?
	JMP RSTMAC	/YES. SET RESTART MAC-11 SW
	SAD (175	/ALT?
	JMP ENDMAC	/YES. SET END MAC-11 SW
	JMS LEFT8	/SHIFT LEFT 12
	JMS LEFT4
	AND (770000	/CLEAR JUNK
	DAC FEXTSN	/STORE FILE EXTENSION
	JMS FILCHR
	JMS LEFT4
	RTL
	XOR FEXTSN
	AND (777700	/CLEAR JUNK
	DAC FEXTSN
	JMS FILCHR
	XOR FEXTSN
	DAC FEXTSN
	JMS FILCHR	/SHOULD NEVER RETURN!!!!!!!
/
/CHECK PRESENCE OF FILE
ENDCSP	.FSTAT -11,FILNAM+20000
	SNA
	JMP BADFNM		/FILE NOT FOUND
	.SEEK -11,FILNAM+20000
	LAC FEXTSN
	DAC EXTSAV
	LAC LSTEXT		/ISSUE .ENTER IN CAS DAT -12
	DAC FEXTSN		/IS FILE ORIENTED
	.ENTER -12,FILNAM+20000
	LAC M11SW		/BIN OUT REQ. ??
	AND (100000
	SZA		/SKIP LEADR IF NO
	JMS LEADR		/PUNCH LEADER
	DZM MEV		/TELL MACRO-11 TO CONTINUE
	JMP WAITEV
/
/ROUTINE TO GET NEXT CHAR IN FILE NAME
/ CONTROL TRANSFERRED TO 'EXTSN' WHEN SPACE ENCOUNTERED
/			'ENDCSP' WHEN CR/ALT ENCOUNTERED
FILCHR	0
	JMS GETCHR
	SAD (40			/SPACE/
	JMP* TEMP		/GO TO APPROPRIATE LOC DEFINED BY TEMP
	SAD (15			/CR?
	JMP RSTMAC		/YES. RESTART MACRO-11
	SAD (175		/ALT.?
	JMP ENDMAC		/YES. SET END MACRO-11 SW
	AND (77			/.SIXBT
	ISZ CHRCT3		/INCREMENT CHAR COUNT
	JMP* FILCHR
	JMP BADFNM		/FILE NAME TOO LONG. REPORT
/
RSTMAC	DZM MACSW		/SET RESTART MACRO-11 SW
	JMP ENDCSP
/
NOUC	LAC	(NOUC15+20000	/GET ERROR MESSAGE ADR (BR-015)
MSG	JMS	WRITM2		/TYPE IT OUT (BR-015)
	JMP	BYE		/DEPART TO DOS (BR-015)
BADMC	LAC	(MACBAD+20000	/GET BAD MACRO IMAGE MESSAGE (BR-016)
	JMP	MSG		/WRITE IT OUT AND EXIT (BR-016)
/
ENDMAC	CLC			/SET END MACRO-11 SW
	DAC MACSW
	JMP ENDCSP
/
BADFNM	LAC (NAMERR+20000		/GET MESSAGE ADDRESS IN AC
	JMP BADCS+1
/
REIDTY	002002
	0
	.ASCII	'>'<175>
/
QUESTM	002002
	0
	.ASCII	'?'<15>
/
NAMERR	005002
	0
	.ASCII	'NAME ERROR/TOO LONG'<15>
NOUC15	005002		/NO UC15 ERROR MESSAGE (BR-015)
	000000
	.ASCII	'UC15 NOT ENABLED'<15>
/
/PAPER TAPE PUNCH OUT OF TAPE
/
IOPS4	LAW	4	/ERROR #
	STL		/TURN NULLS INTO SPACES
	JMS*	(.SCOM+37	/EXPANDED ERROR DIAGNOSTIC
	JMP	PUNCHD	/RETRY
	LAW	-1
	.SIXBT	'PP'
LSTEXT	.SIXBT	'LST'
SRCEXT	.SIXBT	'SRC'
MEMTAB	-17776		/8K OFFSET
	-27776		/12K OFFSET
/
/
	.LTORG
INTEND=.
	.TITLE RELOCATE INTERFACE & MACRO-11
	.LOC	17500
/ THE FOLLOWING SPACE IS USED FOR BUFFERS AFTER INITIALIZATION
/IOPS ASCII READ BUFFER
BUF2=.
BUF3=BUF2+42			/INPUT LINE ASCII BUFFER, FOR PDP-11
/
DSTART	LAC (20000		/ RELOCATE TO BANK 1
	DAC* L10
RELOOP	LAC 1
	IDX .-1
	DAC* 10
	LAC* L10
	SAD (37777		/DONE?
	JMP* (START+20000		/YES. START EXECUTING 
	JMP RELOOP		/NO. CONTINUE
	.TITLE INITIALIZE MACRO-11 & INTERFACE
START=.
	LAC	(20000+BUF3+2*2
	DAC*	(SBCNT+2000
	LAC	(20000+BUF3+3*2
	DAC*	(SADD+20000
ST2	LAC*	SCOM4	/GET SCOM ENABLES WORD (BR-015)
	AND	(000002		/IS UC15 ENABLED (BR-015)
	SNA			/SKIP IF UC15 NENABLED (BR-015)
	JMP	NOUC		/UC15 NOT ENABLED-GIVE ERROR (BR-015)
	LAC	(TCBCOR+20000	/GET MAC11 TASK CODE
	JMS	SENTCB
	LAC COREV+1
	AND L177
	IAC
	DAC MACTCD
	XOR L400
	DAC CONEV+1
	XOR L200
	DAC TCBM11+1
	LAC	CLMSZ		/GET LOCAL MEMORY SIZE (BR-016)
	SAD*	(23261		/IS IT SAME AS IN IMAGE (BR-016)
/*********************************************************************************
/	NOTE ABOVE CONSTANT CRITICAL
/**********************************************************************************
	SKP			/YES - GO COMPUTE OFFSET (BR-016)
	JMP	BADMC		/NO - MACRO IMAGE BAD (BR-016)
	CLL			/SET UP SHIFT (BR-016)
	LRS	15		/COMPUTE POINTER INTO OFFSET TABLE (BR-016)
	TAD	(MEMTAB-2+20000	/POINT TO ENTRY IN OFFSET TABLE (BR-016)
	DAC	CLMSZ		/SAVE IN TEMP (BR-016)
	LAC*	CLMSZ		/GET OFFSET (BR-016)
	DAC	MEMOFS		/SAVE IT (BR-016)
	LAC	(TCBCON+20000		/CONNECT MACRO-11
	JMS SENTCB
/
/INITIALIZE ALL DAT SLOTS
P1	.INIT	-3,1,REST1+20000	/CONSOLE DEV FOR MESSAGE OUTPUT
	.INIT	-12,1,REST1+20000	/LISTING DEV
	.INIT	-11,0,REST1+20000	/INPUT DEV FOR SOURCE
	LAC	(21002			/SET UP HEADER WORDS IN BUFFER
	DAC	BUF2
	DZM	BUF2+1
	LAC	(126
	DAC	BUF3
	LAC	(2
	DAC	BUF3+1
	JMP REST0		/START MACRO-11
/
/ GET MAC11 TASK CODE
TCBCOR	0	/0.	API LVL + TRAP ADD
	601	/1.	NO INT + SD TASK
COREV	0	/2.	REV
	1000	/3.	FUN=COREPT=2(HIGH BYTE)
CLMSZ	0		/LOCAL MEMORY SIZE
	0		/FIRST FREE ADR. (BR-016)
	0		/UNUSED (BR-016)
	0		/NR OF FREE WORDS (BR-016)
MACBAD	005002
	000000
	.ASCII	'IMPROPER MAC11 IMAGE'<15>
	.END DSTART
