	.TITLE BFKM9
 
/ .... EDIT #12 .... 13 DEC 69
 
/NON-RESIDENT KEYBOARD MONITOR FOR
/	THE PDP-9 ADVANCED SOFTWARE
/	BACKGROUND/FOREGROUND SYSTEM.
/
/	COPYRIGHT 1969
/	DIGITAL EQUIPMENT CORPORATION
/	MAYNARD, MASSACHUSETTS
 
/DAVE LENEY - 1 FEB 69
/JEAN-CLAUDE P. PROTEAU
 
/***N.B.
/	IF SYSTEM LOADER .LOC IS CHANGED,
/	CHANGE REGISTER LABELLED .SYSLD
/	(ON NEXT PAGE) AND SIZE.
/	CHANGE .SCOM+3 IN RESMON. ALSO
/	MAKE CHANGES IN SYSBLK.
/
/	IF BFKM9 .LOC IS CHANGED, CHANGE
/	REGISTERS IN RESMON AND SYSBLK.
/	MODIFY SYSBLK IF SIZE CHANGES.
 
	.ABS
	.LOC 12000
 
/PARAMETER ASSIGNMENTS
 
.SCOM=100
IDX=ISZ			/IF SKIP NEVER EXPECTED
 
/NON-RESIDENT MONITOR INITIALIZATION
/RESIDENT MONITOR TRANSFERS CONTROL HERE.
 
	JMP MONINT
 
/THE FOLLOWING REGISTER IS A POINTER USED BY SYSTEM GENERATOR
/TO LOCATE SYS GEN INFORMATION WHICH RESIDES IN BUFFER.
 
	.SGINF
 
	.EJECT
/PHYSICAL LAYOUT OF BFKM9.
/
/ 1.	ROUTINE TO LOAD .SYSLD
/ 2.	KEYBOARD LISTENER
/ 3.	MONITOR COMMAND DECODER
/ 4.	$LOG
/ 5.	$REQUEST
/ 6.	$ASSIGN
/ 7.	$DIRECT
/ 8.	$NEWDIR
/ 9.	$FILES
/ 10.	$FCONTROL
/ 11.	$BCONTROL
/ 12.	FGD .DATS CHANGED SUBR.
/ 13.	$FCORE
/ 14.	$INUSE
/ 15.	$SHARE
/ 16.	$NOSHARE
/ 17.	$VC38
/ 18.	$7CHAN
/ 19.	$9CHAN
/ 20.	$MPON
/ 21.	$MPOFF
/ 22.	BGD .DATS CLEARED SUBR.
/ 23.	ERROR MESSAGES
/ 24.	PUTI, PUT SUBRS. (PACK IN 5/7 ASCII)
/ 25.	GETSI, GETS SUBRS. (UNPACK .SIXBT)
/ 26.	PUTSI, PUTS SUBRS. (PACK IN .SIXBT)
/ 27.	FETCH SUBR. (GENERALIZED UNPACK-PACK SUBR.)
/ 28.	SEARCH SUBR. (GENERALIZED TABLE LOOKUP SUBR.)
/ 29.	FETCHN SUBR. (CONVERT INPUT TO A SIGNED NUMBER)
/ 30.	OCTOUT SUBR. (OCTAL TO 5/7 ASCII CONVERSION)
/ 31.	SMALL UTILITY SUBRS.
/ 32.	IFIOIN SUBR. (COMPARE DATA WITH .IOIN TABLE)
/ 33.	IFMUD SUBR. (IS HANDLER MULTI-UNIT VERSION?)
/ 34.	TYPE, TYPEX SUBRS. (TYPE OUT)
/ 35.	VARIABLE STORAGE
/ 36.	BUFFERS (CONTAINING INITIALIZATION CODE)
/ 37.	BF9CMD (LIST OF LEGAL COMMANDS)
/ 38.	PRGCMD (LIST OF LEGAL PROGRAM CALLS)
/ 39.	CLEANUP CODE PRIOR TO LOADING .SYSLD
/ 40.	GETI, GET SUBRS. (UNPACK 5/7 ASCII)
/ 41.	.IOTAB (TABLE OF DEVICE HANDLERS)
 
	.EJECT
/LOW CORE (IN NON-RES MON) ROUTINE TO
/	BRING IN SYSTEM LOADER
 
GETSYS	.TRAN	-7,0,56,14000,2048
 
.SYSLD=.-2		/SYSTEM LOADER LOAD AND START ADDRESS.
 
	.WAIT	-7
 
	.CLOSE	-7
 
	JMP*	.SYSLD
 
	.EJECT
/KEYBOARD LISTENER
 
/THIS ROUTINE REQUESTS AND ACCEPTS
/	COMMANDS FROM THE CURRENT
/	MONITOR INPUT DEVICE (FOREGROUND
/	CONTROL TELETYPE, BACKGROUND CONTROL
/	TELETYPE, OR BATCH DEVICE).
 
START	.INIT -3,1,START		/SETUP ^P RETURN ADDRESS.
 
	.WAIT -7			/WAIT FOR DT TO STOP.
 
	JMS TYPE
	BF9
 
.KLIST	JMS	TYPE		/PRINT $
	DOLLAR
 
KLREAD	.READ	-2,2,BUFFER-2,64
 
	.WAIT	-2
 
	JMS	ALTSCN		/DOES COMMAND END WITH ESC
L.SKP	SKP			/YES
	JMP	.MCD		/NO
 
	.CLOSE	-3		/SUPPLY CARRIAGE-RETURN
 
	JMP	.MCD
 
BF9	.ASCII	/XKM9 V1A/<15>
DOLLAR	.ASCII	/$/<175>
	.LOC	.-1
 
	.EJECT
/MONITOR COMMAND DECODER
 
/THIS ROUTINE CHECKS FOR TWO TYPES
/	OF COMMANDS:
/	1. MONITOR COMMANDS
/	2. SYSTEM LOADER COMMANDS
 
.MCD	DZM	COMAND		/CLEAR BUFFER
	DZM	COMAND+1
	DZM	COMAND+2
	DZM	COMAND+3
 
	JMS	FETCH		/GET COMMAND
L.BUF	BUFFER			/FROM INPUT BUFFER (.ASCII)
	JMS	GETI
	JMS	GET
	COMAND			/TO COMMAND BUFFER (.SIXBT)
	JMS	PUTSI
	JMS	PUTS
 
	JMP	MCDEND		/NULL COMMAND.
 
	JMS	SEARCH		/TEST FOR MONITOR COMMANDS
	BF9CMD
	JMS	GETSI
	JMS	GETS
	JMS	PUTSI
	JMS	PUTS
	COMAND
	-4
 
	JMP	.+5		/NOT MONITOR COMMAND
	LAC*	CMDADR		/GET PROCESSING ROUTINE ADDRESS
	XOR	BANKBT
	DAC	CMDADR
	JMP*	CMDADR		/DISPATCH
 
	JMS	SEARCH		/TEST FOR SYSTEM LOADER COMMANDS
	PRGCMD
	JMS	GETSI
	JMS	GETS
	JMS	PUTSI
	JMS	PUTS
	COMAND
	-4
 
	JMP	ILLCMD		/ILLEGAL COMMAND
	LAC*	CMDADR		/GET COMMAND WORD
	JMP	SYSLDR
MCDEND	JMS	FINISH		/BETTER HAVE NO MORE PRINTING CHARS.
	JMP	.KLIST		/YES - EMPTY LINE
 
	.EJECT
/LOG PROCESSOR
 
/A LOG COMMAND IS FOR USER'S NOTES AND
/	MUST BE TERMINATED BY AN ALTMODE.
/	IF THE COMMAND IS TERMINATED BY A
/	CARRAIGE RETURN, THE NEXT LINE IS
/	ASSUMED TO BE A CONTINUATION OF
/	THE LOG COMMAND.
 
LOG	JMS	ALTSCN		/TEST FOR ALTMODE
	JMP	.KLIST		/COMMAND FINISHED
 
LOG1	JMS	TYPE
	SPACE4
 
LOG2	.READ	-2,2,BUFFER-2,64
 
	.WAIT	-2
 
	JMS	ALTSCN		/END OF COMMAND?
	SKP			/ALT MODE FOUND - YES
	JMP	LOG1		/NO
 
	.CLOSE	-3
 
	JMP	.KLIST
 
SPACE4	.ASCII	/    /<175>
 
	.EJECT
/REQUEST PROCESSOR
 
/LEGAL FORMATS:
/	1.REQUEST FOR ENTIRE .DAT TABLE
/	2.REQUEST XXX FOR .DAT USAGE
/		BY A SYSTEM PROGRAM WHERE
/		XXX IS FOUND IN PRGCMD
/	3.REQUEST .DAT (-)N FOR CONTENTS
/		OF A PARTICULAR .DAT ENTRY
 
REQUES	LAC	L.SKP		/(SKP
	DAC	RQINSW
	JMS	ENDLIN		/ANY ARGUMENTS?
	JMP	REQALL		/NO
	JMS	CURCMD		/YES
	JMP	REQALL		/STILL EMPTY COMMAND
	LAW	-1
	TAD	FETCHQ		/SUBTRACT 1
	DAC	REQMN1
	DZM*	PUTS4		/CLEAR NEXT WORD
 
	JMS	SEARCH		/CHECK ARGUMENT
	PRGCMD
	JMS	GETSI
	JMS	GETS
	JMS	PUTSI
	JMS	PUTS
	COMAND			/COMMAND TO BE TESTED
REQMN1	XX			/NO. OF WORDS
 
	JMP	ILLARG		/ILLEGAL ARGUMENT
	IDX	CMDADR		/PAST .SYSLD INFO
	LAC*	CMDADR
REQPSV	DAC	REQCMP		/SAVE TABLE POINTER
	SAD	L400K		/IS IT .DAT TYPE?
	JMP	REQOK		/YES - SKIP TEST
	XOR	BANKBT
	DAC	REQCMP
	JMS	FINISH		/BETTER HAVE NO MORE PRINTING CHARS.
	JMP	REQOK
REQALL	JMS	FINISH		/TERMINATE INPUT LINE.
	LAC	(RALLB
	XCT	SKPBGD
	LAC	(RALLF+400000
	JMP	REQPSV
REQOK	LAC	REQCMP
	AND	L400K
	TAD*	(.SCOM+26
	SNA
	JMP	ILLARG		/ILLEGAL ARGUMENT
	LAC	REQCMP		/LEGAL COMMAND FOR FOREGROUND
	SAD	L400K		/IS IT .DAT COMMAND
	JMP	REQDAT		/YES - PROCESS
 
	JMS	TYPE		/NO - PRINT HEADER
	DATHDR
 
	LAC*	REQCMP		/GET REQUEST TABLE SIZE
	DAC	REQSZE
	IDX	REQCMP		/TO FIRST ENTRY
MIN1K=.
REQLOP	LAW	17000
	AND*	REQCMP		/.DAT SLOT NUMBER
	DZM	RQALLP
	SPA
	XOR	(777		/MAKE 18 BIT NEG
	SPA!CLL
	CML
	JMS	ROT6R
	RTR
	RAR
	DAC	RQDATN		/.DAT SLOT #
	SZA!CLA!CMA
	JMP	RQPLOP
	DAC	RQALLP		/SET FOR ALL POSITIVE SLOTS
	IDX	RQDATN		/SET TO SLOT 1
RQPLOP	LAC	L.BUF		/(BUFFER
	JMS	PUTI		/INIT OUTPUT
	JMS	PUT40		/SPACE
	JMS	PUT		/AND ANOTHER SPACE
	LAC	RQDATN		/GET .DAT #
	SPA!CLA			/MINUS OR PLUS .DAT
	LAC	L15		/BUILD MINUS
	TAD	(40		/MINUS OR SPACE
	JMS	PUT
	LAC	RQDATN
	SPA			/POSITIVE OR NEGATIVE?
	JMS	TWOS		/MAKE POSITIVE
	JMS	OCTOUT		/PUT NUMBER IN BUFFER
	LAC	L11
	JMS	PUT		/TAB
	JMS	PUT40		/SPACE
	JMS	REQDEV		/OUTPUT DEVICE NAME AND UNIT
	LAC	L11
	JMS	PUT		/TAB
	LAC*	REQCMP
	AND	(777		/GET MESSAGE OFFSET
	TAD	(MS0		/ADD BASE ADDR
	JMS	GETSI		/INIT MOVE
REQL2	JMS	GETS		/GET CHAR
	SNA			/LAST CHAR?
	JMP	REQL3		/YES
	JMS	PUT		/NO - PACK IT
	JMP	REQL2
REQL3	LAC	L15
	JMS	PUT		/PACK CR
	JMS	TYPEX		/TYPE FROM BUFFER-2
	LAC	RQALLP		/POSITIVE .DATS?
	SNA
	JMP	RQNALP		/NO
	IDX	RQDATN		/YES - NEXT SLOT
	LAC	RQDVDT
	TAD	L1
	SAD*	DATPTR		/ALL DONE?
	JMP	.KLIST		/YES
	JMP	RQPLOP		/NO
RQNALP	IDX	REQCMP
	ISZ	REQSZE		/ANY MORE
	JMP	REQLOP		/YES
	JMP	.KLIST		/NO
REQDAT	LAC	(BUFFER+100
	JMS	PUTI		/INIT OUTPUT
	JMS	PUT40		/2 SPACES
	JMS	PUT
REQDTL	JMS	ENDLIN		/ANY MORE?
	JMP	REQL3X		/NO - CLEAN UP
	JMS	FETCHN		/YES - GO GET IT
	JMS	FINISH		/EMPTY-TERMINATE LINE.
	DAC	RQDATN		/SAVE .DAT NUMBER
	JMS	CHKDAT		/LEGAL .DAT #?
	JMP	ILLDAT		/NO - ERROR
	JMS	REQDEV		/OUTPUT DEV AND UNIT
	JMS	PUT40		/OUTPUT SPACE
	JMP	REQDTL		/GO TEST FOR MORE
REQL3X	LAC	L15
	JMS	PUT
 
	JMS	TYPE
	BUFFER+100
 
	JMP	.KLIST
 
REQDEV	0
 
RQINSW	XX
	JMP	.+4
	JMS	SAVGET		/SAVE GET POINTERS
	LAC	RQDATN		/.DAT #
	TAD	DATPTR		/.DAT POINTER
	DAC	RQDVDT		/.DAT ENTRY POINTER
	LAC*	RQDVDT		/.DAT ENTRY
	SNA
	JMP	RQNONE		/NO ENTRY
	AND	(200000
	SZA
	JMP	RQTTA		/LT19 ENTRY
	LAC*	RQDVDT		/.DAT ENTRY
	SMA
	JMP	RQNORM		/NORMAL ENTRY
	SAD	DATM7S		/CONTENTS OF .DAT -7
	JMP	RQSYSD		/SYSTEM DEVICE
	XCT	SKPBGD
	JMP	DATERR		/DON'T CHECK BATCH IF FGD
	SAD	DATBCH
	JMP	RQBATC		/BATCH DEVICE
	JMP	DATERR		/INTERNAL ERROR
RQNONE	LAC	(NONE		/GET "NONE"
RQOUTP	DAC	RQADR1		/PUT IN FETCH CALL
 
	JMS	FETCH
RQADR1	XX			/ADDRESS OF OUTPUT STRING
	JMS	GETI
	JMS	GET
L.NOP	NOP
	NOP
	JMS	PUT
 
	NOP
REQOUT	JMS	RESGET		/RESTORE GET POINTERS
	JMP*	REQDEV
RQSYSD	LAC	(SYSDEV		/GET SYSTEM DEVICE
	JMP	RQOUTP
RQBATC	LAC	(BATDEV		/GET BATCH DEVICE
	JMP	RQOUTP
RQTTA	LAC*	RQDVDT		/.DAT ENTRY
	AND	(177777
	DAC	RQUNIT		/SAVE UNIT #
	LAC	L1		/TTA DEV IS NUMBER 1
	JMP	RQDEVN
RQNORM	AND	(160000		/GET UNIT #
	CLL
	JMS	ROT6L
	DAC	RQUNIT		/SAVE UNIT #
	LAC*	RQDVDT		/.DAT ENTRY
	AND	(177		/DEV HANDLER #
RQDEVN	STL			/TIMES 4 + 2
	RTL			/TO SKIP CONTROL WORDS.
	TAD	L.IOTB		/TABLE ADDRESS (.IOTAB
	DAC	.+2
 
	JMS	FETCH		/GET HANDLER NAME
	XX
	JMS	GETI
	JMS	GET
	NOP
	NOP
	JMS	PUT
 
	NOP
	LAC	RQUNIT		/GET UNIT #
	JMS	OCTOUT		/OUTPUT AS OCTAL
	JMP	REQOUT		/GO RESET GET AND EXIT
 
	.EJECT
/MESSAGE TYPEOUT TABLES FOR REQUEST
/	COMMAND PROCESSOR
 
/TABLE FORMAT:
/	WD0 IS TWOS COMPLEMENT NUMBER OF ENTRIES
/	WD1 TO WDN ARE ENTRIES
 
/ENTRY FORMAT:
/	BITS 0 TO 8 IS .DAT SLOT NUMBER
/	BITS 9 TO 17 IS MESSAGE ADDRESS MINUS MS0
 
REXECU	-2
	-4&777*1000 MS11-MS0
	-3&777*1000 MS17-MS0
RPATCH	-4
	-14&777*1000 MS3-MS0
	-10&777*1000 MS27-MS0
	-3&777*1000 MS17-MS0
	-2&777*1000 MS16-MS0
RCHAIN	-6
	-6&777*1000 MS13-MS0
	-5&777*1000 MS21-MS0
	-4&777*1000 MS20-MS0
	-3&777*1000 MS17-MS0
	-2&777*1000 MS16-MS0
	-1&777*1000 MS10-MS0
RMACRO	-6
	-13&777*1000 MS13-MS0
	-12&777*1000 MS12-MS0
	-11&777*1000 MS11-MS0
	-10&777*1000 MS27-MS0
	-3&777*1000 MS17-MS0
	-2&777*1000 MS16-MS0
RF4	-5
	-13&777*1000 MS13-MS0
	-12&777*1000 MS12-MS0
	-11&777*1000 MS11-MS0
	-3&777*1000 MS17-MS0
	-2&777*1000 MS16-MS0
REDIT	-5
	-15&777*1000 MS14-MS0
	-14&777*1000 MS3-MS0
	-10&777*1000 MS27-MS0
	-3&777*1000 MS30-MS0
	-2&777*1000 MS16-MS0
RLOAD	-5
	-7&777*1000 MS10-MS0
	-5&777*1000 MS21-MS0
	-4&777*1000 MS20-MS0
	-3&777*1000 MS17-MS0
	-2&777*1000 MS16-MS0
RDDT	-6
	-7&777*1000 MS10-MS0
	-5&777*1000 MS21-MS0
	-4&777*1000 MS20-MS0
	-3&777*1000 MS17-MS0
	-2&777*1000 MS16-MS0
	-1&777*1000 MS22-MS0
RSGEN	-4
	-15&777*1000 MS26-MS0
	-14&777*1000 MS25-MS0
	-3&777*1000 MS17-MS0
	-2&777*1000 MS16-MS0
RDUMP	-4
	-14&777*1000 MS11-MS0
	-12&777*1000 MS12-MS0
	-3&777*1000 MS17-MS0
	-2&777*1000 MS16-MS0
RUPDAT	-6
	-15&777*1000 MS13-MS0
	-14&777*1000 MS11-MS0
	-12&777*1000 MS12-MS0
	-10&777*1000 MS27-MS0
	-3&777*1000 MS17-MS0
	-2&777*1000 MS16-MS0
RCONV	-5
	-15&777*1000 MS13-MS0
	-14&777*1000 MS11-MS0
	-12&777*1000 MS12-MS0
	-3&777*1000 MS17-MS0
	-2&777*1000 MS16-MS0
RUSER	-1
	0 MS1-MS0
MIN3=.
RPIP	-3
	-3&777*1000 MS17-MS0
	-2&777*1000 MS16-MS0
	0 MS3-MS0
RALLF	-16
	-15&777*1000 MS3-MS0
	-14&777*1000 MS3-MS0
	-13&777*1000 MS3-MS0
	-12&777*1000 MS3-MS0
	-11&777*1000 MS3-MS0
	-10&777*1000 MS3-MS0
	-7&777*1000 MS2-MS0
	-6&777*1000 MS13-MS0
	-5&777*1000 MS21-MS0
	-4&777*1000 MS5-MS0
	-3&777*1000 MS24-MS0
	-2&777*1000 MS24-MS0
	-1&777*1000 MS10-MS0
	0 MS1-MS0
RALLB	-16
	-15&777*1000 MS13-MS0
	-14&777*1000 MS11-MS0
	-13&777*1000 MS13-MS0
	-12&777*1000 MS12-MS0
	-11&777*1000 MS11-MS0
	-10&777*1000 MS11-MS0
	-7&777*1000 MS2-MS0
	-6&777*1000 MS13-MS0
	-5&777*1000 MS21-MS0
	-4&777*1000 MS5-MS0
	-3&777*1000 MS6-MS0
	-2&777*1000 MS7-MS0
	-1&777*1000 MS10-MS0
	0 MS1-MS0
 
/NO DEVICE ASSIGNED TYPEOUT
 
NONE	.ASCII	/NONE/
 
/REQUEST HEADER
 
DATHDR	.ASCII	/ .DAT/<11>/DEVICE/<11>/ USE/<15>
 
/REQUEST USE MESSAGES
 
MS0=.
MS1	.SIXBT	/USER@/
MS2	.SIXBT	/SYS DEV@/
MS13=.+2
MS3	.SIXBT	/INPUT-OUTPUT@/
MS5	.SIXBT	/SYS INPUT@/
MS6	.SIXBT	/BGD CTL TTY@/
MS7	.SIXBT	/BGD CTL TTY OR BATCH DEV@/
MS10	.SIXBT	/SYS LIBR@/
MS11	.SIXBT	/INPUT@/
MS12	.SIXBT	/LISTING@/
MS14	.SIXBT	/OUTPUT-SCRATCH@/
MS16	.SIXBT	/CMD STRING@/
MS17	.SIXBT	/CTL & ERR MSGS@/
MS20	.SIXBT	/USER PROGS@/
MS21	.SIXBT	/USER LIBR@/
MS22	.SIXBT	/DDT@/
MS24	.SIXBT	/FGD CTL TTY@/
MS25	.SIXBT	/OLD SYS DEV@/
MS26	.SIXBT	/NEW SYS DEV@/
MS27	.SIXBT	/SECONDARY INPUT@/
MS30	.SIXBT	/TTY OUTPUT & ERRORS@/
 
	.EJECT
/ASSIGN PROCESSOR
 
/LEGAL FORMAT:
/	ASSIGN	XXXN M,O,P/YYYQ R
/		WHERE XXX AND YYY REPRESENT HANDLER NAMES
/		      N AND Q REPRESENT UNIT NUMBERS
/		      M,O,P, AND R REPRESENT .DAT SLOT NUMBERS
 
/NOTE:	IF NO UNIT NUMBER IS GIVEN,
/	UNIT ZERO IS ASSUMED.  ALSO
/	IF ONLY A TWO CHARACTER HANDLER
/	NAME IS USED, THE THIRD LETTER
/	WILL BE ASSUMED TO BE AN "A"
/	(THE FULL VERSION OF THE HANDLER).
 
ASSIGN	LAC	(BUFFER+77
	XOR	BANKBT
	DAC*	L10		/STORE AUTO-INDEX
	DAC*	L11		/LOAD AUTO-INDEX
	DZM	COMAND
	DZM	COMAND+1
	DZM	COMAND+2
	JMP	ASSBGN		/GO BEGIN PROCESSING
ASSLOP	JMS	ENDLIN		/ANY MORE ARGUMENTS?
	JMP	ASSPRC		/NO-PROCESS COMMAND
	JMS	CURCMD		/YES-GET .SIXBT
	SKP			/MUST BE SLASH, ALTMODE OR CR
	JMP	ASSDEV
	JMS	ENDLIN
	JMP	ASSLOP		/CR OR ALTMODE
	SAD	(57
	JMP	ASSLOP		/EXTRA SLASH
	JMP	ILLARG
ASSDEV	LAC	COMAND		/IS IT TWO LETTER NAME
	AND	(77
	SNA
	JMP	ASSUMA		/YES. ASSUME "A" VERSION.
	AND	(70		/IS 3RD CHAR NUMERIC?
	SAD	(60
	JMP	ASSUMA		/YES. ASSUME "A" VERSION
ASSUMR	LAC	COMAND		/TEST IF COA.
	SAD	(31701		/.SIXBT "COA"
	JMP	ASSCOA
	LAC	COMAND+1		/GET UNIT #
	SNA			/ANY?
ASSZER	LAC	(600000		/NO-USE ZERO
ASSNZR	DAC	ASSUNT		/YES-SAVE UNIT #
	DZM	ASSUNT+1
	JMP	ASSCKD		/GO CHECK DEVICE
ASSCOA	XCT	SKPBGD		/FORCE ASSIGNMENT OF COA0 TO FGD
	JMP	ASSZER		/AND COA1 TO BGD SO THAT, EVEN IF
	LAC	(610000		/$SHARE COMMAND NOT GIVEN, THE BGD
	JMP	ASSNZR		/LINK LOADER WILL NOT COMPLAIN.
ASSUMA	LAC	COMAND+1
	AND	(77
	SZA			/LAST CHAR MUST BE 00
	JMP	ILLDEV
	LAC	COMAND+1		/MOVE OVER SIX
	JMS	ROT6R
	AND	(7777
	DAC	COMAND+1
	LAC	COMAND		/MOVE THIS TOO
	RAR
	JMS	ROT6R
	AND	(770000
	XOR	COMAND+1		/MERGE INTO COMMAND
	DAC	COMAND+1
	LAW	17700
	AND	COMAND
	XOR	L1		/PUT "A" AS 3RD LETTER
	DAC	COMAND
	JMP	ASSUMR		/CONTINUE NORMAL PROCESSING
ASSCKD	LAC	COMAND+2
	SZA			/THIS MUST BE ZERO
	JMP	ILLDEV		/ILLEGAL DEVICE/UNIT
	DZM	COMAND+1
	JMS	SAVGET
 
	IDX	CMD1CH		/NO SINGLE LETTER COMMANDS
	JMS	SEARCH		/LOOK FOR HANDLER
L.IOTB	.IOTAB			/.IOTAB (13 BITS)
	JMS	GETI
	JMS	GET
	JMS	PUTSI
	JMS	PUTS
	COMAND
MIN2	-2
 
	JMP	ILLDEV		/ILLEGAL DEVICE NAME
	JMS	RESGET
	LAC	CMDCNT
	DAC	ASHNDC		/SAVE HANDLER CODE
	SNA
	JMP	ASNONE
	LAC*	CMDADR
	AND	(77
	DAC	ASDEVC		/SAVE DEVICE CODE
	LAC	(ASSUNT		/UNIT SAVE ADDR
	JMS	GETSI
	DZM	ASUNTC		/CLEAR CODE STORAGE
ASFUNT	JMS	GETS		/GET CHAR
	DAC	ASSCHR
	SNA			/IS IT NULL?
	JMP	ASUNTD		/YES-UNIT # DONE
	AND	(170		/CHECK FOR OCTAL
	SAD	(60		/IS IT?
	SKP			/YES
	JMP	ILLDEV		/NO-ILLEGAL DEV/UNT
	LAC	ASSCHR
	AND	L7		/OCTAL DIGIT ONLY
	DAC	ASSCHR
	LAC	ASUNTC		/CURRENT UNIT
	CLL!RAL
	RTL
	XOR	ASSCHR		/NEXT DIGIT
	DAC	ASUNTC		/SAVE NEW UNIT #
	JMP	ASFUNT		/GET NEXT DIGIT
ASUNTD	LAC	ASHNDC		/BUILD .IOIN ENTRY
	SAD	L1		/IS DEVICE TTA?
	JMP	ASIOTT		/YES-LT19 TYPE ENTRY
	LAW	17770
	AND	ASUNTC
	SZA!CLL			/IS UNIT TOO LARGE?
	JMP	ILLDEV		/YES
	LAC	ASUNTC
	JMS	ROT6R
	DAC	ASIOIN		/SAVE AS .DAT ENTRY UNIT
	LAC	ASDEVC
	CLL!RAL
	JMS	ROT6L
	XOR	ASIOIN		/MERGE UNIT+DEVICE
	XOR	ASHNDC		/MERGE HANDLER
	JMP	ASSDAC
ASIOTT	LAC	ASUNTC
	TAD*	(.SCOM+76		/- # OF TTYS ON THIS MACHINE
	SMA
	JMP	ILLDEV
	LAC	ASUNTC
	XOR	(200000		/SPECIAL .DAT ENTRY
ASSDAC	DAC	.IOWRD
	JMS	FGDCHK
	JMP	ILLFDV
ASDVOK	LAC	.IOWRD		/ALL TESTS OK
	DAC*	10		/STORE IN BUFFER
ASDATL	JMS	FETCHN		/GET .DAT #
	JMP	ASDATE		/GO DO END TEST
	DAC*	10		/STORE IN BUFFER
	SAD	(-7
	JMP	ILLPEM
	SAD	MIN3
	JMP	ILLPEM
	SAD	MIN2
	JMP	ILLPEM
	JMS	CHKDAT		/IS .DAT # OK?
	JMP	ILLDAT		/NO-ERROR
ASDATE	LAC	LASTCR		/YES-DO END TEST
	SAD	(40
	JMP	ASDATL		/SPACE
	SAD	(54
	JMP	ASDATL		/COMMA
ASSBGN	LAC	L400K
	DAC*	10		/SET END OF DEVICE
	JMP	ASSLOP		/GO CHECK REST OF COMMAND
ASSPRC	LAW			/SET END OF COMMAND
	DAC*	10
ASPRCL	LAC*	11		/PROCESS LOOP
	SAD	L400K		/END DEVICE?
	JMP	ASDEVX		/YES
	TAD	DATPTR		/NO-.DAT #
	DAC	ASSDAT		/SAVE .DAT POINTER
	LAC	.IOWRD		/GET NEW .DAT CONTENTS
	DAC*	ASSDAT		/SETUP .DAT SLOT
	JMP	ASPRCL
ASDEVX	LAC*	11		/GET .DAT ENTRY
	SAD	ASSPRC		/END COMMAND?
	JMP	.KLIST		/YES
	DAC	.IOWRD		/NO-SAVE ENTRY
	JMP	ASPRCL
ASNONE	LAC	ASSUNT		/CHECK FOR "E" OR
	SZA			/NOTHING
	SAD	(50000
	SKP!CLA
	JMP	ILLDEV		/ERROR
	JMP	ASDVOK+1		/ZERO FOR .DAT ENTRY
 
.IOWRD	0			/UNIT, DEV, + HANDLER CODES
 
	.EJECT
/DIRECT PROCESSING ROUTINE
 
/LEGAL FORMAT:
/	DIRECT N OR D N
/	WHERE N = UNIT # ON
/	THE SYSTEM DEVICE.
 
/COMMAND PRODUCES A DIRECTORY LISTING,
/	ASSUMING THAT THE DIRECTORY
/	STRUCTURE CONFORMS TO DECTAPE.
 
DIRECT	JMS CHKDIR
	JMP DIREAD
 
/CODE COMMON TO DIRECT AND NEWDIR COMMANDS.
 
CHKDIR	0
 
	JMS FETCHN	/GET NUMERIC ARG
	JMP ARGFMT	/NULL ARG - ILLEGAL
	SPA
	JMP ARGFMT	/NEG ARG - ILLEGAL
	DAC DUNIT
	TAD MIN10
	SMA
	JMP ARGFMT	/NOT 0-7; ILLEGAL
	JMS FINISH	/BETTER HAVE NO MORE PRINTING CHARS.
	CLL
	LAC DUNIT		/ROTATE UNIT # INTO
	JMS ROT6R		/POSITION AS IT WOULD
	DAC DUNIT		/BE IN .IOIN ENTRY.
	XCT SKPBGD
	JMP DIROK		/O.K. TO LIST FOR FGD.
	LAC* (.SCOM+13	/POINTER TO .IOIN
	TAD L3
	DAC .IOWRD	/POINTER TO SYS DEVICE ENTRY
	LAC* .IOWRD
	AND (17777	/SAVE HANDLER AND DEVICE CODE
	XOR DUNIT		/ADD IN NEW UNIT #.
	DAC .IOWRD
	JMS FGDCHK	/IS IT LEGAL TO USE THAT UNIT?
	JMP ILLFDV	/NO.
DIROK	LAW -6
	TAD DATPTR	/POINTER TO .DATF OR .DATB
	DAC DATM6		/POINTER TO .DAT -6
	LAC* DATM6
	DAC DATM6C	/SAVE C(.DAT -6)
 
DIR1	.INIT -3,1,DIREND	/CHANGE ^P ADDR SO .DAT -6 CAN BE RESTORED.
 
	LAC DATM7S	/C(.DAT -7)
	AND (617777	/MASK OFF UNIT #
	XOR DUNIT		/ADD NEW UNIT #
	DAC* DATM6	/SETUP .DAT -6
 
/NOTE: CONTROL P WILL RETURN TO A LOCATION THAT WILL RESET .DAT -6
/TO ITS ORIGINAL CONTENTS.
 
	JMP* CHKDIR
 
/READ IN BLOCK 100 TO OBTAIN DIRECTORY INFORMATION. THE FIRST 40
/OCTAL WORDS IN BLOCK 100 CONTAIN THE DIRECTORY BIT MAP INDICATING
/ALL BLOCKS IN USE.
 
DIREAD	LAC (772		/.TRAN IN FORWARD THRU .DAT -6
	DAC TRAN1
	LAC (100		/BLOCK 100
	DAC TRAN1+2
	JMS XTRAN1
	LAC TRAN1+3	/BUFFER ADDRESS
	DAC BUFPTR
	LAW -40		/40 WORDS PER BIT MAP
	DAC WRDCNT
	DZM TTLBLK	/INIT COUNT OF BLOCKS USED
WDLOOP	LAW -22		/18 BITS PER WORD
	DAC BITCNT
	LAC* BUFPTR	/GET NEXT WORD FROM BIT MAP
BTLOOP	SPA!RCL
	IDX TTLBLK	/ADD 1 TO BIT MAP COUNT
	ISZ BITCNT
	JMP BTLOOP
	IDX BUFPTR	/POINT AT NEXT WORD IN BIT MAP
	ISZ WRDCNT
	JMP WDLOOP
 
BLK100	.WRITE -3,2,DRLIST,0	/TYPE "DIRECTORY LISTING"<15>.
 
DATM6C=.-1			/SAVED CONTENTS OF .DAT -6
	LAC TTLBLK	/# OF USED BLOCKS
	JMS TWOS
	TAD (1100		/AC NOW HAS # OF FREE BLOCKS
	CLL
	JMS NUMOUT	/PRINT IN FORMAT 1
 
FRE.BK	.WRITE -3,2,FREBKS,0	/TYPE "FREE BLKS"<15>.
DATM6=.-1			/PTR TO .DAT -6
 
	LAW -70
	DAC FILCNT	/COUNT FOR 56 FILE ENTRIES.
	LAC (LAC BEGBUF+40
	DAC BUFPTR	/POINTER TO FILE NAME INFO.
MIN40=.
FNLOOP	LAW -40		/CHECK WHEN WORKING ON WORD 200.
	SAD FILCNT
	SKP		/YES.
	JMP BUFPTR
 
/CHECK BIT 3 OF WORD 203. IF=1 THIS IS A SYSTEM TAPE.
 
	LAC BUFPTR	/CONTAINS LAC BEGBUF+200.
	TAD L3
	DAC .+1
TCOUNT	XX		/GET WORD 203.
	AND (100000
	SNA
	JMP BUFPTR
 
/IT IS A SYSTEM TAPE. MOVE POINTERS AHEAD TO SKIP SYSTEM BIT MAP.
 
	LAW -30
	DAC FILCNT	/SKIP BIT MAP.
	LAC (40
	TAD BUFPTR
	DAC BUFPTR	/SAME.
 
BUFPTR	XX		/LAC WORD FROM INPUT BUFFER.
	SNA
	JMP NULFIL	/NULL FILE ENTRY.
	LAC BUFPTR
	AND (17777	/13 BIT ADDRESS OF FILENAME.
	JMS GETSI		/INIT GET 6BIT.
	LAC (SEARCD+2
	JMS PUTI		/INIT PUT 5/7 ASCII.
	LAW -6
	DAC TCOUNT	/6 CHARS FOR FILENAME.
NAMLP1	JMS GETS		/GET CHAR.
	SNA		/REPLACE NULL CHAR WITH SPACE.
	LAC (40
	JMS PUT
	ISZ TCOUNT
	JMP NAMLP1
 
	JMS PUT40		/SPACE.
	LAW -3
	DAC TCOUNT	/3 CHARS FOR EXTENSION.
NAMLP2	JMS GETS
	SNA
	LAC (40
	JMS PUT
	ISZ TCOUNT
	JMP NAMLP2
 
	LAC (175		/TERMINATE WITH ALTMODE.
	JMS PUT
 
SEAR.C	.WRITE -3,2,SEARCD,0	/PRINT FILENAME AND EXTENSION.
FILCNT=.-1			/BIT MAP COUNTER (8 PER BLOCK)
 
	.WAIT -3
 
	LAC BUFPTR
	TAD L3
	DAC BUFPTR	/POINTING AT START BLOCK #.
	XCT BUFPTR	/GET IT.
	IDX BUFPTR
	AND (377777	/MASK OFF "IN USE" BIT.
	STL
	JMS NUMOUT	/PRINT # IN FORMAT 2.
 
	.CLOSE -3		/PRINT CAR. RET. LINE FEED.
 
	JMP .+4
NULFIL	LAC BUFPTR	/MOVE ON TO NEXT FILENAME.
	TAD L4
	DAC BUFPTR
	ISZ FILCNT
	JMP FNLOOP
 
/CONTROL P, IF TYPED WHILE PROCESSING THE D OR N COMMANDS, WILL RETURN
/HERE SO THAT .DAT -6 CAN BE RESTORED TO ITS ORIGINAL CONTENTS.
 
DIREND	LAC DATM6C
	DAC* DATM6
	JMP START
 
	.EJECT
/SUBROUTINE NUMOUT: CALLED BY DIRECTORY LISTING ROUTINE TO CONVERT
/AN OCTAL # FOR PRINTOUT.
 
/CALLING SEQUENCES: (# TO BE PRINTED IS IN THE AC)
 
/	CLL		/WITH LINK=0, CONVERT AND
/	JMS NUMOUT	/PRINT IN FORMAT 1.
/	(RETURN)
/
/	STL		/WITH LINK=1, CONVERT AND
/	JMS NUMOUT	/PRINT IN FORMAT 2.
/	(RETURN)
/
/FORMAT 1:	SP SP SP # # # # SP
/FORMAT 2:	      SP # # # #
/
/WHERE SP = A SPACE; # = AN OCTAL DIGIT (LEADING 0 CONVERTED TO SPACE).
 
NUMOUT	0		/LINK SAVED IN BIT 0 BY THE JMS.
 
	DAC NUMTMP	/SAVE # TO BE CONVERTED.
	LAC L.SCD		/SET UP TO PACK INTO SEARCD BUFFER.
	JMS PUTI
	LAC (40		/SPACE.
	DAC SUPCHR	/SET SPACE AS LEADING 0 SUPPRESSOR.
	JMS PUT		/STORE A SPACE.
	LAC NUMTMP
	JMS OCTOUT	/CONVERT # AND STORE IN BUFFER.
	LAC NUMOUT
	SMA		/SKIP IF FORMAT 2.
	JMP .+4
	LAC L4
	DAC SEARCD	/SET CHARS 1 AND 2 TO NULL.
	CLA!SKP		/SET CHAR 8 TO NULL.
	LAC (40		/SPACE.
	JMS PUT
	LAC (175		/ALTMODE.
	JMS PUT
 
NUM1	.WRITE -3,2,SEARCD-2,0
NUMTMP=.-1		/TEMP STORAGE.
 
	JMP* NUMOUT
 
	.EJECT
DRLIST=.-2
	.ASCII /DIRECTORY LISTING/<15>
FREBKS=.-2
	.ASCII /FREE BLKS/<15>
 
WRDCNT	0		/WORD COUNTER (40 OCTAL PER BIT MAP).
BITCNT	0		/BIT COUNTER (18 PER WORD).
TTLBLK	0		/COUNT OF BLOCKS IN USE.
DUNIT	0		/UNIT # IN .IOIN ENTRY POSITION.
 
	.EJECT
/NEWDIR PROCESSING ROUTINE
 
/LEGAL FORMAT:
/	NEWDIR # OR N #
/	WHERE # IS A UNIT NUMBER
/	ON THE SYSTEM DEVICE.
/	UNIT 0 IS ILLEGAL.
 
/COMMAND CLEARS THE FILE DIRECTORY
/	FOR THAT UNIT. NO CONTROL
/	Q AREA IS ALLOWED FOR.
 
NEWDIR	JMS CHKDIR	/CODE IN COMMON WITH D COMMAND.
	LAC DUNIT
	SZA
	JMP NEWDOK	/OK. NOT UNIT 0.
 
	JMS TYPE
	EM03		/ILLEGAL ARG.
 
	JMP DIREND	/RESET .DAT -6 TO FORMER CONTENTS.
 
NEWDOK	LAW -400
	DAC WRDCNT
	LAC (DZM BEGBUF
	DAC .+1
	XX		/0 OUT THE 400 WORD BUFFER.
	IDX .-1
	ISZ WRDCNT
	JMP .-3
 
/BLOCKS 71-77, CONTAINING USER FILE BIT MAPS, WILL BE CLEARED. BLOCK
/100 WILL BE CLEARED EXCEPT FOR WORD 3 (4TH WORD) WHICH WILL BE SET
/TO 077600. THIS INDICATES, IN THE DIRECTORY BIT MAP, THAT BLOCKS
/71-100 ARE IN USE. THE TRANSFER ORDER IS BLOCKS 71-75-72-76-73-77-74-100
/IN THE FORWARD DIRECTION.
 
	LAC (71
	DAC TRAN1+2
	LAC (1772
	DAC TRAN1		/.TRAN OUT FORWARD THRU .DAT -6.
	JMS XTRAN1
	LAC (75
	DAC TRAN1+2
	JMS XTRAN1
	LAC (72
	DAC TRAN1+2
	JMS XTRAN1
	LAC (76
	DAC TRAN1+2
	JMS XTRAN1
	LAC (73
	DAC TRAN1+2
	JMS XTRAN1
	LAC (77
	DAC TRAN1+2
	JMS XTRAN1
	LAC (74
	DAC TRAN1+2
	JMS XTRAN1
	LAC (77600	/IN USE BITS FOR BLKS 71-100
	DAC BEGBUF+3	/IN DIRECTORY BIT MAP.
	LAC (100
	DAC TRAN1+2
	JMS XTRAN1
	JMP DIREND	/REINSTATE .DAT -6.
 
/SUBROUTINE XTRAN1: CALLED BY D AND N COMMANDS.
 
XTRAN1	0
 
TRAN1	.TRAN -6,0,0,BEGBUF,256
 
	.WAIT -6
 
	JMP* XTRAN1
 
	.EJECT
/FILES PROCESSOR
 
/LEGAL FORMAT:
/	FILES XX NN WHERE
/		XX = DEVICE NAME
/		NN = MAX NO. OF FILES
 
/NOTE: THE "A" VERSION OF A DEVICE HANDLER
/	IS EQUIVALENT TO THE DEVICE
/	NAME. THUS DT AND DTA MEAN THE
/	SAME THING AND ARE EQUIVALENT
/	TO THE MULTI-UNIT HANDLER.
 
FILES	JMS	ENDLIN		/ANY ARGUMENTS?
	JMP	ILLARG		/NO - ILLEGAL CMD
	DZM	COMAND+1
	JMS	CURCMD		/YES - GET .SIXBT
	JMP	ILLARG		/ILLEGAL CMD-NULL ARG.
	LAC	COMAND+1		/2ND WORD ZERO?
	SZA
	JMP	ILLDEV		/NO - ILLEGAL DEVICE
	LAC	COMAND
	AND	(77
	SNA			/3RD LETTER EMPTY?
	JMP	IDXCMD
	SAD	L1		/NO - IS IT AN A?
	JMP	.+3		/YES - OK
	JMP	ILLDEV		/NO - ERROR
IDXCMD	IDX	COMAND		/MAKE 3RD LETTER AN A
	JMS	FETCHN		/GET FILES COUNT
	JMP	ILLARG		/ILLEGAL ARGUMENT-NULL ARG.
	DAC	FILCNT		/SAVE COUNT
	SPA
	JMP	ILLFIL		/NEG FILES COUNT
	JMS	FINISH		/BETTER HAVE NO MORE PRINTING CHARS.
	LAC	COMAND
	XOR	(565601		/.SIXBT /..A/
	SNA
	JMP	PS.DEV		/$FILES .. N
 
	IDX	CMD1CH		/NO ONE-LETTER CMDS
	JMS	SEARCH		/LOOK FOR ENTRY
	.IOTAB			/.IOTAB (13 BITS)
	JMS	GETI
	JMS	GET
	JMS	PUTSI
	JMS	PUTS
	COMAND
	-1
 
	JMP	ILLDEV		/ILLEGAL DEVICE
	LAC	CMDCNT		/GET HANDLER NUMBER
PS.DEV	JMS	IFMUD		/TEST FOR .MUD ENTRY
	JMP	ILLNMD		/NO - NOT .MUD DEV
	DAC	FILMUD
	IDX	FILMUD		/TO WD1 OF .MUD ENTRY
	LAC*	FILMUD		/GET MAXIMUM FILES
	AND	(77
	JMS	TWOS		/COUNT AND CHECK
	TAD	FILCNT		/WITH NEW COUNT
	SMA!SZA			/IS COUNT WITHIN MAX
	JMP	ILLFIL		/NO
	LAW	-1		/YES - BACKUP AND INSERT
	TAD	FILMUD
	DAC	FILMUD
	LAC*	FILMUD		/GET HANDLER CODE
	AND	(17700
	XOR	FILCNT		/INSERT FILES COUNT
	XOR	L400K		/INSERT FILES BIT
	DAC*	FILMUD		/PUT IN .MUD
	JMP	.KLIST		/ALL DONE
 
	.EJECT
/FCONTROL COMMAND PROCESSOR
 
/LEGAL FORMAT:
/	FCONTROL N WHERE N=UNIT NUMBER OF THE NEW
/		FOREGROUND CONTROL TELETYPE.
 
/NOTE: IF THE UNIT # ON THE FCONTROL
/	IS PRESENTLY THE BGD CTL TTY, THE BGD AND
/	FGD CTL TTYS WILL BE SWAPPED.
 
FCONTR	XCT	SKPFGD
	JMP	ILLCMD		/ILLEGAL COMMAND FOR BGD
	JMS	BFCTRL		/GET UNIT
	LAC	FCUNIT		/GET TTA ENTRY
	SAD*	FCIOFT		/CURRENT FGD TTY?
	JMP	.KLIST		/YES - IGNORE
	SAD*	FCIOBT		/CURRENT BGD TTY?
	SKP			/YES
	JMP	FCPRC		/NO - GO PROCESS
 
/THE BGD AND FGD CTL TTYS WILL BE SWAPPED. CHANGE ALL FGD
/.DAT SLOTS WHICH REFER TO THE OLD FCONTROL UNIT TO THE NEW UNIT.
 
	LAC*	FCIOBT		/BGD UNIT + 200000
	JMS	FDATCH
FCUNIT	XX			/NEW TTY UNIT + 200000
 
	LAW	-3
	TAD*	(.SCOM+17		/POINTS TO .DATB
	DAC	FCDTM3		/POINTS TO .DATB-3
	LAC*	FCIOFT
	DAC*	FCIOBT		/CHANGE BGD CONTROL .IOIN ENTRY
	TAD	L400K		/ADD "SETUP" BIT
	DAC*	FCDTM3		/.DATB-3 GETS NEW UNIT
 
FCPRC	JMS	TYPE		/TERMINATE. PRINT "CONTROL RELINQUISHED"
	BYEBYE			/ON OLD FGD UNIT.
 
	.INIT -3,1,0,0		/PRINT C.R. LIN. FD. AND
				/DISABLE ^P.
 
	LAW	-3
	TAD*	(.SCOM+16		/POINTS TO .DATF
	DAC	FCDTM3		/POINTS TO .DATF-3
	LAC	FCUNIT
	DAC*	FCIOFT		/SETUP .IOIN ENTRY
	TAD	L400K		/ADD "SETUP" BIT
	DAC*	FCDTM3		/SETUP .DATF-3
 
XIT	.EXIT		/TO BEGIN WITH NEW TTY
 
	.EJECT
/BCONTROL COMMAND PROCESSOR
 
/LEGAL FORMAT:
/	BCONTROL N WHERE N=UNIT NUMBER OF THE
/		NEW BACKGROUND CONTROL TELETYPE
/	COMMAND IS LEGAL IN BOTH FGD AND BGD.
 
BCONTR	JMS	BFCTRL		/GO GET UNIT #
	LAC	BCUNIT
	SAD*	BCIOBT		/BGD TTY?
	JMP	.KLIST		/YES - IGNORE
 
	JMS	IFIOIN		/CHECK .IOIN TABLE
	NOP			/NOT FGD DEVICE - WON'T RETURN HERE
	NOP			/DIFFERENT HANDLER - WON'T GET HERE
	SKP			/NOT A FGD TTY UNIT - OK
	JMP	ILLFDV		/FGD TTY UNIT - ILLEGAL
 
	XCT	SKPBGD		/OK - CHECK BGD
	JMP	BCFCHG		/FGD - NO MSG
 
	JMS	TYPE		/TERMINATE: PRINT "CONTROL
	BYEBYE			/RELINQUISHED" ON OLD BGD UNIT.
 
	.INIT -3,1,0,0		/PRINT C.R. LN. FD. AND
				/DISABLE ^P.
 
BCNPRT	LAW	-3
	TAD*	(.SCOM+17		/POINTS TO .DATB
	DAC	BCDTM3		/POINTS TO .DATB-3
	LAC	BCUNIT		/NEW BGD TTY
	DAC*	BCIOBT		/SETUP .IOIN ENTRY FOR BGD CTL TTY
	TAD	L400K		/ADD "SETUP" BIT
	DAC*	BCDTM3		/SETUP .DATB-3
	XCT	SKPBGD
	JMP	.KLIST
	JMP	XIT		/JMP TO .EXIT.
BCFCHG	LAC*	BCFCTL
	DAC	BCFCTL		/FGD CTL TTY + 200000
 
	LAC	BCUNIT		/BGD CTL TTY + 200000
	JMS	FDATCH		/CHANGE FGD .DATS, IF NEC.
BCFCTL	XX			/FGD CTL TTY + 200000
 
	JMP	BCNPRT
 
BYEBYE	.ASCII /CONTROL RELINQUISHED/<15>
	.LOC .-1
 
/SUBROUTINE BFCTRL: CODE COMMON TO FCONTROL & BCONTROL.
 
BFCTRL	0
 
	JMS FETCHN	/GET UNIT #
	JMP ARGFMT	/ILL FORMAT (NULL ARG)
	SPA
	JMP ARGFMT	/NEG UNIT #
	DAC BCUNIT	/TEMP
	TAD* (.SCOM+76	/- # OF TTYS ON MACHINE
	SMA
	JMP ARGFMT	/# TOO LARGE
	LAC BCUNIT
	XOR (200000
	DAC BCUNIT	/SAVE TTA ENTRY
	DAC .IOWRD	/ARG. FOR IFIOIN SUBR.
	JMS FINISH	/BETTER HAVE NO MORE PRINTING CHARS.
	LAC* (.SCOM+13	/POINTS TO .IOIN
	TAD L5
	DAC BCFCTL	/POINTS TO FGD CTRL TTY ENTRY
	TAD L2
	DAC BCIOBT	/POINTS TO BGD TTY ENTRY
	JMP* BFCTRL
BCUNIT=FCUNIT
FCIOFT=BCFCTL
 
	.EJECT
/SUBROUTINE FDATCH: CALLED BY MONINT, FCONTR, AND BCONTR TO CHANGE
/	FGD .DAT SLOTS WHICH REFER TO THE CURRENT BGD CTRL TTY.
/	SLOTS CHANGED TO REFER TO THE FGD CTRL TTY.
 
/CALLING SEQUENCE:
/	LAC	(BGTTY# + 200000
/	JMS	FDATCH
/	FGTTY# + 200000
/	(RETURN)
 
FDATCH	0
 
	DAC FDBCTL	/SAVE BGTTY#+200000
	LAC* DATPTR	/C(.DAT 0) = PTR TO .DATND.
	DAC FDATND
	LAC* FDATND	/C(.DATND) = PTR TO .DATBG.
	DAC FDATP
	DZM FDFLAG	/0 .DAT-CHANGED FLAG.
 
FDLOOP	LAC* FDATP	/C(.DAT SLOT)
	SAD FDBCTL	/SAME AS BGD CTL TTY?
	JMP FDCHNG	/YES.
FDNEXT	IDX FDATP
	LAC FDATP
	SAD DATPTR	/.DAT 0?
	JMP FDNEXT	/YES - SKIP IT
	SAD FDATND	/.DATND?
	SKP!CLA		/YES. DONE.
	JMP FDLOOP	/NO.
	SAD FDFLAG	/ANY .DATS CHANGED?
	JMP FDEXIT	/NO.
	LAC L15		/CAR. RET.
	JMS PUT
	JMS TYPEX
FDEXIT	IDX FDATCH
	JMP* FDATCH
 
FDCHNG	LAC FDFLAG	/1ST TIME HERE?
	SZA
	JMP FDNOPT	/NO.
 
	.CLOSE -3		/PRINT CAR. RET. LINE FD.
 
	JMS TYPE
	FDATS		/TYPE "FGD .DATS CHANGED ..."
 
	LAC L.BUF
	JMS PUTI		/SETUP TO PACK 5/7 IN BUFFER.
	LAC* FDATCH	/GET FGD TTY #
	AND (37
	JMS OCTOUT	/CONVERT AND STORE
	LAC (72		/:
	JMS PUT
	LAC L15
	JMS PUT
	JMS TYPEX
	LAC L.BUF		/RE-INIT TO PACK 5/7 IN BUFFER.
	JMS PUTI
FDNOPT	JMS PUT40		/SPACE.
	LAC DATPTR	/PTR TO .DATF+0.
	JMS TWOS
	TAD FDATP
	DAC FDFLAG	/SET FLAG WITH .DAT SLOT #.
	SMA
	JMP .+3
	LAC (55		/MINUS SIGN
	JMS PUT
	LAC FDFLAG	/GET .DAT SLOT #
	SPA
	JMS TWOS		/GET ABSVAL
	JMS OCTOUT
	LAC* FDATCH	/FGD CTL TTY# + 200000
	DAC* FDATP	/CHANGE .DATF SLOT.
	JMP FDNEXT
 
FDATS	.ASCII /FGD .DATS CHANGED TO TTA/<175>
	.EJECT
/FCORE PROCESSING ROUTINE
 
/LEGAL FORMAT:
/	FCORE N WHERE N= OCTAL # OF REGISTERS
/	TO BE RESERVED IN FOREGROUND AREA
 
/NOTE: IF THIS COMMAND IS NOT GIVEN THE
/	DEFAULT ASSUMPTION IS TWO REGISTERS
 
FCORE	XCT	SKPFGD
	JMP	ILLCMD		/ILLEGAL BGD CMD
	JMS	FETCHN		/GET NUMERIC ARG
	JMP	ARGFMT		/NULL ARG
	SPA
	JMP	ARGFMT		/NEG ARG
	DAC	FCORES		/SAVE NUMBER
	JMS	FINISH		/BETTER HAVE NO MORE PRINTING CHARS.
	LAW	-1
	TAD	FCORES
	SPA!SNA
	JMP	ILLARG		/FCORE # TOO SMALL
	TAD*	(.SCOM+2		/REGISTER ABOVE RESMON
	JMS	TWOS
	TAD*	(.SCOM		/HIGHEST CORE REGISTER
	SPA
	JMP	ILLARG		/TOO LARGE
	LAC	FCORES		/SET FOR LOADER
	DAC*	(.SCOM+25
	JMP	.KLIST
 
	.EJECT
/INUSE ROUTINE TO PRINT OUT CORE,
/	DEVICE, AND UNIT REQUIREMENTS
/	FOR THE FOREGROUND JOB
 
/COMMAND FORMAT:
/	INUSE
 
INUSE	XCT	SKPBGD		/RUNNING MODE?
	JMP	ILLCMD		/FGD-ERROR
	JMS	FINISH		/BETTER HAVE NO MORE PRINTING CHARS.
 
	JMS	TYPE		/FOREGROUND CORE
	FGDCOR
 
	LAC	L.BUF
	JMS	PUTI
	LAC*	(.SCOM+31
	JMS	OCTOUT		/FIRST FREE REG ABOVE FGD
	LAC	L15
	JMS	PUT
	JMS	TYPEX		/TYPE LINE
	JMS	FGDUSE		/PRINT FGD I/O IN USE
	JMP	.KLIST
 
FGDUSE	0
 
	LAC	L.NOP
	DAC	RQINSW
	LAC*	(.SCOM+13
	DAC	INUSEP		/.IOIN POINTER
	LAC	L3
	TAD*	INUSEP
	DAC	INUSEC		/.IOIN COUNTER
	LAC	INUSEP
	TAD	L5
	DAC	INUSEP		/UPDATE TO TTY
 
	JMS	TYPE		/CONTROL TTY
	INFCTL
 
	LAC	L.BUF
	JMS	PUTI
	LAC	INUSEP
	JMS	REQDEV
	LAC	L15
	JMS	PUT
	JMS	TYPEX
	LAC	INUSEP		/TO FIRST FGD ENTRY
	TAD	L4
	DAC	INUSEP
	LAC	INUSEC
	SMA
	JMP*	FGDUSE		/NO FGD ENTRIES
 
	JMS	TYPE		/DEVICES
	INFDEV
 
INUSEL	LAC	L.BUF
	JMS	PUTI
	JMS	PUT40		/SPACE
	LAC	INUSEP		/.IOIN ENTRY POINTER
	JMS	REQDEV
	LAC	L15
	JMS	PUT		/PRINT NAMES
	JMS	TYPEX
	IDX	INUSEP		/TO NEXT ENTRY
	IDX	INUSEP
	ISZ	INUSEC		/ANY MORE?
	JMP	INUSEL		/YES
	JMP*	FGDUSE		/NO
 
FGDCOR	.ASCII	/1ST REG ABOVE FGD = /<175>
	.LOC	.-1
INFCTL	.ASCII	/FCONTROL = /<175>
	.LOC	.-1
INFDEV	.ASCII	/FGD DEV-UNITS:/<15>
 
	.EJECT
/SHARE COMMAND PROCESSOR
 
/LEGAL FORMAT:
/	SHARE
 
/IF FGD USER ISSUES THIS COMMAND, ALL UNITS ON
/	BULK STORAGE DEVICES FOR WHICH THE
/	MULTIUNIT HANDLER IS IN CORE ARE
/	ACCESSIBLE TO THE BGD JOB. THIS ALLOWS
/	FGD AND BGD TO COMMUNICATE OTHER
/	THAN BY CORE TO CORE XFERS.
 
SHARE	XCT SKPFGD	/COMMAND LEGAL ONLY IN FGD.
	JMP ILLCMD
	JMS FINISH	/BETTER HAVE NO MORE PRINTING CHARS.
	CLC
	DAC* (.SCOM+77	/$SHARE FLAG. NON-0 = SHARE.
	JMP .KLIST
 
/NOSHARE COMMAND PROCESSOR
 
/LEGAL FORMAT:
/	NOSHARE
 
/IF FGD OR BGD ISSUES THIS COMMAND, THE EFFECT
/	OF ANY PREVIOUS SHARE COMMAND IS NULLIFIED.
 
NOSHARE	JMS FINISH	/BETTER HAVE NO MORE PRINTING CHARS.
	DZM* (.SCOM+77	/0 THE SHARE FLAG.
	JMS BDTCLR	/CHECK IF ANY BGD .DATS NEED BE CLEARED.
	JMP .KLIST
 
/VC38 COMMAND PROCESSOR
 
/LEGAL FORMAT:
/	VC38 OR V
 
/COMMAND SETS A FLAG TO SIGNAL LOADING OF
/	THE VC38 CHARACTER TABLE.
 
VC38	JMS FINISH	/BETTER HAVE NO MORE PRINTING CHARS.
	LAC SYS339
	SAD (CLA
	SKP
	JMP ILLFDV	/FGD IS USING THE 339.
	DAC VCFLAG	/SET FLAG.
	JMP .KLIST
 
	.EJECT
/7CHAN AND 9CHAN COMMAND PROCESSORS
 
/LEGAL FORMAT:
/	7CHAN OR 7
/	9CHAN OR 9
 
/THESE COMMANDS ARE LEGAL ONLY IN FGD. THEY CLEAR
/	AND SET, RESPECTIVELY, BIT 6 IN .SCOM+4
/	TO SIGNAL 7 OR 9 CHANNEL OPERATION TO
/	THE MAGTAPE HANDLERS.
 
CHAN7	CLA!SKP		/BIT 6 OFF.
CHAN9	LAC (4000		/BIT 6 ON.
	DAC CHTEMP
	XCT SKPFGD
	JMP ILLCMD	/COMMAND ILLEGAL IN BGD.
	JMS FINISH	/BETTER HAVE NO MORE PRINTING CHARS.
	LAW 13777
	AND* (.SCOM+4	/CLEAR BIT 6.
	XOR CHTEMP
	DAC* (.SCOM+4
	JMP .KLIST
 
/MPON AND MPOFF COMMAND PROCESSORS
 
/LEGAL FORMAT:
/	MPON OR M
/	MPOFF
 
/MPOFF IS LEGAL ONLY IN FGD. IT ALLOWS
/	BGD TO ACCESS ALL OF CORE AND
/	TO ISSUE IOTS. MPON DISABLES
/	THIS CAPABILITY.
 
MPOFF	XCT SKPFGD
	JMP ILLCMD	/COMMAND ILLEGAL IN BGD.
	CLC!SKP
MPON	CLA
	DAC CHTEMP
	JMS FINISH	/BETTER HAVE NO MORE PRINTING CHARS.
	LAC CHTEMP
	DAC* (.SCOM+101
	JMP .KLIST
 
	.EJECT
/SUBROUTINE BDTCLR: CLEARS (ASSIGNS NONE) ALL BGD .DAT SLOTS
/	WHICH CONFLICT WITH FGD I/O.
 
/CALLING SEQUENCE:
/	JMS BDTCLR
/	(RETURN)
 
BDTCLR	0
 
	LAC* (.SCOM+17	/PTR TO .DATB
	DAC BDDATB
	LAC* BDDATB	/PTR TO .DATND
	DAC BDDATN
	LAC* BDDATN	/PTR TO .DATBG
	DAC BDPTR		/RUNNING POINTER.
	LAC BDDATB
	JMS TWOS
	TAD BDPTR
	DAC BDNUM		/.DAT # - INITIALLY MOST NEG.
	DZM BDFLAG	/NONE YET CLEARED.
BDLOOP	LAC* BDPTR	/GET C(.DAT SLOT)
	DAC .IOWRD	/ARG. TO FGDCHK SUBR.
	SNA!SPA		/SKIP IN NOT 0 AND NOT SETUP.
	JMP BDNEXT	/IGNORE THIS SLOT.
	JMS FGDCHK	/SKIP ON RETURN IF O.K.
	SKP!CLA		/NO. CLEAR IT.
	JMP BDDTOK
	SAD BDFLAG	/IS THIS 1ST ONE CLEARED?
	SKP
	JMP BDNOMSG	/NO.
 
	.CLOSE -3		/PRINT CAR. RET. LINE FEED.
 
	JMS TYPE
	DATCLR		/TYPE "BGD .DATS CLEARED ..."
 
	LAC L.BUF		/SETUP TO PACK 5/7 ASCII INTO OUTPUT BUFFER.
	JMS PUTI
BDNOMSG	JMS PUT40		/SPACE.
	DAC BDFLAG	/SET CHANGE-OCCURRED FLAG.
	LAC BDNUM		/.DAT #
	SMA
	JMP .+3
	LAC (55		/MINUS SIGN.
	JMS PUT
	LAC BDNUM
	SPA
	JMS TWOS		/GET ABSVAL.
	JMS OCTOUT	/CONVERT FOR OUTPUT.
	SKP!CLA		/CLEAR .DAT SLOT.
BDDTOK	LAC .IOWRD	/SETUP .DAT SLOT
	DAC* BDPTR
BDNEXT	IDX BDPTR		/INDEX POINTER
	ISZ BDNUM		/INDEX .DAT #
	SKP
	JMP BDNEXT	/BYPASS .DAT 0
	LAC BDPTR
	SAD BDDATN	/END OF TABLE?
	SKP
	JMP BDLOOP	/NO. MORE TO BE DONE.
	LAC BDFLAG	/ANY CHANGE?
	SNA
	JMP* BDTCLR	/NO. RETURN
	LAC L15
	JMS PUT
	JMS TYPEX
	JMS FGDUSE	/PRINT FGD I/O IN USE
 
	.WAIT -3
 
	JMP* BDTCLR	/RETURN
 
DATCLR	.ASCII "BGD .DATS CLEARED BECAUSE OF FGD I/O:"<15>
 
	.EJECT
/ERROR MESSAGE TYPEOUT ROUTINE
 
ARGFMT	JMS	ERROR		/ILLEGAL ARGUMENT FORMAT
	EM01
DATERR	JMS	ERROR		/ILLEGAL .DAT CONTENTS
	EM02
ILLARG	JMS	ERROR		/ILLEGAL ARGUMENT
	EM03
ILLCMD	JMS	ERROR		/ILLEGAL COMMAND
	EM04
ILLDAT	JMS	ERROR		/ILLEGAL .DAT SLOT #
	EM05
ILLDEV	JMS	ERROR		/ILLEGAL DEVICE/UNIT
	EM06
ILLFIL	JMS	ERROR		/ILLEGAL FILES COUNT
	EM07
ILLNMD	JMS	ERROR		/NOT MULTI-UNIT DEVICE
	EM10
ILLNUM	JMS	ERROR		/BAD NUMERIC
	EM11
ILLXCT	JMS	ERROR		/BAD FILE NAME
	EM12
ILLFDV	JMS	ERROR		/OTHER JOB'S DEV-UNIT
	EM13
ILLPEM	JMS	ERROR		/PERMANENT .DAT SLOT
	EM15
 
ERROR	0
 
	LAC*	ERROR
	DAC	.+2
 
	JMS	TYPE
	XX			/ERROR MESSAGE (13 BITS)
 
	JMP	.KLIST
 
	.EJECT
/ERROR MESSAGES
 
EM01	.ASCII	/BAD ARG FORMAT/<15>
EM02	.ASCII	/BAD .DAT CONTENTS/<15>
EM03	.ASCII	/BAD ARG/<15>
EM04	.ASCII	/BAD CMD/<15>
EM05	.ASCII	/BAD .DAT #/<15>
	.LOC	.-1
EM06	.ASCII	/BAD DEV-UNIT/<15>
EM07	.ASCII	/BAD FILES #/<15>
	.LOC	.-1
EM10	.ASCII	/NOT MULTI-UNIT DEV/<15>
EM11	.ASCII	/BAD #/<15>
	.LOC	.-1
EM12	.ASCII	/BAD FILE NAME/<15>
EM13	.ASCII	/OTHER JOB'S DEV-UNIT/<15>
	.LOC	.-1
EM15	.ASCII	/PERM .DAT ENTRY/<15>
	.LOC	.-1
 
	.EJECT
/PACK ROUTINE FOR 5/7 ASCII
 
/CALLING SEQUENCES:
/	1.PACK	INIT
/	LAC	(N		/N=0 OR START ADDR
/	JMS	PUTI
/	(RETURN)			/NEXT PACK ADDR IN AC IF N=0
 
/	2.PACK
/	LAC	(N		/N=CHAR TO BE PACKED
/	JMS	PUT
/	(RETURN)
 
PUTI	0
 
	SNA
	JMP	PUTIX		/GO GET NEXT POINTER
	XOR	BANKBT
	DAC	PUTP		/INIT POINTERS
	DAC	PUT9
	DZM	PUTC		/INIT COUNTER
	JMP*	PUTI
PUTIX	LAC	PUT9		/RETURN POINTER
	JMP*	PUTI
 
PUT	0
 
	AND	(177		/ MASK CHAR TO 7 BIT ASCII
	SNA
	JMP*	PUT		/IGNORE NULL CHAR
	DAC	PUT6		/SAVE CHAR
	LAC	PUTC		/CHAR POSITION (0-4)
	TAD	(JMP PUT7		/BUILD DISPATCH
	DAC	.+3
	LAC	PUT6		/GET CHAR
	RCL
	XX			/MODIFIED JMP PUT7 (+0 TO +4)
PUT7	JMP	PUT1		/CHAR 1
	JMP	PUT2		/CHAR 2
	JMP	PUT3		/CHAR 3
	JMP	PUT4		/CHAR 4
	DZM	PUTC		/RESET CHAR COUNT
	JMP	PUT10
PUT1	DZM*	PUTP		/CLEAR WORD ONE
	IDX	PUT9
	DZM*	PUT9		/CLEAR WORD TWO
	IDX	PUT9		/POINT TO NEXT PAIR
	JMS	ROT6R
	RTR
	RAR
	JMP	PUT8
PUT3	RTR
	RTR
	AND	(17		/4 BITS ONLY
	XOR*	PUTP		/FINISH 1ST WORD
	DAC*	PUTP
	IDX	PUTP		/POINT TO 2ND WORD
	LAC	PUT6		/GET CHAR
	RTR			/4 RIGHT - 2ND HALF
	RTR
	AND	(700000		/3 BITS ONLY
	JMP	PUT8
PUT4	RTL			/8 LEFT
	RTL
PUT2	RTL
	RAL
PUT8	IDX	PUTC		/INDEX CHAR COUNT
PUT10	XOR*	PUTP		/MERGE INTO WORD
	DAC*	PUTP
	LAC	PUTC		/IS 2ND WD COMPLETE?
	SNA			/SKIP IF NOT
	IDX	PUTP		/YES - POINT TO NEXT PAIR
	LAC	PUT6		/RETURN CURRENT CHAR
	JMP*	PUT
 
PUTP	0			/CURRENT PAIR POINTER
PUTC	0			/POSITION COUNTER (0 THRU 4)
PUT6	0			/TEMP CHAR
PUT9	0			/NEXT PAIR POINTER
 
	.EJECT
/UNPACK ROUTINE FOR SIXBIT
 
/CALLING SEQUENCES:
 
/	1. UNPACK INIT
/	LAC 	(N		/N=0 OR START ADDR
/	JMS	GETSI
/	(RETURN)			/NEXT UNPACK ADDR IN AC IF N=0
 
/	2.	UNPACK
/	JMS	GETS
/	(RETURN)			/7 BIT CHAR IN AC
 
GETSI	0
 
	SNA
	JMP	GETSIX		/GO GET POINTER
	XOR	BANKBT
	DAC	GETSP		/INIT POINTER
	LAW	-1
	DAC	GETSC		/INIT COUNTER
	JMP*	GETSI
GETSIX	LAC	GETSP		/RETURN POINTER
	JMP*	GETSI
 
GETS	0
 
	ISZ	GETSC		/CURRENT WORD?
	JMP	GETS1		/YES
	LAC*	GETSP		/NO-GET NEXT WORD
	DAC	GETS2		/SAVE FOR ROTATE
	IDX	GETSP		/TO NEXT WORD
	LAW	-3
	DAC	GETSC		/RESET CHAR COUNT
GETS1	LAC	GETS2		/GET CURRENT WORD
	JMS	ROT6L
	DAC	GETS2		/SAVE FOR NEXT CALL
	RAL			/ONE MORE
	AND	(77		/6 BITS
	DAC	GETS3		/SAVE FOR LATER
	SNA
	JMP*	GETS		/NULL CHAR (NO BIT 7)
	AND	(40
	SNA!CLA			/SHOULD BIT 7 BE ADDED?
	LAC	(100		/YES
	XOR	GETS3		/NO-GET CHAR
	JMP*	GETS
 
GETSP	0			/BUFFER POINTER
GETSC	0			/CHAR COUNTER (-3 THRU -1)
GETS2	0			/TEMP STORE FOR BUFFER WORD
GETS3	0			/TEMP CHAR
 
	.EJECT
/PACK ROUTINE FOR SIXBIT
 
/CALLING SEQUENCES:
/	1.PACK	INIT
/	LAC	(N		/N=0 OR START ADDR
/	JMS	PUTSI
/	(RETURN)			/NEXT PACK ADDR IN AC IF N=0
 
/	2.PACK
/	LAC	(N		/N=CHAR TO BE PACKED
/	JMS	PUTS
/	(RETURN)
 
PUTSI	0
	SNA
	JMP	PUTSIX		/GO GET LAST POINTER
	XOR	BANKBT
	DAC	PUTSP		/INIT POINTER
	TAD	L1
	DAC	PUTS4
	DZM	PUTSC		/INIT COUNTER
	JMP*	PUTSI
PUTSIX	LAC	PUTS4		/RETURN POINTER
	JMP*	PUTSI
 
PUTS	0
	AND	(77		/6 BIT TRIMMED
	DAC	PUTS6		/SAVE CHAR
	CLL
	LAC	PUTSC		/CHAR POSITION
	TAD	(JMP PUTS7	/BUILD DISPATCH
	DAC	.+2
	LAC	PUTS6		/GET CHAR
	XX			/MODIFIED JMP* PUTS7 (+0 TO +2)
PUTS7	JMP	PUTS1		/CHAR 1
	SKP			/CHAR 2
	JMP	PUTS3		/CHAR 3
	JMS	ROT6L
	JMP	PUTS5
PUTS1	JMS	ROT6R		/7 RIGHT
	RAR
	DZM*	PUTSP		/CLEAR WORD
	JMP	PUTS5
PUTS3	DZM	PUTSC		/CLEAR POSITION
	IDX	PUTS4		/TO NEXT WORD
	SKP			/NO MOVEMENT
PUTS5	IDX	PUTSC		/TO NEXT CHAR POSITION
	XOR*	PUTSP
	DAC*	PUTSP		/MERGE IN CHAR
	LAC	PUTSC		/IS WORD COMPLETE?
	SNA			/SKIP IF NOT
	IDX	PUTSP		/YES-POINT TO NEXT WORD
	JMP*	PUTS
 
	.EJECT
/FETCH ROUTINE - COMBINED UNPACK/PACK
/	SUBROUTINE WHICH TERMINATES SCAN
/	ON SPACE,CR,ESC,COMMA,SLASH,
/	OR NULL CHARACTER.
/	LEADING SPACES AND LINE FEEDS ARE IGNORED.
 
/CALLING SEQUENCE:
/	JMS	FETCH
/	ADDR	(13 BITS)		/BEGIN UNPACK
/	JMS	INIT		/UNPACK INIT OR NOP
/	JMS	UNPACK		/.SIXBT OR .ASCII
/	ADDR	(13 BITS)		/BEGIN PACK
/	JMS	INIT		/PACK INIT OR NOP
/	JMS	PACK		/.SIXBT OR .ASCII
/	(RETURN)			/EMPTY
/	(RETURN)			/NON-EMPTY
 
FETCH	0
 
	DZM	FETCHC		/CLEAR CHAR COUNT
	LAC*	FETCH		/GET UNPACK START
	IDX	FETCH
	XCT*	FETCH		/INIT UNPACK OR NOP
	IDX	FETCH
	LAC*	FETCH		/SETUP JMS UNPACK
	DAC	FETCHU
	IDX	FETCH
	LAC*	FETCH		/GET PACK START
	DAC	FETCHQ
	IDX	FETCH
	XCT*	FETCH		/INIT PACK OR NOP
	LAC*	FETCH
	DAC	FETCHT
	IDX	FETCH
	LAC*	FETCH		/SETUP JMS PACK
	DAC	FETCHP
	IDX	FETCH		/NOW POINTS TO EMPTY RETURN
	XCT	FETCHU		/GET CHARACTER
	SAD	L12
	JMP	.-2		/LEADING LINE FEED - IGNORE
	SAD	(40
	JMP	.-4		/LEADING SPACE - IGNORE
	SKP			/DON'T GET CHAR AGAIN
FETCHU	XX			/.SIXBT OR .ASCII UNPACK
	SNA
	JMP	FETCHD		/NULL
	SAD	(40
	JMP	FETCHD		/SPACE
	SAD	(57
	JMP	FETCHD		/SLASH
	SAD	(54
	JMP	FETCHD		/COMMA
	SAD	(175
	JMP	FETCHD		/ALTMODE
	SAD	L15
	JMP	FETCHD		/CARRIAGE-RETURN
FETCHP	XX			/.SIXBT OR .ASCII PACK
	IDX	FETCHC		/INCREMENT CHAR COUNT
	JMP	FETCHU		/NEXT CHAR
FETCHD	DAC	LASTCR		/SAVE LAST CHAR
	LAC	FETCHC
	SZA!CLA
	IDX	FETCH		/TO NON-EMPTY RETURN
FETCHT	XX			/JMS PACKINIT (OR NOP)
	AND	(17777		/NEXT PACK ADDR RETURNED IN AC.
	JMS	TWOS
	TAD	FETCHQ		/INITIAL PACK ADDR
	DAC	FETCHQ		/# OF WORDS FILLED
	LAC	LASTCR		/EXIT WITH LAST CHAR IN AC
	JMP*	FETCH
 
FETCHC	0			/COUNT OF PACKED CHARS
LASTCR	0			/LAST CHAR
NOWORD=.
FETCHQ	0			/NO. OF WORDS FILLED
 
	.EJECT
/SEARCH ROUTINE FOR TABLE LOOKUP
/	ON A .SIXBT OR .ASCII TABLE
 
/TABLE FORMAT:
/	WD0=2'S COMP NUMBER OF ENTRIES
/	WD1=2'S COMP NUMBER OF WDS BETWEEN ENTRIES
/	WD2-WDN=ACTUAL TABLE - ENTRY ENDS WITH NULL
 
/CALLING SEQUENCE:
/	IDX	CMD1CH		/IF SINGLE LETTERS NOT ALLOWED
/	JMS	SEARCH
/	ADDR	(13 BITS)		/TABLE START
/	UNPACK	INIT		/FOR TABLE
/	JMS	UNPACK		/FOR TABLE
/	PACK	INIT		/FOR TABLE
/	JMS	PACK		/FOR TABLE
/	ADDR	(13 BITS)		/COMMAND START
/	-N			/WORDS IN COMMAND
/	(RETURN)			/NOT FOUND
/	(RETURN)			/FOUND
 
SEARCH	0
 
	LAC*	SEARCH		/TABLE START
	XOR	BANKBT
	DAC	SEARTS		/SAVE 15 BIT ADDR
	IDX	SEARCH
	LAC*	SEARCH		/TABLE UNPACK INIT
	DAC	SEAR01
	IDX	SEARCH
	LAC*	SEARCH		/TABLE UNPACK
	DAC	SEAR02
	IDX	SEARCH
	LAC*	SEARCH		/TABLE PACK INIT
	DAC	SEAR03
	IDX	SEARCH
	LAC*	SEARCH		/TABLE PACK
	DAC	SEAR04
	IDX	SEARCH
	LAC*	SEARCH		/COMMAND START
	XOR	BANKBT
	DAC	SEARCS
	IDX	SEARCH
	LAC*	SEARCH		/- WDS IN CMD
	DAC	SEAR05
	TAD	L10
	SPA
	JMP	ARGFMT		/ERROR.
	IDX	SEARCH		/RETURN SET TO NOT FOUND
 
	LAC*	SEARTS
	DAC	SEARTC		/TABLE COUNT
	IDX	SEARTS
	LAC*	SEARTS		/# WORDS BETWEEN ENTRIES
	IDX	SEARTS		/POINTS TO FIRST
	SNA
	LAC	L.SKP		/NO WORDS BETWEEN
	DAC	SEAR06		/LAW -N OR SKP
	LAW	-1
	DAC	SEARCT
 
SEARL1	LAC	SEARTS		/TABLE POINTER
	AND	(17777		/MASK TO 13 BITS
SEAR01	XX			/TABLE UNPACK INIT (JMS)
	LAC	L.SCD		/ADDR OF 10 WORD BUFFER (SEARCD
SEAR03	XX			/TABLE PACK INIT
	LAC	(DZM SEARCD
	DAC	.+3
SEAR05	XX			/-# OF WORDS IN COMMAND
	DAC	SEART1		/TEMP COUNTER
	XX			/CLEAR OUT THAT
	IDX	.-1		/MANY WORDS IN PACK BUFFER.
	ISZ	SEART1
	JMP	.-3
 
SEAR02	XX			/TABLE UNPACK
	XCT	SEAR04		/JMS "PACK"
	LAC	SEARCD
	DAC	SEART2		/SAVE 1ST CHAR
SEARL2	XCT	SEAR02		/TABLE UNPACK
	SNA
	JMP	SEARL3		/NULL IS DONE
SEAR04	XX			/TABLE PACK
	JMP	SEARL2
SEARL3	XCT	SEAR01		/REVERSE UNPACK INIT
	DAC	SEARTS		/GIVES NEXT UNPACK ADDR
	LAC	SEART2
	SZA
	JMP	.+3		/NOT BOUNDARY
	IDX	SEAROL		/NO ONE LETTER CMDS
	JMP	SEARL1		/NEXT CMD
	IDX	SEARCT
	NOP			/IN CASE OF SKIP?!
	LAC	SEAROL
	SZA
	JMP	SEARL4		/NO ONE LETTER
	LAC*	SEARCS		/CHECK 1ST LETTER
	SAD	SEART2
	JMP	SEARFC		/COMMAND FOUND
SEARL4	LAC	SEARCS
	DAC	SEART1		/COMMAND START
	LAC	L.SCD
	XOR	BANKBT
	DAC	SEART2		/ENTRY START
	XCT	SEAR05
	DAC	SEART3		/- SIZE
SEARL5	LAC*	SEART1		/ARE THEY SAME
	SAD*	SEART2
	SKP
	JMP	SEARL6		/NO
	IDX	SEART1		/YES
	IDX	SEART2
	ISZ	SEART3		/WHOLE CMD TESTED
	JMP	SEARL5		/NO
SEARFC	IDX	SEARCH		/YES - TO GOOD RETURN
SEARXT	DZM	SEAROL		/RESET ONE LETTER
	JMP*	SEARCH		/RETURN
SEAR06=.
SEARL6	XX			/LAW -N (# WDS BETW CMDS) OR SKP
	SKP
	JMP	SEARL8		/NONE BETWEEN
	DAC	SEART1
	IDX	SEARTS		/BUMP PAST TO NEXT CMD
	ISZ	SEART1
	JMP	.-2
SEARL8	ISZ	SEARTC		/ANY MORE IN TABLE
	JMP	SEARL1		/YES
	JMP	SEARXT		/NO - BAD RETURN
 
CMDADR=.
SEARTS	0			/TABLE POINTER
SEARCS	0			/COMMAND POINTER
SEARTC	0			/TABLE COUNT
CMDCNT=.
SEARCT	0			/COMMAND COUNT
CMD1CH=.
SEAROL	0			/ON CHAR SWITCH
 
	.EJECT
/FETCH A SIGNED NUMERIC QUANTITY
/	TERMINATED BY A SPACE, CR, ESC,
/	COMMA, OR SLASH CHARACTER
 
/CALLING SEQUENCE:
/	JMS	FETCHN
/	(RETURN)			/EMPTY
/	(RETURN)			/NON-EMPTY - IN AC
 
/NOTE: LASTCR WILL CONTAIN THE SCAN
/	TERMINATION CHARACTER
 
FETCHN	0
 
	DZM	FETSGN		/CLEAR SIGN
	DZM	FETNUM		/CLEAR NUMBER
	DZM	FETCNT
	JMS	GET		/ASCII UNPACK FROM CURRENT LINE
	SAD	L12
	JMP	.-2		/IGNORE LINE FEED
	SAD	(40
	JMP	.-4		/IGNORE LEADING SPACE
	SKP
FETNLP	JMS	GET		/USE CURRENT LINE
	SAD	(40
	JMP	FETDNM		/SPACE
	SAD	(57
	JMP	FETDNM		/SLASH
	SAD	(54
	JMP	FETDNM		/COMMA
	SAD	(175
	JMP	FETDNM		/ALTMODE
	SAD	L15
	JMP	FETDNM		/CARRIAGE RETURN
	SAD	(55
	JMP	FETMUS		/MINUS
	DAC	FETNMT		/TEMP SAVE
	AND	(170
	XOR	(60
	SZA			/TEST FOR OCTAL
	JMP	ILLNUM		/ILLEGAL NUMBER
	IDX	FETCNT		/NO. OF DIGITS
	LAC	FETNMT
	AND	L7
	DAC	FETNMT		/7 BITS ONLY
	LAC	FETNUM		/CURRENT VALUE
	CLL!RAL			/TIMES 10(8)
	RTL
	TAD	FETNMT		/NEW VALUE
	DAC	FETNUM
	JMP	FETNLP		/GO GET NEXT DIGIT
FETMUS	IDX	FETSGN		/MAKE MINUS
	JMP	FETNLP		/GO GET DIGITS
FETDNM	DAC	LASTCR		/SAVE TERMINATOR
	LAC	FETCNT
	SZA
	IDX	FETCHN		/TO NON-EMPTY RETURN
	LAC	FETSGN		/GET SIGN
	SZA!CLL
	CML			/MINUS
	LAC	FETNUM
	SZL
	JMS	TWOS		/COMPLEMENT IF MINUS
	JMP*	FETCHN		/RETURN WITH NUMBER
 
FETSGN	0			/SIGN OF NUMBER
FETNUM	0			/NUMBER ITSELF
FETNMT	0			/TEMP DIGIT
FETCNT	0			/COUNT
 
	.EJECT
/OCTAL TO 5/7 ASCII CONVERSION
 
/CALLING SEQUENCE:
/	LAC	(N		/N=ZERO SUPPRESSION CHAR IF NOT NULL
/	DAC	SUPCHR
/	LAC	(M		/M=WORD TO BE CONVERTED
/	JMS	OCTOUT
 
/NOTES:
/	1.SUPCHR WILL BE RESET TO
/		NULL AFTER EACH CALL
/	2.OUTPUT WILL BE VIA PUT,
/		THEREFORE PUTI MUST HAVE
/		BEEN CALLED PRIOR TO CALLING
/		THIS SUBROUTINE
 
OCTOUT	0
 
	DAC	OCTCHR		/SAVE CHAR
	SZA
	JMP	OCTNZR		/NOT ZERO
	LAW	-5
	DAC	OCTCNT		/FIVE OF SUPCHR
	LAC	SUPCHR
	JMS	PUT
	ISZ	OCTCNT		/ANY MORE?
	JMP	.-3		/YES
	LAC	(60		/N0 - OUTPUT ZERO
	JMS	PUT
OCTXIT	DZM	SUPCHR		/RESET TO NULL
	JMP*	OCTOUT
OCTNZR	LAC	L.NOP
	DAC	OCTZER		/SET SWITCH
	LAW	-6
	DAC	OCTCNT		/SET COUNT
OCTNXD	LAC	OCTCHR		/CHAR FOR CONVERSION
	CLL!RAL
	RTL
	DAC	OCTCHR		/SAVE FOR NEXT
	RAL
	AND	L7		/SEVEN BITS ONLY
OCTZER	XX			/NOP OR JMP OCTDIG
	SNA			/IS IT LEADING ZERO?
	JMP	OCTSUP		/YES
	DAC	SUPCHR
	LAC	.+3		/NO - GET JMP
	DAC	OCTZER
	LAC	SUPCHR
	JMP	OCTDIG		/GO PROCESS DIGIT
OCTSUP	LAC	SUPCHR		/GET SUPRESSION CHAR
	SKP
OCTDIG	XOR	(60		/MAKE ASCII
	JMS	PUT
	ISZ	OCTCNT		/ANY MORE DIGITS?
	JMP	OCTNXD		/YES
	JMP	OCTXIT		/NO
 
OCTCHR	0			/WORD TO BE CONVERTED
SUPCHR	0			/ZERO SUPPRESSION CHAR
OCTCNT	0			/TEMP COUNTER
 
	.EJECT
/ALTMODE SCAN ROUTINE
 
/CALLING SEQUENCE:
/	JMS	ALTSCN
/	(RETURN)		/ALTMODE FOUND
/	(RETURN)		/CR FOUND
 
ALTSCN	0
 
	LAC	L.BUF		/INIT GET ROUTINE
	JMS	GETI
ALTSCL	JMS	GET		/GET CHAR
	SAD	(175		/ALTMODE?
	JMP*	ALTSCN		/YES
	SAD	L15		/NO - CR?
	SKP			/YES
	JMP	ALTSCL		/NO - TEST NEXT
	IDX	ALTSCN		/BUMP TO CR RETURN
	JMP*	ALTSCN
 
/TEST LAST CHARACTER FOR CARRIAGE-RETURN OR ALTMODE.
 
/CALLING SEQUENCE:
/	JMS	ENDLIN
/	(RETURN)			/IF CR OR ALTMODE
/	(RETURN)			/IF NOT CR OR ALTMODE
 
ENDLIN	0
 
	LAC	LASTCR
	SAD	L15
	JMP*	ENDLIN		/CR FOUND.
	SAD	(175
	JMP*	ENDLIN		/ALTMODE FOUND.
	IDX	ENDLIN
	JMP*	ENDLIN		/NOT FOUND.
 
	.EJECT
/SUBROUTINE TO FORM TWOS COMPLEMENT
/	OF ACCUMULATOR
 
/CALLING SEQUENCE:
/	JMS	TWOS
 
TWOS	0
 
	CMA!CLL
	TAD	L1
	JMP*	TWOS
 
/SUBROUTINE TO ROTATE AC 6 ROGHT
 
/CALLING SEQUENCE:
/	JMS	ROT6R
 
ROT6R	0
 
	RTR
	RTR
	RTR
	JMP*	ROT6R
 
/SUBROUTINE TO ROTATE AC 6 LEFT
 
/CALLING SEQUENCE:
/	JMS	ROT6L
 
ROT6L	0
 
	RTL
	RTL
	RTL
	JMP*	ROT6L
 
/SUBROUTINE PUT40: STORE A SPACE CHAR. IN BUFFER.
 
PUT40	0
 
	LAC (40
	JMS PUT
	JMP* PUT40
 
	.EJECT
/FETCH COMMAND FROM CURRENT INPUT
/	LINE (.ASCII) INTO COMAND (.SIXBT).
/	LEADING LINE FEEDS AND SPACES ARE
/	IGNORED. SCAN TERMINATED BY SPACE,
/	COMMA, NULL, SLASH, CAR RET, OR ALTMODE.
 
/CALLING SEQUENCE:
/	JMS	CURCMD
/	(RETURN)			/EMPTY COMMAND
/	(RETURN)			/GOOD FETCH
 
CURCMD	0
 
	JMS	FETCH
	NOP			/NO UNPACK INIT ADDR
	NOP			/NO UNPACK INIT
	JMS	GET		/UNPACK 5/7 ASCII
	COMAND			/INTO COMAND BUFFER
	JMS	PUTSI		/PACK INIT
	JMS	PUTS		/PACK IN 6 BIT
 
	SKP			/EMPTY
	IDX	CURCMD		/NON EMPTY
	JMP*	CURCMD
 
/NOTHING ELSE EXPECTED FROM INPUT LINE.
/	SEARCH FOR END OF LINE. IGNORE
/	NON-PRINTING CHARS.
 
FINISH	0
 
FINLOP	JMS ENDLIN	/DON'T SKIP IF LASTCR=C.R. OR ALTMODE.
	JMP* FINISH	/YES.
	TAD MIN40
	SPA!SNA
	JMP FINGET	/NON-PRINTING CHAR.
	TAD (-137
	SPA!SNA
	JMP ILLCMD	/PRINTING CHAR.
FINGET	JMS GET		/GET NEXT CHAR.
	DAC LASTCR
	JMP FINLOP
 
	.EJECT
/CHECK FOR LEGAL .DAT NUMBER
 
/CALLING SEQUENCE:
/	JMS	CHKDAT		/.DAT# IN AC
/	(RETURN)			/NOT LEGAL
/	(RETURN)			/LEGAL
 
/NOTE: DATPTR CONTAINS ADDRESS OF PROPER
/	.DAT TABLE (.DATF OR .DATB)
 
CHKDAT	0
 
	TAD	DATPTR		/.DAT POINTER
	DAC	CHKDTP		/SAVE
	SAD	DATPTR		/ZERO .DAT?
	JMP*	CHKDAT		/ILLEGAL
	JMS	TWOS
	TAD*	DATPTR		/.DATND ADDR
	SPA!SNA			/TOO LARGE .DAT?
	JMP*	CHKDAT		/ILLEGAL
	LAC*	DATPTR		/GET .DATND ADDR
	DAC	CHKDPR		/SAVE
	LAC*	CHKDPR		/GET .DATBG ADDR
	JMS	TWOS
	TAD	CHKDTP		/ADD REAL .DAT
	SMA			/TOO SMALL?
	IDX	CHKDAT		/NO - GOOD RETURN
	JMP*	CHKDAT		/YES
 
	.EJECT
/SUBROUTINE TO CHECK .DAT SLOT ENTRY
/	AGAINST .IOIN TABLE AND TO CORRECT
/	A NON-MULTI UNIT HANDLER TO THE MULTI-UNIT
/	HANDLER IF THE LATTER IS IN CORE
 
/CALLING SEQUENCE:
/	DAC	.IOWRD
/	JMS	FGDCHK
/	(RETURN)			/ILLEGAL DAT CONTENTS
/	(RETURN)			/LEGAL
 
FGDCHK	0
 
FGDIF	JMS	IFIOIN		/IS IT IN .IOIN?
	JMP	FGDOK		/NO DEVICE MATCH - OK
	JMP	FGDDEV		/NO HANDLER MATCH
	JMP	FGDHAN		/HANDLER (BUT NOT UNIT) MATCH
 
/EXACT MATCH. .IOIN ENTRY # IS IN THE AC.
 
	SAD	L1		/ENTRY 1 = SYS DEVICE & UNIT
	JMP	FGDOK
	SAD	L2		/FGD CTL TTY ENTRY
	JMP	FGDCTL
	SAD	L3		/BGD CTL TTY ENTRY
	JMP	BGDCTL
 
/ONLY BGD GETS HERE.
 
	TAD	IOINFC		/-# OF NON-BGD .IOIN ENTRIES
	SMA!SZA!CLA		/(INCLUDING BGD CTL TTY).
	JMP	FGDOK		/BGD BATCH HANDLER - OK
 
/BGD REQUEST FOR FGD UNIT: $SHARE FLAG MUST BE ON, DEVICE MUST BE
/BULK STORAGE, AND HANDLER MUST BE A .MUD HANDLER.
 
	SAD*	(.SCOM+77		/$SHARE FLAG
	JMP*	FGDCHK		/NO SHARE - ERROR RETURN
	LAC	.IOWRD
	JMS	IFMUD
	JMP*	FGDCHK		/NON-.MUD - ERROR RETURN
	LAC	.IOWRD		/MULTIPLY HANDLER CODE BY 4
	RTL			/(.IOTAB HAS 4 WRDS PER ENTRY).
	AND	(774
	TAD	(LAC .IOTAB+4
	DAC	.+1
	XX			/GET HANDLER'S INFO WORD.
	SPA
	JMP*	FGDCHK		/NON-BULK - ERROR RETURN
	JMP	FGDOK		/OK TO SHARE SAME UNIT.
 
/CONTROL TELETYPE CAN'T BE USED BY OTHER JOB.
 
FGDCTL	XCT	SKPFGD
	JMP*	FGDCHK		/ERROR RETURN
	SKP
BGDCTL	XCT	SKPFGD
FGDOK	IDX	FGDCHK		/.IOWRD OK - SKIP ON RETURN
	JMP*	FGDCHK
 
/FOUND DEVICE (BUT NOT HANDLER) MATCH.
 
FGDDEV	LAC*	IOINPT		/GET .IOIN ENTRY
	AND	(177
	DAC	FGDCOD		/SAVE HANDLER CODE
	JMS	IFMUD
	JMP*	FGDCHK		/NON-.MUD - ERROR RETURN
	777600			/REPLACE HANDLER CODE IN
	AND	.IOWRD		/.IOWRD, E.G., DTB. BECOMES DTA.
	XOR	FGDCOD
	DAC	.IOWRD
	JMP	FGDIF		/CHECK AGAIN.
 
/HANDLER MATCH, BUT NO UNIT MATCH. THE FOLLOWING TEST
/AFFECTS BGD ONLY BECAUSE IN FGD BOTH HANDLERS IN CORE
/ARE .MUD HANDLERS.
 
FGDHAN	LAC	.IOWRD
	JMS	IFMUD
	JMP*	FGDCHK		/NON-.MUD - ERROR RETURN
	JMP	FGDOK
 
FGDCOD	0			/HANDLER CODE.
 
	.EJECT
/.IOIN TABLE LOOKUP
 
/THE VALUE IN THE .IOWRD IS CHECKED FOR
/	THREE TYPES OF MATCH.
/	THE .IOIN ENTRY # IS RETURNED
/	IN THE AC, IF EXACT MATCH.
/	THE ENTRY POINTER WILL BE IN IOINPT.
 
/CALLING SEQUENCE:
/	JMS	IFIOIN
/	(RETURN)			/NO MATCH
/	(RETURN)			/DEVICE CODE MATCH
/	(RETURN)			/DEV HANDLER MATCH
/	(RETURN)			/EXACT MATCH
 
IFIOIN	0
 
	LAC*	(.SCOM+13
	DAC	IOINP		/.IOIN POINTER
	LAC*	IOINP
	DAC	IOINC		/.IOIN COUNTER
	IDX	IOINP
	IDX	IOINP		/TO FGD ENTRIES
	LAC*	IOINP
	DAC	IOINFC		/FGD COUNT
	IDX	IOINP		/TO FIRST ENTRY
	LAC	L1
	DAC	IOINCT		/.IOIN COUNT OF ENTRIES PROCESSED
	LAC	.IOWRD
	AND	(200000		/IS IT TTY?
	SZA
	JMP	IFIOTT		/YES.
IFIODM	LAC	.IOWRD
	AND	(17600		/MASK TO GET DEVICE CODE.
	DAC	IFIOTP		/TEMP SAVE.
	LAC*	IOINP
	AND	(17600		/SAME.
	SAD	IFIOTP		/DEVICE CODE MATCH?
	JMP	.+3		/YES.
	JMS	IFIONX		/MOVE TO NEXT ENTRY.
	JMP	IFIODM		/CONTINUE UNLESS TABLE EXHAUSTED.
	LAC	IOINP
	DAC	IOINPT		/SAVE PTR TO .IOIN ENTRY.
	IDX	IFIOIN		/SET RETURN FOR DEVICE CODE MATCH.
IFIOHM	LAC	.IOWRD		/MASK TO GET DEV CODE
	AND	(17777		/AND HANDLER CODE.
	DAC	IFIOTP		/TEMP SAVE.
	LAC*	IOINP
	AND	(17777		/SAME.
	SAD	IFIOTP		/DEV-HANDLER MATCH?
	JMP	.+5		/YES.
	JMS	IFIONX		/MOVE TO NEXT ENTRY.
	JMP	IFIOHM		/CONTINUE UNLESS TABLE EXHAUSTED.
IFIOTT	JMS	IFIONX
	IDX	IFIOIN
	LAC	IOINP
	DAC	IOINPT		/SAVE PTR TO .IOIN ENTRY.
	IDX	IFIOIN		/SET RETURN FOR DEV-HANDLER MATCH.
IFIOXM	LAC	.IOWRD
	SAD*	IOINP		/EXACT MATCH?
	JMP	.+3		/YES.
	JMS	IFIONX		/MOVE TO NEXT ENTRY.
	JMP	IFIOXM		/CONTINUE UNLESS TABLE EXHAUSTED.
	LAC	IOINP
	DAC	IOINPT		/SAVE PTR TO .IOIN ENTRY.
	IDX	IFIOIN		/SET RETURN FOR EXACT MATCH.
	LAC	IOINCT		/RETURN .IOIN ENTRY # IN AC.
	JMP*	IFIOIN
 
IFIONX	0
 
	IDX	IOINCT
	IDX	IOINP
	IDX	IOINP
	ISZ	IOINC
	JMP*	IFIONX
	JMP*	IFIOIN
 
IOINP	0			/.IOIN POINTER (TEMP)
IOINPT	0			/.IOIN POINTER
IOINC	0			/.IOIN COUNTER
IOINCT	0			/ENTRY COUNT
IOINFC	0			/FGD .IOIN COUNT (2'S)
IFIOTP	0			/TEMP STORAGE
 
	.EJECT
/.MUD TABLE LOOKUP
 
/THE VALUE IN THE AC IS CHECKED
/	AGAINST THE HANDLER NUMBER
/	PORTION OF THE .MUD ENTRIES.
 
/CALLING SEQUENCE:
/	JMS	IFMUD		/DEV CODE IN AC
/	(RETURN)			/NOT IN .MUD
/	(RETURN)			/IN .MUD - POINTER IN AC
 
IFMUD	0
 
	RTL
	SZL!RTL		/SKIP IF NOT LT19.
	LAC (20
	RTL
	AND	(17700
	DAC	IFMDEV		/SAVE HANDLER CODE
	LAC*	(.SCOM+14
	DAC	IFMUDP		/.MUD POINTER
	LAC*	IFMUDP
	DAC	IFMUDC		/.MUD COUNTER
	IDX	IFMUDP
IFMUDL	LAC*	IFMUDP		/GET WD0 OF ENTRY
	AND	(17700
	SAD	IFMDEV		/RIGHT HANDLER CODE?
	JMP	IFMUDV		/YES
	IDX	IFMUDP		/NO - TRY NEXT
	IDX	IFMUDP
	ISZ	IFMUDC		/ANYMORE?
	JMP	IFMUDL		/YES
	JMP*	IFMUD		/NO - RETURN
IFMUDV	IDX	IFMUD		/TO GOOD RETURN
	LAC	IFMUDP		/POINTER IN AC
	JMP*	IFMUD
 
IFMDEV	0			/HANDLER CODE
IFMUDP	0			/.MUD POINTER
IFMUDC	0			/.MUD COUNTER
 
	.EJECT
/TYPE SUBROUTINES
 
/CALLING SEQUENCE:
/	JMS	TYPE
/	ADDR			/13 BITS
/	(RETURN)
 
/WHERE ADDR POINTS TO 5/7 ASCII
/	BUFFER TO BE TYPED
 
/CALLING SEQUENCE:
/	JMS	TYPEX
/	(RETURN)
 
/WHERE THE 5/7 BUFFER IS IN THE BUFFER AREA
 
TYPE	0
 
	LAC*	TYPE		/GET POINTER
	IDX	TYPE
	JMS	GETI		/INITIALIZE
	LAC	L.BUF
	JMS	PUTI
TYPELP	JMS	GET
	JMS	PUT		/INTO BUFFER AREA
	SAD	L15		/CHECK FOR END OF LINE
	SKP
	SAD	(175
	SKP			/YES
	JMP	TYPELP		/NO-GO GET MORE
	JMS	TYPEX		/PRINT BUFFER
	JMP*	TYPE
 
TYPEX	0
 
TYPEW	.WRITE	-3,2,BUFFER-2,50
 
	.WAIT	-3
 
	JMP*	TYPEX
 
	.EJECT
/VARIABLES
 
FCORES=.			/SAVE AREA FOR FCORE SIZE
REQCMP	0		/REQUEST COMMAND POINTER
REQSZE	0		/TABLE SIZE
RQDATN	0		/.DAT #
RQDVDT	0		/.DAT PTR
RQUNIT	0		/DEV UNIT #
RQTDEV	0		/TEMP HANDLER #
RQALLP	0		/ALL + IF NON-0
ASSUNT	0		/.SIXBT UNIT # STORAGE
	0
ASHNDC	0		/HANDLER CODE
ASDEVC	0		/DEVICE CODE
ASUNTC	0		/UNIT CODE
ASSCHR	0		/.SIXBT CHAR - TEMP
ASIOIN	0		/.IOIN ENTRY
ASSDAT	0		/.DAT SLOT POINTER
FILMUD	0		/.MUD ENTRY POINTER
CHTEMP=.			/TEMP. FOR 7/9 CHANNEL COMMANDS.
BCIOBT=.			/PTR TO BGD .IOIN ENTRY
FCIOBT	0		/"
BCDTM3=.			/TEMP
FCDTM3	0		/PTR TO .DATF (.DATB) -3
INUSEP=.			/PTR FOR INUSE COMMAND
FDBCTL	0		/BGD CTL TTY#+200000
INUSEC=.			/COUNTER FOR INUSE COMMAND
FDATND	0		/PTR TO END OF .DATF
FDATP	0		/PTR TO .DATF SLOT
FDFLAG	0		/0 FLAG MEANS NO SLOT CHANGED
BDDATB	0		/PTR TO .DATB+0
BDDATN	0		/PTR TO .DATB END
BDPTR	0		/PTR TO .DATB ENTRY
BDNUM	0		/.DATB SLOT #
BDFLAG	0		/0 FLAG MEANS NO SLOT CLEARED
PUTSP	0		/CURRENT WORD PTR
PUTSC	0		/POSITION COUNTER (0-2)
PUTS4	0		/NEXT WORD PTR
PUTS6	0		/TEMP CHAR
SEART1	0		/TEMP REGS USED
SEART2	0		/IN SEARCH
SEART3	0		/SUBR.
CHKDTP	0		/.DAT ENTRY PTR
CHKDPR	0		/TEMP PTR
	.EJECT
/BUFFER AREA OF 400(OCTAL), 2 10(OCTAL) COMMAND AREAS.
/	THIS CODE IS OVERLAYED.
 
BEGBUF=.
 
	.BLOCK	2
BUFFER	.BLOCK	376
 
COMAND	.BLOCK	10
 
SEARCD	.BLOCK	10
 
 
ENDBUF=.
 
	.LOC	BEGBUF
 
	.EJECT
/MONITOR INITIALIZATION
 
MONINT	LAC*	(.SCOM		/TOP OF CORE
	AND	(60000
	DAC	BANKBT		/BANK BITS FOR TOP BANK.
	LAC	TYPEW+2		/BANK INITIALIZATION DONE
	XOR	BANKBT		/ONLY TO ADDRESSES IN
	DAC	TYPEW+2		/CAL SEQUENCES.
	LAC	KLREAD+2
	XOR	BANKBT
	DAC	KLREAD+2
	LAC	LOG2+2
	XOR	BANKBT
	DAC	LOG2+2
	LAC	START+2
	XOR	BANKBT
	DAC	START+2
	LAC	SEK339+2
	XOR	BANKBT
	DAC	SEK339+2
	LAC	.SYSLD
	XOR	BANKBT
	DAC	.SYSLD
	LAC	DIR1+2
	XOR	BANKBT
	DAC	DIR1+2
	LAC	TRAN1+3
	XOR	BANKBT
	DAC	TRAN1+3
	LAC	NUM1+2
	XOR	BANKBT
	DAC	NUM1+2
	LAC	RD1339+2
	XOR	BANKBT
	DAC	RD1339+2
	LAC	BLK100+2
	XOR	BANKBT
	DAC	BLK100+2
	LAC	FRE.BK+2
	XOR	BANKBT
	DAC	FRE.BK+2
	LAC	SEAR.C+2
	XOR	BANKBT
	DAC	SEAR.C+2
 
/CHECK SYSTEM DEVICE: ASSUMED TO BE EITHER DECTAPE OR DISK.
 
	LAC*	(.SCOM+13		/PTR TO .IOIN
	TAD	L3
	DAC	.
	LAC*	.-1		/SYS DEV ENTRY
	AND	L200		/DTA OR DKA?
	SNA
	JMP	.+3		/DTA
	LAC	ASCDKA		/DKA
	DAC	SYSDEV
	LAC	(.SCOM+16		/POINTS TO .DATF POINTER
	TAD*	(.SCOM+26		/ADDS ONE IF BGD
	DAC	DATPTR
	LAC*	DATPTR		/POINTER TO .DATF OR .DATB
	DAC	DATPTR
	TAD	(-7
	DAC	DATM7S		/POINTS TO .DAT-7
	LAC*	DATM7S
	DAC	DATM7S		/CONTENTS OF .DAT-7
	LAC*	(.SCOM+26
	RAR			/LINK=0 IF FGD, 1 IF BGD
	LAC	L.SKP
	SNL
	DAC	SKPFGD		/SKIP IF FGD
	SZL
	DAC	SKPBGD		/SKIP IF BGD
	XCT	SKPBGD		/SKIP IF BGD
	JMP	CLA339
	LAC	L600		/.IOIN ENTRY CODE FOR 339 DISPLAY.
	DAC	.IOWRD
	JMS	IFIOIN
	JMP	CLA339		/FGD NOT USING THE 339
	NOP
	NOP
	JMP	.+3
CLA339	LAC	(CLA		/ALLOW MODIFICATION OF 339
	DAC	SYS339		/PUSH-DOWN LIST
	XCT	SKPFGD		/IS IT FGD?
	JMP	BGDINT		/NO-GO DO BGD INIT
FGDINT	LAC	L2		/YES
	DAC*	(.SCOM+25		/$FCORE DEFAULT
	LAC*	(.SCOM+13		/POINTER TO .IOIN
	TAD	L5
	DAC	MIFCTL		/POINTER TO FGD CTL TTY ENTRY
	TAD	L2
MIBCTL	DAC	.		/POINTER TO BGD CTL TTY ENTRY
	LAC*	MIFCTL
	DAC	MIFCTL
	LAC*	MIBCTL		/BGD CTL TTY# + 200000
	JMS	FDATCH		/CHANGE .DATF SLOTS IF NECESSARY.
MIFCTL	XX			/FGD CTL TTY# + 200000
 
	LAC	FKM9
	JMP	ENDINT
BGDINT	LAC*	(.SCOM+25
	DAC*	(.SCOM+2		/TO ABOVE FGD
	LAW	-1
	TAD	.SYSLD		/BOTTOM OF .SYSLD -1 NOW
	DAC*	(.SCOM+3		/SETUP TO START BUILDING .IOC TABLE
	LAC*	(.SCOM+15		/RESET C(.BFTAB) TO
	DAC	INIT1		/C(.BFTAB+2)-TOTAL
	TAD	L2		/COUNT EQUALS FGD COUNT
	DAC	INIT2
	LAC*	INIT2
	DAC*	INIT1
	LAC*	(.SCOM+13		/RESET C(.IOIN) TO C(.IOIN+2)
	DAC	INIT1		/-TOTAL COUNT EQUALS FGD COUNT
	TAD	L2
	DAC	INIT2
	LAC*	INIT2
	DAC*	INIT1
	LAC	BDATSZ		/BGD .DAT SIZE
	DAC	INIT1		/COUNTER
	LAC	L.BDSV		/BGD .DAT SAVE POINTER
	XOR	BANKBT
	DAC	INIT2
	DZM	INIT4
	LAC*	DATPTR		/PTR TO .DATND
	DAC	INIT3
	LAC*	INIT3		/PTR TO .DATBG
	DAC	INIT3
BGDILP	LAC*	INIT2		/.DAT ENTRY
	DAC	.IOWRD
	SAD	L400K
	JMP	BGDILX		/LEAVE AS IS.
	JMS	FGDCHK		/CHECK AND CHANGE?
	SKP
	JMP	.+3
	LAC*	INIT2
	SKP
	LAC	.IOWRD		/.DAT ENTRY.
	DAC*	INIT3		/SETUP .DAT ENTRY
BGDILX	IDX	INIT2		/TO NEXT ENTRY
	IDX	INIT3	
	ISZ	INIT1		/ANY MORE?
	JMP	BGDILP		/YES
	JMS	BDTCLR		/CLEAR CONFLICTING BGD .DATS
	LAC	BKM9
ENDINT	DAC	BF9
	LAW	-3
	TAD	DATPTR
	DAC	INIT1		/POINTS TO .DAT-3
	LAC*	INIT1		/CNTS OF .DAT-3
	IDX	INIT1		/POINTS TO .DAT-2
	DAC*	INIT1		/RESET .DAT-2
 
	.EJECT
/ROUTINE TO GENERATE (FGD) OR
/	INITIALIZE (BGD) THE MULTI-UNIT
/	DEVICE TABLE (.MUD)
 
/.MUD TABLE FORMAT:
/	WD0 IS 2'S COMP OF NUMBER OF ENTRIES
 
/ENTRY FORMAT:
/	WD0,BIT 0 IS FILES GIVEN BIT
/	WD0,BITS 5 TO 11 IS HANDLER NUMBER
/	WD0,BITS 12 TO 17 IS FILES COUNT
/	WD1,BITS 0 TO 11 IS BUFFER SIZE
/	WD1,BITS 12 TO 17 IS MAXIMUM FILES COUNT
 
	LAC	.IOTAB		/GET .IOTAB COUNT
	DAC	MUDTCT
	LAC	L.IOTB		/GET .IOTAB ADDRESS
	TAD	L11
	XOR	BANKBT
	DAC	MUDWRD		/POINTS TO .MUD ENTRY WORD
	LAC*	(.SCOM+2
	XCT	SKPBGD		/SKIP IF BACKGROUND
	DAC*	(.SCOM+14		/.MUD POINTER
	LAC*	(.SCOM+14
	DAC	MUDPNT		/TO EACH ENTRY
	IDX	MUDPNT		/FIRST
	DAC	MUDCNT		/TO COUNT
	LAC	L1
	DAC	MUDDEV		/INIT DEVICE HANDLER CODE
	DAC*	MUDCNT
	DZM*	MUDPNT		/FIRST ENTRY IN TABLE IS
	IDX	MUDPNT		/FOR PSEUDO-DEVICE (..)
	LAC	(10077		/WHOSE BUFFER SIZE IS 100
	DAC*	MUDPNT		/AND MAXCNT IS 77.
	IDX	MUDPNT
MUDLOP	LAC*	MUDWRD		/GET 2ND MUD WORD
	SNA
	JMP	MUDNXT		/NOT A .MUD HANDLER
	LAC	MUDDEV		/GET HANDLER CODE
	JMS	ROT6L
	AND	(17700		/CLEAR FILES COUNT
	DAC*	MUDPNT		/SAVE IN .MUD
	IDX	MUDPNT
	LAC*	MUDWRD
	XCT	SKPBGD		/SKIP IF BACKGROUND
	DAC*	MUDPNT
	IDX	MUDPNT	
	IDX*	MUDCNT
MUDNXT	LAC	MUDWRD		/UPDATE TO NEXT ENTRY
	TAD	L4
	DAC	MUDWRD
	IDX	MUDDEV		/TO NEXT HANDLER NUMBER
	ISZ	MUDTCT		/ANY MORE
	JMP	MUDLOP		/YES
	LAC*	MUDCNT		/NO-CLEAN UP
	JMS	TWOS
	DAC*	MUDCNT		/KEEP TWOS COMP COUNT
	LAC	MUDPNT
	XCT	SKPBGD		/SKIP IF BACKGROUND
	DAC*	(.SCOM+2		/UPDATE FREE POINTER
	LAC*	(.SCOM+2
	DAC*	(.SCOM+1
	XCT	SKPBGD
	DAC*	SCM106		/ADDRESS ABOVE RESMON.
	JMP	START
 
INIT1=.
MUDTCT	0			/TEMP COUNTER
INIT2=.
MUDWRD	0			/POINTS TO .MUD ENTRY
				/WORD IN .IOTAB
INIT3=.
MUDPNT	0			/POINTS TO ACTUAL .MUD ENTRY
INIT4=.
MUDCNT	0			/POINTS TO .MUD
MUDDEV	0			/DEVICE HANDLER COUNT
 
FKM9	.ASCII	/FKM/
	.LOC	.-1
BKM9	.ASCII	/BKM/
	.LOC	.-1
ASCDKA	.ASCII	/DKA/
	.LOC	.-1
L.BDSV	BDATSV			/BGD .DAT SAVE POINTER
L200	200
L600	600			/.IOIN FORMAT FOR 339 DEVICE CODE.
SCM106	.SCOM+106
 
/THE FOLLOWING INFORMATION IS FOR THE USE OF SYSTEM GENERATOR.
 
.SGINF	.IOTAB			/POINTER TO .IOTAB
	.IOTAB-.IOTND		/2'S COMP SIZE OF .IOTAB
	BDATSV			/POINTER TO BGD .DAT IMAGE
 
	.EJECT
/BACKGROUND .DAT IMAGE FOR MONITOR INITIALIZATION
 
/NOTE:IF IMAGE ENTRY IS 400000, THEN LEAVE .DAT SLOT
/	CONTENTS AS IS
 
BDATSZ	.-BDATND			/2'S COMP OF TABLE SIZE
 
BDATSV	6*20000	4*200+4		/(-15) DTA6
	4*20000	4*200+4		/(-14) DTA4
	5*20000	4*200+4		/(-13) DTA5
	10*200+10			/(-12) LPA
	4*20000	4*200+4		/(-11) DTA4
	6*200+6			/(-10) PRA
	400000			/(-7) LEAVE ALONE
	6*20000	4*200+4		/(-6) DTA6
	000000			/(-5) NONE
	5*20000	4*200+4		/(-4) DTA5
	400000			/(-3) LEAVE ALONE
	400000			/(-2) LEAVE ALONE
	4*200+4			/(-1) DTA0
	400000			/(0) LEAVE ALONE
	4*20000	4*200+4		/(1) DTA4
	5*20000	4*200+4		/(2) DTA5
	10*200+10			/(3) LPA
	600000			/(4) TTA0
	6*200+6			/(5) PRA
	7*200+7			/(6) PPA
	6*20000	4*200+4		/(7) DTA6
BDATND	7*20000	4*200+4		/(10) DTA7
 
	.EJECT
/THIS IS THE END OF THE OVERLAYED CODE
/	A TEST MUST BE MADE TO SEE IF A .LOC IS NECESSARY
 
	.IFNEG	.-ENDBUF
 
/.LOC WILL POSITION REMAINING CODE ABOVE BUFFER AREA
 
	.LOC	ENDBUF
 
	.ENDC
 
	.EJECT
/TABLE OF MONITOR COMMANDS
 
/ENTRY FORMAT:
/	WD0 TO WDN IS COMMAND
/	WDN+1 IS PROCESS ADDRESS
 
/NOTE: IF 1-LETTER COMMAND IS ALLOWED, 1ST ONE FOUND IS CHOSEN,
/	E.G., L = LOG
 
BF9CMD	-21			/# OF COMMANDS
	-1			/# OF WORDS BETWEEN CMDS
	.SIXBT	/LOG@/
	LOG
	.SIXBT	/REQUEST@/
	REQUES
	.SIXBT	/ASSIGN@/
	ASSIGN
	.SIXBT	/FILES@/
	FILES
	.SIXBT	/FCORE@/
	FCORE
	.SIXBT	/FCONTROL@/
	FCONTR
	.SIXBT	/BCONTROL@/
	BCONTR
	.SIXBT	/DIRECT@/
	DIRECT
	.SIXBT	/NEWDIR@/
	NEWDIR
	.SIXBT	/7CHAN@/
	CHAN7
	.SIXBT	/9CHAN@/
	CHAN9
	.SIXBT	/VC38@/
	VC38
	.SIXBT	/INUSE@/
	INUSE
	.SIXBT	/SHARE@/
	SHARE
	.SIXBT	/NOSHARE@/
	NOSHARE
	.SIXBT	/MPON@/
	MPON
	.SIXBT	/MPOFF@/
	MPOFF
BATCH=ILLCMD
 
	.EJECT
/TABLE OF SYSTEM PROGRAM COMMANDS
/	USED TO LOAD PROGRAMS OR
/	AS ARGUMENT FOR REQUEST COMMAND.
 
/ENTRY FORMAT:
/	WD0 TO WDN IS COMMAND
/	WDN+1 IS SYSTEM LOAD WORD
/	WDN+2 IS REQUEST TABLE (+400000 IF LEGAL FOR FOREGROUND)
 
PRGCMD	-23			/# OF COMMANDS
	-2			/# OF WORDS BETWEEN COMMANDS
	.SIXBT	/EXECUTE@/
L13	13
	REXECU+400000
 
/IN SEARCH SUBROUTINE, THE /@/ IS A BOUNDARY THAT DISALLOWS 1-LETTER
/COMMANDS FROM HERE ON.
 
	.SIXBT	/@/
	.SIXBT	/PATCH@/
L15	15
	RPATCH
	.SIXBT	/CHAIN@/
L14	14
	RCHAIN
	.SIXBT	/MACRO@/
L2	2
	RMACRO
	.SIXBT	/MACROA@/
L11	11
	RMACRO
	.SIXBT	/F4@/
L4	4
	RF4
	.SIXBT	/F4A@/
L12	12
	RF4
	.SIXBT	/EDIT@/
L1	1
	REDIT
	.SIXBT	/PIP@/
	300003			/GLOAD FOR FGD + PIP CODE (3)
	RPIP+400000
	.SIXBT	/LOAD@/
L100K	100000
	RLOAD+400000
	.SIXBT	/GLOAD@/
L300K	300000
	RLOAD+400000
	.SIXBT	/DDT@/
L400K	400000
	RDDT
	.SIXBT	/DDTNS@/
L500K	500000
	RDDT
	.SIXBT	/SGEN@/
L5	5
	RSGEN
	.SIXBT	/DUMP@/
L6	6
	RDUMP
	.SIXBT	/UPDATE@/
L7	7
	RUPDAT
	.SIXBT	/CONV@/
L10	10
	RCONV
	.SIXBT	/USER@/
	0
	RUSER+400000
	.SIXBT	/.DAT@/
	0
	400000
 
	.EJECT
/SYSTEM LOADER INITIALIZATION AND
/	STARTUP ROUTINE
 
/THIS ROUTINE WILL GENERATE THE RADIX 50
/	.IOC TABLE FOR THE SYSTEM LOADER. IT
/	WILL ALSO PERFORM SPECIAL FUNCTIONS
/	FOR THE FOLLOWING SYSTEM PROGRAMS:
/	1. PIP - GENERATE THE .DEV TABLE
/	2. EXECUTE - PROCESS THE FILE NAME
 
/NOTE:	THE CODE FROM SYSIOC TO THE
/	END OF THE NON-RESIDENT MONITOR
/	MUST START AT OR ABOVE .SYSLD
/	SINCE THE .IOTAB BUILD ROUTINE
/	WILL OVERLAY EARLIER SECTIONS
/	OF CODE.
 
SYSLDR	DAC	SYSLCD		/SAVE LOAD CODE
	SNA
	JMP	ILLCMD		/NOT SYS PROGRAM
	IDX	CMDADR
	LAC*	CMDADR		/GET FGD LEGAL BIT
	AND	L400K
	XCT	SKPBGD		/SKIP IF BACKGROUND
	SZA			/IS IT LEGAL CMD IN FGD?
	SKP			/YES
	JMP	ILLCMD		/NO - ERROR
	DZM	COMAND
	DZM	COMAND+1
	DZM	COMAND+2
	LAC	SYSLCD
	SAD	L13		/EXECUTE?
	SKP
	JMP	SYSEND		/NO.
	JMS	ENDLIN		/ANY ARGUMENTS ?
	JMP	SYSNOP		/NO - BETTER BE PAPERTAPE INPUT.
	JMS	CURCMD		/GO GET ARGS
				/FROM CURRENT LINE
	JMP	ILLXCT		/NONE. BAD FILE NAME.
SYSEND	JMS	FINISH		/BETTER HAVE NO MORE PRINTING CHARS.
SYSNOP	LAC	SYSLCD		/GET LOAD CODE
	AND	(700000
	DAC*	(.SCOM+6		/SET LOAD REG
	XOR	SYSLCD		/GET LOAD CODE
	DAC*	(.SCOM+5
	SAD	L13		/IS IT EXECUTE
	SKP			/YES
	JMP	SYSNEX		/NO - NO FILE NAME
	LAC	COMAND+2
	SZA
	JMP	ILLXCT		/ILLEGAL FILE NAME
	LAC	(.SCOM+106	/FGD XCT FILE NAME PTR.
	XCT	SKPFGD
	TAD	L3		/BGD XCT FILE NAME IS IN .SCOM+111.
	DAC*	L10		/AUTO-INDEX REG. 10
	LAC	COMAND		/MOVE FILE NAME
	DAC*	10
	LAC	COMAND+1
	DAC*	10
	LAC	(300324		/"XCT" IN .SIXBT
	DAC*	10
SYSNEX	LAC*	(.SCOM+5		/IS IT PIP ?
	SAD	L3
	SKP			/YES - BUILD .DEV
	JMP	SYS339		/NO
	LAC*	(.SCOM+2
	DAC	SYSDVP		/SAVE .DEV POINTER
	DAC*	(.SCOM+1
	LAC*	DATPTR		/COMPUTE .DEV SIZE
	JMS	TWOS
	TAD	DATPTR
	TAD	L1
	DAC*	SYSDVP		/SAVE IN .DEV TABLE
	DAC	SYSDVC		/ALSO AS COUNTER
	IDX	SYSDVP		/TO FIRST ENTRY
	LAC	DATPTR
	TAD	L1
	DAC	DATIDX		/TO 1ST .DATB ENTRY
SYSPLP	LAC*	DATIDX		/GET .DAT CONTENTS
	SPA			/IS SLOT SETUP?
	JMP	SYSBDT		/YES - BATCH DEVICE
	AND	(200000		/NO - NORMAL .DAT SLOT
	SZA			/IS IT TTY?
	JMP	SYSTTY		/YES
	LAC*	DATIDX		/NO
	AND	(177
	STL			/TIMES 4 + 2
	RTL			/TO SKIP CONTROL WORDS
	TAD	L.IOTB
	XOR	BANKBT
	DAC	SYSIOP		/POINTS TO DEV NAME
	LAC*	SYSIOP
	RTR
	RTR
	DAC	SYSAVE		/SAVE WORD
	AND	(77
	DAC*	SYSDVP		/SAVE 2ND LETTER
	LAC	SYSAVE
	RAR
	AND	(7700		/GET 1ST LETTER
	XOR*	SYSDVP		/MERGE WITH 2ND
SYSDSV	DAC*	SYSDVP		/SAVE IN .DEV TABLE
	IDX	SYSDVP
	IDX	DATIDX
	ISZ	SYSDVC		/ANY MORE .DAT SLOTS
	JMP	SYSPLP		/YES
	LAC	SYSDVP		/POINTS TO FREE REG.
	DAC*	(.SCOM+2
	JMP	SYS339		/GO FINISH SYSLDR
SYSBDT	LAC	BATSIX		/BATCH DEV AS .SIXBT
	JMP	SYSDSV		/SAVE IN .DEV
SYSTTY	LAC	(2424		/TT AS .SIXBT
	JMP	SYSDSV		/SAVE IN .DEV
SYS339	JMP	SYSIOC		/THIS REG. CHANGED TO CLA DURING
				/INITIALIZATION CODE UNLESS LOADING
				/BGD WITH 339 IN USE BY FGD.
	SAD	VCFLAG		/CHECK FOR VC38 ON
	JMP	NOVC38		/NO
	LAC*	(.SCOM+2		/YES - GET LOWER BOUND
	TAD	(777
	AND	MIN1K		/MOD 1000(8)
	DAC	VCPONT		/START OF CHAR GEN TABLE
 
	.INIT	-7,0		/GO GET VC38 TABLE
 
SEK339	.SEEK	-7,VC38FL
L3=.-2
 
RD1339	.READ	-7,4,VC38WC,1
 
VCPONT=.+2			/POINTS TO VC38 TABLE LOAD ADDR.
VC38WC=.+3			/VC38 SIZE (2'S COMP) FROM FILE
VCFLAG=VC38WC			/SET NON-0 TO INDICATE THAT THE
				/VC38 CHARACTER TABLE IS TO BE
				/LOADED.
 
	.READ	-7,4,0,0		/DUMP MODE; DEFAULT COND = NO VC38.
 
	.CLOSE	-7		/COMBINED WAIT AND END OF TRANSFER
 
	LAC	VC38WC		/COMPUTE NEW LOWER BOUND
	JMS	TWOS
	TAD	VCPONT
	DAC*	(.SCOM+2
NOVC38	LAC*	(.SCOM+12
	DAC	PDPONT		/START OF PDLIST
	LAC	VCPONT		/PUT VC38 TABLE POINTER
				/(0 IF NOT LOADED) IN
	DAC*	PDPONT		/FIRST REG OF PUSH-DOWN LIST
 
/THIS LOC MUST BE > OR = START OF .SYSLD .
 
SYSIOC	LAC*	(.SCOM+3		/NOW BUILD .IOC TABLE
	DAC	SYSCM3		/FOR .SYSLD
	LAC	.IOTAB		/GET # HANDLERS
	TAD	L1		/DON'T WANT "NON"
	DAC*	SYSCM3		/SETUP COUNT
	DAC	SYSDVC
	TAD	SYSCM3
	DAC	SYSDVP		/SETUP POINTER
	TAD	MINUS1		/(-1
	DAC*	(.SCOM+3
	LAC	L.IOTB
	TAD	L6		/SKIP CONTROL WORDS AND "NON"
	DAC	SYSIOP
SYSQZE	DZM*	SYSDVP		/CLEAR OUT TABLE ENTRY
	LAC	SYSIOP
	JMS	GETI		/INIT GET ROUTINE
	LAW	-3
	DAC	SYSCNT		/3 LETTER COUNT
SYSQZN	JMS	GET
	AND	(77		/.SIXBT TRIMMED
	DAC	SYSCH1
	DAC	SYSCH2		/SAVE CHARACTER
	AND	(40
	SNA
	JMP	SYSQOK		/A-Z
	LAC	SYSCH1
	AND	(20
	SNA
	JMP	SYSQ.%		/. OR %
	LAW	-23
	TAD	SYSCH1		/0-9
	DAC	SYSCH1
	JMP	SYSQOK
SYSQ.%	LAC	(33
	DAC	SYSCH1
	LAC	SYSCH2		/ACTUAL CHAR
	SAD	(56		/SKIP IF PERIOD
	IDX	SYSCH1		/%
SYSQOK	LAC*	SYSDVP		/PREVIOUS CHAR
	CLL!RAL			/TIMES 50(8)
	RTL
	DAC	SYSCH2
	RTL
	TAD	SYSCH2
	TAD	SYSCH1		/NEW CHAR
	DAC*	SYSDVP
	ISZ	SYSCNT		/THREE CHARS?
	JMP	SYSQZN		/NO
	XOR	L400K		/SECOND WORD BIT
	DAC*	SYSDVP		/SAVE IN TABLE
	LAC	SYSIOP
	TAD	L4
	DAC	SYSIOP		/TO NEXT ENTRY
	IDX	SYSDVP		/"
	ISZ	SYSDVC		/ANY MORE IN .IOTAB?
	JMP	SYSQZE		/YES
 
	.INIT	-3,1,0		/NO. DISABLE ^P
 
	LAC	SYSLCD
	AND	(77777
	XOR	L400K
	DAC*	(.SCOM+41		/SET WHO'S RUNNING FLAG.
	JMP	GETSYS		/GO GET SYSTEM LOADER
				/LOW-CORE ROUTINE TO PREVENT OVERLAY
 
SYSLCD	0			/SYSTEM PROGRAM LOAD CODE
SYSDVP	0			/DEVICE POINTER
SYSDVC	0			/DEVICE COUNTER
DATIDX	0			/.DAT POINTER
SYSIOP	0			/.IOTAB POINTER
SYSAVE	0			/TEMP
SYSCM3	0			/.SCOM+3 TEMP
SYSCNT	0			/TEMP COUNT
SYSCH1	0			/TEMP FOR R50
SYSCH2	0			/TEMP FOR R50
PDPONT=.-1			/TEMP FOR 339
 
VC38FL	.SIXBT	/VC38TBDMP/
 
	.EJECT
/UNPACK ROUTINE FOR 5/7 ASCII
 
/CALLING SEQUENCES:
/	1.UNPACK	INIT
/	LAC	(N		/N=0 OR START ADDR
/	JMS	GETI
/	(RETURN)			/NEXT UNPACK ADDR IN AC IF N=0
 
/	2.UNPACK
/	JMS	GET
/	(RETURN)			/CHAR IN AC
 
/	3.SAVE ACTIVE REGISTERS
/	JMS	SAVGET
/	(RETURN)
 
/	4.RESTORE ACTIVE REGISTERS
/	JMS	RESGET
/	(RETURN)
 
GETI	0
 
	SNA
	JMP	GETIX		/GO GET LAST POINTER
	XOR	BANKBT
	DAC	GETP		/INIT POINTER
MINUS1	LAW	-1
	DAC	GETC		/INIT COUNTER
	JMP*	GETI
GETIX	LAC	GETP		/RETURN POINTER
	JMP*	GETI
 
GET	0
 
	ISZ	GETC		/USE CURRENT WORD PAIR?
	JMP	GET4		/YES
	LAC*	GETP		/NO - GET NEXT PAIR
	DAC	GET1		/FIRST PART
	IDX	GETP
	LAC*	GETP
	DAC	GET2		/LAST PART
	IDX	GETP
	LAW	-5		/RESET CHAR COUNT
	DAC	GETC
MIN10=.
GET4	LAW	-10		/SHIFT LOOP 7+1/2 TIMES
	DAC	GET3
GET5	LAC	GET2		/DOUBLE AC ROTATE LOOP
	RAL
	ISZ	GET3
	JMP	.+3		/KEEP GOING
	AND	(177		/7 - BIT ASCII
	JMP*	GET		/CHAR IN AC
	DAC	GET2
	LAC	GET1
	RAL
	DAC	GET1
	JMP	GET5		/LOOP SOME MORE
 
SAVGET	0
 
	LAC	GETP		/SAVE ACTIVE REGISTERS
	DAC	GETP+1
	LAC	GETC
	DAC	GETC+1
	LAC	GET1
	DAC	GET1+1
	LAC	GET2
	DAC	GET2+1
	LAC	LASTCR
	DAC	TEMPLC
	JMP*	SAVGET
 
RESGET	0
 
	LAC	GETP+1		/RESTORE ACTIVE REGISTERS
	DAC	GETP
	LAC	GETC+1
	DAC	GETC
	LAC	GET1+1
	DAC	GET1
	LAC	GET2+1
	DAC	GET2
	LAC	TEMPLC
	DAC	LASTCR
	JMP*	RESGET
 
GETP	0			/STRING POINTER
	0
GETC	0			/CHARACTER COUNTER
	0
GET1	0			/TEMP
	0
GET2	0			/TEMP
	0
GET3	0			/TEMP
TEMPLC	0			/TEMP FOR LAST CHAR
 
	.EJECT
/I/O HANDLER TABLE (.IOTAB)
 
/ENTRY FORMAT:
/	WD0 AND WD1 ARE .ASCII OF HANDLER NAME
/	WD2 IS DESCRIPTION WORD AS FOLLOWS
/	WD3 IS .MUD ENTRY (0 NOT IN .MUD)
 
/DESCRIPTION WORD:
/	BIT0=1 FOR NON-BULK STORAGE
/	BITS 12 TO 17 ARE DEVICE CODE
 
/.MUD ENTRY WORD:
/	BITS 0 TO 11 IS HANDLER BUFFER SIZE
/	BITS 12 TO 17 IS MAXIMUM NUMBER OF FILES
 
.IOTAB	-13			/# OF DEVICE HANDLERS
	-2			/# OF WORDS BETWEEN ENTRIES
	.ASCII	/NON/
	0
	0
	.ASCII	/TTA/
	400001
	000020
	.ASCII	/COA/
	400002
	000077
	.ASCII	/DYA/
	400003
	000000
	.ASCII	/DTA/
	000004
	060020
	.ASCII	/DKA/
	000005
	060020
	.ASCII	/PRA/
	400006
	000000
	.ASCII	/PPA/
	400007
	000000
	.ASCII	/LPA/
	400010
	000000
	.ASCII	/CDB/
	400011
	000000
	.ASCII	/MTA/
	000012
	000077
	.BLOCK	20*4
 
.IOTND=.
 
	.EJECT
/SPECIAL REGISTERS WHICH MUST BE
/	INITIALIZED BY THE NON-RESIDENT
/	MONITOR WHENEVER IT IS RE-LOADED
 
BANKBT	0			/BANK BITS FOR BANK INITIALIZATION
DATPTR	0			/POINTS TO .DATF OR .DATB
DATM7S	0			/CONTENTS OF EITHER
				/.DATF-7 OR .DATB-7
DATBCH	0			/CONTENTS OF .DATB-2 IF
				/IN BATCH MODE, 0 IF NOT OR FGD
SYSDEV	.ASCII	/DTA/		/.ASCII OF CONTENTS OF
				/.DATF-7 OR .DATB-7
BATDEV	0			/.ASCII OF .DATB-2 IF
	0			/IN BATCH MODE, 0 IF NOT OR FGD
BATSIX	0			/.DEV ENTRY FOR BATCH DEVICE
SKPFGD	NOP			/SKP IF FGD, NOP IF BGD
SKPBGD	NOP			/SKP IF BGD, NOP IF FGD
 
	.EJECT
/LITERALS
 
L.SCD	SEARCD			/NOT TO BE BANK INITIALIZED.
 
	.END
 
/LITERAL LIST
 
	.END
