	.IFUND RSX						/(142)
	.SYSID <	.TITLE EDIT15 >,<000>
	.ENDC							/(142)
	.IFDEF RSX						/(142)
	.TITLE EDIT15 XVM/RSX V1B000				/(142)
	.ENDC							/(142)
/
/COPYRIGHT (C) 1976
/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
/DOS-15 TEXT EDITOR FOR THE PDP-9/15.
/
/ EDIT NUMBER 021   DATE OF EDIT JULY 31,1971
/E. MARISON
/R. MCLEAN - RSX-15
/
/EDIT NUMBER 022	15-JUL-74	EK	CHANGE SIGNON NUMBER
/				2. PTP AND .DAT
/				3. RSX
/				4. BULKST
/				5. DOS15
/ 032	23-APR-75 (RCHM)	INSTAL "PUT" AND "PCLOSE" COMMANDS.
/ 033	23-APR-75 (RCHM)	REMOVE ICLOSE FROM SYSTEM.
/ 034	24-APR-75 (RCHM)	FIX READ ACROSS ENTER PROBLEM.
/ 035	24-APR-75 (RCHM)	REMOVE CODE FOR PDP-7 COMPATABILITY.
/ 136	02-MAY-75 (RCHM)	INSTALL XVM HELLO MESSAGES AND OTHER XVM CHANGES.
/ 137	05-JUN-75 (RCHM)	CHECK FOR EXTENSION NAMES LONGER THAN 3 CHARACTERS.
/ 138	10-SEP-75 (RCHM)	NO MORE MAGIC NUMBERS FOR EDITOR
/ 139	23-SEP-75 (RCHM)	COSMETIC CHANGES TO EDITOR TO REMOVE
/				POSSIBLE PROBLEM FOR MONITOR.
/				NO .INIT OF .DAT -10 AT BEGIN TIME
/				FIRST SHOT AT IOPS 0 AND OTHER PROBLEMS.
/ 140	07-NOV-75 (RCHM)	STICK IN FSTAT IN CALL PROCESSORS TO MAKE
/				BLACKETT HAPPY ABOUT THINGS IN GENERAL.
/ 141	13-NOV-75 (RCHM)	STICK IN FSTAT ON OUTPUT FILE RENAME TO
/				GET AROUND A LONG OUTSTANDING DISK HANDLER
/				BUG.
/ 142	10-MAY-76 (RCHM)	RETRO FIT DOS EDITOR TO RSX.	/(142)
/
/
/
/THIS PROGRAM CONTAINS A 37(8) PATCH
/AREA STARTING AT "PATCHF" AND ENDING
/AT "PATCHL". THIS AREA IS TO BE USED
/FOR PATCHING, WHEN THE PROGRAM IS MADE INTO
/A SYSTEM FILE WITH THE PATCH LOADER
/
/
/
///
///	THIS SOURCE CAN PRODUCE THE FOLLOWING VERSIONS
///
///	VP STORAGE SCOPE VERSION
///	VT15 DISPLAY VERSION
///	STANDARD TEXT EDITOR
///	RSX VERSION (RSX VERSION NOT COMPLETE AT THIS TIME)
///
/ASSEMBLY PARAMETER ASSIGNMENTS:
/*** THIS SOURCE IS MADE TO PRODUCE A BINARY
/*** FILE WHICH IS MADE INTO A CORE IMAGE
/*** SYSTEM FILE WITH "PATCH"
/
/*** TO GET A BIN FILE WHICH WILL RUN
/*** UNDER THE LINKING LOADER OR DDT
/*** BIN=0  MUST BE DEFINED
/
/   I. FOR THE DOS -15 VERSION
/	NO PARAMETERS NEEDED
/		NOTE***************************
/	WHEN THIS PROGRAN IS PUT ON THE SYSTEM WITH THE 'READR' COMMAND IN PATCH,
/	 THERE MUST BE A 'MAGIC' NUMBER TO ALLOW FOR THE BUFFER SPACE AT THE END
/	 WHICH IS EXPECTED TO START AT "EDLINE".   (THE ACTUAL SPACE IS NOT ALLOCATED
/	 SO THAT DISK BLOCKS ARE NOT WASTED.)THE MAGIC NUMBER IS:
/		((ADDRESS(LABUF)+(BUFLEN-1))-SIZE)-17636.
/	FOR THE VT15 VERSION
/	    EDITVT=0
/	MUST BE DEFINED
/	FOR THE VP STORAGE SCOPE VERSION
/	    EDITVP=0
/	MUST BE DEFINED
/
/	THE STD TEXT EDITOR VERSION IS THE DEFAULT
/
/	C. *** NOTE EDITVT AND NONEAE ARE ILLEGAL ***
/	   *** ALSO EDITOR ***
/
/   IV.	IF OBJECT MACHINE DOES NOT HAVE EAE
/	THEN NONEAE=0 MUST BE DEFINED.
/
/
///	.ABS
///  ORIGIN-SETTING STATEMENTS WERE DELETED TO MAKE THIS DISPLAY
/// EDITOR RELOCATABLE AND LINK-LOADABLE. THE '.IODEV' STATEMENT WAS
/// INSERTED, ADDING .DAT SLOT 10 FOR THE DISPLAY.
///	.LOC BANK*20000+EDSTRT
/
/
	.EBREL
	.IFUND RSX						/(142)
.DAT=141
	.IFUND EDITVP
	.IFUND EDITVT
EDITOR=0
	.ENDC
	.ENDC
	.IFUND NONEAE
EAE=0
	.ENDC
	.IFDEF EDITVP
	.IODEV	-10,-12,-13,-14,-15,10	/(RCHM-032) DAT SLOT 10: VP09 DISPLAY
	.ENDC
	.IFUND EDITVP
	.IODEV -10,-12,-13,-14,-15	/(RCHM-032)
	.ENDC
TTICAL=-2			/(RCHM-139) DAT SLOT -2: KEYBOARD INPUT
TTOCAL=-3			/(RCHM-139) DAT SLOT -3: TELEPRINTER OUTPUT
INPCAL=2764		/DAT SLOT -14: EDIT FILE INPUT
OUTCAL=2763		/DAT SLOT -15: EDIT FILE OUTPUT
ALTIPT=-10			/(RCHM-025) .DAT SLOT -10: AUXILIARY INPUT.
PUTDEV=-13			/(RCHM-032) .DAT SLOT -13: AUXILIARY OUTPUT.
LIST=-12			/(RCHM-025) .DAT SLOT -12: LISTING DEVICE.
OPOCAL=1763		/DAT SLOT -15: OPEN OUTPUT FILE
OPICAL=0764		/DAT SLOT -14: OPEN INPUT FILE
DATM14=.DAT-14			/ABSOLUTE DAT -14.
DATM15=.DAT-15			/ABSOLUTE DAT -15.
.SCOM=100			/SYSTEM COMMUNICATION AREA.
	.ENDC							/(142)
	.IFDEF RSX						/(142)
	.DEC							/(142)
TTILUN=12							/(142)
TTOLUN=13							/(142)
INLUN=17							/(142)
OUTLUN=18							/(142)
ALTINP=20							/(142)
ALTOUT=19							/(142)
LIST=16								/(142)
EAE=0								/(142)
EDITOR=0							/(142)
	.OCT							/(142)
ECLA=641000							/(142)
X10=10								/(142)
	.ENDC							/(142)
BUFLEN=70			/(RCHM-027) READ-WRITE LINE BUFFER SIZE.
				/(RCHM-027)  THE NUMBER OF WORDS TO CONTAIN 135 (BASE 10)
				/(RCHM-027)  CHARACTERS IN A LINE BUFFER.
	.IFDEF EDITVP
	.IFDEF RSX						/(142)
	.END ILLEGAL PARAMETER COMBINATION.			/(142)
	.ENDC							/(142)
	.IFDEF EDITOR
	.END	ILLEGAL PARAMETER COMBINATION
	.ENDC
	.IFDEF EDITVT
	.END	ILLEGAL PARAMETER COMBINATION
	.ENDC
	.ENDC
	.IFDEF EDITOR
	.IFDEF EDITVT
	.END	ILLEGAL PARAMETER COMBINATION
	.ENDC
	.ENDC
	.TITLE VARIABLES AND SWITCHES.
PUTSW	NOP			/(RCHM-032) (PUT) IN ALTERNATE FILE (SW)ITCH.
				/(RCHM-032)  NOP => NO ALTERNATE FILE EXISTS.
				/(RCHM-032)  SKP => ALTERNATE FILE EXISTS.
 
BUFEND	0			/(RCHM-033) ADDRESS OF END OF INCORE BUFFER
 
HRSW	NOP			/(RCHM-034) (H)OT (R)EAD (SW)ITCH
				/(RCHM-034)  NOP => READ AND WAIT FROM TTY SYNCHRONIZED.
				/(RCHM-034)  SKP => READ EXECUTED, EXECUTE WAIT.
 
IEMSW	NOP			/(RCHM-034) (I)NPUT OR (E)DIT (M)ODE (SW)ITCH
				/(RCHM-034)  NOP => INPUT MODE.
				/(RCHM-034)  SKP => EDIT MODE.
 
BLANK	40			/(RCHM-035) CONSTANT USED BY EDITOR.
				/(RCHM-033)  DURING BLOCK MODE EDIT'S.
 
QUIT	0			/(RCHM-1388) 0 => ABORT CURRENT PROCESS.
 
LOOPCT	0			/(RCHM-139) LOOP COUNTER
POINTR=LOOPCT							/(142)
 
SRCNAM	.SIXBT 'SRC'		/(RCHM-139) DEFAULT SOURCE EXTENSION NAME.
 
CHRCT	0			/(RCHM-139) CHARACTER COUNTER.
 
	.IFDEF RSX						/(142)
 
EVA	0		/ EVENT VARIABLE FOR MISCELLANEOUS I/O	/(142)
 
WFEVA	20		/ WAIT FOR EVA.				/(142)
	EVA							/(142)
 
HINF	3600		/ HINF FUNCTION CODE.			/(142)
	EVA							/(142)
	XX		/ LUN NUMBER SUPPLIED BY ROUTINE.	/(142)
 								/(142)
PUTWR	2700		/ PUT DEVICE WRITE.			/(142)
	PUTEV		/ EVENT VARIABLE.			/(142)
	ALTOUT		/ OUT PUT LUN NUMBER.			/(142)
	2		/ IOPS ASCII.				/(142)
PUTWBA	XX		/ BUFFER ADDRESS.			/(142)
 
PUTEV	1		/ INITIAL SETTING OF EVENT VARIABLE.	/(142)
 
WFPUT	20		/ WAIT FOR PUT WRITE TO COMPLETE.	/(142)
	PUTEV		/ EVENT VARIABLE ADDRESS.		/(142)
								/(142)
WLIST	2700		/ WRITE					/(142)
	EVA		/ EVENT VARIABLE.			/(142)
	LIST		/ LUN (LISTING DEVICE).		/(142)
	2		/ IOPS ASCII.				/(142)
LISTOA	XX		/ BUFFER ADDRESS.			/(142)
 
CLSLST	3400		/ CLOSE FILE FOR SPOLLER.		/(142)
	0		/ WHO CARES.				/(142)
	LIST		/ USE A GARBAGE FILE NAME.		/(142)
	.ENDC							/(142)
	.TITLE INITIALIZE VARIABLES, INPUT & EDIT MODE PROCESSORS.
LINSIZ=BUFLEN-2/2*5+1	/MAXIMUM CHARACTERS PER LINE.
QUESMK=77			/QUESTION MARK.
NUM	0		/TEMP STORAGE
BEGIN	JMP SETBNK	/SET EPC BITS FOR CURRENT BANK.
	.IFDEF RSX						/(142)
	LAC (OUTLUN)	/ ATTACH OUTPUT DEVICE.			/(142)
	DAC OUTPCL	/ INITIAL OUTPUT LUN NUMBER.		/(142)
	JMS ATTACH						/(142)
	LAC (INLUN)	/ ATTACH INPUT DEVICE.			/(142)
	DAC INPTCL	/ INITIAL INPUT LUN NUMBER.		/(142)
	JMS ATTACH						/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	.INIT TTOCAL,1,RECOUP	/(RCHM-139) INITIALIZE TELETYPES.
	.ENDC							/(142)
	LAC NOPLIT	/CLEAR EXIT SWITCHS
	DAC EXITSW
	DAC EXITRQ
	DAC PUTSW		/(RCHM-032) ENABLE PUT COMMAND.
	LAC BADARG		/(RCHM-032) BUT KEEP IT DISABLED UNTIL
	DAC PUT			/(RCHM-032)  AN OPEN HAS BEEN EXECUTED.
	LAC SKPLIT		/(RCHM-029) FETCH "ON" FLAG
	DAC PARSWT		/(RCHM-029) LEAVE PARITY PROCESSING ON AFTER ^P.
	DZM MOVESW
	DZM INPSW
	DZM BUFEMP
	DZM OUTPSW	/SET OUTPUT AND
/	DZM VERISW	/VERIFY TO "ON". LEAVE ALONE FOR TV
ALTMOD	175\777777	/1'S COMPLEMENT ALT MODE TERMINATOR.
	DAC PBLKSW	/TURN OFF BLOCK MODE.
	DAC GBLKSW	/..
	DAC BRFSW		/SET BRIEF TO OFF.
	DAC OPEN		/ALLOW USE OF OPEN AND
	DAC CALL		/CALL SEQUENCES.
	DAC SAVESW	/TURN OFF SAVE OPTION.
	DAC OUTSW1	/INDICATE NOTHING IN OUTPUT FILE.
	LAW -67		/55(10).
	DAC BUFSIZ	/DEFAULT BLOCK-BUFFER SIZE.
	DAC NAMSW		/INDICATE NO NAME PRESENT.
	LAC JMSCLS	/PERMIT CLOSE SEQUENCE TO USE
	DAC CLOSE1	/SUBROUTINE CLSOUT.
	.IFUND RSX						/(142)
	LAW OUTCAL	/DAT SLOT -15.
	AND ADRMSK	/THROW AWAY JUNK.
	DAC OUTPCL	/INITIAL OUTPUT DAT SLOT IS -15.
	DAC INPTCL	/SET UP INPUT DAT SLOT.
	ISZ INPTCL	/INITIAL INPUT DAT SLOT IS -14.
	.ENDC							/(142)
	DZM DIRSW		/INITIAL TRANSFER DIRECTION (READ -14, WRITE -15).
	LAC TFILE1	/SET UP DEFAULT EDIT FILE NAME (.TFIL2 EDT).
	DAC INNAME	/..
	LAC TFILE1+1	/..
	.IFDEF RSX						/(142)
	TAD (4000)	/ GUARENTEE A UNIQUE INITIAL OUTPUT	/(142)
			/ NAME.					/(142)
	.ENDC							/(142)
	DAC INNAME+1	/..
	ISZ INNAME+1	/MAKE IT .TFIL2.
	LAC EDNAM		/"EDT"
	DAC INNAME+2	/EXTENSION FOR DEFAULT FILE NAME.
FSTFL1	JMS IOINIT
	JMS FSTAT		/GO SEE IF .TFIL1 EDT IS PRESENT.
	XCT TFILE1	/BIT 0 = 1 MEANS CHECK THE OUTPUT DEVICE.
	DAC LOOPCT	/SAVE RESULTS OF FSTAT.
	.IFDEF EDITVT
	JMS CTXOFF
	.ENDC
	LAW EDTMES
	JMS TYPOUT	/PRINT "PGM NAME VNN".
	LAC LOOPCT	/PICK UP RESULTS OF PREVIOUS FSTAT.
	SNA		/FILE MAY BE PRESENT.
	JMP FND6		/NOT FOUND, OK.
TFIFND	SAD FENCE		/TEMP FILE FOUND, IS OUTPUT DEVICE FILE-STRUCTURED?
	JMP FND6		/NO, THEN GO START UP AS USUAL.
	LAW TFILE1	/YES, INFORM USER OF DIFFICULTY.
	JMS TYNAME	/"FILE .TFIL1 EDT"
	LAW TWOFIL	/COMPLETE THE COMMENT.
	JMS TYPOUT	/"IS PRESENT ON OUTPUT DEVICE."
	LAW TWOFL0	/TYPE NEXT LINE OF COMMENT.
	JMS TYPOUT	/"PLEASE DELETE OR RENAME IT."
	JMP FND6		/GO READ A CONTROL REQUEST (SHOULD BE DELETE OR RENAME).
/TURN ON INPUT MODE.
	.IFDEF EDITVT
INPUT	JMS CTXOFF
	LAW INPTM
	.ENDC
	.IFUND EDITVT
INPUT	LAW INPTM		/TYPE CONTROL MODE NOW IN EFFECT.
	.ENDC
	JMS TYPOUT	/"INPUT"
	LAC NOPLIT		/(RCHM-034) SIGNAL INPUT MODE WITH A NOP.
	DAC IEMSW		/(RCHM-034)
	.IFDEF EDITVT
	JMS TYPRTN
	JMS CTLXON	/BUMP SCREEN UP ONE
	JMS TYPRTN
	JMS TVXUT		/THE DELETE IT <CR-LF> FORM SCREEN
	JMS CTLXON
	.ENDC
/MAIN PROCESSING LOOP FOR INPUT MODE.
RDNPUT	LAW TYLINE	/PUT LINE TO BE TYPED IN TYLINE.
	DAC QUIT		/INDICATE PROCESSING IS IN PROGRESS.
	JMS TYPEIN	/THEN GO READ THE KEYBOARD.
DHROIP	CLA			/(RCHM-034) WAS CONTROL P STRUCK DURING TYPEIN?
	SAD QUIT		/SKIP IF NOT.
	JMP TTRS		/IF SO, GO RETURN CARRIAGE, CHANGE MODES.
	.IFDEF EDITVT
	ISZ VTFLAG	/SET FLAG FOR INPUT MODE (APPEND)
	.ENDC
	JMS UNPACK	/NORMAL INPUT LINE, GO UNPACK IT.
EDLAD1	TYLINE		/FROM TYLINE...
EDLADR	EDLIN		/TO EDLIN.
	SNA		/LENGTH COMES BACK IN AC.
	JMP EDIT1A	/LINE IS EMPTY (JUST CR ISSUED), CHANGE MODES.
	ADD EDLADR	/START OF LINE PLUS LENGTH.
	DAC QUIT		/ADDRESS OF TERMINATOR.
	LAC* QUIT		/GET TERMINATOR TYPED.
	SAD ALTMOD	/ALT MODE?
	JMS TYPRTN	/YES, GO RETURN CARRIAGE.
	JMS PUTLIN	/PUT AWAY THE PREVIOUS CURRENT LINE.
	JMP FULBUF	/FULL BUFFER RETURN.
	LAC EDLADR	/NORMAL RETURN; GET ADDRESS OF CURRENT-LINE BUFFER.
	DAC NXTPTR	/SET UP NEXT-CHARACTER POINTER.
	DAC INPSW
	DZM LENGTH	/ZERO TOTAL CHARACTERS IN CURRENT LINE.
	LAC SKPLIT	/SET EXIT SWITCH
	DAC EXITSW
	JMS APPEND	/THEN GO MOVE TYPED INPUT LINE TO INLINE ARRAY.
	XCT HRSW		/(RCHM-034) READ OUTSTANDING?
	JMP RDNPUT	/READ ANOTHER INPUT LINE.
	JMS WAIT		/(RCHM-034) YES, WAIT FOR USER TO ENTER SOMETHING.
	JMP DHROIP		/(RCHM-034) ALL DONE, CONTINUE PROCESSING.
/TURN ON EDIT MODE.
EDIT1A=.
	.IFDEF EDITVT
	JMS TVXUT		/DELETE <CR-LF> FROM SCREEN
	DZM VTFLAG	/INDICATE EDIT MODE IN EFFECT
	JMS CTXOFF	/ ^X OFF DURRING EDIT MODE
	.ENDC
EDIT	LAW EDTM		/TYPE CONTROL-MODE INDICATION.
	JMS TYPOUT	/"EDIT"
	JMP FND6		/GO TYPE A RIGHT ANGLE BRACKET.
/MAIN PROCESSING LOOP FOR EDIT MODE.
RDLIN	CLC			/(RCHM-138) SET UP QUIT FOR FURTHER PROCESSING.
	DAC QUIT		/(RCHM-138) PROCESSING CAN NOW OCCUR.
	DZM	NOPKSW	/RESET NO REPACK SW
	LAC SKPLIT		/(RCHM-034) INDICATE EDIT MODE IN PROGRESS WITH A SKP.
	DAC IEMSW		/(RCHM-034)
	.IFDEF EDITVT
	JMS CTXOFF
	.ENDC
	LAW TYLINE	/READ NEXT REQUEST FROM TELETYPE.
	JMS TYPEIN	/INPUT-LINE AREA.
	DZM BOTTSW	/INDICATE BOTTOM NOT IN PROCESS (GETLIN)
	LAC QUIT		/(RCHM-138) CHECK FOR ^P DURING READ.
	SNA			/(RCHM-138) 0 => KILL.
	JMP BEGIN		/(RCHM-138) RESTART EDITOR.
	JMS UNPACK	/UNPACK THE TYPED LINE.
ADR002	TYLINE		/FROM TYLINE...
	EDLIN		/...TO EDLIN.
	SNA		/SKIP IF TOTAL CHARS IN LINE .G. 0.
	JMP INPUT		/CARRIAGE RETURN ONLY, CHANGE MODE.
	TAD EDLADR	/CHECK TERMINATOR
	DAC NUM
	LAC* NUM
	SAD ALTMOD	/IF AN ALTMODE GIVE A <CR-LF>
	JMS TYPRTN
	LAC EDLADR	/EDLADR POINTS TO EDLIN (WHERE TYPED LINE IS).
	DAC NXTPTR	/SET INITIAL POINTER IN NXTCHR.
	JMS GETCOM	/GO EXTRACT CONTROL WORD FROM INPUT LINE.
  
/DECODE WHAT IS PRESUMED TO BE AN EDITING CONTROL WORD (IN CWD ARRAY)
/AND TAKE ACTION IF LEGAL. IF NOT, IGNORE INPUT LINE, COMPLAIN ON
/TELEPRINTER, AND REENTER EDIT MODE READ SEQUENCE AT FND6.
  
DECODE	LAW CWDTBL-TABEND	/TOTAL ENTRIES IN CWD TABLE (2'S COMPLEMENT).
	DAC LOOPCT	/SET UP COUNT OF CONTROL WORDS TO EXAMINE.
	LAC CWDTOP	/GET BEGINNING OF CONTROL WORD TABLE.
CWDLP1	DAC SCN1		/SET UP NEXT CALL TO UNPACK.
	JMS UNPACK	/UNPACK NEXT CONTROL WORD.
SCN1	0		/MODIFIED EACH TIME TO POINT TO NEW ENTRY.
ADR003	TYLINE		/USE TYLINE AS OUTPUT ARRAY.
	JMS SCAN		/COMPARE INPUT COMMAND WITH CURRENT ENTRY.
CWDLIT	CWD		/TYPED COMMAND IS IN CWD...CWD+7.
	TYLINE		/CURRENT TABLE ENTRY HAS JUST BEEN UNPACKED INTO TYLINE.
SKPLIT	SKP		/NO MATCH.
	SKP		/END STRING 1.
	JMP CWDLP2	/FAILED COMPARE, GET NEXT TABLE ENTRY.
	LAC* STR2		/POSSIBLE MATCH, GET NEXT WORD FROM TYLINE.
	SMA!CLL!CML	/MATCH IF NEXT WORD IN TYLINE IS NEGATIVE...
	SKP!CLA!RAL	/...OR IF TOTAL CHARS IN CWD .E. 1.
	JMP CWDISP	/FULL CONTROL WORD, GO DISPATCH.
	SAD NCHARS	/CHECK FOR ABBREVIATION (AC .E. 1 NOW).
	JMP CWDISP	/NCHARS .E. 1, GO DISPATCH.
CWDLP2	LAW -1		/MATCH FAILED, SET UP NEW ARG TO UNPACK...
	TAD* (12)		/(RCHM-139) ...USING A POINTER INTERNAL TO UNPACK.
	ISZ LOOPCT	/COUNT ENTRIES IN CONTROL WORD TABLE.
	JMP CWDLP1	/MORE TO DO, CONSIDER NEXT ENTRY.
/UNRECOGNIZED CONTROL WORD COMES HERE.
ILLCWD	LAC BRFSW		/IS BRIEF MODE IN EFFECT?
	SMA		/NOT IF BRFSW IS NEGATIVE.
	JMP TYQUES	/BRIEF MODE ON, JUST PRINT A QUESTION MARK.
	LAW ERREQM	/BRIEF MODE IS OFF, PRINT FULL ERROR MESSAGE.
	JMS TYPOUT	/"NOT A REQUEST:"
	LAW 40		/PRINT A LEADING
	JMS TYONCH	/BLANK CHARACTER.
	JMS PACK		/REPACK INPUT LINE.
ADR004	EDLIN		/FROM HERE.
	TYLINE		/TO HERE.
	LAW TYLINE	/PRINT OFFENDING INPUT LINE.
	JMS TYPOUT	/..
	JMP FND6		/GO BACK TO READ SOME MORE.
TYQUES	LAW QUESMK	/BRIEF IS ON, GET QUESTION MARK.
	JMS TYONCH	/GO TYPE IT OUT.
	JMS TYPRTN	/PRINT CARRIAGE RETURN, LINE FEED.
	JMP FND6		/READ NEXT COMMAND.
CWDISP	LAC TABEND	/GET END OF DISPATCH TABLE.
	TAD LOOPCT	/CALCULATE OUR CURRENT POSITION IN IT.
	ADD XCTZRO	/INSERT AN XCT AS TABLE REFERENCE.
	DAC CWDXCT	/GIVE TO DISPATCHER.
/GO TO SERVICE SECTION FOR THIS CONTROL WORD.
CWDXCT	XX		/RESULTS IN XCT OF PROPER TABLE ENTRY (JMP OR JMS).
	JMP FND4		/IN CASE TABLE ENTRY WAS A JMS.
	.TITLE CONTROL WORD AND DISPATCH TABLE
/TABLE OF CONTROL WORDS FOR COMPARE AGAINST TYPED EDIT COMMANDS.
/CONTROL WORDS ARE LIMITED TO SEVEN CHARACTERS IN LENGTH.
CWDTOP	.-1
	.ASCII 'PRINT'<15>
	.LOC .-1
C104	104
	.ASCII	'PARITY'<15>	/(RCHM-029) COMMAND FOR PARITY CHECKING.
	.ASCII 'NEXT'<15>
	.ASCII 'FIND'<15>
	.ASCII 'LOCATE'<15>
	.LOC .-1
C122	122
	.ASCII	'LIST'<15>	/(RCHM-026) KEYWORD FOR LIST COMMAND.
	.ASCII 'LC'<15>
	.ASCII 'GET'<15>
	.ASCII 'INSERT'<15>
	.LOC .-1
C111	111
	.ASCII 'DELETE'<15>
NAMSW=.-1		/0, FILE NAME GIVEN IN OPEN REQUEST; -1, NO NAME GIVEN.
	.ASCII 'SIZE'<15>
	.ASCII 'OVERLAY'<15>
	.ASCII 'CHANGE'<15>
NAMSW1=.-1
	.ASCII 'CONVERT'<15>
	.ASCII 'VERIFY'<15>
STR1=.-1
	.ASCII 'TOP'<15>
	.IFUND EDITOR
	.ASCII 'TV'<15>
	.ENDC
	.ASCII 'BOTTOM'<15>
STR2=.-1		/POINTER FOR CHANGE REQUEST.
	.ASCII 'BRIEF'<15>
PBLKSW=.-1		/OUTPUT BLOCK BUFFER: 0, WRITE BUFFER. -1, WRITE FILE.
	.ASCII 'RETYPE'<15>
GBLKSW=.-1
	.ASCII 'APPEND'<15>
CURPUT=.-1
	.ASCII 'KEEP'<15>
	.ASCII 'RENEW'<15>
	.LOC .-1
C77	77
	.ASCII 'READ'<15>
	.ASCII 'WRITE'<15>
CURGET=.-1
	.ASCII 'MODIFY'<15>
	.ASCII 'MOVE'<15>
	.ASCII 'CALL'<15>
	.ASCII 'BLOCK'<15>
DIRSW=.-1
	.ASCII 'OUTPUT'<15>
ERRSW=.-1
	.ASCII 'EXIT'<15>
	.ASCII 'OPEN'<15>
	.ASCII 'CLOSE'<15>
BTEMP=.-1		/GETNUM: TEMPORARY STORAGE.
	.ASCII 'SCLOSE'<15>
FBUFSW=.-1
	.ASCII 'PUT'<15>	/(RCHM-032) PUT COMMAND.
	.ASCII 'PCLOSE'<15>	/(RCHM-032) PCLOSE COMMAND.
	.EJECT
/TABLE OF DISPATCHERS TO CONTROL-WORD SERVICE SECTIONS. ENTRIES ARE
/EITHER "JMP"S OR "JMS"S AND ARE REFERENCED BY AN XCT (AT CWDXCT)
/OF THE APPLICABLE TABLE LOCATION AFTER COMMAND DECODING. NOTE THAT
/ENTRIES ARE SO ORDERED AS TO CORRESPOND WITH ASCII ENTRIES IN TABLE
/OF CONTROL WORDS ABOVE. FOR BOTH TABLES, NOTE THAT ANY CONTROL WORD
/WHICH CAN LEGALLY BE ABBREVIATED MUST PRECEDE ANY OTHER CONTROL WORD
/HAVING THE SAME INITIAL CHARACTER (THUS "BOTTOM" PRECEDES "BRIEF").
		/MAY COMMAND BE ABBREVIATED?
CWDTBL	JMP PRINT		/YES -- "P"
	JMP PARITY		/(RCHM-029) NO.
	JMP NEXT		/YES -- "N"
	JMP FIND		/YES -- "F"
	JMP LOCATE	/YES -- "L"
	JMP	LISTFL		/(RCHM-026) NO -- LIST COMMAND.
	JMP LNCONV	/NO!  //LINE CONVERT
	JMP GET		/YES -- "G"
	JMP INSERT	/YES -- "I"
	JMP DELETE	/YES -- "D"
	JMP SIZE		/YES -- "S"
	JMP OVRLAY	/YES -- "O"
	JMP CHANGE	/YES -- "C"
	JMP CONVRT	/NO!
	JMP VERIFY	/YES -- "V"
	JMP TOP		/YES -- "T"
	.IFUND EDITOR
	JMP TV		/NO!
	.ENDC
	JMP BOTTOM	/YES -- "B"
	JMP BRIEF		/NO!
	JMP RETYPE	/YES -- "R"
	.IFUND EDITVT
	JMS APPEND	/YES -- "A"
	.ENDC
	.IFDEF EDITVT
	JMS APPD1
	.ENDC
	JMP KEEP		/YES -- "K"
	JMP RENEW		/NO!
	JMS READ		/NO!
	JMS WRITE		/COULD BE, BUT THIS FACT IS NOT ADVERTISED.
	JMP MODIFY	/YES
	JMP MOVE		/NO!
	JMP CALL		/NO!
	JMP BLOCK		/NO!
	JMP OUTPUT	/NO!
	JMP EXIT		/COULD BE, BUT NOT ADVERTISED.
	JMP OPEN		/NO!
	JMP CLOSE		/NO!
	JMP SCLOSE	/NO!
	JMP PUT			/(RCHM-032) DISPATCH TO PUT PROCESSOR.
	JMP PCLOSE		/(RCHM-032) DISPATCH TO PCLOSE PROCESSOR.
TABEND	CAL TABEND	/13-BIT END-OF-TABLE DEFINITION.
	.TITLE PUT COMMAND PROCESSOR.
/+
/ ROUTINE: PUT
/
/ COMMAND FORMAT:
/
/	PUT FILNAM EXT
/
/ IF FILNAM EXT ARE NOT SPECIFIED, THE ROUTINE ASSUMES THAT THE NAME TO BE USED
/ IS "FILNAM SRC" WHERE FILNAM IS THE FILNAM TAKEN FROM THE LAST OPEN COMMAND
/ ISSUED TO THE EDITOR.
/
/ INITIAL CONDITIONS:
/ 1.	.DAT -10 MUST BE ASSIGNED TO A WRITABLE DEVICE.
/ 2.	AN OPEN COMMAND MUST HAVE BEEN PREVIOUSLY ISSUED.
/ 3.	THE FILNAM EXT SPECIFIED IN THE COMMAND SHOULD NOT EXISTS ON .DAT -10.
/	THE COMMAND WILL RECOVER IF IT IS THERE.
/
/ TERMINAL CONDITIONS:
/ 1.	THE FILE FILNAM EXT IS OPENED FOR OUTPUT.
/ 2.	PUTSW IS CHANGED TO A SKP INSTRUCTION.
/
/ SIDE EFFECTS:
/ THE FOLLOWING COMMANDS WILL SIMULATE THE EXECUTION OF A PCLOSE IF A PUT IS
/ CURRENTLY IN EFFECT:
/
/	TOP
/	CLOSE
/	SCLOSE
/-
PUT	JMP ILLCWD		/(RCHM-032) JMP ILLCWD => NO OPEN ISSUED.
				/(RCHM-032)  NOP=> OPEN ISSUED.
	XCT PUTSW		/(RCHM-032) HAVE WE ALREADY OPENED AN ALTERNATIVE OUTPUT FILE?
	SKP			/(RCHM-032) NO, ALLOW PROCESSING TO CONTINUE.
	JMP ILLCWD		/(RCHM-032) YES.
	LAC SRCNAM		/(RCHM-032) FETCH DEFAULT EXTENSION NAME.
	DAC PUTNAM+2		/(RCHM-032) AND STORE IT IN PUT DEB.
	JMS GETCOM		/(RCHM-032) EXTRACT FILNAM FROM COMMAND STRING.
	SNA			/(RCHM-032) WAS THERE A FILE NAME?
	JMP PUT010		/(RCHM-032) NO, ASSUME DEFAULT.
	LAW -2			/(RCHM-032) FETCH NUMBER OF WORDS TO PACK.
	JMS PK6BT		/(RCHM-032) SET FILE NAME IN PUT NAME DEB.
	CWD			/(RCHM-032) FROM...
	PUTNAM			/(RCHM-032) TO.
	JMS GETCOM		/(RCHM-032) FETCH EXTENSION FROM COMMAND STRING.
	SNA!CLA!CMA		/(RCHM-032) WAS AN EXTENSION SPECIFIED?
	JMP PUTFST		/(RCHM-032) NO, GO SEEK SPECIFIED FILE.
	JMS PK6BT		/(RCHM-032) PACK EXTENSION INTO PUT FILE NAME DEB.
	CWD			/(RCHM-032) FROM...
	PUTNAM+2		/(RCHM-032) TO.
	.IFDEF RSX						/(142)
PUTFST	LAC PUTCPB+2	/ FETCH LUN NUMBER.			/(142)
	JMS ATTACH	/ ATTACH ALTERNATE OUTPUT DEVICE.	/(142)
	LAC PUTCPB+2	/ FETCH LUN NUMBER			/(142)
	JMS PSF		/ ISSUE PSUEDO FSTAT.			/(142)
	CAL PUTNAM	/ 13 BIT ADDRESS OF FILE NAME.		/(142)
	SZA		/ FILE ON OUTPUT DEFICE?		/(142)
	JMP PUT020	/ YES, GIVE ERROR.			/(142)
	LAC (3300)	/ FETCH ENTER I/O FUNCTION.		/(142)
	DAC PUTCPB	/ FETCH PUT.				/(142)
	CAL PUTCPB	/ ISSUE ENTER.				/(142)
	CAL WFEVA	/ WAIT FOR ENTER TO FINISH.		/(142)
	LAC EVA		/ FETCH FUNCTION CODE.			/(142)
	SMA		/ ERROR?				/(142)
	JMP PUT030	/ NO.					/(142)
	JMS IOERR	/ YES, PRINT ERROR MESSAGE.		/(142)
	LAC PUTCPB+2	/ LUN NUMBER.				/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
PUTFST	.INIT PUTDEV,1,RECOUP	/(RCHM-032) INITIALIZE DEVICE HANDLER.
	.FSTAT PUTDEV,PUTNAM	/(RCHM-032) SCAN DIRECTORY FOR SPECIFIED FILE.
	SZA			/(RCHM-032) DOES THE SPECIFIED FILE EXIST?
	JMP PUT020		/(RCHM-032) YES, GENERATE ERROR MESSAGE.
	.ENTER PUTDEV,PUTNAM	/(RCHM-032) SET UP ALTERNATIE OUTPUT FILE.
	.ENDC							/(142)
PUT030	LAC SKPLIT		/ FETCH SKP INSTRUCTION.		/(142)
	DAC PUTSW		/(RCHM-032) AND FLAG THE EXISTANCE OF AN ALTERNATE
				/(RCHM-032)  OUTPUT STREAM.
	JMP FND4		/(RCHM-032) GO READ NEXT COMMAND.
/+
/ A FILE NAME WAS NOT GIVEN IN THE COMMAND STRING. TAKE THE FILE NAME GIVEN IN THE
/ OPEN AND USE "PUT" AS AN EXTENSION. TELL THE USER ABOUT IT AND GO PERFORM
/ ALL THE FILE CHECKING AS NORMAL.
/-
PUT010	LAW NOFLNM		/(RCHM-032) TELL THE USER ABOUT NO FILE NAME.
	JMS TYPOUT		/(RCHM-032) PRINT THE MESSAGE.
	LAC INNAME		/(RCHM-032) MOVE INPUT NAME SPECIFIED INTO
	DAC PUTNAM		/(RCHM-032) THE PUT FILE NAME SPECIFICATION.
	LAC INNAME+1		/(RCHM-032)
	DAC PUTNAM+1		/(RCHM-032)
	LAW PUTNAM		/(RCHM-032) FETCH ADDRESS OF FILE NAME TO BE USED
	JMS TYNAME		/(RCHM-032) PRINT FILE NAME AND EXTENSION.
	LAW ISASS		/(RCHM-032) AND TELL HIM THAT THE FILNAM EXT PRINTED
	JMS TYPOUT		/(RCHM-032)  IS ASSUMED TO BE THE ONE HE IS TALKING ABOUT.
	JMP PUTFST		/(RCHM-032) GO PERFORM .FSTAT AND .ENTER.
ISASS=.-2			/(RCHM-032) FAKE OUT HEADER INFORMATION.
	.ASCII 'IS ASSUMED.'<15> /(RCHM-032) TAIL END OF ASSUMED MESSAGE.
	.IFDEF RSX						/(142)
PUTCPB	XX		/ FUNCTION CODE IS CALCULATED.		/(142)
	EVA							/(142)
	ALTOUT		/ I/O LUN NUMBER.			/(142)
	.ENDC							/(142)
PUTNAM	.BLOCK 3		/(RCHM-032) PUT FILE NAME DEB.
/+
/ THE FILE NAME AND EXTENSION SPECIFIED ALREADY EXIST ON .DAT -13. TELL
/ THE USER AND RETURN FOR ANOTHER COMMAND.
/-
PUT020	LAW PUTNAM		/(RCHM-032) FETCH ADDRESS OF FILE SPECIFICATION.
	JMS TYNAME		/(RCHM-032) PRINT FILE NAME.
	LAW PUTPME		/(RCHM-032) GET THE REST OF THE MESSAGE.
	JMS TYPOUT		/(RCHM-032) AND PRINT IT TOO.
	JMP FND4		/(RCHM-032) RETURN FRO THE NEXT COMMAND.
PUTPME=.-2			/(RCHM-032)
	.ASCII 'IS ALREADY PRESENT ON .DAT -13.'<15> /(RCHM-032)
	.TITLE PCLOSE COMMAND PROCESSOR.
/+
/ ROUTINE NAME: PCLOSE
/
/ COMMAND FORMAT:
/
/	PCLOSE
/
/ INITIAL CONDITIONS:
/ 1.	A PUT COMMAND MUST HAVE BEEN PREVIOUSLY ISSUED.
/
/ TERMINAL CONDITIONS:
/ 1.	THE FILE NAME WPECIFIED BY THE PUT COMMAND IS CLOSED.
/ 2.	THE STATE OF PUTSW IS MODIFIED TO REFLECT THE LACK OF AN OUTPUT FILE.
/-
PCLOSE	XCT PUTSW		/(RCHM-032) IS A PUT FILE OPEN?
	JMP ILLCWD		/(RCHM-032) NO.
	JMS PCLS		/(RCHM-032) PERFORM PCLOSE.
	JMP FND4		/(RCHM-032) GO GET NEXT COMMAND.
/+
/ ROUTINE TO PERFORM PCLOSE FUNCTION. THIS ROUTINE IS ALSO CALLED BY
/ CLSOUT DURING THE CLOSE PROCEDURES FOR A TOP, CLOSE, AND SCLOSE PROCESS.
/-
PCLS	XX			/(RCHM-032) PCLOSE ENTRY POINT.
	.IFDEF RSX						/(142)
	LAC PUTCPB+2	/ FETCH LUN NUMBER.			/(142)
	JMS DETACH	/ DETACH THE DEVICE (DETACH DOES AN	/(142)
			/ IMPLICIT CLOSE).			/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	.CLOSE PUTDEV		/(RCHM-032) CLOSE THE ALTERNATE OUTPUT FILE.
	.ENDC							/(142)
PCLS10	LAC NOPLIT	/ FETCH NEW VALUE OF SWITCH.		/(142)
	DAC PUTSW		/(RCHM-032) AND SET SWITCH TO INDICATE NO OUTPUT FILE.
	JMP* PCLS		/(RCHM-032) RETURN TO CALLER
	.TITLE	CMD PROC -- PRINT & LIST
/
/PRINT N LINES FROM EDIT FILE.
/
	.IFDEF RSX						/(142)
LISTFL	LAC (LIST)	/ DO A HINF ON THE LISTING LUN.		/(142)
	JMS HINFLN						/(142)
	AND (40000)	/ IS TH SILLY THING FILE ORIENTED?	/(142)
	SZA		/ AC = 0 IF NOT.			/(142)
	JMP PRT010	/ FILE ORIENTED, ERROR.			/(142)
	LAC (LIST)	/ ATTACH THE LISTING DEVICE.		/(142)
	JMS ATTACH						/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
LISTFL	.INIT	LIST,5,RECOUP	/(RCHM-136) INIT LP AND CHECK STATUS OF LIST DEV.
	LAW	-376		/(RCHM-026) FETCH SMALLEST FILE ORIENTED BUFFER SIZE.
	TAD	.-2		/(RCHM-026) AC<0 IF .DAT -12 IS NON-FILE ORIENTED.
	SMA			/(RCHM-026) NON-FILE ORIENTED?
	JMP	PRT010		/(RCHM-026) NO!
	.ENDC							/(142)
	LAC	(JMS	LISTIT	/(RCHM-026) FETCH LISTING COMMAND SWITCH.
	SKP
PRINT	LAC	(JMS	TYPOUT	/(RCHM-026) FETCH PRINT COMMAND SWITCH.
	DAC	PRINTC		/(RCHM-026) STORE IN PRINT CONTROL SWITCH.
	JMS GETNUM	/GET ARGUMENT.
	DAC LOOPCT	/N LINES TO PRINT.
PRLIN	LAC LENGTH	/GET TOTAL CHARS IN CURRENT LINE.
	SNA		/PRINT ONLY IF LINE IS NON-EMPTY.
	JMP PRT1		/OTHERWISE IGNORE IT.
	JMS PACK		/PACK THE CURRENT LINE.
ADR005	INLINE		/FROM INLINE...
	TYLINE		/TO TYLINE.
	LAW TYLINE	/THEN PRINT THIS DATA LINE.
	XCT	PRINTC		/(RCHM-026) TRANSFER LINE TO -3 OR -12 (.DAT).
PRT1	ISZ LOOPCT	/COUNT LINES TO BE PRINTED.
	JMP PRT020		/(RCHM-136) MORE TO DO.
	LAC PRINTC		/(RCHM-136) CHECK IF A .CLOSE MUST BE EXECUTED.
	SAD (JMS LISTIT)	/(RCHM-136) ARE WE DOING A .LIST?
	SKP			/(RCHM-136) YES.
	JMP FND4		/(RCHM-136) NO, RETURN TO COMMAND PROCESSOR.
	.IFDEF RSX						/(142)
	CAL CLSLST	/ CLOSE LIST FILE TO KEEP SPOOLER HAPPY	/(142)
	LAC (LIST)						/(142)
	JMS DETACH	/ DETACH THE LISTING DEVICE.		/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	.CLOSE LIST		/(RCHM-136) ISSUE A .CLOSE TO MAKE SPOOLER HAPPY.
	.ENDC							/(142)
	JMP FND4		/(RCHM-136) RETURN TO COMMAND PROCESSOR.
PRT020	JMS PUTLIN		/(RCHM-136) WRITE OUT THIS LINE.
	JMP FULBUF	/NO MORE ROOM.
	LAC (1)			/(RCHM-139)
	DAC	NOPKSW	/SET NO REPACK SW
	JMS GETLIN	/GET NEXT LINE.
	INLINE
	JMP EOF		/RETURN IF EOF ENCOUNTERED.
	.IFDEF EDITVT
	LAC TVSW	/IF TV IS ON
	SNA
	JMS TYPRTN	/GIVE A <CR-LF> TO TTY
	.ENDC
	.IFUND EDITOR
	JMS	TVCL	/DISPLAY NEW CURRENT LINE.
	.ENDC
	JMP PRLIN		/GO PRINT NEW CURRENT LINE.
 
/(RCHM-026)
/ PRINT ERROR MESSAGE ".DAT -12 FILE ORIENTED"
 
PRT010	LAW	D12FO		/(RCHM-026) BEGINNING OF ERROR MESSAGE.
	JMS	TYPOUT		/(RCHM-026) TELL USER AND ABORT PRINT PROCESS.
	JMP	FND4		/(RCHM-026) GO BEGIN NEX COMMAND INPUT.
 
/(RCHM-026)
/ PRINT VARIABLES AND CONSTANTS.
 
PRINTC	XX			/(RCHM-026) PRINT AND LIST COMMAND SWITCH.
				/(RCHM-026)  PRINT=JMS TYPOUT
				/(RCHM-026)  LIST=JMS LISTIT
D12FO=.-2			/(RCHM-026) FAKE OUT FOR TTY .IOPS ASCII PROCESSOR.
	.ASCII	".DAT -12 IS FILE-ORIENTED."<15> /(RCHM-026) ERROR MESSAGE.
 
/(RCHM-026)
/ LISTING FILE OUTPUT ROUTINE
/ CALLING SEQUENCE:
/
/	LAW	MESADR		/ADDRESS OF MESSAGE.
/	JMS	LISTIT
/	...			/RETURN ADDRESS
 
LISTIT	XX			/(RCHM-026) LISTIT ENTRY POINT.
	JMS	GETBNK		/(RCHM-026) GET BANK BITS FOR REAL ADDRESSING.
	DAC	LISTOA		/(RCHM-026) STORE OUTPUT BUFFER ADDRESS IN .WRITE.
	.IFDEF RSX						/(142)
	CAL WLIST	/ WRITE LINE TO LISTING DEVICE.		/(142)
	CAL WFEVA	/ WAIT FOR I/O TO COMPLETE.		/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
LISTOA=.+2			/(RCHM-026) ADDRESS OF OUTPUT ADDRESS IN MACRO.
	.WRITE	LIST,2,0,BUFLEN	/(RCHM-026) WRITE THE LINE TO THE PRINTER.
	.WAIT	LIST		/(RCHM-026) WAIT FOR I/O TO COMPLETE.
	.ENDC							/(142)
	JMP*	LISTIT		/(RCHM-026) RETURN.
	.TITLE	CMD PROC -- DELETE, NEXT, FIND, AND LOCATE.
DELETE=.
	.IFUND EDITOR
	JMS	TVXUT	/CROSS OUT CURRENT LINE ON DISPLAY
	.ENDC
	CLA		/SET DELSW TO ZERO.
/MOVE POINTER DOWN N OR 1.
NEXT	DAC DELSW		/SET DELSW. AC IS GUARANTEED NON-ZERO.
	JMS GETNUM	/GET ARGUMENT.
	DAC LOOPCT	/N LINES TO SKIP OVER.
NXTLIN	LAC DELSW		/GET DELETE-NEXT INDICATOR.
	SNA		/DELSW .E. 0, OPERATION IS "DELETE."
	DAC LENGTH	/DELETE, FORESTALL WRITE OF THIS LINE.
	JMS PUTLIN	/NEXT, SAVE CURRENT LINE.
	JMP FULBUF	/..
	LAC (1)			/(RCHM-139) SET NO REPACK SWITCH.
	DAC	NOPKSW
	LAC INFILE	/IF NO INPUT FILE DON'T
	SNA
	JMP NEXT0
	LAC BLOKSW
	SZA		/GET A LINE
	JMP FND4		/NO NEED TO DO ANYTHING MORE
NEXT0	JMS GETLIN	/GET NEXT LINE.
	INLINE		/..
	JMP EOF		/..
	.IFUND EDITOR
NEXT1	LAC	DELSW	/IF CURRENT OPERATION IS DELETE
	SZA		/DO NOT
	JMS	TVCL	/DISPLAY CURRENT LINE.
	.ENDC
	ISZ LOOPCT	/COUNT LINES CONSIDERED.
	JMP NXTLIN	/MORE LINES TO SKIP.
	.IFUND EDITOR
	LAC	DELSW	/IF CURRENT OPERATION IS 'NEXT'
	SNA		/THE CURRENT LINE HAS ALREADY
	JMS	TVCL	/BEEN DISPLAYED.
	.ENDC
	JMP FND4		/ALL FINISHED, RETURN TO MAIN LINE.
/FIND A LINE.
FIND	LAC NXTPTR	/GET POINTER TO CURRENT CHAR IN COMMAND LINE.
	DAC FND2  	/INSERT IN ARGUMENT LIST.
FND1	JMS PUTLIN	/OUTPUT CURRENT LINE.
	JMP FULBUF	/..
	LAC (1)			/(RCHM-139) SET THE NO REPACK SWITCH.
	DAC	NOPKSW	/THIS WILL JUST SWAP BUFFER'S
	JMS GETLIN	/GET NEXT LINE.
	INLINE		/..
	JMP EOF		/IF END-OF-FILE.
	.IFUND EDITOR
	JMS	TVCL	/DISPLAY CURRENT LINE.
	.ENDC
	JMS SCAN		/CALL STRING COMPARER.
FND2	0		/SEARCH FOR THIS STRING...
	INLINE		/...IN THIS LINE.
	SKP		/NOT FOUND.
	SKP		/EOL, STRING 1.
	JMP FND1		/GO BACK TO SEARCH SOME MORE.
/DESIRED LINE HAS BEEN LOCATED. ASCERTAIN WHETHER OR NOT CONFIRMATORY
/PRINT SHOULD BE UNDERTAKEN.
FND3	LAC LENGTH
	DZM	NOPKSW	/CLEAR THE NO REPACKING SWITCH
	SNA
	JMP FND6
	LAC INLADR
	DAC NXTPTR
	ADD LENGTH
	DAC APPEND
	LAC* APPEND
	DAC LOC2
	LAW -3
	DAC TABCT
	LAC BRFSW
	SMA
FNDLP1	JMS NXTCHR
	JMP FND5
	SAD BLANK
	JMP TABFND
	SAD (11)		/(RCHM-139)
	JMP TABFND
	SAD SLASH
	JMP FND5-2
	LAC NXTPTR
	DAC APPEND
	LAC* APPEND
	DAC LOC2
	JMP FNDLP1
TABFND	ISZ TABCT
	JMP FNDLP1
	CLA!CMA
	DAC* APPEND
FND5	LAC VERISW
	SPA
	JMP FNDRS
	JMS PACK
ADR006	INLINE
	TYLINE
	LAW TYLINE
	JMS TYPOUT
FNDRS	LAC LOC2
	DAC* APPEND
FND4=.
	.IFUND EDITOR
	LAC ERRSW		/HAS A READ ERROR OCCURED
	SZA
	JMS TVCL		/YES -- DISPLAY OFFENDING LINE
	.ENDC
	DZM ERRSW		/CLEAR READ ERROR SWITCH
	LAC QUIT
	SNA
	JMP TTRS
FND6=.
	.IFDEF EDITVT
	JMS CTXOFF
	.ENDC
	LAW 76
	JMS TYONCH
	JMP RDLIN
/COME HERE ON BUFFER OVERFLOW
FULBUF	LAW BOVFLM
	DZM	NOPKSW	/CLEAR LINE BUFFER SWITCHING SWITCH
	JMS TYPOUT
	JMS PACK
ADR011	INLINE
	TYLINE
	LAW TYLINE
	JMS TYPOUT
	JMP FND4
/LOCATE A LINE.
LOCATE	LAC NXTPTR	/GET ADDRESS OF NEXT CHAR IN COMMAND LINE.
	DAC LOC2		/GIVE TO SCAN ARGUMENT LIST.
LOC5	JMS PUTLIN	/WRITE THE CURRENT LINE.
	JMP FULBUF	/FULL-BUFFER RETURN.
	LAC (1)			/(RCHM-139) SET THE NO REPACK SWITCH.
	DAC	NOPKSW
	JMS GETLIN	/READ THE NEXT LINE.
	INLINE		/TO CURRENT-LINE AREA.
	JMP EOF		/END-OF-FILE RETURN.
	.IFUND EDITOR
	JMS	TVCL	/DISPLAY CURRENT LINE.
	.ENDC
	LAC INLADR 	/GET START ADDRESS OF NEW LINE.
	DAC LOC4		/INSERT AS SCAN ARGUMENT #2.
LOC1	JMS SCAN		/CALL SCAN.
LOC2	0		/STRING TO LOOK FOR.
LOC4	0		/WHERE TO LOOK FOR IT.
TABCT=LOC4		/COUNT OF TABS AND BLANKS FOR BRIEF MODE SERVICER.
	JMP LOC3		/NOT FOUND THIS TRY.
	JMP FND3		/FOUND.
	JMP LOC5		/NOT FOUND ANYWHERE IN THIS LINE.
LOC3	ISZ LOC4		/BUMP SCAN ARG TO NEW STRING IN CURRENT LINE.
	JMP LOC1		/THEN GO SEARCH THE NEW STRING.
	.TITLE CMD PROC--VERIFY,BLOCK,BRIEF,OUTPUT&TV
/
/SET VERIFY SWITCH
/
VERIFY	JMS DCODSW	/GO INTERPRET NEXT WORD IN LINE.
VERISW	0		/VERIFY ON-OFF SWITCH.
	JMP FND4
/SET BLOCK-MODE INDICATOR.
BLOCK	JMS DCODSW	/"ON" OR "OFF"?
BLOKSW	-1		/BLOCK MODE ON-OFF SWITCH.
	SNA
	JMP SETPBL-1
	LAC BUFEMP
	SZA!CLA!CMA
	JMP BLOK01
	DAC GBLKSW
SETPBL	DAC PBLKSW
	JMP FND4
BLOK01	LAW BFNEMM
	JMS TYPOUT
	JMP FND4
/SET BRIEF MODE SWITCH.
BRIEF	JMS DCODSW	/INTERPRET NEXT CONTROL WORD.
BRFSW	-1		/BRIEF IS OFF INITIALLY.
	JMP FND4
/SET OUTPUT-SUPPRESSION INDICATOR.
OUTPUT	JMS DCODSW	/CHECK ARGUMENT.
OUTPSW	0		/OUTPUT IS "ON" IF ZERO.
	JMP FND4
 
/(RCHM-029)
/ TO ALLOW EDIT TO READ PDP-11 PAPER TAPES, WHICH DO NOT HAVE PARITY
/ BITS, THE FOLLOWING COMMAND DISABLES THE PARITY CHECKING FEATURE
/ OF THE EDITOR. THE USER IS RESPONSIBLE FOR THE INTEGRITY OF ANY DATA READ IN
/ THIS MANNER.
/
/ COMMAND FORMAT:
/
/	PARTIY[ ON]		/TURN PARITY CHECKING ON
/	PARITY OFF		/TURN PARITY CHECKING OFF.
/
/ UPON ENTRY TO THE EDITOR, PARITY CHECKING IS ENABLED. UPON EACH
/ RESTART, PARITY CHECKING WILL BE RE-ENABLES.
 
PARITY	JMS DCODSW		/(RCHM-029) CHECK KEY WORD IN BUFFER.
PARSWT	XX			/(RCHM-029) PARITY SWITCH./
				/(RCHM-029)  SKP=>PARITY ON
				/(RCHM-029)  NOP=>PARITY OFF
				/(RCHM-029) THIS SWITCH MUST CONTAIN ONLY THE ABOVE VALUES.
	SZA			/(RCHM-029) WAS THE KEYWORD "ON"?
	LAC (-1000		/(RCHM-029) NO, PREPARE TO TURN PARITY OFF.
	TAD SKPLIT		/(RCHM-029) AC CONTAINS EITHER A NOP OR SKP NOW.
	DAC PARSWT		/(RCHM-029) SET UP PARITY SWITCH.
	JMP FND4		/(RCHM-029) GO GET NEXT COMMAND.
/SET DISPLAY-WANTED INDICATOR.
	.IFUND EDITOR
TV	JMS DCODSW	/GET ARGUMENT.
TVSW	-1		/TV IS OFF INITALLY.
	SAD	TVON	/ANY CHANGE IN STATUS?
	JMP	TV2	/NO.
	DAC	TVON	/YES,SAVE NEW STATUS.
	.IFDEF EDITVT
	JMS TVCLR		/CLEAR SCREEN
	.ENDC
	JMS	TVST	/START OR STOP DISPLAY.
	LAC	LENGTH	/IF THERE IS ONE,
	SZA
	JMS	TVCL	/DISPLAY THE CURRENT LINE.
TV2	LAC	TVSW	/IF TV WAS TURNED ON,
	SZA!CLC
	JMP	FND4
	DAC	VERISW
	JMP FND4
	.ENDC
	.TITLE CMD PROC--INSERT,RETYPE & APPEND
/
/INSERT A LINE AFTER CURRENT LINE.
/
INSERT	JMS PUTLIN	/WRITE CURRENT LINE.
	JMP FULBUF	/RETURN HERE IF NO MORE ROOM.
	DZM LENGTH	/ZERO TOTAL CHARACTERS.
	JMS APPEND	/CALL APPEND.
	LAC LENGTH	/GET CALCULATED LENGTH.
	SNA		/WAS THERE ANY STUFF AFTER THE COMMAND?
	JMP INPUT		/NO, CHANGE TO INPUT MODE.
	DAC INPSW
	JMP FND4		/YES, GET NEXT COMMAND. LINE INSERTED IS NOW THE CURRENT LINE.
/REPLACE CURRENT INLINE WITH CONTENTS OF EDLIN.
RETYPE	DZM LENGTH	/ZERO TOTAL CHARACTERS PRESENTLY IN CURRENT LINE,
	.IFUND EDITOR
	JMS	TVXUT	/CROSS OUT CURRENT LINE ON DISPLAY.
	.ENDC
	JMS APPEND	/...THEN PERFORM A NORMAL APPEND.
	DAC INPSW
	JMP FND4		/GO GET NEXT COMMAND.
/ADD SOME DATA TO THE CURRENT LINE.
	.IFDEF EDITVT
APPD1	0
	LAC APPD1		/FAKE CALL TO APPEND
	DAC APPEND
	JMS TVXUT		/DELETE LAST LINE ON DISPLAY
	JMP APPND1	/JUMP INTO APPEND
	.ENDC
APPEND	0		/APPEND IS REACHED VIA JMS.
	.IFDEF EDITVP
	LAC	LENGTH	/IF CURRENT OPERATION IS 'APPEND'
	SZA		/(L>0) PREPARE TO ADD TO CURRENT LINE
	JMS	TVMLF	/BY MOVING DISPLAY LINE POINTER UP ONE.
	.ENDC
APPND1	LAC INLADR	/GET START OF CURRENT LINE.
	ADD LENGTH	/BUMP BY TOTAL DATA CHARACTERS.
	DAC POINTR	/GIVE TO NEXT-CHARACTER INDICATOR
	LAW -3		/ENSURE THAT THIS CHAR WILL FIT.
	TAD MAXLEN	/MAXLEN=(LINSIZ.
	CMA
	TAD LENGTH
	SMA
	JMP APPTRN
	JMS NXTCHR	/GET NEXT CHARACTER FROM INPUT STREAM
NOPLIT	NOP		/IGNORE NXTCHR END-OF-LINE RETURN.
	DAC* POINTR	/INSERT IN LINE.
	SPA		/END-OF-LINE?
	JMP	APPOUT	/YES, RETURN TO CALLER.
	ISZ LENGTH	/NO, BUMP TOTAL CHARACTERS.
	JMP APPND1	/GO GET ANOTHER CHARACTER.
APPOUT	DAC	QUOTE		/SAVE TERMINATOR
	.IFDEF EDITVT
	LAC VTFLAG	/IF IN INPUT MODE
	SNA		/DON'T DISPLAY THE LINE AGAIN
	.ENDC
	.IFUND EDITOR
	JMS	TVCL	/DISPLAY CURRENT LINE.
	LAC	QUOTE	/RESTORE TERMINATOR
	.ENDC
	JMP*	APPEND	/RETURN
/
APPTRN	JMS NXTCHR	/IS NEXT CHAR A TERMINATOR
	JMP NOPLIT	/YES --OK
	LAW TRNMES	/GIVE USER MESSAGE
	JMS TYPOUT
	.IFDEF EDITVT
	LAW 12
	JMS TYONCH
	.ENDC
	CLC
	JMP NOPLIT
/
	.TITLE CMD PROC--LINE CONVERT,CHANGE & CONVERT
/
/
/CONVERT STRING#1 TO STRING#2 FOR
/THE SPECIFIED NUMBER OF LINES IN THE
/FILE OR BLOCK BUFFER.
/LINE CONVERT PROCESSING GETS THE NUMBER
/OF LINES TO CONVERT AN SETS UP LOOPCT
/TO THAT VALUE. IT THEN SETS LINCSW TO NOP
/AND GOES TO CONVERT PROCESSING
/WHICH TESTS LINCSW.
/
/
LNCONV	JMS GETNUM
	DAC LOOPCT
	.IFUND EDITOR
	SAD FENCE		/IF ONLY ONE LINE
	JMS TVXUT		/DELETE LAST LINE ON SCREEN
	.ENDC
	LAC NOPLIT
	DAC LINCSW
	JMP CONVRT
/
/
/
/REPLACE STRING 1 WITH STRING 2.
/CHANGE REQUEST PROCESSING
/SET SWITCH AND GO TO CONVERT
/PROCESSING WHICH TESTS THE SWITCH
/
CHANGE	LAC NOPLIT	/GET A NOP
	DAC CHGREQ	/AND SET SWITCH
/
/CONVERT STRING#1 TO STRING#2 THRU OUT
/THE FILE OR BLOCK BUFFER IF IN BLOCK MODE.
/STRING#1 IS DELIMITTED AS IN "CHANGE"
/BY QUOTE CHARACTERS. STRING#2 CAN BE
/DELIMITTED BY EITHER THE APPERANCE OF
/THE QUOTE CHARACTER OR A TERMINATOR
/
CONVRT	JMS TOPBOM	/ARE WE AT THE TOP OR BOTTOM OF THE PAGE
	DZM CONVLT	/GET A LINE IF SO---ZERO COUNTER
	DZM NUM		/INDICATE LINE NAS NOT BEEN ALTERED
	.IFDEF RSX						/(142)
	LAC (TYLINE-1)	/ FETCH BEGINNING OF LINE BUFFER.	/(142)
	.ENDC							/8142)
	.IFUND RSX						/(142)
	LAW TYLINE-1	/SET UP POINTER TO TYLINE FOR A.I.REG
	JMS GETBNK
	.ENDC							/(142)
	DAC TYLNPT
	DAC QUIT		/INDICATE COMMAND PROC. IN PROGRESS
	TAD MAXLEN
	TAD MTWO		/SET OVERFLOW ADDRESS
	DAC OVFLAD
	JMS NXTCHR	/GET 1'ST QUOTE CHAR
	JMP NOSTNG	/NO STRING---COMPLAIN
	DAC QUOTE
	LAC NXTPTR	/GIVE POINTER OF NEXT CHAR
	DAC STRG1		/TO CALL FOR SCAN
GETCHR	JMS NXTCHR	/COUNT CHARS. IN STRING
	JMP NOSTNG
	SAD QUOTE
	JMP QUCHR
	ISZ CONVLT
	JMP GETCHR
QUCHR	LAC CONVLT	/IS THERE A STRING
	SNA
	JMP NOSTG1	/NO!
CHNOSG	LAW -1
	TAD NXTPTR	/DECREMENT POINTER
	DAC NXTPTR
	CLC		/STORE A TERMINATOR IN
	DAC* NXTPTR	/PLACE OF 2'ND QUOTE CHAR
/
/MAJOR LOOP FOR CONVERT, EVERY
/SEARCH OF A NEW LINE STARTS HERE.
/
CVBACK	LAC TYLNPT	/SET UP POINTERS
	DAC* (12)		/(RCHM-139)
	.IFDEF RSX						/(142)
	LAC (INLINE-1)						/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	LAW INLINE-1
	JMS GETBNK
	.ENDC							/(142)
	DAC INLNPT
	DAC STRG2
	ISZ STRG2
	JMP CVSCAN	/BYPASS CHANGE TEST FOR 1'ST TIME THRU
/
/MINOR LOOP FOR CONVERT, LOOPS BACK
/HERE AFTER PROCESSING OF EITHER
/NO MATCH FOUND, OR A MATCH FOUND
/
SCANCT	XCT CHGREQ	/WAS THIS A CHANGE REQUEST
	JMP CHGEX1	/YES 
CVSCAN	JMS SCAN		/GO SCAN LINE FOR STRING#1
STRG1	0
STRG2	0
	JMP NOMTCH
	JMP MTCHFD
/
/END OF LINE BEING SEARCHED FOUND COMES HERE
/THIS IS THE EXIT PROCESSING FOR
/THE MINOR LOOP. ON LINE OVERFLOW
/THIS SECTION IS ENTERED AT "TRANL"
/ALSO, NORMAL EXIT FROM THE CONVERT
/COMMAND PROCESSING IS DONE HERE
/
CHGEX1	CLC		/TRANSFER REST OF
	JMS SGTRAN	/INLINE TO TYLINE
TRANL	JMS LINESW	/NOW SWAP TYLINE
	TYLINE-1	/BACK TO INLINE
	INLINE-1
	XCT CHGREQ	/WAS THIS A CHANGE
	JMP CHGEX2	/YES GO EXIT FOR CHANGE
	XCT LINCSW	/WAS THIS A LINE CONVERT
	JMP LINCEX	/YES
LNCVBK=.
	.IFUND EDITOR
	LAC NUM		/HAS LINE BEEN ALTERED
	SZA
	JMS TVCL		/YES--DISPLAY LINE
	DZM NUM		/RESET FLAG
	.ENDC
	JMS PUTLIN	/PUT LINE AWAY
	JMP FULBUF	/BUFFER OVERFLOW RETURN
	LAC (1)			/(RCHM-139) SET NO REPACK SWITCH.
	DAC	NOPKSW	/**IF A CHANGE HAS BEEN MADE (IE MATCH FOUND)
			/THE SWITCH IS RESET
	JMS GETLIN	/GO GET ANOTHER LINE
	INLINE		/PUT IT HERE
	JMP COVEX4	/NO MORE LINES TO GET***DONE**EXIT
	JMP CVBACK	/ENTER MAJOR LOOP
/
/EXIT FOR CHANGE COMMAND
/
CHGEX2	LAC SKPLIT	/GET SKP
	DAC CHGREQ	/RESET SWITCH
	.IFUND EDITOR
	LAC TVSW		/CHECK TO SEE IF TV IS ON
	SZA
	JMP FND3		/TV IS OFF GO CONFIRM ON TTY
	JMS	TVXUT	/CROSS OUT CURRENT LINE ON DISPLAY
CONEX3	JMS	TVCL	/DISPLAY NEW CURRENT LINE
	JMP	FND6	/EXIT
	.ENDC
	.IFDEF EDITOR
	JMP	FND3
	.ENDC
/
/EXIT FROM LINE CONVEERT
/
LINCEX	ISZ LOOPCT	/ARE WE DONE
	JMP LNCVBK	/NO
	LAC SKPLIT	/RESET SWITCH
	DAC LINCSW
	JMS CONCHK	/HAS A LINE BEEN CHANGED
	.IFUND EDITOR
	LAC TVSW		/IF TV IS OFF
	SZA
	JMP FND3		/GO CONFIRM ON TTY
	JMP CONEX3	/EXIT
	.ENDC
	.IFDEF EDITOR
	JMP	FND3
	.ENDC
/
/
/EXIT FROM CONVERT END OF FILE
/
COVEX4	XCT LINCSW	/WAS THIS A LINE CONVERT
	JMP COVEX5
	JMS CONCHK
	JMP FND6		/NO EXIT
COVEX5	LAC SKPLIT	/RESET SWITCH
	DAC LINCSW
	JMS CONCHK
	JMP EOF		/TELL USER
/NOTE ONLY PART OF THE COMMAND STRING
/UP TO BUT NOT INCLUDING THE SECOND
/QUOTE CHAR. WILL BE DISPLAYED
/
/
/SUBROUTINE TO CHECK IF STRING#1 WAS EVER FOUND
/
CONCHK	0
	LAC SCN1		/WAS A MATCH FOUND
	SNA
	JMP* CONCHK	/YES--OK
	LAW FILN1
	JMS TYPOUT	/NO--TELL USER
	JMP* CONCHK
/
/
/NO MATCH COMES HERE
/LOOPS BACK TO SCAN
/
NOMTCH	LAC* (12)		/(RCHM-139) WILL LINE OVERFLOW
	SAD OVFLAD
	JMP LNOVFL	/YES HANDLE
	LAC* STRG2	/NO  PUT CHAR IN TYLINE
	DAC* 12
	ISZ STRG2	/BUMP ADDR FOR SCAN
	JMP CVSCAN	/GO BACK AN SCAN
/
/A MATCH FOUND COMES HERE
/LOOPS BACK TO SCAN
/
MTCHFD	CLA		/GO TRANSFER REPLACEMENT
	DAC SCN1		/INDICATE A MATCH FOUND
	DZM	NOPKSW	/RESET NO REPACK SW
	JMS SGTRAN	/STRING TO TYLINE
	LAC STRG2	/UPDATE "SCAN" ADDRESS POINTER
	TAD CONVLT
	DAC STRG2
	ISZ NUM		/INDICATE LINE HAS BEEN ALTERED
	JMP SCANCT	/GO BACK AN SCAN
/
/COMES HERE WHEN A LINE WILL OVERFLOW
/
LNOVFL	CLC		/PUT TERMINATOR
	DAC* 12		/IN TYLINE
	XCT CHGREQ	/WAS THIS A CHANGE
	JMP CHGOVF	/YES JUST PRINT "TRUNCATED"
	.IFDEF RSX						/(142)
	LAC (TYLINE)						/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	LAW TYLINE	/SET UP FOR PACK
	JMS GETBNK
	.ENDC							/(142)
	DAC FROMA
	.IFDEF RSX						/(142)
	LAC (INLINE)						/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	LAW INLINE
	JMS GETBNK
	.ENDC							/(142)
	DAC TOB
	JMS PACK	/GO PACK LINE
FROMA	0
TOB	0
	LAW INLINE	/TYPE IT OUT
	JMS TYPOUT
CHGOVF	LAW TRNMES	/TELL USER IT IS TRUNCATED
	JMS TYPOUT	/GO TO EXIT PROCESSING FROM MINOR LOOP
	.IFDEF EDITVT
	JMS TYPRTN
	.ENDC
	JMP TRANL
/
/SUBROUTINE SGTRAN TRANSFERS EITHER
/REPLACEMENT STRING OR REST OF INLINE
/(CURRENT LINE) TO TYLINE
/CALL	CLA	/AC=0 TRANSFER REPLACEMENT STRING
/OR	CLC	/AC NOT .EQ. 0 TRANSFER REST OF INLINE
/	JMS SGTRAN
/	NORMAL RETURN	/GOES TO LNOVFL IF TYLINE WILL OVERFLOW
/
SGTRAN	0
	SNA!CLC		/TEST WHICH LINE AN
	JMP RPLSG	/SET SWITCH AND A.I.REG 13
	DAC SGTSW
	TAD STRG2
	SKP
RPLSG	LAC NXTPTR
	DAC* C13
TRMORE	LAC* (12)		/(RCHM-139) CHECK FOR OVERFLOW
	SAD OVFLAD
	JMP OVFLCD	/HANDLE IT
	LAC SGTSW
	SZA
	JMP INLNTR
	LAC* 13		/GET DATA
	SPA		/IS IT A TERMINATOR
	JMP SGEXIT	/YES EXIT
	SAD QUOTE	/CHECK FOR QUOTE CHAR
	JMP SGEXIT
TRANCH	DAC* 12		/NO STORE IT
	JMP TRMORE	/GO BACK FOR MORE
INLNTR	LAC* 13		/GET DATA
	SMA		/IA IT A TERMINATOR
	JMP TRANCH	/NO
STORCH	DAC* 12		/YES STORE IT AND EXIT
SGEXIT	DZM SGTSW
	JMP* SGTRAN
/COMES HERE ON POSSIBLE TYLINE OVERFLOW
OVFLCD	LAC SGTSW	/CHECK SWITCH
	SMA
	JMP RPLINE	/REPLACEMENT STRING
	LAC* 13		/GET CHAR IS IT A TERMINATOR
	SPA
	JMP STORCH	/YES--LUCKY GO STORE AND EXIT
OFEXIT	DZM SGTSW
	JMP LNOVFL	/INFORM USER
RPLINE	LAC* 13		/GET DATA
	SPA		/IS IT A TERMINATOR
	JMP SGEXIT	/YES -- LUCKY
	SAD QUOTE	/IS IT THE QUOTE CHAR
	JMP SGEXIT	/YES LUCKY
	JMP OFEXIT	/NOT EITHER -- TO BAD
/
/ERROR MESSAGE FOR NO STRING TO CONVERT
NOSTG1	XCT CHGREQ	/IS THIS A CHANGE
	JMP CHNOSG	/YES---GO PROCESS
NOSTNG	LAW NOSTGM
	JMS TYPOUT
	JMP FND4
	.TITLE CMD PROC MOVE
/
/
/SUBROUTINE LINESW TRANSFER DATA FROM AN ARRAY
/TO ANOTHER ARRAY. TRANSFER TERMINATES
/ON A NEG. DATA WORD (TERMINATOR)
/CALL	JMS LINESW
/	.DAS ARRAY1-1	/FROM ARRAY1
/	.DSA ARRAY2-1	/TO ARRAY2
/	RETURN
/
LINESW	0
	LAC* LINESW	/GET ADDR POINTER TO INPUT ARRAY
	.IFUND RSX						/(142)
	JMS GETBNK
	.ENDC							/(142)
	DAC* (12)		/(RCHM-139) SET UP A.I. REG.
	ISZ LINESW	/BUMP TO ARG. TWO
	LAC* LINESW	/GET POINTER TO OUTPUT ARRAY
	.IFUND RSX						/(142)
	JMS GETBNK
	.ENDC							/(142)
	DAC* C13	/SET UP A.I. REG.
	ISZ LINESW	/BUMP TO RETURN
	DZM LENGTH	/ZERO LENGTH
CONSWP	LAC* 12		/GET DATA
	SPA		/IS IT A TERMINATOR
	JMP SWPDON	/YES WERE DONE ALMOST
	DAC* 13		/STORE IT
	ISZ LENGTH	/COUNT IT
	JMP CONSWP	/GO BACK FOR MORE
SWPDON	DAC* 13		/STORE TERMINATOR
	JMP* LINESW	/RETURN TO CALLER
/
/SUBROUTINE TOPBOM  CHECKS TO SEE
/IF WE ARE AT THE TOP OR END OF THE
/FILE OR BLOCK BUFFER
/
TOPBOM	0
	LAC	LENGTH		/ARE WE AT TOP OR
	SZA			/END OF FILE
	JMP*	TOPBOM		/NO--EXIT
	JMS	GETLIN		/ GET A LINE
	INLINE			/PUT IT HERE
	JMP	EOF		/AT END OF FILE
	JMP*	TOPBOM		/EXIT
/
/
/PROCESSING FOR THE MOVE COMMAND
/MOVE N LINES TO BEFORE THE LINE
/BEGINING WITH STRING.
/
MOVE	JMS	GETNUM		/GET NUMBER OF LINES TO MOVE
	DAC	NUM		/STORE IT
	DAC	QUIT		/INDICATE COMMAND PROC. IN PROGRESS
	DAC	MOVESW
	DZM	LOOPCT		/ZERO COUNTER
	JMS	TOPBOM		/CHECK FOR TOP OR END OF FILE
	JMS	LINESW		/SAVE CURRENT LINE
	INLINE-1
	TYLINE-1
	.IFUND EDITOR
	JMS	TVXUT		/CROSS OUT CURRENT LINE
	.ENDC
	ISZ	NUM		/COUNT THIS LINE
	SKP			/SKIP IF THERE ARE MORE LINES TO MOVE
	JMP	MVSCN1		/NO MORE LINES GO SEARCH FOR STRING
	LAC	BLOKSW		/ARE WE IN BLOCK MODE
	SNA
	JMP	MVBLPC		/YES - GO PROCESS
	.IFDEF RSX						/(142)
	LAC ENDPAR	/ PICK UP THE END OF THE PARTITION	/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	LAC*	SCOM3		/NO IN LINE MODE SETUP
	.ENDC							/(142)
	DAC	BUFEND		/POINTERS TO BUFFER AREA
	.IFDEF RSX						/(142)
	LAC EDTSIZ	/ PICK UP THE SIZE OF THE EDITOR.	/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	LAC*	SCOM2
	.ENDC							/(142)
	DAC	CURPUT		/POINTERS FOR "PUTLIN"
	DAC	NXTPUT
	DZM	PBLKSW		/TURN ON BLOCK MODE FOR "PUTLIN"
MVMORE	JMS	GETLIN		/GO GET A LINE
	INLINE			/PUT IT HERE
	JMP	NELERR		/NO MORE LINES TO GET
	JMS	PUTLIN		/NORMAL RETURN - PUT LINE IN BUFFER
	JMP	NEBERR		/BUFFER IS FULL
	ISZ	LOOPCT		/LINE PUT AWAY OK - COUNT IT
	ISZ	NUM
	JMP	MVMORE		/MORE LINES TO MOVE
	LAW	-1		/TURN BLOCK MODE
	DAC	PBLKSW		/OFF FOR PUTLIN
MVSCN1	LAC	NXTPTR		/GET POINTER TO STRING
	DAC	MVSTRG		/TO SEARCH FOR AND GIVE TO SCAN
	.IFDEF RSX						/(142)
MVSCN2	LAC (INLINE)	/ FETCH INITIAL ADDRESS OF SEARCH.	/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
MVSCN2	LAW	INLINE		/SEARCH INLINE
	JMS	GETBNK		/PUT ON BANK BITS
	.ENDC							/(142)
	DAC	MVSEAC
	JMS	GETLIN		/GO GET A NEW LINE
	INLINE
	JMP	MVEOFE		/END OF FILE OR BLOCK REACHED
	LAC	ERRSW		/WAS THERE A READ ERROR IN GETLIN
	SZA
	JMS	 MVRDER		/YES -- TELL USER
MVSCAN	JMS	SCAN		/SCAN CURRENT LINE FOR
MVSTRG	0			/THIS STRING
MVSEAC	0			/IN THIS LINE
	JMP	MVNMCH		/NO MATCH
	JMP	MVMACH		/MATCH FOUND
/
/CONTROL COMES HERE IF THE END OF
/THE CURRENT LINE BEING SEARCHED IS FOUND
/OR THERE HAS BEEN NO MATCH
/
MVNMCH	JMS	PUTLIN		/GO PUT LINE AWAY
CRGTSV	0			/BUFFER OVERFLOW CAN NOT HAPPEN
	LAC (1)			/(RCHM-139) SET NO REPACK SWITCH.
	DAC	NOPKSW
	.IFUND EDITOR
	JMS	TVCL		/DISPLAY LINE
	.ENDC
	JMP	MVSCN2		/GO BACK FOR NEXT LINE
/
/
/CONTROL COMES HERE IF A
/MATCH IS FOUND
/
MVMACH	JMS	LINESW		/GO SAVE THIS
	INLINE-1		/LINE FOR LATER
	EDLIN-1
MVLINE	JMS	LINESW		/GET FIRST LINE
	TYLINE-1		/TO BE MOVED
	INLINE-1
	DZM	NOPKSW	/RESET NO REPACK SW
	JMS	PUTLIN		/GO PUT IT IN OUTPUT
MVEXSW	-1			/OVERFLOW CAN NOT HAPPEN
	.IFUND EDITOR
	JMS	TVCL		/DISPLAY LINE
	.ENDC
	LAC	LOOPCT		/RETURN - SETUP
	TCA		/ CONVERT LINE COUNT TO NEGATIVE NUMBER./(142)
	SNA			/ARE WE DONE
	JMP	MVEXIT		/YES EXIT
	DAC	LOOPCT		/NO-STORE NEG LOOPCT
	LAC	BLOKSW		/ARE WE IN
	SNA			/BLOCK MODE
	JMP	MVLNBL		/YES
	DZM	GBLKSW		/NO - TURN ON BLOCK MODE
	.IFDEF RSX						/(142)
	LAC EDTSIZ	/ FETCH THE SIZE OF THE EDITOR.		/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	LAC*	SCOM2		/AND SET POINTER FOR "GETLIN"
	.ENDC							/(142)
	DAC	CURGET
	LAW	-1		/INDICATE BUFFER
	DAC	BUFEMP		/NOT EMPTY
CONTMV	JMS	GETLIN		/GET A LINE FROM BUFFER
	INLINE			/PUT IT HERE
MVESW1	-1			/NO MORE LINES TO GET CANNOT OCCUR
	JMS	PUTLIN		/PUT LINE AWAY
MVESW2	-1			/BUFFER OVERFLOW CAN NOT HAPPEN
	.IFUND EDITOR
	JMS	TVCL		/DISPLAY LINE
	.ENDC
	ISZ	LOOPCT		/COUNT IT
	JMP	CONTMV		/MORE TO MOVE
	LAW	-1
	DAC	GBLKSW		/TURN OFF SWITCH
	DZM	BUFEMP		/INDICATE BUFFER EMPTY
	JMP	MVEXIT		/DONE EXIT
/
/ERROR SWITCHES ARE SET HERE
/
NELERR	LAW	-1		/RESET BLOCK MODE
	DAC	PBLKSW		/FOR PUTLIN
	SKP
MVEOFE	DZM	MVESW2		/END OF FILE FOUND
	DZM	MVEXSW		/NO MORE LINES TO GET
	JMP	MVLINE		/GO TRANSFER MOVED LINES
/
/
NEBERR	DZM	MVESW1		/NOT ENOUGH BUFFER
	LAW	-1		/RESET BLOCK SWITCH
	DAC	PBLKSW		/FOR PUTLIN
	JMP	MVMACH		/SAVE CURRENT LINE & MOVE LINES
/
/
/PROCESSING WHEN IN BLOCK MODE
/
MVBLPC	LAC	CURGET		/SAVE POINTER TO NEXT
	DAC	CRGTSV		/LINE TO GET FOR "GETLIN"
	LAW	-2		/CHECK NUMBER OF LINES TO
	TAD	NUM		/MOVE AGAINST SIZE OF BUFFER
	CMA
	TAD	BUFSIZ
	SMA
	JMP	BTSERR		/BUFFER IS TOO SMALL
BUFFOK	JMS	GETLIN		/GET A LINE
	INLINE			/PUT IT HERE
	JMP	NLBKER		/NO MORE LINES TO GET
	ISZ	LOOPCT		/NORMAL RETURN - COUNT LINES
	ISZ	NUM		/ARE WE DONE
	JMP	BUFFOK		/GO BYPASS ANOTHER LINE
	JMP	MVSCN1		/YES - GO SEARCH LINES FOR STRING
/
/STRING FOUND AND IN BLOCK MODE
/AFTER CURRENT LINE IS SAVED
/AND FIRST LINE TO BE MOVED HAS
/BEEN PLACED IN OUTPUT BUFFER
/CONTROL COMES HERE
/
MVLNBL	LAC	CURGET		/GET POINTER TO NEXT LINE
	DAC	NUM		/AND SAVE IT
	LAC	CRGTSV		/GET POINTER TO LINE TO BE MOVED
	DAC	CURGET		/AND GIVE TO CURGET
MVBLM	JMS	GETLIN		/GO GET A LINE
	INLINE
	NOP			/NO MORE LINES CAN NOT HAPPEN
	JMS	PUTLIN		/RETURN - PUT LINE IN
	NOP			/OUTPUT BUFFER - OVERFLOW CAN NOT HAPPEN
	.IFUND EDITOR
	JMS	TVCL		/DISPLAY LINE
	.ENDC
	ISZ	LOOPCT		/IS THERE MORE TO DO
	JMP	MVBLM		/YES
	LAC	NUM		/DONE RESTORE POINTER FOR
	DAC	CURGET		/GETLIN
/
/COMMON EXIT ROUTINE FOR MOVE
/
MVEXIT	LAC	MVEXSW		/TEST ERROR SWITCH
	DZM	MOVESW
	SNA
	JMP	ERROR1		/THERES AN ERROR
	JMS	LINESW		/GO RESTORE CURRENT LINE
	EDLIN-1			/TO INLINE
	INLINE-1
	LAC	MVESW1		/TEST ERROR SWITCH
	SNA
	JMP	ERROR2		/THERE'S AN ERROR
EXERR2	LAW	-1		/RESET SWITCH
	DAC	MVESW1
	.IFUND EDITOR
	JMS	TVCL		/DISPLAY LINE
	.ENDC
	JMP	FND6		/EXIT FOR NEXT COMMAND
/
ERROR2	LAW	NENGMS		/TELL USER THAT
	JMS	TYPOUT		/NOT ENOUGH BUFFER SPACE
	LAW	BUFSPM
	JMS	TYPOUT
	JMP	EXERR2		/EXIT
/
ERROR1	LAC	MVESW2		/CHECK ERROR SWITCH
	SNA
	JMP	ERROR3		/THERE'S AN ERROR
	LAW	NENGMS		/GIVE USER MESSAGE
	JMS	TYPOUT		/NOT ENOUGH LINES,
	LAW	LINEMS
	JMS	TYPOUT
EXERR1	LAW	-1		/RESET SWITCHES
	DAC MVEXSW
	DAC MVESW2
	JMP	EOF		/EXIT EOF MESS. & NEXT COMMAND
/
ERROR3	LAW	LMEOFM		/GIVE USER MESSAGE - LINES
	JMS	TYPOUT		/MOVED TO END
	JMP	EXERR1		/EXIT
/
/NOT ENOUGH LINES TO MOVE IN BLOCK MODE
NLBKER	LAC	CRGTSV		/RESTORE POINTER FOR
	DAC	CURGET		/GETLINE
	LAW	NENGMS		/TELL USER OF PROBLEM
	JMS	TYPOUT
	LAW	LINEMS
	JMS	TYPOUT
	JMS	LINESW		/SWAP BACK ORG. CURRENT LINE
	TYLINE-1
	INLINE-1
	JMP	MVBEEX		/EXIT FOR NEXT COMMAND
/
/BUFFER SIZE TO SMALL IN BLOCK MODE
/
BTSERR	LAW	BUFTSM		/TELL USER OF PROBLEM
	JMS	TYPOUT
MVBEEX	DZM	MOVESW
	JMP	FND6		/EXIT FOR NEXT COMMAND
/
MOVESW	0
/
/SUBROUTINE  MVRDER
/A READ ERROR HAS OCCURED IN GETLIN
/DETERMINE THE ERROR TYPE AND GIVE USER
/MESSAGE WITH OFFENDING LINE
/THEN CONTINUE THE MOVE
/
MVRDER	0
	SAD C60		/IS IT A TRUNCATED LINE
	JMP MVTRN		/YES
	LAW PRTYMS	/NO -- READ ERROR
	SKP
MVTRN	LAW TRNMES
	JMS TYPOUT	/GIVE MESSAGE
	JMS PACK	/PRINT OFFENDING LINE
ADR018	INLINE
	SBUFF
	LAW SBUFF
	JMS TYPOUT
	.IFDEF EDITVT
	JMS TYPRTN
	.ENDC
	DZM ERRSW		/CLEAR OUT ERROR SW
	DZM	NOPKSW	/RESET NO REPACK SW
	JMP* MVRDER	/GO CONTINUE MOVE
/
	.TITLE CMD PROC MODIFY
/
/
/PROCESSING FOR MODIFING A LINE
/WITH THE TERMINATOR OF THE TYPED IN
/LINE DETERMINING IF THE REST OF THE
/CURRENT LINE IS TRUNCATED.
/LINE IS TRUNCATED ON A <CR> AND
/APPENDED ON AN ALTMODE
/
/
MODIFY	LAC NXTPTR	/GIVE ADDR OF STRING
	DAC MDSTG1	/TO SEARCH FOR TO SCAN
	DZM LOOPCT
	JMS TOPBOM	/CHECK FOR TOP OR END OF FILE
CNTMOR	JMS NXTCHR	/COUNT HOW MANY CHAR
	JMP CNTDON	/IN THE STRING
	ISZ LOOPCT
	JMP CNTMOR
CNTDON	LAC LOOPCT	/CHECK FOR PRESENTS
	SNA		/OF A STRING
	JMP FND6	/EXIT  NO STRING
	.IFDEF RSX						/(142)
	LAC (INLINE)						/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	LAW INLINE
	JMS GETBNK
	.ENDC							/(142)
	DAC MDSTG2
MDSCAN	JMS SCAN	/LINE FOR STRING
MDSTG1	0
MDSTG2	0
	JMP MDNMCH	/NO MATCH
	JMP MDMACH	/MATCH FOUND
	JMP FND6	/EXIT NO MATCH IN LINE
/
/NO MATCH COMES HERE
/
MDNMCH	ISZ MDSTG2	/BUMP ADDR
	JMP MDSCAN	/SCAN SOMEMORE
/
/MATCH FOUND COMES HERE
/
MDMACH	LAC MDSTG2	/CALCULATE ADDR OF 1'ST CHAR
	TAD LOOPCT	/AFTER STRING
	DAC MDSTG1	/SAVE IT
	LAC* MDSTG1	/GET CHAR
	DAC NUM		/SAVE IT
	LAW -176	/PUT ALTMODE TERMINATOR IN LINE
	DAC* MDSTG1
	JMS PACK	/GO PACK 1'ST HALF
ADR014	INLINE		/OF INLINE
	TYLINE
	LAW TYLINE	/TYPE OUT 1'ST
	JMS TYPOUT	/HALF OF INLINE
	LAW TYLINE	/GET NEW INPUT ON TTY
	JMS TYPEIN
	JMS UNPACK	/UNPACK IT TO EDLIN
ADR013	TYLINE
	EDLIN
	LAC NUM		/RESTORE CHAR TO INLINE
	DAC* MDSTG1
	LAC MDSTG1	/SET UP FROM ADDR
	TAD FENCE	/FOR "LINESW"
	DAC MDFROM
	JMS LINESW	/SWAP 2'ND PART OF
MDFROM	0		/INLINE TO TYLINE
	TYLINE-1
	.IFDEF RSX						/(142)
	LAC (INLINE-1)						/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	LAW INLINE-1	/CALCULATE NEW INLINE LENGTH
	JMS GETBNK
	.ENDC							/(142)
	CMA
	TAD MDSTG1
	DAC LENGTH	/STORE IT
	.IFDEF RSX						/(142)
	LAC (EDLIN)						/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	LAW EDLIN	/SET UP NXTPTR FOR
	JMS GETBNK	/"APPEND"
	.ENDC							/(142)
	DAC NXTPTR
	.IFUND EDITOR
	LAC TVSW	/IS TV ON
	SNA
	JMP TVFMD1	/YES HANDLE
	.ENDC
MDAPP1	JMS APPEND	/APPEND NEW DATA TO INLINE
	CMA		/IS TERMINATOR A <CR>
	SAD C15
	.IFUND EDITOR
	JMP TVFMD3	/YES EXIT FOR TV
	.ENDC
	.IFDEF EDITOR
	JMP FND6
	.ENDC
	LAC POINTR	/DECREMENT POINTER FOR STORING
	TAD FENCE	/DATA IN "APPEND"
	DAC POINTR
	.IFDEF RSX						/(142)
	LAC (TYLINE)						/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	LAW TYLINE	/SET UP POINTER FOR GETTING DATA
	JMS GETBNK
	.ENDC							/(142)
	DAC NXTPTR	/IN "APPEND"
	JMS APPEND	/REST OF ORG. INLINE
	.IFUND EDITOR
	LAC NUM		/WAS TV ON
	SNA
	JMP TVFMD2	/YES -- EXIT FOR TV
	.ENDC
	JMS PACK	/TYPE OUT REST OF
ADR015	TYLINE		/ORGINAL INLINE
	EDLIN
	LAW EDLIN
	JMS TYPOUT
	JMP FND6	/EXIT
	.IFUND EDITOR
/
/HANDLING OF THE DISPLAY WHEN IT IS ON
/FOR THE MODIFY COMMAND
/
TVFMD1	DAC NUM		/SAVE CURRENT TVSW (0)
	CMA
	DAC TVSW	/TURN OFF TV FOR APPEND
	JMP MDAPP1	/GO APPEND NEW DATA
/
TVFMD2	DAC TVSW	/TURN TV BACK ON
	JMS TVXUT	/CROSS OUT CURRENT LINE
	JMS TVCL	/DISPLAY NEW CURRENT LINE
	JMS TYPRTN	/<CR><LF> FOR TTY IN CASE OF ALTMODE
	JMP FND6	/EXIT
/
TVFMD3	LAC NUM		/WAS TV ON
	SZA
	JMP FND6	/NO EXIT
	JMP TVFMD2	/YES EXIT FOR TV ON
/
	.ENDC
	.TITLE CMD PROC--SIZE,OVERLAY,CALL,OPEN & KEEP
/
/
/SET N LINES IN BLOCK BUFFER.
SIZE	JMS GETNUM	/GET DECIMAL ARGUMENT.
	SAD FENCE		/-1?
	JMP ILLCWD	/ILLEGAL IF SO.
	.IFDEF RSX						/(142)
	PAL		/ SAVE NUMBER OF LINES.		/(142)
	TCA		/ MAKE THEM POSITIVE.			/(142)
	TAD MAXBUF	/ CHECK NUMBER AGAINST CALCULATED MAX.	/(142)
	SMA		/ AC WILL BE < 0 IF NUMBER IS OK.	/(142)
	JMP ILLCWD						/(142)
	PLA		/ RESTORE NUMBER TO AC.			/(142)
	.ENDC							/(142)
	DAC BUFSIZ	/ARG .G. 1, SAVE NEW SIZE.
	JMP FND4		/GET NEXT COMMAND.
/CHANGE N LINES.
OVRLAY	JMS GETNUM	/GET TOTAL LINES TO REPLACE.
	DAC LOOPCT	/SAVE AS COUNTER.
	.IFUND EDITOR
	JMS	TVXUT	/CROSS OUT CURRENT LINE ON DISPLAY.
	.ENDC
OVRLP1	DZM LENGTH	/FORESTALL WRITE OF FINAL LINE SKIPPED OVER.
	ISZ LOOPCT	/COUNT CURRENT LINE.
	SKP		/MORE TO DO, GET NEXT LINE.
	JMP INPUT		/DONE, GO CHANGE TO INPUT MODE.
	JMS GETLIN	/READ NEXT LINE FROM FILE OR INPUT BUFFER.
	INLINE		/..
	JMP EOF		/END-OF-FILE RETURN FROM GETLIN.
	JMP OVRLP1	/READ WAS SUCCESSFUL, PROCESS THIS LINE.
	.EJECT
/+
/ UTILITY ROUTINE TO CHECK TO SEE IF MESSAGE LENGTH IS GREATER THAN 3.
/ USED BY BOTH DELETE AND RENAME TO CHECK FOR LENGTH OF EXTENSION.
/-
EXTCHK	XX			/(RCHM-137) ENTRY8 POINT.
	LAC NCHARS		/(RCHM-137) FETCH NUMBER OF CHARACTERS IN MESSAGE.
	AAC -3			/(RCHM-137) SUBTRACT MAXIMUM LENGTH.
	SMA!SZA!CLA!CMA		/(RCHM-137) RETURN -1 IF OK.
	JMP ILLCWD		/(RCHM-137) OTHERWIZE RETURN TO ILLEGAL COMMAND EXIT.
	JMP* EXTCHK		/(RCHM-137) RETURN TO CALLER.
/
/
CALL	NOP
	JMS GETCOM
	LAC CWD
	SAD C104
	JMP CDEL
	SAD C122
	JMP CREN
	JMP ILLCWD
CDEL	JMS GETDAT
	JMS GETCOM
	SNA
	JMP ILLCWD
	LAW -2
	JMS PK6BT
	CWD
CALLDB	CALDB1
	LAC SRCNAM
	DAC CALDB1+2
	JMS GETCOM
	SNA			/(RCHM-137) ANY CHARACTERS IN EXTENSION?
	JMP CDEL1		/ NO
	JMS EXTCHK		/(RCHM-137) CHECK LENGTH OF EXTENSION.
	JMS PK6BT
	CWD
	CALDB1+2
CDEL1	LAC CALLDB
	ADD CALDAT
	DAC CDEL2+1
	DAC CDEL3		/(RCHM-140) SET UP .FSTAT PROCESSING.
	JMS FSTAT		/(RCHM-140) ISSUE .FSTAT TO CORRECT DEVICE.
CDEL3	XX			/(RCHM-140)
	SPA			/(RCHM-140) FILE ORIENTED?
	JMP IOSET		/(RCHM-140) NO, NO USE ISSUING THE DELETE.
	SNA			/(RCHM-140) FILE THERE?
	JMP CRER.1		/(RCHM-140) NO.
CDEL2	JMS DELFIL
	0
	JMP IOSET
CRER.1	LAW CALDB1		/(RCHM-140) FETCH DATA BLOCK POINTER.
	JMS TYNAME		/(RCHM-140) PRINT FILE NAME.
	LAW FILN1		/(RCHM-140) GET READY TO COMPLETE MESSAGE.
	JMS TYPOUT		/(RCHM-140) PRINT REST OF MESSAGE.
	JMP IOSET		/(RCHM-140) GO RE-INIT THE I/O DEVICES.
CREN	JMS GETDAT
	JMS GETCOM
	SNA
	JMP ILLCWD
	LAW -2
	JMS PK6BT
	CWD
	CALDB1
	JMS GETCOM
	SNA			/(RCHM-137) ANY CHARACTERS IN EXTENSION?
	JMP ILLCWD
	JMS EXTCHK		/(RCHM-137) CHECK LENGTH OF EXTENSION.
	JMS PK6BT
	CWD
	CALDB1+2
	LAC CALLDB		/(RCHM-140) FETCH ADDRESS OF DATA BLOCK.
	ADD CALDAT		/(RCHM-140) SET UP TOP BIT APPROPRIATELY.
	DAC CREN1A		/(RCHM-140)
	JMS FSTAT		/(RCHM-140) CHECK ON THE DEVICE.
CREN1A	XX			/(RCHM-140)
	SPA			/(RCHM-140) FILE ORIENTED?
	JMP IOSET		/(RCHM-140) NO, NO USE DOING ANYTHING ELSE.
	SNA			/(RCHM-140) FILE PRESENT?
	JMP CRER.1		/(RCHM-140) NO, ERROR
	JMS GETCOM
	SNA
	JMP ILLCWD
	LAW -2
	JMS PK6BT
	CWD
	CALDB2
	LAC CALDB1+2
	DAC CALDB2+2
	JMS GETCOM
	SNA			/(RCHM-137) ANY CHARACTERS IN EXTENSION?
	JMP CREN2
	JMS EXTCHK		/(RCHM-137) CHECK LENGTH OF EXTENSION.
	JMS PK6BT
	CWD
	CALDB2+2
CREN2	LAC CALLDB
	ADD CALDAT
	DAC CREN1
	LAC CREN1B		/(RCHM-141) FETCH ADDRESS OF OUTPUT FILE NAME
	ADD CALDAT		/(RCHM-141) SET HIGH BIT FOR INPUT OR OUTPUT DAT.
	DAC CREN0		/(RCHM-141) SET UP CALL TO .FSTAT ROUTINE.
	JMS FSTAT		/(RCHM-141) IS THE FILE NAME ALREADY PRESENT.
CREN0	XX			/(RCHM-141) ADDRESS OF DEB.
	SNA			/(RCHM-141) FILE THERE?
	JMP CREN0A		/(RCHM-141) NO
	LAW CALDB2		/(RCHM-141) PRINT OUTPUT FILE NAME.
	JMS TYNAME		/(RCHM-141)
	LAC CALDAT		/(RCHM-141) CHECK FOR INPUT OR OUTPUT DAT.
	SMA			/(RCHM-141) BIT 0 SET => OUTPUT
	JMP CREN0B		/(RCHM-141) GO PRINT INPUT DATSLOT MESSAGE.
	LAW TWOFIL		/(RCHM-141) FETCH ADDRESS OF OUTPUT FILE MESSAGE.
	JMS TYPOUT		/(RCHM-141)
	JMP IOSET		/(RCHM-141) EXIT COMMAND.
CREN0B	LAW TWOFL1		/(RCHM-141) FETCH ADDRESS OF INPUT FILE MESSAGE.
	JMS TYPOUT		/(RCHM-141) PRINT INPUT FILE MESSAGE.
	JMP IOSET		/(RCHM-141) EXIT COMMAND.
CREN0A	JMS RENAME		/(RCHM-141)
CREN1	0
CREN1B	CALDB2			/(RCHM-141)
IOSET	JMS IOINIT
	JMP FND6
/GETDAT...
GETDAT	0
	JMS GETCOM
	LAC CWD
	SAD OFF
	JMP COUT
	SAD C111
	JMP CIN
	JMP ILLCWD
CIN	CLA!SKP
COUT	LAC XCTZRO
	DAC CALDAT
	JMP* GETDAT
	.IFUND RSX						/(142)
								/(142)
/ ^P INTERRUPT SERVICE ROUTINE FOR DOS.				/(142)
								/(142)
RECOUP	LAC QUIT
	SNA
	JMP BEGIN
	LAC MOVESW
	SZA
	JMP MOVEIP
	DZM QUIT
	LAC NOPLIT
	DAC EXITRQ
MOVEIP=.
	LAC* SCOM16	/RESTORE LINK.
	DAC QRETN		/SAVE RETURN.
	RAL		/..
	LAC* SCOM17	/RESTORE AC.
	JMP* QRETN	/REENTER INTERRUPTED SEGMENT.
	.ENDC							/(142)
TTRS	JMS TYPRTN
	DZM	NOPKSW	/CLEAR THE PACKING SWITCH
	JMP EDIT
/OPEN AN INPUT FILE FOR EDITING.
OPEN	NOP		/OR JMP ILLCWD, IF OPEN SEQUENCE ALREADY EXECUTED.
	LAC INDEV		/IS INPUT DEVICE FILE-STRUCTURED?
	SPA		/INDEV IS POSITIVE IF SO.
	JMP FND4		/NON-FILE-STRUCTURED, IGNORE OPEN REQUEST.
	JMS GETCOM	/GET FILE NAME FROM COMMAND STRING.
	SNA		/SKIP IF A NAME WAS IN FACT TYPED.
	JMP NONAM1	/NO NAME FURNISHED, PUBLISH ERROR.
	LAW -2		/FILE NAME GIVEN, PACK INTO FIRST
	JMS PK6BT		/TWO WORDS OF DEB.
	CWD		/..
INNADR	INNAME		/..
	LAC SRCNAM	/USE "SRC" AS DEFAULT EXTENSION.
	DAC INNAME+2	/..
	JMS GETCOM	/THEN GO GET TYPED EXTENSION, IF PRESENT.
	SNA!CLA!CMA	/SKIP IF AN EXTENSION WAS TYPED.
	JMP DZMNAM	/OTHERWISE, ASSUME "SRC" IS WANTED.
	JMS PK6BT		/NOW PACK UP THE EXTENSION TYPED.
	CWD		/..
	INNAME+2		/INTO THIRD WORD OF DEB.
DZMNAM	DZM NAMSW		/INDICATE THAT A FILE NAME HAS BEEN FURNISHED.
	JMS IOINIT		/INIT INPUT AND OUTPUT DEVICE.
	JMS FSTAT		/NOW GO LOOK FOR THE NAMED FILE.
	INNAME		/FILE NAME IS IN INNAME...INNAME+2.
	SNA		/SKIP IF FILE IS PRESENT ON INPUT DEVICE.
	JMP NTFND		/FILE NOT FOUND, COMMENT.
	DZM INFILE	/INDICATE THAT AN INPUT FILE IS PRESENT.
	JMS SEEK		/GO OPEN THE INPUT FILE FOR READING.
	INNAME		/..
	LAC BADARG	/GET A TRANSFER TO ILLCWD
	DAC OPEN		/AND SHUT OUT FURTHER ACCESS TO OPEN
	DAC CALL		/AND CALL SEQUENCES.
	LAC SKPLIT	/SET EXITSW TO INDICATE
	DAC EXITSW	/A FILE IS OPEN
	LAC NOPLIT		/(RCHM-032) ENABLE THE PUT COMMAND
	DAC PUT			/(RCHM-032)  BY INSERTING A NOP.
	JMP EDIT		/THEN GO PREPARE TO EDIT THE FILE JUST OPENED.
INNAME	.BLOCK 3
NONAM1	LAW NOFLNM
	JMS TYPOUT
	JMP FND4
NTFND	LAW INNAME	/ADDR OF NAME OF ABSENT FILE.
	JMS TYNAME	/TYPE OUT FILE NAME.
	LAW FILN1		/COMPLETE THE COMMENT.
	JMS TYPOUT	/"NOT FOUND."
	LAC BADARG	/DON'T ALLOW OPEN
	DAC OPEN	/OR CALL SEQUENCES
	DAC CALL
	LAC SKPLIT	/SET EXITSW TO INDICATE
	DAC EXITSW	/A FILE IS OPEN
	LAC NOPLIT		/(RCHM-032) ENABLE THE PUT COMMAND
	DAC PUT			/(RCHM-032) BY INSERTING A NOP.
	JMP INPUT		/ACCEPT SOME INPUT.
/SERVICE KEEP REQUEST.
KEEP	LAC DIRSW		/ARE WE GOING FROM -14 TO -15?
	SMA		/IF NOT, SKIP; COULD BE TROUBLE.
	JMP KEEP1		/YES, OK.
	JMS DEVCHK
	JMP KEEP1		/SAME UNIT FOR BOTH DAT SLOTS, OK. HONOR REQUEST.
	LAW TOPRQM	/TWO UNITS AND GOING WRONG WAY, COMMENT.
	JMS TYPOUT	/"TOP REQUEST NEEDED."
	JMP FND6		/GET NEXT COMMAND.
KEEP1	JMS GETCOM	/GET FILE NAME WANTED.
	SNA		/SKIP IF A FILE NAME WAS GIVEN.
	JMP NONAM1	/IF NOT, GO COMPLAIN.
	JMS GETSNM
SETSAV	DZM SAVESW	/INDICATE A SAVE IS WANTED.
	JMP FND6		/THEN REENTER MAIN LINE.
/
/SUBROUTINE GETSNM WILL MAKE UP THE DIRECTORY
/ENTRY BLOCK (DEB) IN SAVNAM WITH WHAT THE USER
/HAS TYPED FOR A FILE NAME AND EXTENSION. IF NO
/EXTENSION WAS TYPED SRC WILL BE USED.
/
/CALL	JMS	GETCOM		/GET FILE NAME INTO CWD
/	JMS	GETSNM
/	RETURN
/
GETSNM	0
	LAW	-2		/PACK 2 WORDS
	JMS	PK6BT		/IN SIXBT
	CWD
	SAVNAM
	LAC	SRCNAM		/PUT SRC IN DEB
	DAC	SAVNAM+2
	JMS	GETCOM		/GET EXIT IF ONE
	SNA!CLC			/PACK ONE WORD
	JMP*	GETSNM		/EXIT
	JMS	PK6BT
	CWD
	SAVNAM+2
	JMP*	GETSNM		/EXIT
/
	.TITLE CMD PROC--SCLOSE & CLOSE
/
/
SCLOSE	LAW -1
	DAC DIRSW
/
/
CLOSE	LAC OUTDEV
	SMA
	JMP CLOSE2
JMSCLS	JMS CLSOUT
	JMP EXITCH	/GO CHECK FOR EXIT REQUEST
CLOSE2	JMS GETCOM
	DZM NAMSW1
	SZA!CLA		/SKIP IF NO NAME TYPED IN CLOSE REQUEST.
	JMP NAME1A	/A NAME WAS TYPED.
	SAD NAMSW		/SKIP IF NO NAME GIVEN IN OPEN REQUEST.
	JMP CLOS1A	/AT LEAST ONE NAME HAS BEEN PROVIDED.
	LAW NOFLNM
	JMS TYPOUT
	JMP FND4
NAME1A	JMS GETNNM
/
/DETERMIN IF WE ARE AT THE TOP A FILE
/AND IF BOTH INPUT AND OUTPUT DEVICES
/ARE FILE STRUCTURED. ALSO, IF WE ARE
/NOT IN BLOCK MODE AND IF BOTH INPUT
/AND OUTPUT FILES ARE ON THE SAME
/DEVICE AND UNIT NUMBER.
/ALSO, THAT INPUT MODE HAS NOT BEEN ENTERED
/AND A SAVE IS NOT WANTED (IE A KEEP)
/IF ALL THE ABOVE CONDITIONS ARE MEET
/THEN THE OUTPUT FILE IS DELETED (.TFIL1 EDT)
/AND THE INPUT FILE CLOSED. ALSO,IF A NAME
/WAS TYPED IN THE CLOSE (SCLOSE,EXIT)
/COMMAND THE INPUT FILE WILL BE RENAMED.
/
CLOS1A	LAC BLOKSW
	SMA
	JMP CLOSE1	/BLOCK MODE ON
	LAC SAVESW
	SNA
	JMP CLOSE1	/A SAVE IS WANTED
	LAC INPSW	/HAS INPUT MODE BEEN ENTERED
	SZA
	JMP CLOSE1	/YES--TO BAD
	LAC FILSTR
	SPA
	JMP CLOSE1	/BOTH INPUT AND OUTPUT ARE NOT FILE STRUCT.
	JMS DEVCHK
	SKP
	JMP CLOSE1	/NOT SAME DEVICE AND UNIT
	LAC RDFNOP
	SAD RDFJMP
	JMP CLOSE1	/NOT AT TOP OF FILE
	AND OUTSW1
	SMA
	JMP CLOSE1	/NOT AT TOP OF FILE
	JMS DELFIL	/DELETE .TFIL1 EDT FROM
	XCT TFILE1	/OUTPUT DEVICE
	CLA
	JMS CLSFIL	/CLOSE INPUT FILE
	LAC NAMSW1	/WAS NAME TYPED IN COMMAND
	SNA
	JMP EXITCH	/NO--DONE
	JMP CKNAM		/GO DO RENAME
/
/
CLOSE1	JMS CLSOUT	/CLOSE I/O FILES
	LAC INDEV	/IS INPUT DEVICE FILE ORIENTED IE--(FOD)
	SPA
	JMP GETNM2	/NO
	JMS DEVCHK	/YES--SAME DEVICE UNIT #
	JMP GETNM2	/YES
	LAC DIRSW	/SCLOSE WANTED
	SMA
	JMP GETNM2	/NO
	JMS SEEK
	INNAME
	JMP CLOSE1
GETNM2	LAC NAMSW1	/IS A RENAME WANTED
	SNA
	JMP EXITCH	/GO CHECK FOR EXIT REQUEST
CKNAM	LAC INDEV	/YES-- LINK=1 IF INPUT (FOD)
	RAL
	LAC CKNM1	/GET ADDR OF NEWNAM DEB
	AND CL0777	/SET BIT 0 TO A 1 IF INPUT NOT (FOD)
	SZL
	ADD XCTZRO
	DAC CKNM1	/STORE RESULT
	LAC CKNM2	/DO THE SAME FOR INNAME AS FOR NEWNAM
	AND CL0777
	SZL
	ADD XCTZRO
	DAC CKNM2
	LAC NAMSW	/NAMESW=0 NAME WAS TYPED IN OPEN REQ
	SNA!CLA!CMA	/SKIP IF SO AC=-1
	JMP CKNM3
CKNM0	JMS FSTAT	/SEE IF NAME IS OK TO USE
CKNM1	NEWNAM
	SZA
	JMP NMERR2	/NO -- TELL USER AND REQUEST ANOTHER NAME
RNM2	JMS RENAME	/RENAME FILE
CKNM2	INNAME
	NEWNAM
	JMP EXITCH	/GO CHECK FOR EXIT REQUEST
/NAMES GIVEN BOTH IN OPEN AND CLOSE REQUESTS. FIND OUT IF TWO
/NAMES ARE IDENTICAL. IF SO, ACCEPT CLOSE REQUEST.
CKNM3	TAD CKNM1	/AC=-1 WHEN WE GET HERE
	DAC* (12)		/(RCHM-139)
	CLA!CMA
	TAD CKNM2
	DAC* C13
	LAW -3
	DAC WRITE
CKNM4	LAC* 12	/CHECK NAMES
	SAD* 13
	SKP
	JMP CKNM0	/NOT THE SAME
	ISZ WRITE
	JMP CKNM4
	JMP EXITCH	/GO CHECK FOR EXIT REQUEST
/
/A NAME ERROR HAS OCCURED INFORM USER
/AN ASK FOR ANOTHER NAME.  DO THIS
/UNTIL THE USER HAS TYPED
/A GOOD NAME
/
NMERR2	LAW	BADNAM		/INFORM USER OF TROUBLE
	JMS	TYPOUT
	LAW 76
	JMS TYONCH
	LAW	TYLINE		/GET NEW NAME
	JMS	TYPEIN
	JMS	UNPACK		/UNPACK TO 7BIT ASCII
ADR017	TYLINE
	EDLIN
	SNA			/DID HE TYPE ANYTHING
	JMP	NMERR2		/NO--GO BACK AN COMPLAIN
	LAC EDLADR
	DAC NXTPTR
	JMS	GETCOM		/MAKE UP DEB IN NEWNAM
	JMS	GETNNM
	JMP	CKNAM		/GO CHECK NAME
/
/
/SUBROUTINE GETNNM---GET NAME TYPED BY
/USER AND MAKE UP THE DEB IN NEWNAM
/
/CALL	JMS	GETCOM
/	JMS	GETNNM
/	RETURN
/
GETNNM	0
NAMEIN	LAW	-2		/PACK TWO WORDS
	JMS	PK6BT
	CWD
	NEWNAM
	LAC	SRCNAM		/PUT SRC IN FOR EXTENSION
	DAC	NEWNAM+2
	DAC	NAMSW1	/INDICATE A NEW NAME IS WANTED
	JMS	GETCOM		/GET EXTENSION IF THERE IS ONE
	SNA!CLC
	JMP*	GETNNM		/NO EXT--EXIT
	JMS	PK6BT		/PACK ONE WORD
	CWD
	NEWNAM+2
	JMP*	GETNNM
/
/
NEWNAM	.BLOCK 3		/NEW NAME DEB
	.TITLE	CMD PROC -- TOP AND BOTTOM
/
/SERVICE TOP COMMAND.
/
TOP	LAC PBLKSW
	SZA
	JMP TOPFIL
	JMS RSBUFF
	JMS CHBUFF
	JMP TOPFL2
TOPFIL	LAC FILSTR
	SPA
	JMP ILLCWD
	XCT RDFRDF		/(RCHM-023)-HAS THE INPUT FILE EVER BEEN READ?
	JMP TOPFL1		/(RCHM-023)-YES.
	LAC RDFNOP
	SAD RDFJMP
	JMP TOPFL1
	AND OUTSW1
	SPA
	JMP FND4
TOPFL1	JMS CLSOUT
	JMS SEEK
	INNAME
TOPFL2	DZM INPSW
	JMP FND4
/MOVE POINTER TO LAST LINE OF FILE OR BUFFER.
BOTTOM	ISZ BOTTSW	/INDICATE BOTTOM IN PROCESS
BOTT1	LAC LENGTH
	DAC LEN1
	JMS GETLIN	/GET NEXT LINE.
	EDLIN		/SAVE TEMPORARILY IN EDLIN ARRAY.
	JMP FND3		/ALL DONE IF END OF FILE.
	LAC LEN1
	DAC LENGTH
	JMS PUTLIN	/NOT YET, OUTPUT CURRENT LINE.
	JMP FULBUF
	DZM LENGTH	/MOVE EDLIN TO INLINE.
	LAC EDLADR
	DAC NXTPTR
	JMS APPEND
	LAC ERRSW		/WERE THERE ANY READ ERRORS IN GETLIN
	SNA
	JMP BOTT1		/NO -- GO BACK FOR NEXT LINE
	DZM ERRSW		/CLEAR ERROR SW
	SAD C60		/GIVE CORRECT ERROR MESSAGE
	JMP TYTRN		/TRUNCATED
	XCT PARSWT		/(RCHM-029) PARITY ON?
	JMP BOTT1		/(RCHM-029) NO, CONTINUE WITH BOTTOM PROCESSING.
	JMP TYPAR		/(RCHM-029) YES, GIVE PARITY ERROR.
/
/
BOTTSW	0
	.TITLE	CMD PROC -- GET
/
/READ SOME LINES FROM SUBSIDIARY DEVICE.
 
/(RCHM-025)
/ A NEW SYNTAS HAS BEEN ADDED TO "GET". IF .DAT -10 IS FILE ORIENTED.
/ THE COMMAND SYNTAX IS EXPECTED TO BE "GET FILNAM EXT" RATHER THAN "GET NNN".
/ BOTH SYNTAXES ARE ALLOWABLE BUT DEPEND ON THE ORIENTATION OF .DAT -10.
 
/ DETERMINE THE SYNTAX EXPECTED BY THE GET COMMAND.
 
	.IFDEF RSX						/(142)
GET	LAC (ALTINP)	/ ATTACH INPUT DEVICE.			/(142)
	JMS ATTACH						/(142)
	LAC (ALTINP)	/ GET DEVICE INFORMATION.		/(142)
	JMS HINFLN						/(142)
	ALS 3		/ SHIFT FILE ORIENTED BIT TO AC 0.	/(142)
	CMA		/ MAKE IT READ LIKE DOS.		/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
GET	.INIT ALTIPT,0,RECOUP	/(RCHM-138) FIRE UP ALTERNATE INPUT DEVICE.
	LAW -376		/(RCHM-138) FETCH DIRECT ACESS BLOCK LENGTH.
	TAD .-2			/(RCHM-138) CALCULATE ALTIPT STATUS WORD.
	.ENDC							/(142)
	DAC .D10S		/(RCHM-138) SAVE STATUS FOR TERMINATOR TEST.
	SPA			/(RCHM-025) FILE-ORIENTED?
	JMP	.D10NF		/(RCHM-025) NO, EXPECTED INPUT NUMERIC.
	LAC	SRCNAM		/(RCHM-025) INITIALISE EXTENSION OF SOURCE.
	DAC	GETNAM+2	/(RCHM-025) EXTENSION IS NOW SOURCE.
	JMS	GETCOM		/(RCHM-025) FETCH FIRST PART OF COMMAND.
	SNA			/(RCHM-025) ANY CHARACTERS IN COMMAND STRING?
	JMP	GET010		/(RCHM-025) NO, NO NAME ENTERED. TELL USER AND LEAVE.
	LAW	-2		/(RCHM-025) FETCH WORD COUNT FOR 6 BIT PACKING ROUTINE.
	JMS	PK6BT		/(RCHM-025) PACK THE FILENAM FROM
	CWD			/(RCHM-025)  TO
	GETNAM			/(RCHM-025)
	JMS	GETCOM		/(RCHM-025) FETCH EXTENSION, IF ANY.
	SNA			/(RCHM-025) ANY EXTENSION?
	JMP	.D10SU		/(RCHM-025) NO, GO SET UP FOR FILE-ORIENTED I/O.
	LAW	-1		/(RCHM-025) FETCH WORD COUNT FOR 6 BIT PACKING ROUTINE.
	JMS	PK6BT		/(RCHM-026) AND PACK EXTENSION FROM
	CWD			/(RCHM-025)  TO
	GETNAM+2		/(RCHM-025)
	.IFDEF RSX						/(142)
.D10SU	LAC (ALTINP)	/ PERFORM FSTAT ON THE FILE.		/(142)
	JMS PSF							/(142)
	CAL GETNAM						/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
.D10SU	.FSTAT	ALTIPT,GETNAM	/(RCHM-138) CHECK FOR SPECIFIED FILE NAME.
	.ENDC							/(142)
	SNA			/(RCHM-025) FILE NAME THERE?
	JMP	GET020		/(RCHM-025) NO, TELL USER AND LEAVE.
	.IFDEF RSX						/(142)
	LAC (3200)	/ BUILD SEEK DIRECTIVE.			/(142)
	DAC GETCPB						/(142)
	CAL GETCPB						/(142)
	CAL WFEVA	/ WAIT FOR SEEK TO FINISH.		/(142)
	LAC EVA		/ THIS HAD BETTER BE POSITIVE.		/(142)
	SMA							/(142)
	JMP SBREAD						/(142)
	JMS IOERR	/ I/O ERROR OCCURED.			/(142)
	LAC (ALTINP)	/ LUN CAUSING I/O ERROR.		/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	.SEEK	ALTIPT,GETNAM	/(RCHM-025) COMPLETE I/O LINKAGE.
	JMP	SBREAD		/(RCHM-025) BEGIN THE TRANSFER PROCESS.
	.ENDC							/(142)
.D10NF	JMS GETNUM		/(RCHM-025) FETCH NUMBER OF LINES TO TRANSFER.
	DAC LOOPCT
	.IFDEF RSX						/(142)
SBREAD	CAL RDIN2	/ READ SECONDARY INPUT FILE.		/(142)
	JMS WFEV	/ WAIT FOR READ TO COMPLETE.		/(142)
	LAC (ALTINP)						/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
SBREAD	.READ	ALTIPT,2,SBUFF,BUFLEN /(RCHM-025) FETCH LINE FROM ALTERNATE INPUT.
	.WAIT	ALTIPT		/(RCHM-025) WAIT FOR I/O COMPLETEION.
	.ENDC							/(142)
	LAC SBUFF
	AND C7
	SAD C5
	SKP
	SAD (6)			/(RCHM-139)
	JMP GETEOF
	JMS PUTLIN
	.IFDEF RSX						/(142)
	JMP FULBUA	/ DETACH DEVICE BEFORE GIVING ERROR.	/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	JMP FULBUF
	.ENDC							/(142)
	JMS UNPACK
ADR008	SBUFF
	INLINE
	DAC LENGTH
	.IFUND EDITOR
	JMS	TVCL	/DISPLAY NEW CURRENT LINE.
	.ENDC
	LAC SBUFF
	AND C60
	SNA			/(RCHM-029) ANY ERRORS?
	JMP GET005		/(RCHM-029) NO, SKIP ERROR CHECKING.
	SAD C60
	JMP TYTRN
	XCT PARSWT		/(RCHM-029) PARITY CHECKING ON?
	CLA!SKP			/(RCHM-029) NO, PRETEND NO ERROR OCCURED.
	JMP TYPAR		/(RCHM-029) YES, PARITY ON PRODUCE ERROR.
GET005	DAC INPSW		/(RCHM-029) RECORD STATE OF CURRENT READ.
	LAC	.D10S		/(RCHM-025) FETCH .DAT -10 STATUS.
	SMA			/(RCHM-025) NON-FILE ORIENTED?
	JMP	SBREAD		/(RCHM-025) NO.
	ISZ LOOPCT
	JMP SBREAD
	.IFDEF RSX						/(142)
	LAC (ALTINP)	/ DETACH INPUT DEVICE.			/(142)
	JMS DETACH						/(142)
	.ENDC							/(142)
	JMP FND4
	.IFDEF RSX						/(142)
GETEOF	LAC (ALTINP)						/(142)
	JMS DETACH	/ DETACH INPUT DEVICE.			/(142)
	LAC .D10S	/ FETCH ALTINP LUN STATUS WORD.		/(142)
	SMA		/ SHOULD WE PRINT A MESSAGE (THE DETACH	/(142)
			/ HAS IMPLICITELY CLOSED THE OPEN INPUT	/(142)
			/ FILE ALREADY.				/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
GETEOF	LAC .D10S		/(RCHM-25) FETCH .DAT -10 STATUS WORD.
	SPA			/(RCHM-028) FILE ORIENTED?
	JMP NFOEOF		/(RCHM-028) NON-FILE ORIENTED END OF FILE ENCOUNTERED.
	.CLOSE	ALTIPT		/(RCHM-028) TERMINATE ALTERNATE INPUT FILE.
	.ENDC							/(142)
	JMP FND4		/(RCHM-028) GO GET NEXT COMMAND.
NFOEOF	LAW EOMRM		/(RCHM-028) FETCH UNRELOCATED MESSAGE ADDR FOR TYPOUT.
	JMS TYPOUT
	JMP EOFCOM
								/(142)
	.IFDEF RSX					/(142)
FULBUA	LAC (ALTINP)	/ DETACH DEFICE AND CLOSE FILE.		/(142)
	JMS DETACH						/(142)
	LAC (3400)	/ BUILD CLOSE CPB.			/(142)
	DAC GETCPB						/(142)
	CAL GETCPB	/ ISSUE CLOSE.				/(142)
	CAL WFEVA	/ WAIT FOR CLOSE TO COMPLETE.		/(142)
	JMP FULBUF	/ TAKE ERROR EXIT.			/(142)
	.ENDC							/(142)
 
/(RCHM-025)
/ GET COMMAND ERROR PROCESSORS.
 
/ NO FILE NAME ENTERED FOR COMMAND "GET FILNAM EXT"
 
GET010	LAW	NOFLNM		/(RCHM-025) FETCH MESSAGE ADDRESS.
	JMS	TYPOUT		/(RCHM-025) PRINT ERROR MESSAGE.
	JMP	FND4		/(RCHM-025) GET NEXT COMMAND.
 
/ "FILENAM EXT NOT FOUND"
 
GET020	LAW	GETNAM		/(RCHM-025) FETCH ADDR OF FILE NAME FOR PRINTING.
	JMS	TYNAME		/(RCHM-025) PRINT FILE NAME.
	LAW	FILN1		/(RCHM-025) "NOT FOUND" MESSAGE ADDRESS.
	JMS	TYPOUT		/(RCHM-025) PRINT IT.
	JMP	FND4		/(RCHM-025) GET NEXT COMMAND.
 
/(RCHM-025)
/ GET VARIABLES AND CONSTANTS.
 
.D10S	XX			/(RCHM-025) .DAT -10 STATUS.
				/(RCHM-025)  .D10S < 0 IF NON FILE ORIENTED.
				/(RCHM-025)  .D10S >=0 IF FILE ORIENTED.
								/(142)
	.IFDEF RSX						/(142)
GETCPB	XX		/ I/O FUNCTION IS BUILT HERE.		/(142)
	EVA		/ EVENT VARIABLE ADDRESS.		/(142)
	ALTINP		/ ALTERNATE INPUT LUN.			/(142)
	.ENDC							/(142)
GETNAM	.BLOCK	3		/(RCHM-025) AREA FOR "GET" FILNAM EXT CONSTRUCT.
	.TITLE	CMD PROC -- RENEW, WRITE, AND READ.
RENEW	JMS WRITE		/FIRST WRITE OUT THE CURRENT BUFFER.
	JMS READ		/THEN FILL UP THE BUFFER FROM THE INPUT FILE.
	JMP FND4		/AND GO READ ANOTHER REQUEST.
/SERVICE WRITE REQUEST.
WRITE	0		/ENTRY TO WRITE BLOCK BUFFER INTO OUTPUT FILE.
	LAC PBLKSW	/IS BLOCK MODE ON?
	SZA		/SKIP IF IT IS.
	JMP ILLCWD	/IF BLOCK MODE IS OFF, DON'T ACCEPT WRITE REQUEST.
	JMS RSBUFF	/GO FILL UP OUTPUT BUFFER FROM INPUT BUFFER.
	JMS CHBUFF	/THEN CHANGE THE BUFFERS AROUND.
	LAC BLOKSW	/SAVE THE CURRENT STATUS OF BLOKSW.
	DAC LOOPCT	/..
FENCE	LAW -1		/THEN TURN BLOCK MODE OFF.
	DAC PBLKSW	/..
	DAC BLOKSW	/..
	JMS RSBUFF	/NOW GO EMPTY THE INPUT BUFFER, AND THIS TIME WRITE OUTPUT FILE.
	LAC LOOPCT
	DAC BLOKSW
	DZM PBLKSW
	JMS CHBUFF
	DZM BUFEMP
	JMP* WRITE	/RETURN TO CALLER.
/SERVICE READ REQUEST.
READ	0		/ENTRY TO FILL INPUT BUFFER.
	LAC BUFEMP
	SZA
	JMP NEMPBF
	LAC BUFSIZ
	DAC LOOPCT
	LAC BLOKSW
	SZA!CLA!CMA	/SKIP IF BLOCK ON,-1 TO AC
	JMP ILLCWD	/ILLEGAL COMMAND IF NOT.
	DAC PBLKSW	/OFF PUTLIN BLOCK SWITCH.
	JMS PUTLIN	/OUTPUT CURRENT LINE IF ANY.
	JMP FULBUF
	DZM PBLKSW	/RESET PUTLIN BLOCK SWITCH ON.
	JMS CHBUFF
	LAW -1
	DAC GBLKSW
READ1	JMS GETLIN
	INLINE
	JMP EOF
	JMS PUTLIN
	JMP FULBUF
	ISZ LOOPCT
	JMP READ1
	JMS CHBUFF
	JMP* READ
NEMPBF	LAW BFNEMM
	JMS TYPOUT
	JMP* READ
	.TITLE SUBROUTINES RSBUFF,CHBUFF,RDFILE &WRFILE
/
/SUBROUTINE RSBUFF; EMPTY INPUT BUFFER, FILL OUTPUT BUFFER.
RSBUFF	0
NCHARS=RSBUFF		/GETCOM: TOTAL TYPED CHARACTERS IN CURRENT COMMAND.
RSB01	JMS PUTLIN
	JMP FULBUF
	LAC GBLKSW
	SZA
	JMP* RSBUFF
	JMS GETLIN
	INLINE
	JMP* RSBUFF
	JMP RSB01
/SUBROUTINE CHBUFF, EXCHANGE INPUT AND OUTPUT BUFFERS; SET GET
/AND PUT POINTERS TO BUFFER TOPS.
CHBUFF	0
	LAC BBUF1		/GET TOP OF BUFFER 1.
	DAC NXTPUT	/GIVE TO OUTPUT POINTERS.
	DAC CURPUT	/..
	TAD FENCE
	ADD BBUFX
	DAC BUFEND
	LAC BBUF2		/GET TOP OF BUFFER 2.
	DAC CURGET	/GIVE TO INPUT POINTER.
	DAC BBUF1		/SWITCH BUFFERS.
	LAC NXTPUT	/..
	DAC BBUF2		/..
	LAC PBLKSW
	DAC GBLKSW
	LAC BFPTSW	/ANYTHING IN OLD OUTPUT BUFFER?
	SNA		/SKIP IF SO
	DZM CURGET
	DZM BFPTSW	/NOW INDICATE NOTHING IN NEW OUTPUT BUFFER.
	.IFUND EDITOR
/INITIALIZATION FOR DISPLAY BUFFERS.
TVINIT	LAW	-TVNLN	/NUMBER OF LINES TO BUFFER FOR DISPLAY.
	DAC	TVCNT
	LAC	(TVBUF1	/ADDRESS OF 1ST BUFFER IN THE RING.
	DAC	TVSPTR	/SET UP START POINTER.
	DAC	TVCPT2	/SET UP FILL-BUFFERS POINTER.
TVNT10	DAC	TVCPTR	/SET UP TO INITIALIZE BUFFERS.
	DZM*	TVCPTR	/0 1ST WORD MEANS EMPTY BUFFER.
	TAD	(BUFLEN+1	/NEXT BUFFER.
	ISZ	TVCNT	/ALL BUFFERS DONE?
	JMP	TVNT10	/NO,RECYCLE.
	LAC	(JMP TVVP20	/SET SWITCH TO ROUTINE USED TO
	DAC	TVVP10	/FILL UP BUFFERS.
	.IFDEF EDITVP
	LAC	TVSW	/GET STATUS OF TV SWITCH
	DAC	TVCL
	SZA		/IF IT WAS ON,
	JMP	TVOFF
	LAW	-1	/TURN OFF
	DAC	TVSW	/THE DISPLAY SWITCH
	JMS TVST	/TURN OFF THE DISPLAY.
TVOFF	LAC	TVCL	/THEN RESET THE
	DAC	TVSW	/DISPLAY SWITCH.
	.ENDC
	.IFDEF EDITVT
	JMS TVCLR	/GO CLEAR SCREEN
TVOFF=.
	.ENDC
	.ENDC
	JMP* CHBUFF	/RETURN TO CALLER.
C5	5
C777	777
C175	175
BFPTSW	0
/SUBROUTINE RDFILE, DOUBLE-BUFFERED READ-INPUT-FILE. BEFORE
/FIRST CALL, RDFNOP MUST CONTAIN SOME INSTRUCTION PERMITTING
/CONTROL TO FALL THROUGH TO RDFNOP+1.
/CALL:	JMS RDFILE
/	LINE BUFFER ADDRESS
/	RETURN IF NO MORE LINES (EOF CODE IN AC)
/	NORMAL RETURN
RDFILE	0
	LAC INFILE	/IS THERE AN INPUT FILE PRESENT?
	SMA		/THERE IS NOT IF INFILE IS NON-ZERO.
	JMP .+4		/IF INFILE .E. ZERO, THERE IS AN INPUT FILE.
	LAW NOFIL1	/NO FILE, COMPLAIN.
	JMS TYPOUT	/"NO INPUT FILE PRESENT."
	JMP FND4		/GO READ NEXT COMMAND.
	LAC* RDFILE	/GET LINE OUTPUT ADDRESS.
	ISZ RDFILE	/BUMP TO RETURN.
	.IFUND RSX						/(142)
	JMS GETBNK	/INSERT BANK BITS.
	.ENDC							/(142)
	DAC RDUP02	/GIVE OUT ADDRESS TO UNPACKER.
RDFUPD	LAC RDCAL2	/GET LAST BUFFER READ.
	DAC RDUP01	/UNPACK THAT BUFFER.
	LAC RDALTB	/READ INTO THE OTHER BUFFER.
	DAC RDCAL2	/..
	LAC RDUP01	/UPDATE OTHER-BUFFER POINTER.
	DAC RDALTB	/..
	.IFDEF RSX						/(142)
	CAL WFEVR	/ WAIT FOR LAST I/O TO COMPLETE.	/(142)
	LAC EVR		/ FETCH EVENT VARIABLE.			/(142)
	SMA		/ CHECK FOR ERRORS.			/(142)
	JMP RDCOK	/ READ THE NEXT RECORD.			/(142)
	JMS IOERR	/ PRINT ERROR MESSAGE.			/(142)
	LAC INPTCL	/ INPUT LUN NUMBER.			/(142)
RDCOK	CAL RDINP	/ READ THE INPUT LUN.			/(142)
	.ENDC							/(1429
	.IFUND RSX						/(142)
INPTCL	INPCAL		/ISSUE READ.
	10
RDCAL2	RDBUF2		/MODIFIED AT EACH CALL.
	-BUFLEN
	.ENDC							/(142)
RDFNOP	NOP		/MODIFIED AFTER FIRST TIME THROUGH.
	LAC NOPLIT		/(RCHM-023) SET READ ONCE FLAG TO READ.
	DAC RDFRDF
	LAC RDFJMP	/ONE-TIME SECTION TO PRIME READ BUFFERS.
	DAC RDFNOP
	JMP RDFUPD	/READ AGAIN FIRST TIME ONLY.
RDFJMP	JMP .+1
	LAC* RDUP01	/GET BUFF HEADER.
	AND C7		/THROW AWAY JUNK.
	SAD C5		/END OF FILE?
	SKP		/YES, SO INDICATE.
	SAD (6)			/(RCHM-139) OR END OF MEDIUM?
	JMP RDFEOF	/YES, TAKE EOM RETURN.
	LAC* RDUP01	/CHECK FOR READ AND LONG-LINE ERRORS, GET BUFFER HEADER.
	AND C60		/EXTRACT ERROR BITS.
	DAC ERRSW		/SAVE AS ERROR-PRESENT INDICATOR.
	JMS UNPACK	/CALL UNPACK.
RDUP01	0		/CURRENT READ BUFFER ADDRESS.
RDUP02	0		/CALLER'S LINE BUFFER AREA.
	ISZ RDFILE	/INDEX TO RETURN.
	JMP* RDFILE	/RETURN TO CALLER.
RDFEOF	LAC NOPLIT
	DAC RDFNOP
	JMP* RDFILE	/RETURN TO CALLER.
RDALTB	RDBUF1
RDFRDF	SKP!CLA!CMA		/(RCHM-023) THESE CONTENTS NEVER READ.
/SUBROUTINE WRFILE, DOUBLE-BUFFERED WRITE-OUTPUT-FILE.
/CALL:	JMS WRFILE
/	RETURN
WRFILE	0
	LAC OUTPSW	/IS OUTPUT WANTED? (OUTPSW SET BY OUTPUT ON/OFF COMMAND.
	SZA		/SKIP IF OUTPUT IS ON.
	JMP* WRFILE	/OTHERWISE IGNORE THIS CALL.
	LAC WRPAK2	/EXCHANGE BUFFER ADDRESSES. GET BUFFER USED LAST.
	DAC RDFILE	/SAVE THAT ADDRESS TEMPORARILY.
	LAC WRALTB	/GET START OF ALTERNATE BUFFER.
	DAC WRPAK2	/USE THAT BUFFER FOR PACKING THIS LINE.
	DAC WRCAL2	/WRITE FROM THAT BUFFER ALSO.
	.IFUND EDITOR
	DAC	TVWRFL	/ADD TO DISPLAY BUFFERS.
	.ENDC
	LAC RDFILE	/NOW GET THE FIRST BUFFER AGAIN.
	DAC WRALTB	/AND SAVE AS ALT BUFFER FOR NEXT TIME.
	LAC	NOPKSW	/CHECK NO PACKING SWITCH
	SZA
	JMP	PACKA	/SET DON'T PACK THE LINE JUST SWAP THE BUFFER
	JMS PACK		/GO PACK THE OUTPUT LINE.
INLADR	INLINE		/LINE TO BE PACKED IS ALWAYS IN INLINE.
WRPAK2	WRBUF2		/MODIFIED EACH TIME TO POINT TO "CURRENT" BUFFER.
PKFIN=.
	.IFUND EDITOR
	JMS	TVVP	/ADD A LINE TO THE DISPLAY RING BUFFERS.
TVWRFL	0		/THIS LINE.
	.ENDC
	LAC OUTSW1
	SNA			/(RCHM-034) SHOULD WE ENTER THE FILE YET?
	.IFDEF RSX						/(142)
	JMP WROV4	/ DIFFERENT JUMP.			/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	JMP OUTPCL		/(RCHM-034) NO, NOT YET.
	.ENDC							/(142)
	LAW TYLINE		/(RCHM-034) FETCH TTY INPUT BUFFER ADDRESS.
	XCT IEMSW		/(RCHM-034) WILL THE USER BE ENTERING DATA?
	JMS HTREAD		/(RCHM-034) YES, ISSUE A READ BEFORE ENTERING.
	JMS OUTENT	/GO CLEAN UP OUTPUT DEVICE AND ENTER FILE
	.IFDEF RSX						/(142)
WROV4	CAL WFEVW	/ WAIT FOR LAST WRITE TO COMPLETE.	/(142)
	LAC EVW		/ DID THE WRITE FINISH OK?		/(142)
	SMA							/(142)
	JMP WROV5	/ YES, WRITE WAS OK.			/(142)
	JMS IOERR	/ PRINT ERROR.				/(142)
	LAC OUTPCL	/ OUTPUT LUN NUMBER.			/(142)
WROV5	CAL WROUT	/ WRITE NEXT RECORD.			/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
OUTPCL	OUTCAL		/WRITE THE LINE JUST PACKED.
	11
WRCAL2	0		/UPDATED EACH TIME TO CORRESPOND TO WRPAK2.
C1000	1000		/WORD COUNT -- IGNORED BY DEVICE HANDLERS.
	.ENDC							/(142)
	DZM OUTSW1	/INDICATE SOMETHING WRITTEN INTO OUTPUT FILE.
	XCT PUTSW		/(RCHM-032) ALTERNATE OUTPUT FILE RUNNING?
	JMP* WRFILE		/(RCHM-032) NO, RETURN TO CALLER.
	LAC WRCAL2		/(RCHM-032) FETCH CURRENT BUFFER ADDRESS.
	DAC PUTWBA		/(RCHM-032) SET UP .WRITE WITH THE PROPER ADDRESS.
	.IFDEF RSX						/(142)
	CAL WFPUT	/ WAIT FOR PUT TO COMPLETE.		/(142)
	LAC PUTEV	/ FETCH EVENT VARIABLE.			/(142)
	SMA		/ WRITE OK?				/(142)
	JMP WR.000						/(142)
	JMS IOERR	/ NO, GIVE ERROR.			/(142)
	LAC (ALTOUT)						/(142)
WR.000	CAL PUTWR	/ WRITE "PUT" FILE.			/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
PUTWBA=.+2			/(RCHM-032) ADDRESS OF .WRITE BUFFER ADDRESS.
	.WRITE PUTDEV,2,0,0	/(RCHM-032) WRITE RECORD INTO ALTERNATE OUTPUT FILE.
	.ENDC							/(142)
	JMP* WRFILE	/NO WAIT REQUIRED AFTER WRITING.
WRALTB	WRBUF1		/MODIFIED EACH TIME TO POINT TO "OTHER" BUFFER.
/
/ PACKA SWITCHES THE INPUT AND OUTPUT BUFFERS TO SAVE
/REPACKING
/
PACKA	LAC	RDALTB	/PICK UP THE INPUT LINE ADDRESS
	DAC	RDFILE	/SAVE IT TEMPORARILY
	LAC	WRPAK2	/PICK UP THE OUTPUT FILE BUFFER
	DAC	RDALTB	/SET IT UP FOR THE NEXT READ
	LAC	RDFILE	/PICK UP THE BUFFER TO BE OUTPUT
	DAC	WRPAK2	/SET IT IN THE BUFFER POINTER
	DAC	WRCAL2	/SET UP WRITE CAL
	.IFUND EDITOR
	DAC	TVWRFL	/ALSO SET THE POINTER TO THE DISPLAY OUTPUT
	.ENDC
	JMP	PKFIN	/FINISHED RETURN
NOPKSW	0	/NO PACK SWITCH JUST SWITCH LINE BUFFER'S
/
/SUROUTINE OUTENT 
/DELETE .TFIL1 EDT ON OUTPUT
/DEVICE IF DISK OR DISK PACK
/AND THEN ENTER .TFIL1 EDT
/ON THE OUTPUT DEVICE
/
OUTENT	0
OUTFST	JMS FSTAT
	XCT TFILE1
	SNA
	JMP OUTETR
	.IFUND RSX						/(142)
	LAC DTYP1
	AND CL7000
	SAD (200000
	JMP DELEFL
	SAD (300000
	JMP DELEFL
	JMP OUTETR
	.ENDC							/(142)
DELEFL	JMS DELFIL
	XCT TFILE1
	JMP OUTFST
OUTETR	JMS ENTER
TFLDEB	TFILE1
	JMP* OUTENT
/
/
	.TITLE SUBROUTINES DCODSW,SCAN,PUTLIN & GETLIN
/
/SUBROUTINE DCODSW, DECODE CONTROL WORDS "OFF" AND "ON". ON EXIT,
/C(C(DCODSW)) .E. 0 IF ON, -1 IF OFF. IF NO ARGUMENT IS PRESENT, APPROPRIATE
/SWITCH IS SET TO "ON" (0). 
DCODSW	0
	JMS GETCOM	/GET PARAMETER TYPED.
	SNA!CLA		/SKIP IF A PARAMETER WAS PRESENT.
	JMP SETSW 	/IF NO PARAMETER GIVEN, GO TREAT AS "ON".
	JMS SCAN		/CALL STRING COMPARER.
	CWD		/TYPED PARAMETER IS HERE.
	OFF		/COMPARE WITH "OFF".
	JMP DCOD01	/NO MATCH THIS TIME.
	SKP		/POSSIBLE MATCH.
	JMP ILLCWD	/ILLEGAL PARAMETER.
	LAC* STR2		/END OF STRING 2 FOUND?
	SPA!CLA!CMA	/NO, SKIP.
	JMP SETSW		/YES, SET SWITCH TO "OFF" (-1).
DCOD01	JMS SCAN		/COMPARE AGAIN.
	CWD		/PARAMETER IS STILL HERE.
	ON		/THIS TIME, TRY "ON".
	SKP		/NOT FOUND.
	SKP		/POSSIBLE HIT.
	JMP ILLCWD	/NO MATCH, GO COMPLAIN.
	LAC* STR2		/ENSURE END OF STRING 2 REACHED.
	SMA!CLA		/SKIP IF SO.
	JMP ILLCWD	/IF NOT, COMPLAIN.
SETSW	DAC* DCODSW	/AC IS EITHER 0 OR 777777 HERE.
	ISZ DCODSW
	JMP* DCODSW
OFF	117		/"O"
	106		/"F"
	106		/"F"
XCTZRO	XCT 0		/BIT 0 = 1 TO TURN OFF STRING COMPARE IN SCAN.
ON	117		/"O"
SCOM17=ON			/.SCOM+17: AC ON TTY INTERRUPTS.
	116		/"N"
CL7770	777000
/SCAN, ATTEMPT TO MATCH TWO CHARACTER STRINGS.
/CALL:	JMS SCAN
/	ADDRESS OF STRING TO SEARCH FOR.
/	ADDRESS OF STRING UPON WHICH SEARCH IS TO BE PERFORMED.
/	RETURN IF STRING NOT FOUND.
/	RETURN IF END OF STRING1 FOUND.
/	RETURN IF END OF STRING2 FOUND.
SCAN	0
	LAC* SCAN
	.IFUND RSX						/(142)
	JMS GETBNK
	.ENDC							/(142)
	DAC STR1
	ISZ SCAN
	LAC* SCAN
	.IFUND RSX						/(142)
	JMS GETBNK
	.ENDC							/(142)
	DAC STR2
	ISZ SCAN
SLOOP1	LAC* STR1
	SPA
	JMP SLP1
	LAC* STR2
	SPA
	JMP SLP2
	SAD* STR1
	SKP
	JMP* SCAN
	ISZ STR1
	ISZ STR2
	JMP SLOOP1
SLP2	ISZ SCAN
SLP1	ISZ SCAN
	JMP* SCAN
/SUBROUTINE PUTLIN, INSERT A LINE EITHER IN THE CURRENT OUT BUFFER
/OR IN THE OUTPUT FILE ITSELF.
/POINTER TO WHERE THE NEXT LINE WILL BE PACKED IS
/STORED IN THE CHECKSUM WORD OF THE CUURENT LINE
/BLOCK MODE ONLY
/
/PUTLIN ALWAYS GET LINE FROM INLINE
/
/CALL:	JMS PUTLIN
/	RETURN IF BUFFER FULL (LINE NOT INSERTED)
/	NORMAL RETURN.
PUTLIN	0
	LAC LENGTH
	DAC BTEMP
	SNA!CLA!CLL!CML
	JMP PTOFLO-2
	SAD QUIT
	JMP TTRS
	SAD PBLKSW	/SKIP IF BLOCK MODE IS OFF.
	SKP!RAL		/BLOCK MODE ON. SET AC = 1.
	JMP WRCAL		/BLOCK MODE OFF, GO OUTPUT LINE.
	DAC NPAIRS	/SET INITIAL WORD-PAIR COUNTER.
	ISZ BTEMP		/ACCOUNT FOR A CARRIAGE RETURN.
COUNT1	ISZ NPAIRS	/COUNT A PAIR.
	LAW -5		/5 CHARS PER PAIR.
	TAD BTEMP		/ADJUST CHARACTER COUNT.
	DAC BTEMP		/SAVE NEW ONE.
	SZA!SMA		/DONE IF ZERO OR MINUS.
	JMP COUNT1	/MORE TO DO.
	LAC NPAIRS	/ALL DONE, GET TOTAL PAIRS REQUIRED BY THIS LINE.
	CLL!RAL		/NPAIRS * 2 TO GIVE TOTAL WORDS THIS LINE.
	ADD NXTPUT	/FORM CURRENT ADDRESS + WORDS THIS LINE.
	DAC BTEMP		/SAVE TEMPORARILY.
	CMA		/2'S COMPLEMENT LAST ADDR REQUIRED.
	TAD BUFEND	/COMPARE WITH LAST ADDRESS AVAILABLE.
	SPA!SNA		/LAST NEEDED .L. LAST AVAILABLE, OK.
	JMP PTOFLO	/ERROR OTHERWISE.
PKCAL	JMS PACK
ADR009	INLINE
NXTPUT	0		/WHERE TO BEGIN WRITING NEXT LINE.
	.IFUND EDITOR
	LAC	NXTPUT	/GET ADDRESS OF
	DAC	.+2
	JMS	TVVP	/A LINE TO ADD TO THE DISPLAY RING BUFFERS.
	0
	.ENDC
	LAC NXTPUT
	SAD CURPUT
	SKP
	DAC* CURPUT
	ADD (1)			/(RCHM-139)
	DAC CURPUT
	DZM* CURPUT
	LAC BTEMP
	DAC NXTPUT
	DAC BUFEMP
	DAC BFPTSW
PUTRTN	ISZ PUTLIN	/..
	DZM LENGTH
PTOFLO	JMP* PUTLIN
WRCAL	LAC PBLKSW
	SZA
	JMP WRCAL1
	DZM PBLKSW
	JMP PUTLIN+1
WRCAL1	JMS WRFILE
	JMP PUTRTN
/GETLIN, RETURN NEXT LINE FROM CURRENT BUFFER OR FROM INPUT FILE.
/GETLIN GETS THE POINTER TO THE NEXT LINE FROM THE CHECKSUM
/WORD OF THE CURRENT LINE BLOCK MODE ONLY
/
/CALL:	JMS GETLIN
/	 BUFF
/	RETURN IF NO MORE LINES TO GET.
/	NORMAL RETURN
GETLIN	0
	LAC QUIT
	SNA
	JMP TTRS
	LAC* GETLIN	/GET LINE ADDRESS.
	.IFUND RSX						/(142)
	JMS GETBNK	/INSERT HIGH-ORDER BITS.
	.ENDC							/(142)
	DAC UPKCAL+2	/GIVE TO UNPACKER.
	DAC RDCAL+1	/AND TO FILE READER.
	LAC GBLKSW	/GET BLOCK MODE.
	SZA		/SKIP IF BLOCK IS ON.
	JMP RDCAL		/READ FROM FILE IF NOT.
	LAC BUFEMP
	SNA
	JMP EMPBUF
	LAC CURGET	/GET POINTER TO NEXT LINE
	SNA		/SKIP IF THERE IS ANOTHER LINE TO GET.
	JMP EMPBUF	/NO MORE LINES.
	DAC UPKCAL+1	/GIVE TO UNPACKER.
UPKCAL	JMS UNPACK	/CALL UNPACK.
PWRD1	0		/FROM.
PWRD2	0		/TO.
	DAC LENGTH
	ISZ CURGET
	LAC* CURGET
	DAC CURGET
	ISZ GETLIN	/BUMP TO RETURN.
EMPBUF	ISZ GETLIN	/..
	JMP* GETLIN
RDCAL	JMS RDFILE
PWRD3	0
	JMP EMPBUF
	DAC LENGTH
	LAC BOTTSW	/IF BOTTOM IN PROGRESS DON'T GIVE
	SZA		/ERROR MESSAGE NOW IF THERE IS AN ERROR
	JMP EMPBUF-1
	LAC MOVESW	/IF MOVE IS IN PROGRESS
	SZA		/LET MOVE GIVE MESSAGE IF 
	JMP EMPBUF-1	/THERE IS AN ERROR
	LAC ERRSW
	SAD C60
	JMP TYTRN
	SNA
	JMP EMPBUF-1
TYPAR	LAW PRTYMS
	JMS TYPOUT
	.IFDEF EDITVT
	JMS TYPRTN
	.ENDC
	JMP FND3
TYTRN	LAW TRNMES
	JMS TYPOUT
	.IFDEF EDITVT
	JMS TYPRTN
	.ENDC
	JMP FND3
	.TITLE CHARACTER PACKING & UNPACKING SUBROUTINES
/
/CLOSED SUBROUTINES FOR CHARACTER PACKING AND UNPACKING.
  
  
/SUBROUTINE UNPACK, IOPS ASCII TO ONE CHAR PER WORD. ON RETURN,
/IOPS LINE IS UNPACKED IN "TO" ARRAY AS 7-BIT CHARACTERS, ONE PER
/WORD, RIGHT-ADJUSTED WITH LEADING ZEROES. INITIAL LINE FEED (IF
/ANY) AND TERMINATING CARRIAGE RETURN (OR ALT MODE) ARE DELETED. IN PLACE
/OF THE TERMINATING CHARACTER IS INSERTED ITS 1'S COMPLEMENT (I.E.,
/000015 BECOMES 777762). THE ACCUMULATOR AND REGISTER "TOTCHR" HOLD POSITIVE
/TOTAL NUMBER OF DATA CHARACTERS UNPACKED, EXCLUSIVE OF THE TERMINATOR.
/NOTA BENE: UNPACK USES AUTOINDEX REGISTERS 3 AND 4 (LOCATIONS 12 AND 13)
/AS INPUT AND OUTPUT POINTERS.
/CALL:	JMS UNPACK	/GO TO UNPACK.
/	FROM		/15-BIT ADDRESS OF WORD 0 OF LINE BUFFER HEADER.
/	TO		/15-BIT ADDRESS OF FIRST CHAR OF OUTPUT LINE.
UNPACK	0		/ENTRY TO UNPACK.
PKFROM=UNPACK		/PACK, PK6BT: POINTER TO NEXT CHARACTER IN INPUT ARRAY.
	LAC* UNPACK	/GET ADDRESS OF INPUT LINE.
	DAC* (12)		/(RCHM-139) SAVE AS INPUT POINTER (IN LOC 12).
	ISZ* (12)		/(RCHM-139) ADJUST TO POINT TO FIRST DATA PAIR.
	ISZ UNPACK	/BUMP TO SECOND ARGUMENT.
	LAC* UNPACK	/ARG 2 IS ADDRESS OF OUTPUT LINE.
	TAD FENCE		/DECREMENT BY ONE.
	DAC* C13		/SAVE AS POINTER TO OUTPUT ARRAY (IN LOC 15).
	ISZ UNPACK	/BUMP TO RETURN.
	DZM TOTCHR	/ZERO TOTAL CHARACTERS IN LINE.
	DZM FSTSW		/INDICATE NO DATA ENCOUNTERED YET.
/ENTER MAJOR LOOP TO GET NEW WORD PAIR FROM INPUT LINE AND
/RESET CHARACTER COUNTER (PK5CHR) TO 5.
UNPLP1	LAC* 12		/GET NEXT WORD FROM LINE BUFFER.
	.IFUND	EAE
	DAC PWRD2		/SAVE AS FIRST WORD OF PARI.
	.ENDC
	.IFDEF	EAE
	DAC	PWRD1
	.ENDC
	LAC* 12		/PICK UP NEXT WORD.
	.IFUND	EAE
	DAC PWRD3		/SECOND WORD OF NEW CURRENT PAIR.
	.ENDC
	.IFDEF	EAE
	DAC	PWRD2
	.ENDC
	LAW -5		/SET UP TO EXTRACT 5 CHARACTERS FORM THIS PAIR.
	DAC PK5CHR	/..
	.IFDEF	EAE
	LAC	(UNPKJP	/SET UP THE POINTER TO THE JUMP TABLE
	DAC	UNPKJS	/TO UNPACK 5/7 ASCII
	.ENDC
/ENTER INNER LOOP TO GET NEXT CHARACTER FROM CURRENT WORD PAIR,
/STORE IT IN OUTPUT ARRAY, AND CHECK FOR COMPLETION.
	.IFUND	EAE
UNPLP2	JMS PRAL7		/GET NEXT CHAR FROM CURRENT PAIR.
	.ENDC
	.IFDEF	EAE
UNPLP2	XCT*	UNPKJS	/UNPACK A CHARACTER
	ISZ	UNPKJS	/MOVE POINTER FORWARD ONE
	.ENDC
	AND C177		/TAKE ONLY RIGHTMOST SEVEN BITS.
	SNA		/ACCEPT ONLY IF NON-NULL.
	JMP UNPB5C	/NULL CHARACTER, IGNORE.
	SAD (12)		/(RCHM-139) LINE FEED?
	JMP UNPLNF	/YES, GO IGNORE ONLY IF FIRST CHARACTER IN LINE.
	SAD C175		/ALT MODE TYPE TERMINATOR?
	JMP UNPCR		/YES, TREAT JUST LIKE CARRIAGE RETURN.
	SAD C15		/CARRIAGE RETURN?
	JMP UNPCR		/YES, LINE IS COMPLETE.
UNPDAC	DAC* 13		/REAL ASCII CHAR, DEPOSIT IN OUTPUT ARRAY.
	DAC FSTSW		/INDICATE SOME DATA ENCOUNTERED.
	ISZ TOTCHR	/BUMP TOTAL DATA CHARACTERS SEEN.
	LAC TOTCHR	/GET TOTAL CHARACTERS SEEN.
	TAD TWO		/WILL WE OVERFLOW NEXT TIME?
	SAD MAXLEN	/SKIP IF NOT.
	JMP UNPOFL	/OTHERWISE, STOP NOW.
UNPB5C	ISZ PK5CHR	/COUNT 5 CHARACTERS FROM CURRENT PAIR.
	JMP UNPLP2	/NOT FINISHED WITH THIS PAIR, GET NEXT CHARACTER.
	JMP UNPLP1	/CURRENT PAIR EXHAUSTED, GET NEXT ONE.
UNPOFL	LAC C15		/TOO MANY CHARS, GET CARRIAGE RETURN.
UNPCR	CMA		/LINE FINISHED, GET TERMINATOR.
	DAC* 13		/INSERT AS LAST WORD OF OUTPUT LINE.
	LAC TOTCHR	/PICK UP TOTAL DATA CHARACTERS PROCESSED.
	JMP* UNPACK	/RETURN TO CALLER.
UNPLNF	LAC FSTSW		/LINE FEED FOUND. IS IT LEADING?
	SNA		/SKIP IF NOT.
	JMP UNPB5C	/YES, WELL GO IGNORE IT.
	LAC (12)		/(RCHM-139) NO, WELL ACCEPT IT THEN.
	JMP UNPDAC
  
/SUBROUTINE PACK, RIGHT-ADJUSTED 7-BIT CHARACTER ARRAY TO HEADERED
/IOPS ASCII. TERMINATES ON NEGATIVE WORD IN INPUT ARRAY.
/NOTE: USES AUTOINDEX REGISTER 3 (LOCATION 12) AS POINTER TO
/OUTPUT LINE.
/CALL:	JMS PACK		/GO TO PACK.
/	FROM		/15-BIT ADDRESS OF FIRST CHAR OF INPUT ARRAY.
/	TO		/15-BIT ADDRESS OF FIRST WORD OF OUTPUT LINE.
PACK	0		/ENTRY TO PACK.
	LAC* PACK		/PICK UP START OF INPUT ARRAY.
	DAC PKFROM	/GIVE TO INPUT POINTER.
	ISZ PACK		/BUMP ENTRY TO ARG 2.
	LAC* PACK		/GET ADDRESS OF LINE BUFFER TO FILL.
	DAC PLBH		/SAVE AS ADDRESS OF WORD 0 OF HEADER.
	DAC* (12)		/(RCHM-139) AND ALSO IN OUTPUT POINTER.
	ISZ* (12)		/(RCHM-139) SET LOC 12 TO POINT TO CHECKSUM.
	DZM* PLBH		/SET INITIAL VALUE OF HEADER WORD 0.
	DZM LSTSW		/INDICATE TERMINATOR NOT SEEN YET.
	ISZ PACK		/BUMP TO RETURN.
/ENTER MAJOR LOOP TO UPDATE WORD-PAIR COUNT IN LINE BUFFER HEADER
/(LOCATION POINTED TO BY "PLBH") FOR WORD-PAIR JUST CONSTRUCTED
/(OR FOR HEADER PAIR ON FIRST TIME THROUGH) AND TO RESET CHARACTER
/COUNTER (PK5CHR) TO -5.
PLOOP1	LAC C1000		/TURN ON BIT 8.
	ADD* PLBH		/ADD IN WORD PAIR COUNT DEVELOPED SO FAR.
	DAC* PLBH		/NEW WORD 0.
	LAW -5		/SET UP TO PUT 5 CHARACTERS IN THE NEW PAIR.
	DAC PK5CHR	/..
	.IFDEF	EAE
	LAC	(PKJMPT	/SET UP THE JUMP TABLE
	DAC	PKJMS
	.ENDC
/ENTER INNER LOOP TO GET NEXT CHARACTER FROM INPUT LINE, CHECK FOR
/COMPLETION, AND INSERT IN CURRENT PAIR.
PLOOP2	LAC* PKFROM	/GET NEXT CHARACTER FROM INPUT ARRAY.
	SPA		/TERMINATOR? (NEGATIVE IF SO.)
	JMP PDONE		/(RCHM-032) YES, GO TRY TO CLOSE THE OUTPUT LINE.
	ISZ PKFROM	/NO, BUMP POINTER TO NEXT CHARACTER.
	.IFUND	EAE
PLOOP6	RTR		/SHIFT THIS CHARACTER TO BITS 0-6.
	RTR		/..
	RTR		/..
	RTR		/..
	DAC PWRD3		/ADD TO RIGHT-HAND END OF EMERGING PAIR.
PLOOP7	JMS PRAL7		/GO ROTATE THIS CHARACTER INTO THE PAIR.
	ISZ PK5CHR	/COUNT 5 CHARACTERS PER PAIR.
	JMP PLOOP2	/NOT FINISHED WITH THIS PAIR, GET NEXT CHARACTER.
	LAC PWRD2		/PAIR IS COMPLETE, BUT STILL OFF BY ONE BIT.
	CLL!RAL		/CLEAR PAIR BIT 35.
	DAC PWRD2		/PAIR BIT 17 IS NOW IN LINK.
	LAC PWRD1		/GET FIRST WORD OF PAIR...
	RAL		/...AND MOVE PAIR BIT 17 IN.
	DAC* 12		/PAIR IN PROPER FORMAT; DEPOSIT WORD 1 IN LINE BUFF.
	LAC PWRD2		/PICK UP WORD 2.
	DAC* 12		/STORE IT IN LINE BUFFER ALSO.
	.ENDC
	.IFDEF	EAE
PLOOP6	AND	(177)	/MASK OFF CHARACTER
	XCT*	PKJMS	/GO PACK A CHARACTER
PLOOP7	ISZ	PKJMS	/UPDATE PACK POINTER
	ISZ	PK5CHR	/COUNT 5 CHARACTERS PER PAIR
	JMP	PLOOP2	/NOT FINISHED WITH THIS PAIR
	.ENDC
	JMP PLOOP1	/GO REINITIALIZE FOR NEXT PAIR.
/COME HERE ON TERMINATOR FOUND IN INPUT ARRAY.
PDONE	SAD LSTSW		/(RCHM-032) HAVE WE BEEN HERE BEFORE? (LSTSW = 0 IF NOT.)
	JMP PKNULL	/YES, GO FILL CURRENT PAIR WITH NULLS.
	DAC LSTSW		/NO, SET LSTSW TO ENABLE BYPASS NEXT TIME THROUGH.
	CMA		/INVERT TERMINATOR.
	SNA		/IS IT NOW A NULL CHARACTER?
	LAC C15		/IF SO, GET CARRIAGE RETURN.
	JMP PLOOP6	/GO PUT CARRIAGE RETURN OR ALT MODE AWAY.
/COME HERE TO PAD WORD-PAIR WITH NULLS AFTER TERMINATING CHARACTER
/HAS BEEN INSERTED.
PKNULL	LAW -5		/FIRST, SEE IF PAIR IS ALREADY FULL.
	XOR PK5CHR	/..
	SZA!CLA!CLL!CML	/PAIR IS FULL IF PK5CHR .E. -5.
	JMP PLOOP6	/PAIR IS NON-FULL, INSERT NULL JUST GENERATED.
	RTL		/FULL, SET IOPS ASCII INDICATOR (AC = 2).
	ADD* PLBH		/INSERT MODE IN HEADER.
	DAC* PLBH		/RESTORE HEADER IN LINE BUFFER AREA.
	JMP* PACK		/ALL DONE, EXIT.
	.IFUND	EAE
  
/SUBROUTINE PRAL7, ROTATE IOPS ASCII WORD PAIR SEVEN BITS TO THE LEFT.
/DURING UNPACKING, THE WORD PAIR BEING TREATED MUST BE STORED IN REGISTERS
/PWRD2 AND PWRD3; THE NET EFFECT OF PRAL7 IS TO PLACE "THIS" CHARACTER FROM
/THE PAIR IN THE RIGHTMOST SEVEN BITS OF REGISTER PWRD1 AND TO LEAVE THE
/"NEXT" CHARACTER IN THE LEFTMOST SEVEN BITS OF REGISTER PWRD2. DURING PACKING,
/THE CHARACTER TO BE ADDED MUST BE STORED IN THE LEFTMOST SEVEN BITS OF 
/REGISTER PWRD3; THE CHARACTER IS ADDED TO THE RIGHT-HAND END OF THE WORD
/PAIR BEING DEVELOPED. AFTER FIVE CALLS TO PRAL7, THE 5-CHARACTER PAIR,
/SHIFTED ONE BIT TO THE RIGHT, APPEARS IN REGISTERS PWRD1 AND PWRD2.
PRAL7	0
	LAW -7		/SET UP SEVEN-BIT COUNTER.
	DAC PK7BTS	/..
PRALL7	LAC PWRD3		/ROTATE A SINGLE BIT
	RAL		/FROM PWRD3 TO PWRD1.
	DAC PWRD3
	LAC PWRD2
	RAL
	DAC PWRD2
	LAC PWRD1
	RAL
	DAC PWRD1
	ISZ PK7BTS	/COUNT SEVEN BITS TO GET.
	JMP PRALL7	/NOT FINISHED, ROTATE OUT ONE MORE BIT.
	JMP* PRAL7	/ALL DONE, RETURN TO CALLER.
	.ENDC
	.IFDEF	EAE
/
/ EAE SUBROUTINE TO UNPACK 5/7 ASCII -- THIS ROUTINE
/RETURNS THE CHARACTER  IN THE RIGHTMOST 7 BITS
/
UNPKJP	JMP	VPW1	/UNPACK WORD1
	LLS	7	/UNPACK CHARACTER 2
	JMP	VPW3	/UNPACK CHARACTER 3
	LLS	7	/UNPACK CHARACTER 4
	LLS	7	/UNPACK CHARACTER 5 -- SAME AS UNPACKING CHARACTER 4
/
VPW1	LAC	PWRD1	/PICK UP THE FIRST WORD
	LRS	13	/MOVE THE DESIRED 7 BITS TO 11-17 OTHERS TO MQ
	JMP	UNPLP2+1 /RETURN TO CALLER
/
/
VPW3	LAC	PWRD2	/PICK UP THE LAST 4 BITS
	LMQ		/SAVE IT IN MQ
	LAC	PWRD1	/PICK UP THE FIRST WORD FOR 4 BITS
	LLS	3	/FORM A CHARACTER
	JMP	UNPLP2+1 /RETURN
/
UNPKJS	0	/UNPACKING AND PACKING POINTER
PKJMS=UNPKJS
/
PKJMPT	JMP	PKWD1	/PACK THE FIRST CHARACTER
	JMP	PKWD2	/PACK THE ECOND CHARACTER
	JMP	PKWD3
	JMP	PKWD4
	JMP	PKWD5
/
PKWD1	ALSS	7	/ALREADY MASKED PUT INTO BITS 5-10
	DAC	PWRD1	/SAVE FOR NXT CHARACTER
	JMP	PLOOP7	/RETURN FOR NEXT CHARACTER
PKWD2	XOR	PWRD1	/ADD IN LAST CHARACTER
	ALSS	4	/MOVE OVER FOR 3RD CHARACTER
	DAC	PWRD1
	JMP	PLOOP7	/RETURN
PKWD3	LRSS	3	/SAVE THE RIGHT 3 BITS
	XOR	PWRD1	/ADD IN SAVED WORD
	DAC*	12	/PUT IT IN THE LINE BUFFER
	LLS	12	/MOVE THE 3 SAVED CHARACTERS TO BITS 8-10
	AND	(1600)	/MASK OFF THE WORD
	DAC	PWRD1	/SAVE IT FOR THE NEXT PASS
	JMP	PLOOP7	/RETURN FOR NEXT CHARACTER
PKWD4	XOR	PWRD1	/ADD IN 3 BITS FROM LAST CHARACTER
	ALSS	7	/SHIFT FOR 5TH CHARACTER
	DAC	PWRD1
	JMP	PLOOP7
PKWD5	XOR	PWRD1	/MASK IN CHARACTERS 3,4
	CLL!RAL		/BIT 17 = 0
	DAC*	12	/STORE IN WORD COUNT
	JMP	PLOOP7
/
	.ENDC
  
/SUBROUTINE PK6BT, RIGHT-ADJUSTED 7-BIT CHARACTERS TO 3-6 TRIMMED
/ASCII, ZERO-FILLED. TERMINATES ON END CODE (BIT 0 = 1) IN INPUT ARRAY
/OR WORD COUNT OVERFLOW (COUNT -- 2'S COMPLEMENT -- IN AC AT CALL).
/CALL:	LAW -MAXWDS	/2'S COMPLEMENT WORDS TO FILL.
/	JMS PK6BT		/CALL PK6BT.
/	FROM		/START OF INPUT ARRAY.
/	TO		/START OF OUTPUT ARRAY.
PK6BT	0		/ENTRY TO PK6BT.
TOTCHR=PK6BT		/UNPACK: TOTAL CHARS IN OUTPUT LINE.
	DAC PK6WDC	/SAVE COUNT OF  TOTAL WORDS TO FILL.
	LAC* PK6BT	/GET START OF INPUT ARRAY.
	.IFUND RSX						/(142)
	JMS GETBNK	/MAKE IT A 15-BIT ADDRESS.
	.ENDC							/(142)
	DAC PKFROM	/GIVE TO INPUT POINTER.
	ISZ PK6BT		/BUMP TO OUTPUT ADDRESS.
	LAC* PK6BT	/GET START OF OUTPUT ARRAY.
	.IFUND RSX						/(142)
	JMS GETBNK	/MAKE IT 15 BITS LONG ALSO.
	.ENDC							/(142)
	DAC PK6TO		/GIVE TO OUTPUT POINTER.
	ISZ PK6BT		/BUMP TO RETURN.
PK6LP1	LAW -3		/THREE CHARS PER WORD.
	DAC PK6CT1	/SET UP 3-CHARACTER COUNTER.
	DZM* PK6TO	/ZERO NEW OUTPUT WORD.
PK6LP2	LAC* PKFROM	/GET NEXT CHARACTER FROM INPUT ARRAY.
	SPA!CLL		/IS THIS THE ARRAY TERMINATOR? (NEGATIVE IF SO.)?
	JMP PK6CLS	/YES, GO GENERATE A NULL CHARACTER.
	AND C77		/NO, EXTRACT RIGHTMOST SIX BITS.
	DAC PK6CHR	/THEN SAVE AS CURRENT CHARACTER.
	ISZ PKFROM	/BUMP INPUT POINTER FOR NEXT TIME.
PK6LP3	LAC* PK6TO	/GET 3-6 WORD GENERATED SO FAR.
	RTL		/SHIFT IT SIX BITS LEFT TO MAKE ROOM FOR CURRENT CHAR.
	RTL		/..
	RTL		/..
	ADD PK6CHR	/THEN INSERT CURRENT CHARACTER.
	DAC* PK6TO	/SAVE NEW 3-6 WORD.
	ISZ PK6CT1	/COUNT 3 CHARACTERS PACKED IN THIS WORD.
	JMP PK6LP2	/MORE TO DO, GET NEXT CHARACTER.
	ISZ PK6TO		/ALL DONE WITH THIS WORD, BUMP OUTPUT POINTER.
	ISZ PK6WDC	/COUNT MAXIMUM WORDS IN OUTPUT ARRAY.
	JMP PK6LP1	/MORE ROOM IN OUTPUT ARRAY, SET UP NEW WORD.
PK6RET	JMP* PK6BT	/OUTPUT ARRAY IS FULL, RETURN TO CALLER.
/COME HERE ON TERMINATOR FOUND IN INPUT ARRAY. FILL REMAINDER OF OUTPUT
/ARRAY WITH NULL (00) CHARACTERS.
PK6CLS	DZM PK6CHR	/MAKE CURRENT CHAR A NULL.
	JMP PK6LP3	/AND PUT IT AWAY. NEXT INPUT CHAR WILL BE SAME TERMINATOR
	.IFUND RSX						/(142)
	.TITLE DOS FILE PROCESSING SUBROUTINES			/(142)
/
/EXECUTE SEEK ON NAMED FILE.
/	JMS SEEK
/	POINTER TO DEB
/	RETURN
SEEK	0
PK7BTS=SEEK
PK6WDC=SEEK
	LAC INPTCL
	AND C777
	DAC SKCAL
	LAC* SEEK
	JMS GETBNK
	DAC SKCAL+2
	ISZ SEEK
	DZM INFILE
SKCAL	0
PK6CHR=SKCAL
LSTSW=SKCAL
FSTSW=SKCAL
	3
	0
PK6TO=SKCAL+2
	JMP* SEEK
/EXECUTE ENTER ON NAMED FILE.
/	JMS ENTER
/	POINTER TO DEB
/	RETURN
ENTER	0
	LAC OUTPCL		/(JMW:024)NEED OUTPUT .DAT SLOT.
	AND C777		/(JMW:024)
	DAC ENTCAL		/(JMW:024)SAVE FOR LATER USE.
	AND (700		/(JMW:024)MUST SEE IF WORKING WITH NEGATIVE SLOT.
	SAD (700		/(JMW:024)
	JMP ENTMIN		/(JMW:024)YES - MUST MAKE NEGATIVE NUMBER.
	LAC ENTCAL		/(JMW:024)
ENTERA	TAD* (.SCOM+25		/(JMW:024)LOOK AT UIC ASSIGNED TO THIS .DAT SLOT.
	DAC ENTCL1		/(JMW:024)
	LAC* ENTCL1		/(JMW:024)NOW HAVE UIC IN AC.
	SAD* (.SCOM+41		/(JMW:024)SAME AS LOGGED-IN UIC?
	CLA!SKP			/(JMW:024)YES - USE DEFAULT PROTECTION CODE.
	LAC C1000		/(JMW:024)NO - USE PROTECT CODE OF 1.
	XOR ENTCAL		/(JMW:024)
	DAC ENTCAL
	LAC* ENTER
	JMS GETBNK
	DAC ENTCL1		/(JMW:024 - JUST ADDED A LABEL)
	ISZ ENTER
ENTCAL	0
	4
ENTCL1	0				/(JMW:024 - ADDED A LABEL)
	JMP* ENTER
ENTMIN	LAC (777000		/(JMW:024)
	XOR ENTCAL		/(JMW:024)
	JMP ENTERA		/(JMW:024)
/EXECUTE FSTAT ON NAMED FILE.
/	JMS FSTAT
/	DEB POINTER	(BIT 0 .E. 0, INPUT FILE.
/			(BIT 0 .E. 1, OUTPUT FILE.)
/	RETURN		(AC .E. -1, NON-FILE-ORIENTED.
/			(AC .E. 0, NOT FOUND)
FSTAT	0
	LAC* FSTAT
	RAL
	LAC OUTPCL
	SNL
	LAC INPTCL
	AND C777
	ADD C3000
	DAC FSTCAL
	LAC* FSTAT
	JMS GETBNK
	DAC FSTCAL+2
	ISZ FSTAT
FSTCAL	0
	2
DTYP1	0		/DIRECTORY TYPE CODE IN BITS 0-3.
	DAC FSTCAL
	LAC DTYP1
	AND CL7000
	SZA!CLA!CMA
	LAC FSTCAL
	JMP* FSTAT
/EXECUTE CLOSE ON IN OR OUT FILE.
/	JMS CLSFIL	(AC .E. 0 IF INPUT, AC BIT 0 .E. 1 IF OUTPUT.)
/	RETURN
CLSFIL	0
	RAL
	LAC (SKP!CLA!CMA		/(RCHM-023) SET UP READ ONCE FLAG IF NEC.
	SNL				/(023) OUTPUT FILE BEING CLOSED?
	DAC RDFRDF			/(023) NO.
	LAC INPTCL
	SZL
	LAC OUTPCL
	AND C777
	DAC CLSCAL
CLSCAL	0
	6
	JMP* CLSFIL
/RENAME A FILE.
/	JMS RENAME
/	DEB1		(BIT 0 .E. 0, INPUT; BIT 0 .E. 1, OUTPUT.)
/	DEB2
/	RETURN
RENAME	0
	LAW -2
	DAC RENMCT
	LAC* RENAME
	RAL
	LAC INPTCL
	SZL
	LAC OUTPCL
	AND C777
	ADD C2000
	DAC RNMCAL
	LAW RNMFIL-1
	JMS GETBNK
	DAC* C13
RNMLP1	LAW -3
	DAC RNMWRD
	CLA!CMA
	TAD* RENAME
	ISZ RENAME
	JMS GETBNK
	DAC* (12)		/(RCHM-139)
RNMLP2	LAC* 12
	DAC* 13
	ISZ RNMWRD
	JMP RNMLP2
	ISZ RENMCT
	JMP RNMLP1
RNMCAL	0
	2
DEB1	RNMFIL
	JMP* RENAME
/EXECUTE DELETE ON NAMED FILE.
DELFIL	0
	LAC* DELFIL
	JMS GETBNK
	DAC DELNAM
	LAC* DELFIL
	RAL
	LAC OUTPCL
	SNL
	LAC INPTCL
	AND C777
	ADD C1000
	DAC DELCAL
DELCAL	0
	2
DELNAM	0
	ISZ DELFIL
	JMP* DELFIL
	.ENDC							/(142)
	.IFDEF	RSX
	.TITLE RSX FILE PROCESSING SUBROUTINES			/(142)
/
/
/	FILE PROCESSING FOR RSX  
/		ONLY EDITING ON THE DISK IS LEGAL
/		OTHER DEVICES ARE NOT PERMITTED
/		I/O ERRORS CAUSE TERMINATION OF EDITING A FILE
								/(142)
/ GENERALISED HINF CALL.					/(142)
/
/ CALLING SEQUENCE.						/(142)
/								/(142)
/	LAC LUN							/(142)
/	JMS HINFLN						/(142)
/	...		AC = HINF VALUE.			/(142)
								/(142)
HINFLN	XX		/ ENTRY POINT.				/(142)
	DAC HINF+2	/ STORE LUN NUMBER.			/(142)
	CAL HINF	/ PERFORM HINF.				/(142)
	CAL WFEVA	/ WAIT FOR HINF TO COMPLETE.		/(142)
	LAC EVA		/ FETCH HINF INFO.			/(142)
	SMA		/ ERROR?				/(142)
	JMP* HINFLN	/ NO, RETURN HINF CODE TO USER.		/(142)
	JMS IOERR	/ I/O ERROR OCCURED, RSX HANDLER DIDN'T	/(142)
	LAC HINF+2	/ RESPOND TO A "HINF".			/(142)
								/(142)
								/(142)
/ SIMULATE FSTAT ON FILE. NORMAL EDITOR STYLE CALLING		/(142)
/ SEQUENCE.							/(142)
/
/	CALLING SEQUENCE.					/(142)
/								/(142)
/	JMS FSTAT						/(142)
/	[CAL!XCT] FILENM					/(142)
/	...		AC = 0 => FILE NOT FOUND.		/(142)
/			AC >< 0 => FILE FOUND.			/(142)
								/(142)
FSTAT	0		/ ENTRY POINT.				/(142)
	LAC* FSTAT	/ FETCH I/O LUN + FILE NAME POINTER.	/(142)
	ISZ FSTAT	/ POINT TO RETURN ADDRESS.		/(142)
	DAC CPF.1	/ SET UP CALLING LIST TO PSUEDO FSTAT	/(142)
	RAL		/ STORE I/O LUN IN LINK.		/(142)
	LAC OUTPCL	/ FETCH OUTPUT LUN.			/(142)
	SNL		/ IS THIS FOR THE OUTPUT LUN?	/(142)
	LAC INPTCL	/ NO, FETCH INPUT LUN			/(142)
	JMS PSF		/ CALL PSUEDO FSTAT PROCESSOR.		/(142)
CPF.1	XX		/ FILE NAME POINTER IN 13 BIT FORM	/(142)
	JMP* FSTAT	/ AC = RETURN CODE.			/(142)
/
/ATTACH A LUN
/
ATTACH	0
	DAC	ATLUN
	CAL	ATCH
	JMP*	ATTACH
/
/	DETACH A LUN
DETACH	0
	DAC	DETLUN
	CAL	DTCH
	CAL	WFEVTA
	JMP*	DETACH
/
WFEV	0
	CAL	WFEVTA	/WAIT FOR EVENT VARIABLE
	LAC	EVTA
	SMA		/WAS REQUEST OK?
	JMP*	WFEV	/YES RETURN
	XCT*	WFEV	/PICK UP THE BAD LUN
	DAC	WFEV+1	/SAVE IT FOR I/O ERROR MESSAGE
	LAC	EVTA	/PICK UP THE EVENT VARIABLE
	JMS	IOERR	/I/O ERROR
	LAC	WFEV+1	/LUN OF I/O ERROR -- FATAL ERROR
/
/
/
/
/ EXECUTE SEEK ON NAMED FILE
/	JMS SEEK
/	POINTER TO DEB
/	RETURN
/
SEEK	0
	LAC	INPTCL	/PICK UP THE INPUT LUN SLOT
	DAC	SEKCAL	/SAVE IT IN THE SEEK REQUEST
	LAC*	SEEK	/PICK UP THE POINTER TO THE FILE NAME
	ISZ	SEEK	/MOVE SEEK POINTER
	JMS	MOVENM	/MOVE FILE NAME
	SEEKNM		/POINTER TO SEEK REQUEST
	CAL	SEKFI	/SEEK REQUEST
	CAL	WFEVA	/WAIT FOR EVENT VARIABLE
	DZM	INFILE	/CLEAR THE FILE NOT OPEN SWITCH
	LAC	EVA	/PICK UP EVENT VARIABLE TO SEE IF LEGAL
	SMA
	JMP*	SEEK	/LEGAL FILE MUST HAVE BEEN FOUND
	JMS	IOERR	/ILLEGAL FILE NOT PRESENT OR OTHER ERROR
	LAC	SEKCAL	/LUN ON WICH ERROR OCCURRED
/
/EXECUTE ENTER ON NAMED FILE.
/	JMS ENTER
/	POINTER TO DEB
/	RETURN
/
ENTER	0
	LAC	OUTPCL	/PICK UP THE OUTPUT LUN SLOT
	DAC	ENTECL	/SAVE IT IN THE ENTER CAL
	LAC*	ENTER	/PICK UP THE FILE NAME POINTER
	ISZ	ENTER	/MOVE POINTER PAST FILE NAME POINTER
	JMS	MOVENM	/MOVE THE FILE NAME
	ENTENM		/POINTER TO ENTER REQUEST NAME
	CAL	ENTFI	/ENTER REQUEST
	CAL	WFEVA	/WAIT FOR EVENT VARIABLE
	LAC	EVA	/PICK UP THE EVENT VARIABLE
	SMA		/IS IT LEGAL?
	JMP*	ENTER	/YES -- ENTER DONE
	JMS	IOERR	/NO -- ERROR EXIT FILE
	LAC	OUTPCL	/LUN ON WHICH ERROR OCCURRED
								/(142)
/ EXECUTE A SIMULATED FSTAT.					/(142)
/								/(142)
/	CALLING SEQUENCE.					/(142)
/								/(142)
/	LAC LUN							/(142)
/	JMS PSF							/(142)
/	FILENAME&17777						/(142)
/	...		AC = 0 IF FILE NOT FOUND.		/(142)
/			AC >< 0 IF FILE WAS FOUND.		/(142)
								/(142)
PSF	XX		/ ENTRY POINT.				/(142)
	DAC	SEKCAL	/SET IT IN THE SEEK CAL
	DAC	CLOCL	/SET IT IN THE CLOSE CAL LUN
	LAC* PSF	/ PICK UP THE FILE NAME POINTER.	/(142)
	ISZ PSF		/ POINT TO RETURN ADDRESS.		/(142)
	JMS	MOVENM	/MOVE THE FILE NAME
	SEEKNM		/POINTER TO THE SEEK REQUEST
	CAL	SEKFI	/ISSUE A SEEK REQUEST
	CAL	WFEVA	/WAIT FOR EVENT VARIABLE
	LAC	EVA	/PICK UP EVENT VARIABLE
	SAD	(-13)
	JMP	FSTNF	/FILE NOT FOUND
	SPA!CLA!CMA		/WAS THE FILE FOUND?
	JMP* PSF	/ NO, RETURN -1 FOR FILE NOT FOUND.
	CAL	CLOSCA	/CLOSE THE FILE
	CAL	WFEVA	/WAIT FOR EVENT VARIABLE
	LAC	EVA	/CLOSE OK?
	SMA
	JMP* PSF	/ YES RETURN AC +1 TO INDICATE FOUND FILE.
	JMS	IOERR	/NO I/O ERROR
	LAC	SEKCAL	/LUN ON WHICH ERROR OCCURRED
/
FSTNF	CLA		/FILE NOT FOUND
	JMP* PSF						/(142)
/
/EXECUTE CLOSE ON IN OR OUT FILE
/	JMS CLSFIL	(AC .EQ. 0 IF INPUT OR BIT 0 =1 IF OUTPUT)
/
CLSFIL	0
	RAL		/SET INPUT OR OUTPUT IN LINK
	LAC	INPTCL	/PICK UP INPUT LUN
	SZL		/IS IT INPUT?
	LAC	OUTPCL	/NO MUST BE OUTPUT
	DAC	CLOCL	/SET IN CLOSE LUN
	CAL	CLOSCA	/ISSUE CLOSE REQUEST
	CAL	WFEVA	/WAIT FOR CLOSE
	LAC	EVA	/PICK UP EVENT VARIABLE
	SMA		/WAS IT OK?
	JMP*	CLSFIL	/YES RETURN
	SAD	(-11)	/WAS THE EVENT VARIABLE -11?
	JMP*	CLSFIL	/YES MUST BE OK
	JMS	IOERR	/NO -- I/O ERROR
	LAC	CLOCL	/LUN ON WHICH ERROR OCCURRED
/
/EXECUTE DELETE FILE ON NAMED FILE
DELFIL	0
	LAC*	DELFIL
	JMS	MOVENM	/MOVE NAME
	DELNAM		/DELETE NAME
	LAC*	DELFIL	/PICK UP THE INPUT  OR OUTPUT BIT
	RAL
	ISZ	DELFIL	/SKIP OVER POINTER
	LAC	OUTPCL	/IS IT OUTPUT
	SNL
	LAC	INPTCL	/NO MUST BE INPUT
	DAC	DELLUN	/SET IN DELETE LUN
	CAL	DEFILE	/EXECUTE DELETE REQUEST
	CAL	WFEVA	/WAIT FOR EVENT VARIABLE
	LAC	EVA	/PICK UP EVENT VARIABLE
	SMA		/WAS IT LEGAL?
	JMP*	DELFIL	/YES RETURN
	SAD	(-13)	/NOT FOUND?
	JMP*	DELFIL	/YES -- OK IT IS DELETED 
	JMS	IOERR	/NO I/O ERROR
	LAC	DELLUN	/LUN ON WHICH ERROR OCCURRED
/
/RENAME A FILE
/	JMS RENAME
/	DEB1	/(BIT0 =0 IF INPUT : 1 IF OUTPUT
/	DEB2
/
RENAME	0
	LAC*	RENAME
	JMS	MOVENM	/MOVE NAME TO RSEEK REQUEST
	RENMSK		/RENAME SEEK
	LAC*	RENAME	/SETUP THELINK FOR INPUT OR OUTPUT
	RAL
	LAC	INPTCL	/PICK UP INPUT LUN
	SZL
	LAC	OUTPCL	/MUST BE OUTPUT CAL
	DAC	RENSK	/STORE IN REQUEST
	DAC	CLOCL
	CAL	RENCAL	/ISSUE RENAME SEEK
	CAL	WFEVA	/WAIT FOR EVENT VARIABLE
	LAC	EVA	/PICK UP EVENT VARIABLE
	SPA		/WAS REQUEST OK?
	JMP	IOERRA	/NO I/O ERROR
	ISZ	RENAME
	LAC*	RENAME	/PICK UP SECOND NAME
	JMS	MOVENM
	CLONAM		/MOVE TO CLOSE REQUEST
	ISZ	RENAME
	CAL	CLOSCA	/ISSUE CLOSE WITH RENAME REQUEST
	CAL	WFEVA	/WAIT FOR EVENT VARIABLE
	LAC	EVA	/PICK UP EVENT VARIABLE
	SMA		/IS IT POSITIVE
	JMP*	RENAME	/YES MUST BE OK
IOERRA	JMS	IOERR	/NO I/O ERROR
	LAC	CLOCL	/LUN ON WHICH ERROR OCCURRED
/
MOVENM	0
	JMS	GETBNK	/GET BANK BITS FOR XCT NAME
	DAC	TEMPA	/SAVE FROM ADDRESS
	LAC*	MOVENM	/PICK UP THE TO ADDRESS
	DAC	TEMPB	/SAV IT
	ISZ	MOVENM	/INCREMENT PAST TO POINTER
	LAW	-3	/MOVE ONLY THREE CHARACTERS
	DAC	TEMPC
MOVELP	LAC*	TEMPA	/PICK UP A WORD
	DAC*	TEMPB	/SAVE IT
	ISZ	TEMPA	/MOVE POINTERS
	ISZ	TEMPB
	ISZ	TEMPC
	JMP	MOVELP	/NOT FINISHED TRY NEXT ONE
	JMP*	MOVENM	/FINISHED RETURN
/
/
/	I/O CPB'S
/
TDVEV	0	/TDV EVENT VARAIBLE
/
REQTDV	1	/REQUEST FOR TDV
	0
	.SIXBT	'TDV...'
	0
/
/
ENDPAR	0
SEKFI	3200	/SEEK REQUEST
	EVA	/EVENT VARIABLE
SEKCAL	0	/LOGICAL UNIT
SEEKNM	.BLOCK	3	/FILE NAME
/
ATCH	2400
	0
ATLUN	0
/
DTCH	2500
	EVTA
DETLUN	0
/
ENTFI	3300	/ENTER REQUEST
	EVA	/EVENT VARIABLE
ENTECL	0	/LOGICAL UNIT NUMBER
ENTENM	.BLOCK	3	/FILE NAME
/
CLOSCA	3400	/CLOSE REQUEST
	EVA	/EVENT VARIABLE ADDRESS
CLOCL	0	/LOGICAL UNIT NUMBER
CLONAM	.BLOCK	3	/FILE NAME FOR CLOSE WITH RENAME
/
DEFILE	3500	/DELETE REQUEST
	EVA	/EVENT VARIABLE 
DELLUN	0	/LOGICAL UNIT NUMBER
DELNAM	.BLOCK	3	/FILE NAME
/
RENCAL	3700	/OPEN TO RENAME CAL
	EVA	/EVENT VARIABLE ADDRESS
RENSK	0	/LOGICAL UNIT NUMBER
RENMSK	.BLOCK	3	/FILE NAME
/
CRLF	2700	/WRITE
	EVTA	/EVENT VARIABLE
	TTOLUN							/(142)
	3	/IMAGE ASCII
	CHRMSG	/LINE
WRIMG	2700	/WRITE
	EVTA	/EVENT VARIABLE
	TTOLUN							/(142)
	3	/IMAGE ASCII
ADR000	CHRMS	/LINE
/
WFEVTA	20	/WAITFOR
	EVTA	/EVENT VARIABLE
EVTA	0
/
RDIN2	2600	/INPUT
	EVTA	/EVENT VARIABLE ADDRESS
	ALTINP							/(142)
	2	/MOVE
SBADR	SBUFF	/DATA BUFFER
	BUFLEN	/MAX WORD COUNT
/
WFEVR	20	/WAIT FOR
	EVR
EVR	1
RDINP	2600	/INPUT
	EVR	/EVENT VARIABLE
INPTCL	0	/LUN SLOT
	2	/ASCII
RDCAL2	RDBUF2	/LINE BUFFER
	BUFLEN	/MAX WORD COUNT
/
WFEVW	20	/WAIT FOR
	EVW
EVW	1
WROUT	2700	/WRITE
	EVW	/EVENT VARIABLE
OUTPCL	0	/LUN SLOT
	2	/MODE
WRCAL2	0	/BUFFER ADDRESS
/
WRCAL3	2700	/WRITE TTY
	EVTA	/EVENT VARIABLE ADDRESS
	TTOLUN							/(142)
	2	/IOPS ASCII
TTOUT	0	/BUFFER ADDRESS
/
RDCALT	2600	/READ
	EVTA	/EVENT VARIABLE ADDRESS
	TTILUN							/(142)
	2	/IOPS ASCII
TTIN	0	/BUFFER ADDRESS
	BUFLEN	/WORD COUNT
/
/
/	TEMPORARY STORAGE AND CONSTNTS
/
CHRMSG	2003	/CRLF MESSAGE
	0
C12	12	/LF
	15	/CR
TAB	11	/TAB
OUTDEV	1
INDEV	1
FSTSW=SEEKNM
LSTSW=SEEKNM
PK7BTS=SEEK
PK6WDC=SEEK
PK6CHR=SEEKNM
PK6TO=SEEKNM+2
C1000	1000
C15	15
C6	6
ONE	1
TEMPA	0
TEMPB	0
TEMPC	0
/
/
/	I/O ERROR HAS OCCURRED OUTPUT TO USER
/		EDT-I/O ERROR LUN XX YYYYYY
/
IOERR	0
	TCA		/COMPLEMENT EVENT VARIABLE TO MAKE IT POSITIVE
	LMQ		/SAVE IT IN MQ
	LAW	-6	/DECODE6 DIGITS
	DAC	TEMPA	/SAVE COUNT
	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 SUPPRESSING
	DAC	DECODS	/SET JUMP
	PLA		/RESTORE AC
DECODR	DAC*	X10	/STORE CHARACTER
	ISZ	TEMPA	/FINISHED?
	JMP	DECOD	/NO DECODE IT
	LAC	(IOERL-1)	/SET UP TO DECODE LUN
	DAC*	(X10)
	XCT*	IOERR	/PICK UP LUN
	IDIV		/DIVIDE BY 10 TO FIND DECIMAL LUN
	12
	PAX		/SAVE REMAINDER
	LACQ		/PICK UP THE QUOTENT
	AND	(17)	/MASK OFF 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	WFEVA	/WAIT FOR EVENT VARIABLE
	LAC	(2)	/FORCE TDV TO BE CALLED
	DAC	TDVEV
	JMP	EXIT1	/EXIT EDITOR
/
NDECOD	CLA		/SUPPRESS PRINTING
DECRRA	JMP	DECODR	/RETURN
/
IOERMS	ERMSE-IOERMS/2*1000+3
	0
	105	/E
	104	/D
	124	/T
	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
	012	/LF
ERMSE=.
/
WRIOER	2700	/WRITE I/O ERROR MESSAGE
	EVA	/EVENT VARIABLE
	TTOLUN							/(142)
	3	/IMAGE ASCII
	IOERMS	/BUFFER ADDRESS
/
/
/
	.ENDC
	.TITLE SUBR,CLSOUT FOR CLOSE PROC & EXIT PROC
/
/SUBROUTINE CLSOUT, CLOSE INPUT AND OUTPUT FILES.
CLSOUT	0
	JMS PUTLIN	/TRANSFER CURR LINE TO OUTPUT
	JMP FULBUF
	LAW -1		/START TURNING OFF BLOCK MODE
	DAC BLOKSW
	JMS RSBUFF
	LAC PBLKSW	/IF 0 WRITE OUT BUFFER
	SZA
	JMP CLS01	/WRITE OUT FILE
	JMS CHBUFF
	LAW -1		/KEEP TURNING OFF BLOCK MODE
	DAC PBLKSW
	JMS RSBUFF
	JMS CHBUFF
	DZM BUFEMP
CLS01	LAC INFILE	/IS THERE AN INPUT FILE PRESENT?
	SPA		/SKIP IF SO.
	JMP CLS01A	/IF NOT, GO TRY TO CLOSE OUTPUT FILE.
CLS01B	JMS PUTLIN	/WRITE OUT THE CURRENT LINE.
	NOP		/..
	LAC (1)			/(RCHM-139) SET UP NOREPACK SWITCH.
	DAC	NOPKSW
	JMS GETLIN
	INLINE
	SKP!CLA
	JMP CLS01B	/MORE TO DO, GO WRITE THIS LINE.
	DZM	NOPKSW	/CLEAR THE NO PACKING SWITCH
	JMS CLSFIL	/CLOSE THE INPUT FILE.
CLS01A	LAC OUTSW1	/HAS ANYTHING BEEN PUT INTO THE OUTPUT FILE?
	SPA!CLA!CMA	/SKIP IF SO.
	JMP EMPFIL	/NOTHING IN FILE, GO COMMENT.
	JMS CLSFIL
	LAC INFILE	/IS THERE AN INPUT FILE PRESENT?
	SPA		/SKIP IF SO.
	JMP CLS03		/IF NOT, GO DEAL WITH OUTPUT FILE.
	LAC OUTDEV	/IS THE OUTPUT DEVICE FILE-STRUCTURED?
	SPA		/SKIP IF SO.
	JMP* CLSOUT	/OTHERWISE, RETURN TO CALLER.
	LAC SAVESW	/IS A SAVE WANTED?
	SZA		/SKIP IF SO.
	JMP CLS02		/IF NOT, GO CLOSE AS USUAL.
SAVBCK	JMS FSTAT		/CHECK FOR PRESENCE OF SAVNAM.
	SAVNAM		/..
	SZA		/NOT FOUND, SKIP.
	JMP SAVERR	/SAVNAM IS IN USE, COMPLAIN.
	JMS RENAME	/NAME IS OK, RENAME THE INPUT FILE.
	INNAME		/..
	SAVNAM		/..
	LAW -1		/TURN OFF SAVESW.
	DAC SAVESW	/..
	JMP CLS03
CLS02	JMS DELFIL
	INNAME
CLS03	XCT PUTSW		/(RCHM-032) IS AN ALTERNATE FILE ACTIVE?
	SKP			/(RCHM-032) NO.
	JMS PCLS		/(RCHM-032) YES, SIMULATE A 'PCLOSE' COMMAND.
	JMS FSTAT		/(RCHM-032) CHECK FOR FILE NAME ON INPUT .DAT SLOT.
	XCT INNAME
	SZA
	JMP CLSERR
	JMS RENAME
	XCT TFILE1
	INNAME
	LAC FILSTR
	SMA		/SKIP IF NON-FILE-ORIENTED.
	JMS CHDAT		/FILE-ORIENTED, GO EXCHANGE DAT ASSIGNMENTS.
	JMP* CLSOUT	/AND RETURN TO CALLER.
/COME HERE ON FILE-NAME DIFFICULTIES DURING CLOSE SEQUENCE.
CLSERR	LAC TFLDEB	/ADDRESS OF .TFIL1 EDT DIR ENTRY BLOCK.
	DAC CLSENT	/SET UP TO USE THAT NAME.
	LAC FILSTR	/BOTH DEVICES FILE-STRUCTURED?
	SPA		/SKIP IF SO.
	JMP SETF1		/IF NOT, SKIP ALL THIS STUFF.
	JMS DEVCHK
	JMP SETF1		/SAME UNIT, DON'T BOTHER SWITCHING.
	LAC DIRSW		/WHICH DIRECTION ARE WE GOING?
	SPA		/SKIP IF GOING FROM -14 TO -15.
	JMP SETF1		/GOING BACK TO -14, EVERYTHING OK.
/COME HERE ON TROUBLE TRYING TO CLOSE ON -15.
	JMS CHDAT		/GO CHANGE DAT SLOTS AROUND.
	JMS FSTAT		/IS THERE A .TFIL1 EDT ON -14?
	XCT TFILE1	/-14 IS NOW THE OUTPUT DAT SLOT.
	SZA		/SKIP IF .TFIL1 EDT IS NOT PRESENT.
	JMP SETF1		/.TFIL1 EDT IS THERE, GO COMMENT.
	JMS FSTAT		/MAYBE ORIGINAL FILE NAME IS THERE.
CLSINN	XCT INNAME	/..
	SZA		/SKIP IF INNAME IS OK FOR -14.
	JMP CLSSK		/NOT OK, USE .TFIL1 EDT.
	LAC CLSINN	/USE INNAME.
	DAC CLSENT	/..
CLSSK	JMS SEEK		/SEEK THE INPUT FILE.
	TFILE1
	JMS ENTER		/OPEN UP THE OUTPUT FILE.
CLSENT	0		/INNAME OR .TFIL1
	DZM OUTSW1	/FORESTALL ANOTHER ENTER.
CLSRD	JMS RDFILE	/READ A LINE.
	INLINE
	JMP CLSCLS	/IF EOF ENCOUNTERED.
	JMS WRFILE	/WRITE THE LINE READ.
	JMP CLSRD		/GO FOR MORE.
/COME HERE ON COMPLETE FILE TRANSFERRED.
CLSCLS	CLA!CMA
	JMS CLSFIL	/CLOSE THE OUTPUT FILE.
	CLA
	JMS CLSFIL	/CLOSE THE INPUT FILE, TOO.
	JMS DELFIL	/THEN DELETE THE INPUT FILE.
	TFILE1		/..
SETF1	LAW INNAME
	JMS TYNAME
	LAW TWOFIL
	JMS TYPOUT
	LAW NUFIL1
	JMS TYPOUT
	LAC OUTPCL
	RTR
	LAW 64
	SZL
	ADD (1)			/(RCHM-139)
	JMS TYONCH
	LAW NUFIL2
	JMS TYPOUT
	LAC CLSENT
	JMS TYNAME
	JMS TYPRTN
	LAW OLDEL
	JMS TYPOUT
	JMP EXITCH	/CHECK FOR EXIT REQUEST
SAVERR	LAW	SAVNAM		/GIVE USER ERROR MESSAGE
	JMS	TYNAME		/ABOUT SAVNAM BEING ON
	LAW	TWOFL1		/INPUT DEVICE
	JMS	TYPOUT
	LAW	BADNAM
	JMS	TYPOUT
	LAW 76
	JMS TYONCH
	LAW	TYLINE
	JMS	TYPEIN		/READ IN NEW NAME
	LAW	-1		/RESET SAVE SW
	DAC	SAVESW
	JMS	UNPACK		/UNPACK IT TO EDLIN
ADR016	TYLINE
	EDLIN
	SNA			/IF NO NAME TYPED
	JMP	CLS02		/DO NOT SAVE INPUT FILE
	LAC	EDLADR
	DAC	NXTPTR
	JMS	GETCOM		/GET FILE NAME
	JMS	GETSNM		/AND MAKE UP DEB
	JMP	SAVBCK		/GO BACK AND CKECK NEW NAME
EMPFIL	LAC OUTPSW		/(RCHM-023) OUTPUT SWITCH OFF?
	SZA			/(023) NO - GO AHEAD AND PRINT ERROR MSG.
	JMP* CLSOUT		/CLLSE COMPLETED - RETURN TO CALLER.
	LAW EMPFLM
	JMS TYPOUT
	JMS DELFIL	/DELET TFILE1
	XCT TFILE1	/FROM OUTPUT DEVICE
	JMP EXITCH	/CHECK FOR EXIT REQUEST
SAVNAM	.BLOCK 3
/
/
/COMMON EXIT ROUTINE.
/
/
EXIT	LAC SKPLIT	/SET REQUEST SWITCH
	DAC EXITRQ
	XCT EXITSW	/IS THERE A FILE OPEN
	JMP EXIT1	/NO  GO AN EXIT
	JMP CLOSE	/YES GO AN CLOSE OUT FILES
EXITCH	XCT EXITRQ	/COME HERE AFTER CLOSING FILES
	JMP BEGIN	/IF THIS WAS NOT AN EXIT REQUEST
	.IFUND RSX						/(142)
	.IFDEF EDITVP
	DZM NUM		/WAIT FOR VP TO ERASE TO AVOID IOPS3 ERROR
	ISZ NUM
	JMP .-1
	.ENDC
	.IFDEF EDITVT
EXIT1	LAC*	SCOMCX
	AND	(1
	SAD	CTRLSV
	JMP	EXIT2
	LAC*	SCOMCX
	JMS	CTLXSD
	.ENDC
	.IFUND EDITVT
EXIT1=.
	.ENDC
	.IFDEF EDITVT
EXIT2=.
	.ENDC
	.EXIT		/EXIT TO MONITOR
C15=.-1
	.ENDC							/(142)
	.IFDEF RSX						/(142)
EXIT1	LAC (INLUN)	/ DETACH ALL I/O DEVICES.		/(142)
	JMS DETACH						/(142)
	LAC (OUTLUN)						/(142)
	JMS DETACH						/(142)
	LAC (ALTINP)						/(142)
	JMS DETACH						/(142)
	LAC (ALTOUT)						/(142)
	JMS DETACH						/(142)
	LAC (LIST)						/(142)
	JMS DETACH						/(142)
	LAC TDVEV	/ DO WE RECALL TDV?			/(142)
	SAD (2)							/(142)
	CAL REQTDV	/ YES.					/(142)
	CAL (10)	/ EXIT THE EDITOR.			/(142)
	.ENDC							/(142)
	.TITLE TELETYPE I/O SUBROUTINES
/CLOSED SUBROUTINES FOR TYPEWRITER INPUT AND OUTPUT.
  
  
/SUBROUTINE TYPOUT, SET UP AND ISSUE CAL FOR IOPS ASCII OUTPUT MESSAGE.
/CALL:	LAW OUTMSG	/START ADDRESS (HEADER WORD 0) OF MESSAGE TO PRINT.
/	JMS TYPOUT	/GO TO TYPOUT.
TYPOUT	0		/ENTRY TO TYPOUT.
	JMS GETBNK	/GET SOME EPC BITS.
	DAC TTOUT
	.IFDEF RSX						/(142)
	CAL WRCAL3						/(142)
	JMS WFEV	/ WAIT FOR THE TELETYPE TO FINISH.	/(142)
	LAC (TTOLUN)	/ LUN NUMBER.				/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
TTOUT=.+2
	.WRITE TTOCAL,2,0,0	/(RCHM-139)
	.WAIT TTOCAL		/(RCHM-139)
	.ENDC							/(142)
	JMP* TYPOUT	/RETURN TO CALLER.
  
/SUBROUTINE TYPEIN, SET UP AND ISSUE CAL FOR IOPS ASCII INPUT LINE.
/CALL:	LAW INBUFF	/WHERE TO PUT INCOMING LINE.
/	JMS TYPEIN	/GO TO TTY READER.
TYPEIN	0		/ENTRY TO TYPEIN.
	JMS HTREAD		/(RCHM-034) ISSUE A READ.
	JMS WAIT		/(RCHM-034) ISSUE A WAIT.
	JMP* TYPEIN	/RETURN TO CALLER.
HTREAD	XX			/(RCHM-034) ISSUE A READ TO THE TELETYPE.
	JMS GETBNK		/(RCHM-034) SET UP ADDRESSING BITS.
	DAC TTIN		/(RCHM-034) STORE ADDRESS IN READ.
	.IFDEF RSX						/(142)
	CAL RDCALT	/ READ A LINE FROM THE TTY.		/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
TTIN=.+2
	.READ TTICAL,2,0,BUFLEN	/(RCHM-139)
	.ENDC							/(142)
	LAC SKPLIT		/(RCHM-034) SIGNAL THAT A HOT READ IS IN PROGRESS.
	DAC HRSW		/(RCHM-034)
	JMP* HTREAD		/(RCHM-034) RETURN TO CALLER.
WAIT	XX			/(RCHM-034) ISSUE A .WAIT TO THE TELETYPE.
	.IFDEF RSX						/(142)
	JMS WFEV	/ WAIT FOR THE TTY I/O TO FINISH.	/(142)
	LAC (TTILUN)						/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	.WAIT TTICAL		/(RCHM-139) .DAT -2
	.ENDC							/(142)
	LAC NOPLIT		/(RCHM-034) SIGNAL THAT A WAIT FOR THE LAST READ HAS
	DAC HRSW		/(RCHM-034)  OCCURED.
	JMP* WAIT		/(RCHM-034) RETURN TO CALLER
  
/SUBROUTINE TYNAME, TYPE OUT FILE NAME STORED IN DEB FORMAT.
/CALL:	LAW DEBADR	/START ADDRESS OF DEB TO TYPE OUT.
/	JMS TYNAME	/GO PRINT IT.
TYNAME	0		/ENTRY TO TYNAME.
	JMS GETBNK	/13-BIT ADDRESS OF DEB IS IN AC AT CALL.
	DAC ERNAME	/SAVE 15-BIT ADJUSTED ADDRESS.
	LAW FILMES	/TYPE "FILE".
	JMS TYPOUT	/..
	JMP LAWBLK	/THEN PRINT OUT A BLANK.
TYNSW1	LAW -3		/WILL BE -2 WHEN CONTROL FIRST COMES HERE.
	DAC LOOPCT	/COUNT TWO WORDS (FILE NAME) OR ONE WORD (EXT).
TYNLP1	LAW -3		/COUNT THREE CHARACTERS EACH WORD.
	DAC CHRCT		/..
	LAC* ERNAME	/GET NEXT WORD FROM DIRECTORY ENTRY BLOCK.
	DAC ERWORD	/SAVE AS CURRENT WORD.
TYNLP2	LAC ERWORD	/GET CURRENT WORD. NEXT CHAR IS IN BITS 0-5.
	RTL		/SHIFT OUT SIX BITS.
	RTL		/..
	RTL		/..
	DAC ERWORD	/SAVE REMAINDER FOR NEXT TIME.
	RAL		/GET SIXTH BIT FROM LINK.
	AND C77		/THROW AWAY JUNK.
	XOR C77		/COMPLEMENT RIGHT SIX BITS ONLY.
	SAD C77		/NULL CHARACTER?
	JMP TYNLP3	/YES, IGNORE.
	TAD LAWBLK	/GENERATE SEVENTH (LEFTMOST) BIT.
	XOR C77		/RESTORE RIGHTMOST FIVE BITS.
	XOR LAWBLK	/RESTORE SIXTH BIT.
	JMS TYONCH	/GO TYPE OUT THIS CHARACTER.
TYNLP3	ISZ CHRCT		/COUNT CHARS PER WORD.
	JMP TYNLP2	/MORE CHARS IN THIS WORD, GO GET NEXT ONE.
	ISZ ERNAME	/CURRENT WORD EMPTY, SERVICE NEXT ONE.
	ISZ LOOPCT	/COUNT WORDS IN THIS PORTION OF DEB.
	JMP TYNLP1	/ANOTHER WORD TO TREAT, DO SO.
LAWBLK	LAW 40		/FILE NAME OR EXT FINISHED, GET BLANK.
	JMS TYONCH	/TYPE IT OUT.
	ISZ TYNSW1	/COUNT THREE BLANK CHARS TYPED.
	JMP TYNSW1	/ANOTHER GROUP TO DO.
	LAW -3		/ALL DONE, RESET TYNSW1 FOR NEXT TIME.
	DAC TYNSW1	/..
	JMP* TYNAME	/RETURN TO CALLER.
FILMES	002002		/HEADER WORD 1: 2 PAIRS, IOPS ASCII.
C2000	2000		/CHECKSUM -- IGNORED BY TELETYPE HANDLER.
	.ASCII 'FILE'<175>
/SUBROUTINE TYONCH, OUTPUT SINGLE CHARACTER IN AC.
/NO WAIT REQUIRED BEFORE STORING C(AC) IN SINGCH.
/CALL:	LAW CHAR  	/CHARACTER TO BE TYPED IN AC(11-17).
/	JMS TYONCH	/GO TO TYONCH.
TYONCH	0		/ENTRY TO TYONCH.
	DAC SINGCH	/STORE CHAR TO TYPE IN IMAGE ASCII LINE BUFFER.
	.IFDEF RSX						/(142)
	CAL WRIMG						/(142)
	JMS WFEV	/ WAIT FOR TTY TO FINISH.		/(142)
	LAC (TTOLUN)	/ LUN NUMBER.				/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	.WRITE TTOCAL,3,CHRMS,0	/(RCHM-139) IMAGE MODE WRITE TO TTY.
	.WAIT TTOCAL		/(RCHM-139)
	.ENDC							/(142)
	JMP* TYONCH	/RETURN TO CALLER.
CHRMS	002003		/HEADER WORD 0: 2 PAIRS, IMAGE ASCII.
C3000	3000		/CHECKSUM -- IGNORED BY TELETYPE HANDLER.
SINGCH	0		/CHARACTER TO BE TYPED IN BITS 11-17.
C177	177		/RUBOUT WILL TURN OFF TYPING.
C13	13	/CONSTANT 13 FOR AUTO XR'S
  
/SUBROUTINE TYPRTN, PRODUCE CARRIAGE-RETURN AND LINE-FEED ON TELETYPE.
/CALL:	JMS TYPRTN
TYPRTN	0		/ENTRY TO TYPRTN.
OCTNUM=TYPRTN		/GETOCT: RESULTS REGISTER.
	.IFDEF RSX						/(142)
	CAL CRLF	/ RETURN CARRIAGE.			/(142)
	JMS WFEV	/ WAIT FOR TTY I/O TO COMPLETE.		/(142)
	LAC (TTOLUN)	/ TTY OUTPUT LUN.			/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	.CLOSE TTOCAL		/(RCHM-139)
	.ENDC							/(142)
	JMP* TYPRTN	/RETURN TO CALLER.
	.IFUND EDITOR
	.TITLE DISPLAY ROUTINES FOR THE GRAPHICS HARDWARE
/SUBROUTINES FOR DISPLAYING OUTPUT ON VP09 STORAGE SCOPE.
/
/
/
/
/START OR STOP DISPLAY, DEPENDING ON TVSW.
/	CALL:	JMS	TVST
/	WILL START THE VP09 AND DISPLAY ALL LINES IN THE RING BUFFERS IF
/	TVSW=0(ON) OR .CLOSE(ERASE) THE DISPLAY IF TVSW=-1(OFF)
/
TVST	XX
	.IFUND EDITVT
/INITIALIZE AND RESET DISPLAY.
TVST10	.INIT	TVDAT,1,RECOUP		/INIT DISPLAY
	DZM	TVLCT	/RESET COUNT OF DISPLAYED LINES
	.ENDC
	LAC	TVSW		/CHECK ON STATUS OF TV SWITCH.
	SZA			/GO DISPLAY BUFFERS IF ON.
	JMP*	TVST		/RETURN IF OFF.
/DISPLAY ALL THE LINES IN THE RING OF BUFFERS
	LAC	TVSPTR		/FIRST LINE IN BUFFERS.
	DAC	TVCPTR
	LAW	-TVNLN		/NUMBER OF BUFFERS.
	DAC	TVCNT
TVST12=.
	.IFDEF EDITVT
	JMS CTXOFF
	.ENDC
	LAC*	TVCPTR		/GET BUFFER POINTER.
	SNA
	JMP*	TVST		/NO MORE LINES IF 0, RETURN.
	DAC	TVTEMP
	.IFDEF EDITVT
	JMS CTLXON
	.ENDC
	ISZ	TVCPTR		/POINT AT HEADER PAIR,
	LAC	TVCPTR
	DAC	.+3		/INSERT BUFFER ADDRESS IN WRITE CAL
	.WRITE	TVDAT,2,0,0	/WRITE TO DISPLAY, IOPS ASCII
	.IFUND EDITVT
	ISZ	TVLCT		/INCREMENT LINE COUNT.
	.ENDC
	LAC	TVTEMP		/RESET POINTER
	DAC	TVCPTR		/TO NEXT BUFFER.
	ISZ	TVCNT		/CHECK BUFFER COUNT.
	JMP	TVST12		/RECYCLE.
	.IFDEF EDITVT
	JMS CTXOFF
	.ENDC
	JMP*	TVST		/ALL LINES DONE, RETURN.
/
/
/DISPLAY THE CURRENT LINE,UNPACKED, FROM INLINE.
/	CALL:	JMS	TVCL
/	WILL DISPLAY THE CURRENT LINE IF TVSW=0(ON)
/
TVCL	XX
	LAC	TVSW		/TV ON OR OFF
	SZA			/0=ON
	JMP*	TVCL		/OFF, NO ACTION.
/PACK LINE TO BE DISPLAYED
	.IFDEF EDITVT
	DZM VTFLAG
	.ENDC
	JMS	PACK		/SACK INTO IOPS ASCII
	INLINE			/FROM (CURRENT LINE)
	TVLINE			/TO
	.IFDEF EDITVT
	JMS CTLXON
	.ENDC
/DISPLAY IS RUNNING,ADD THE LINE TO IT.
	.IFUND EDITVT
	LAW	-70		/CHECK IF SCREEN IS FULL (56 LINES)
	TAD	TVLCT
	SMA
	JMS	TVST		/FULL SCREEN,GO RESTART DISPLAY.
	ISZ	TVLCT		/INCREMENT LINE COUNT.
	.ENDC
	.WRITE	TVDAT,2,TVLINE,0	/WRITE THE LINE.
	.WAIT	TVDAT	/WAIT TO AVOID CATCHING UP WITH DISPLAY.
	.IFDEF EDITVT
	JMS CTXOFF
	.ENDC
	JMP*	TVCL		/RETURN.
/
/
/ADD A LINE TO THE DISPLAY RING BUFFERS.
/	CALL:	JMS	TVVP
/		BUFFER POINTER
/	WILL ADD THE PACKED LINE AT BUFFER POINTER TO THE DISPLAY RING
/	BUFFERS, REGARDLESS OF TVSW.
/
TVVP	XX
	LAC*	TVVP		/GET ARGUMENT
	ISZ	TVVP		/POINT TO RETURN LOCATION.
	DAC	TVTEMP		/SAVE ARGUMENT.
/INSERT PACKED LINE FROM ARGUMENT INTO DISPLAY BUFFER RING.
TVVP10	XX			/SWITCH FOR BUFFERS FULL OR BEING FILLED.
	/BUFFERS FULL, REPLACE OLD FIRST BY NEW LAST LINE.
	LAC	TVSPTR		/POINTS TO FIRST LINE.
	TAD	(1
	DAC	TVCPTR		/POINTS TO HEADER PAIR.
	LAC*	TVSPTR		/BUFFER POINTER TO NEXT BUFFER,
	DAC	TVSPTR		/WHICH BECOMES NEW FIRST LINE.	
	JMP	TVVP30		/GO MOVE TYLINE TO TVCPTR
	/BUFFERS BEING FILLED.
TVVP20	LAC	TVCPT2		/POINTS TO FIRST EMPTY BUFFER.
	TAD	(1
	DAC	TVCPTR		/POINTS TO HEADER PAIR.
	TAD	(BUFLEN		/POINTS TO NEXT BUFFER.
	SAD	TVBPTR		/IF THIS IS THE LAST BUFFER
	JMP	TVVP24		/GO MAKE IT POINT TO THE FIRST ONE.
TVVP22	DAC*	TVCPT2		/SET BUFFER POINTER
	DAC	TVCPT2		/SET FIRST-EMPTY POINTER.
	JMP	TVVP30		/GO MOVE TYLINE INTO TVCPTR.
TVVP24	LAC	NOPLIT		/NOP INTO BUFFERS-FULL SWITCH
	DAC	TVVP10
	LAC	(TVBUF1		/ADDR OF FIRST BUFFER INTO LAST BUF PTR.
	JMP	TVVP22
	/MOVE LINE INTO BUFFER POINTED AT BY TVCPTR.
TVVP30	LAW	-BUFLEN		/BUFFER LENGTH
	DAC	TVCNT		/INTO COUNTER.
TVVP32	LAC*	TVTEMP		/GET A WORD FROM THE LINE.
	DAC*	TVCPTR		/INSERT INTO BUFFER.
	ISZ	TVTEMP		/NEXT WORD.
	ISZ	TVCPTR		/...
	ISZ	TVCNT		/CHECK COUNT,
	JMP	TVVP32		/RECYCLE.
	JMP*	TVVP		/RETURN.
	/
/
	.IFDEF EDITVP
/
/
/BACK THE DISPLAY LINE COUNTER UP ONE LINE.
/	CALL:	JMS	TVMLF
/	REPOSITIONS THE DISPLAY UP ONE LINE AND REDUCES THE LINE
/	COUNT BY ONE, IF TVSW=0(ON)
/
TVMLF	XX
	LAC	TVSW		/CHECK TV ON OR OFF
	SZA			/0=ON
	JMP*	TVMLF		/OFF,NO ACTIONN
	LAW	-TVLF		/NUMBER OF RASTER UNITS PER LF
	DAC	TVCNT
	LAW	-2021		/TOP OF SCREEN + 1 LINE.
TVMLF2	TAD	TVLCT		/ADD NUMBER OF LINES LF TIMES,IE
	ISZ	TVCNT		/TVLF * TVLCT (TVLCT=NUMBER OF LINES	JMP	TVMLF2	
	JMP	TVMLF2		/DISPLAYED-1)
	CMA; TAD (1		/CHANGE SIGN
	RCR			/REDUCE TO X=0, Y =9 BITS.
	DAC	TVTEMP
	AND (777000
	SZA
	JMP TVWR
	.WRITE	TVDAT,14,TVTEMP,1	/PLOT IN NON-STORE MODE (POSITION BEAM)
TVWR	LAC	TVLCT		/SUBTRACT 1 FROM LINE COUNT.
	TAD	FENCE
	DAC	TVLCT
	JMP*	TVMLF
/
/
/CROSS OUT A LINE ON THE DISPLAY.
/	CALL:	JMS	TVXUT
/	CAUSES A BROKEN LINE TO BE DRAWN THROUGH THE DISPLAY LINE
/	BEFORE THE ONE ABOUT TO BE WRITTEN, IF TVSW=0(ON).
/
TVXUT	XX
	LAC	TVSW		/CHECK TV ON OR OFF
	SZA			/0=ON
	JMP*	TVXUT		/OFF, NO ACTION
	JMS	TVMLF		/BACK UP TO PREVIOUS LINE.
	ISZ	TVLCT		/BUMP LINE COUNT FOR THIS WRITE.
	LAC TVTEMP
	AND (777000
	SZA
	JMP TVWR1
	.WRITE	TVDAT,2,TVDASH,0	/CROSS OUT LINE.
	.WAIT	TVDAT
TVWR1	JMP*	TVXUT		/RETURN
/
/
	.ENDC
/
	.IFDEF EDITVT
/
/
/SUBROUTINE "TVCLR" WILL CLEAR THE  ENTIRE
/SCREEN IF VT ON WAS TYPED
/**CODE TO ^X IN MONITOR IS 34(8) <LAW 34>
/
/
TVCLR	0
	XCT CTRLSW	/WAS VT ON TYPED
	JMP* TVCLR	/NO!
	LAC TVSW		/SAVE STATUS OF TVSW
	DAC TVXUT
	DZM TVSW		/TURN TVSW ON
	JMS CTLXON	/TURN ON ^X
	LAW 34
	JMS TYONCH
	JMS CTXOFF	/TURN OFF ^X
	LAC TVXUT		/RESTORE STATUS OF TVSW
	DAC TVSW
	JMP* TVCLR
/
/
/DELETE THE LAST LINE ON THE DISPLAY
/IF THE TV IS ON  IE  TVSW=0
/
/	CALL	JMS TVXUT
/	SENDS ASCII CODE (036) TO THE
/	CONTROL X FEATURE WHICH REMOVES
/	THE LAST LINE FROM THE DISPLAY FILE
/
/
TVXUT	0
	XCT CTRLSW	/WAS VT ON TYPED
	JMP* TVXUT	/NO--EXIT
	LAC TVSW
	SZA
	JMP* TVXUT
	JMS CTLXON	/TURN ^X ON
	LAW 36		/GIVE DELETE CODE TO MONITOR ^X CODE
	JMS TYONCH
	JMS CTXOFF
	JMP* TVXUT
/
/
/TURN ON CTRL X IF VT ON
/WAS TYPED AND TV IS ON
/
CTLXON	0
	LAC TVSW	/IS TV ON
	SZA
	JMP* CTLXON	/NO -- EXIT
	LAW -2
	AND* SCOMCX	/MAKEUP DATA WORD
	JMS CTLXSD
	JMP* CTLXON
/
/
/TURN CTRL X OFF IF VT ON
/WAS TYPED
/
CTXOFF	0
	XCT CTRLSW
	JMP* CTXOFF
	CLA		/GIVE A <LF> TO ^X -- ^X PACKS ON A <LF>
	JMS TYONCH	/AND THIS WILL GIVE IT ONE DUE TO OVERPRINT
	LAW -2		/MAKE UP DATA WORD
	AND* SCOMCX
	XOR (1
	JMS CTLXSD
	JMP* CTXOFF
/
/
/SET CTRL X STATUS REGISTER TO THE
/DATA WORD IN THE AC AND THEN ISSUE
/A CTRL X TO THE MONITOR IF VT ON
/WAS TYPED
/
CTLXSD	0
	XCT CTRLSW	/WAS VT ON TYPED
	JMP* CTLXSD	/NO--EXIT
	DAC* SCOMCX	/SET STATUS REG.
	LAW 30
	JMS* CTRLX	/SEND ^X TO MONITOR
	JMP* CTLXSD
/
/
/
	.ENDC
/
/
/
/
/
/DISPLAY CONSTANTS AND STORAGE.
TVNLN=5
TVSPTR	TVBUF1			/POINTS TO LOGICALLY 1ST BUFFER TO DISPLAY
TVBUF1	.BLOCK	BUFLEN+1*TVNLN	/RING BUFFER FOR TVNLN LINES
TVBPTR	.			/END OF BUFFERS
TVCPTR	0			/CURRENT BUFFER POINTER
TVCPT2	TVBUF1			/...USED BY BUFFER FILLER
TVCNT				/COUNTER
	.IFUND EDITVT
TVLCT				/LINES ON THE SCREEN
	.ENDC
TVON	-1			/DISPLAY ON INDICATOR
TVLF=22				/VP09 LINE FEED, RASTER UNITS
	.IFDEF EDITVP
TVDAT=10				/VP09 .DAT SLOT
TVDASH	TVDEND-.*400+2
TVTEMP	0			/TEMPORARY STORE
	.ASCII	'----------------------------------------'
	.ASCII	'------------------------------'<15>
TVDEND=.
	.ENDC
	.IFDEF EDITVT
TVDAT=-3
VTFLAG	0
TVTEMP	0
	.ENDC
	.ENDC
/
/
	.TITLE MESSAGES
/MESSAGES OUT.
EDTMES	ENDED1-.*400+2
BUFSIZ	-67	/LINES PER BLOCK MODE BUFFER LOAD (INITALLY 55(10)).
	.IFDEF RSX						/(142)
	.ASCII "EDITOR XVM/RSX V1B000"<15>			/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	.IFDEF EDITOR
	.SYSID <	.ASCII 'EDITOR >,<000'<15>> /(RCHM-136)
	.ENDC
	.IFDEF EDITVP
	.SYSID <	.ASCII 'EDITVP >,<000'<15>> /(RCHM-136)
	.ENDC
	.IFDEF EDITVT
	.SYSID <	.ASCII 'EDITVT >,<000'<15>> /(RCHM-136)
	.ENDC
	.ENDC							/(142)
ENDED1=.
ERREQM	ENDERQ-.*400+2
BNUM	0	/PARTIAL RESULT DURING RADIX CONVERT OF NUMERIC ARGS.
PK5CHR=BNUM	/5-CHARACTER COUNTER FOR PACK-UNPACK.
PK6CT1=BNUM
	.ASCII 'NOT A REQUEST:'<15>
ENDERQ=.
INPTM	ENDINM-.*400+2
FINDSW	0	/INDICATOR FOR FIND AND LOCATE SEQUENCES.
	.ASCII 'INPUT'<15>
OUTSW1=.-1		/-1 IF OUTPUT FILE IS EMPTY, 0 OTHERWISE.
ENDINM=.
EOFRM	ENDEFM-.*400+2
NUMPTR	0	/POINTER TO CURRENT DIGIT IN ARGUMENT STRING.
PLBH=NUMPTR	/POINTER TO LINE BUFFER HEADER, WORD 0.
	.ASCII 'END OF FILE REACHED BY:'<15>
ENDEFM=.
EOMRM	ENDEMM-.*400+2
MAXLEN	LINSIZ
	.ASCII 'END OF MEDIUM REACHED BY:'<15>
ENDEMM=.
EOBRM	ENDEBM-.*400+2
NXTPTR	0	/POINTER TO NEXT CHARACTER IN CONTROL WORD STRING.
	.ASCII 'END OF BUFFER REACHED BY:'<15>
ENDEBM=.
BOVFLM	ENDBOM-.*400+2
	.IFDEF RSX						/(142)
	0							/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
SCOM16	.SCOM+16
	.ENDC							/(142)
	.ASCII 'BUFFER CAPACITY EXCEEDED BY:'<15>
ENDBOM=.
NOFIL1	ENDNF1-.*400+2
BUFEMP	0
	.ASCII 'NO INPUT FILE PRESENT.'<15>
ENDNF1=.
NOFLNM	ENDNFN-.*400+2
QRETN	0	/QRETN MAY NEVER BE USED EXCEPT FOR ^P PC STORAGE.
	.ASCII 'NO FILE NAME GIVEN.'<15>
ENDNFN=.
TOPRQM	ENDTRQ-.*400+2
BNKMSK	060000
	.ASCII 'TOP REQUEST NEEDED.'<15>
ENDTRQ=.
TWOFIL	ENDTF-.*400+2
GBADR	0
	.ASCII 'IS PRESENT ON OUTPUT DEVICE.'<15>
ENDTF=.
TWOFL0	ENDTF0-.*400+2
EXITRQ	0		/EXIT REQUEST SWITCH
	.ASCII 'PLEASE RENAME IT OR IT WILL BE DELETED.'<15>
ENDTF0=.
TWOFL1	ENDTF1-.*400+2
SAVESW	-1
	.ASCII 'IS PRESENT ON INPUT DEVICE.'<15>
ENDTF1=.
BADNAM	ENDBDN-.*400+2
QUOTE	0		/QUOTE CHARACTER FOR CHANGE REQUEST.
	.ASCII 'PLEASE TYPE IN ANOTHER NAME.'<15>
ERWORD=QUOTE
ENDBDN=.
FILN1	ENDFN1-.*400+2
DELSW	0		/INDICATOR FOR NEXT AND DELETE SEQUENCES.
ERNAME=DELSW
	.ASCII 'NOT FOUND.'<15>
	.LOC .-1
C7	7
ENDFN1=.
EMPFLM	ENDEMF-.*400+2
LEN1	0
	.ASCII 'NOTHING IN FILE.'<15>
	.LOC .-1
C17	17
ENDEMF=.
PRTYMS	ENDPMS-.*400+2
CONVLT	0
	.ASCII 'READ ERROR:'<15>
	.LOC .-1
ADRMSK	017777
ENDPMS=.
TRNMES	ENDTRN-.*400+2
CL0777	077777
	.ASCII 'TRUNCATED:'<15>
	.LOC .-1
C60	60
ENDTRN=.
BFNEMM	ENDBNM-.*400+2
CL7000	700000
	.ASCII 'BUFFER NON-EMPTY.'<15>
ENDBNM=.
NUFIL1	ENDNF1-.*400+2
EXITSW	0		/INDICATES OPEN FILE FOR EXIT ROUTINE
	.ASCII 'YOUR EDITED FILE IS ON .DAT -1'<175>
	.LOC .-1
TWO	2
ENDNF1=.
OLDEL	ENDOLD-.*400+2
TYLNPT	0
	.ASCII 'ORIGINAL FILE DELETED.'<15>
ENDOLD=.
NUFIL2	ENDNF2-.*400+2
INLNPT	0
	.ASCII ' AS '<175>
ENDNF2=.
SLASH	57	/SLASH (/) FOR BRIEF MODE SERVICER.
ENDSVM=.
NOSTGM	NENGMS-.*400+2
OVFLAD	0
	.ASCII 'NO STRING'<15>
NENGMS	BUFSPM-.*400+2
	.IFDEF RSX						/(142)
	0							/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
SCOM2	.SCOM+2
	.ENDC							/(142)
	.ASCII 'NOT ENOUGH '<175>
BUFSPM	LINEMS-.*400+2
	.IFDEF RSX						/(142)
	0							/8142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
SCOM3	.SCOM+3
	.ENDC							/(142)
	.ASCII 'BUFFER SPACE'<15>
LINEMS	LMEOFM-.*400+2
SGTSW	0		/LINE SWITCH FOR "SGTRAN"
	.ASCII 'LINES'<15>
	.LOC .-1
CHGREQ	SKP		/SWITCH FOR CHANGE COMMAND
LMEOFM	BUFTSM-.*400+2
MTWO	-2
	.ASCII 'LINES MOVED TO END'<15>
BUFTSM	MESEND-.*400+2
LINCSW	SKP		/SWITCH FOR LINE CONVERT
	.ASCII 'SIZE TO SMALL'<15>
MESEND=.
	.IFDEF RSX						/(142)
TFILE1	.SIXBT 'USR@@@'	/ THE REST IS FILLED IN AT STARTUP	/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
TFILE1	.SIXBT '.TFIL1'
	.ENDC							/(142)
EDNAM	.SIXBT 'EDT'
EDTM	002002
LENGTH	0	/TOTAL DATA CHARACTERS IN CURRENT LINE.
	.ASCII 'EDIT'<15>
	.TITLE GETBNK,GETCOM & GETNUM
/SUBROUTINE GETBNK, ADD EXTENDED MEMORY BITS REFERENCING CURRENT
/BANK TO 13-BIT ADDRESS IN AC.
/CALL:	LAW ADDR		/GET ADDRESS TO BE MODIFIED.
/	JMS GETBNK	/CALL GETBNK.
/FOR BANK MODE VERSION
/IE 13 BIT ADDRESSING
/ADRMSK=017777 AND BNKMSK=060000
/
GETBNK	0		/ENTRY TO GETBNK.
CWCHRC=GETBNK		/GETCOM: MAXIMUM CHARACTERS POSSIBLE IN LEGAL COMMAND WORD.
	AND ADRMSK	/EXTRACT 13-BIT ADDRESS FROM AC.
	DAC GBADR		/SAVE TEMPORARILY.
	LAC GETBNK	/GET ENTRY.
	AND BNKMSK	/GET BANK BITS
	ADD GBADR		/NOW RETRIEVE 13-BIT ADDRESS.
	JMP* GETBNK	/EXIT WITH 15-BIT ADDRESS IN AC.
/SUBROUTINE GETCOM, EXTRACT CONTROL WORD FROM TYPED INPUT LINE.
/IGNORES LEADING BLANKS IN STRING AND TERMINATES ON FIRST FOLLOWING
/BLANK OR END-OF-LINE. IF STRING BEING EXTRACTED EXCEEDS SEVEN CHARACTERS
/IN LENGTH, THE RIGHTMOST OVERFLOW CHARACTERS ARE THROWN AWAY. TOTAL
/CHARACTERS IN STRING EXTRACTED IS RETURNED TO THE CALLER IN THE AC.
GETCOM	0		/ENTRY TO GETCOM.
NPAIRS=GETCOM		/PUTLIN: TEMPORARY STORAGE.
	LAC CWDLIT	/POINTER TO START OF CONTROL-WORD ARRAY.
	DAC CWDPTR	/SAVE AS CURRENT-CHARACTER POINTER.
FIVE70	LAW -10		/LENGTH OF CONTROL-WORD ARRAY (CWD).
	DAC CWCHRC	/SAVE AS MAXIMUM-CHARACTERS COUNTER.
	DZM NCHARS	/ZERO TOTAL CHARACTERS IN CONTROL-WORD STRING.
	CLL!CML		/INDICATE NO CHARACTERS ENCOUNTERED YET.
GTNXT	JMS NXTCHR	/GET NEXT CHARACTER FROM INPUT LINE.
	JMP GTCLOS	/NO MORE CHARACTERS, CLOSE OUT ARRAY.
	SAD BLANK		/SUCCESS. IS CHARACTER A BLANK?
	JMP BLKFND	/YES, MAKE SURE SOME DATA PRECEDED IT.
	CLL		/NO, INDICATE SOME NON-BLANK CHARACACTER HAS BEEN FOUND.
	ISZ CWCHRC	/BUMP MAXIMUM-CHARACTERS-ALLOWED.
	JMP GTCPUT	/NO OVERFLOW YET, PUT CHARACTER AWAY.
	CLC		/SEVEN CHARACTERS INSERTED, DON'T ALLOW ANY MORE.
	DAC CWCHRC	/RESET CWCHRC TO -1.
	JMP GTNXT		/THEN GO LOOK FOR BLANK OR TERMINATOR.
/COME HERE TO INSERT DATA CHARACTER IN CWD ARRAY.
GTCPUT	DAC* CWDPTR	/PUT CHARACTER AWAY.
	ISZ CWDPTR	/BUMP POINTER FOR NEXT TIME.
	ISZ NCHARS	/AND BUMP CHARACTERS PROCESSED.
	JMP GTNXT		/THEN GO FOR NEXT CHARACTER.
/COME HERE ON BLANK FOUND IN INPUT LINE.
BLKFND	SZL!CLA!CMA	/SKIP IF THIS  S NOT A LEADING BLANK.
	JMP GTNXT		/LEADING BLANK, IGNORE IT.
GTCLOS	DAC* CWDPTR	/NOT LEADING BLANK, THEN TERMINATE STRING (AC = -1 NOW).
	LAC NCHARS		/PICK UP TOTAL CHARACTERS IN STRING.
	JMP* GETCOM	/AND RETURN TO CALLER.
CWD	.BLOCK 10	/ROOM FOR LONGEST LEGAL CONTROL WORD AND TERMINATOR.
/SUBROUTINE NXTCHR, RETURN NEXT 7-BIT CHARACTER FROM UNPACKED INPUT
/ARRAY. NXTPTR MUST BE SET TO BEGINNING OF ARRAY BEFORE FIRST CALL.
/CALL:	JMS NXTCHR	/GO TO NXTCHR.
/	JMP DONE		/RETURN HERE IF END-OF-LINE ENCOUNTERED.
/	DAC CHAR		/RETURN HERE WITH CHARACTER IN AC.
NXTCHR	0		/ENTRY TO NXTCHR.
TNUM=NXTCHR		/GETNUM: TEMPORARY STORAGE.
	LAC* NXTPTR	/GET NEXT CHARACTER.
	SPA		/TERMINATOR?
	JMP* NXTCHR	/YES, RETURN IMMEDIATELY.
	ISZ NXTPTR	/OTHERWISE BUMP POINTER FOR NEXT TIME.
	ISZ NXTCHR	/AND BUMP RETURN ADDRESS.
	JMP* NXTCHR	/THEN RETURN TO CALLER WITH CHARACTER IN AC 11-17.
/SUBROUTINE GETNUM, RETURN BINARY VALUE IN AC OF THE DECIMAL
/ARGUMENT IN THE CONTROL WORD STRING. NUMBER IS RETURNED IN NEGATIVE (2'S
/COMPLEMENT) FORM. IF NO PARAMETER IS PRESENT, AC = 777777. THE
/APPEARANCE OF ANY NON-NUMERIC IN THE PARAMETER STRING CAUSES
/TRANSFER OF CONTROL TO ILLCWD AND SUBSEQUENT DISREGARD OF THE
/ENTIRE COMMAND.
GETNUM	0		/ENTRY TO GETNUM.
	JMS GETCOM	/GET NEXT CONTROL-WORD STRING.
	LAC CWDLIT	/SET DIGIT POINTER TO
	DAC NUMPTR	/BEGINNING OF CONTROL-WORD STRING.
	DZM BNUM		/SET INITIAL RESULT TO ZERO.
GTNLP	LAC* NUMPTR	/ENTER MAIN LOOP, GET NEXT DIGIT FROM INPUT STREAM.
	SPA		/TERMINATOR CHARACTER?
	JMP GTNRTN	/YES, GO TO RETURN.
	AND C17		/NO, MASK OFF NUMERICS.
	DAC TNUM		/SAVE NUMERICS.
	CMA
	TAD (12)		/(RCHM-139)
	SPA
	JMP ILLCWD
	LAC TNUM
	XOR* NUMPTR	/ZERO NUMERICS, REINSERT ZONE BITS.
	XOR C60		/THEN ZERO ZONE BITS. THIS ONLY SEEMS TEDIOUS.
	SZA		/BITS 2 AND 3 ON, BIT 1 OFF: NUMBER PRESENT.
BADARG	JMP ILLCWD	/NON-NUMBER OTHERWISE. GO COMMENT.
	LAC BNUM		/GET VALUE COMPUTED SO FAR, THEN MULTIPLY BY 10.
	CLL!RAL		/FORM BNUM * 2.
	RTL		/BNUM * 8.
	ADD BNUM		/BNUM * 9.
	ADD BNUM		/BNUM * 10.
	ADD TNUM		/BNUM PLUS CURRENT DIGIT.
	DAC BNUM		/NEW VALUE.
	ISZ NUMPTR	/BUMP POINTER TO NEXT DIGIT.
	JMP GTNLP		/LOOP TILL DONE.
GTNRTN	LAC BNUM		/ALL FINISHED, GET FINAL VALUE.
	SZA!CMA		/IF BNUM .E. 0, BNUM = 1.
	TAD (1)			/(RCHM-139) IF BNUM .G. 0, FORM 2'S COMPLEMENT.
	JMP* GETNUM	/RETURN TO CALLER WITH RESULT IN AC.
	.TITLE EOF PROC,I/O .INIT SUBR & CHDAT SUBR
/COME HERE ON EOF ENCOUNTERED IN INPUT FILE.
EOF	LAC GBLKSW
	SZA
	JMP PRTEOF
	LAC BFPTSW
	DAC BUFEMP
	LAW EOBRM
	SKP
PRTEOF	LAW EOFRM
	JMS TYPOUT
EOFCOM	JMS PACK
ADR010	EDLIN
	TYLINE
	LAW TYLINE
	JMS TYPOUT
	JMP FND4
/
/
IOINIT	0
CWDPTR=IOINIT
	.IFUND RSX						/(142)
	LAC INPTCL
	AND C777
	DAC .+1
	OPICAL		/INPUT DEVICE.
UNIT1	1
	0
INDEV	0
	.ENDC							/(142)
	DZM LENGTH	/DON'T ZERO IF ICLOSE REQ
	LAC (SKP!CLA!CMA		/(023) SET ONCE READ SW TO NEVER READ.
	DAC RDFRDF
	.IFUND RSX						/(142)
	LAC OUTPCL
	AND C777
	ADD C1000
	DAC .+1
	OPOCAL		/SCRATCH DEVICE.
UNIT2	1
	0
OUTDEV	0
	.ENDC							/(142)
	LAW -1
	DAC OUTSW1	/INDICATE NOTHING WRITTEN YET IN OUTPUT FILE
	DAC RDFNOP		/(RCHM-033)
	DAC INFILE
	DAC OWFLSW
	.IFUND RSX						/(142)
	LAW -376
	TAD INDEV
	DAC INDEV
	SPA
	DZM INFILE
	LAW -376
	TAD OUTDEV
	SPA
	DZM OWFLSW
	DAC OUTDEV
	.ENDC							/(142)
	.IFDEF RSX						/(142)
	DZM INDEV						/(142)
	DZM OUTDEV						/(142)
	.ENDC							/(142)
	LAC INFILE
	TAD OWFLSW
	SAD NAMEIN
	SKP!CLA
	CLA!CMA
	DAC FILSTR
	CMA
	DAC BLOKSW
	DAC PBLKSW
	JMS CHBUFF
	DZM BFPTSW
	JMP* IOINIT
INFILE	-1
OWFLSW	-1
FILSTR	0
INPSW	0
BBUF1	0		/START OF BLOCK BUFFER 1.
BBUF2	0		/START OF BLOCK BUFFER 2.
BBUFX	0		/LENGTH OF EACH BLOCK BUFFER.
	.IFDEF EDITVT
CTRLSV	0		/ ^X STATUS ON ENTRY
CTRLX	0		/ADDR OF VTLBUF IN MONITOR
CTRLSW NOP		/CTRL X SWITCH
	.ENDC
	.IFUND RSX						/(142)
	.IFDEF EDITVT
SCOMCX	.SCOM+33
	.ENDC
INPDAT	.SCOM+23
OUTDAT	DATM15
INPUIC	.SCOM+25
OUTUIC	0
	.ENDC							/(142)
/
/
/
/
/SUBROUTINE TO CHECK IF BOTH INPUT
/AND OUTPUT DAT SLOTS ARE ASSIGNED
/TO THE SAME DEVICE AND UNIT NUMBER
/
/ALSO, FOR DOS15 CHECK FOR SAME UIC.
/
/CALL	JMS DEVCHK
/	RETURN	/ALL THINGS THE SAME
/	RETURN	/NOT THE SAME
/
/
DEVCHK	0
	.IFUND RSX						/(142)
	LAC* INPDAT	/CHECK DAT SLOTS
	SAD* OUTDAT
	SKP
	JMP NOGO
	LAC* INPUIC
	SAD* OUTUIC
	.ENDC							/(142)
	.IFDEF RSX						/(142)
	LAC (INLUN)	/ GET HINF ON INPUT LUN.		/(142)
	JMS HINFLN						/(142)
	AND (7777)	/ EXTRACT DEVICE AND UNIT.		/(142)
	DAC TEMPB	/ SAVE FOR LATER TEST.			/(142)
	LAC (OUTLUN)	/ GET HINF ON OUTPUT LUN.		/(142)
	AND (7777)	/ DEXTRACT DEVICE AND UNIT.		/(142)
	SAD TEMPB	/ ARE THEY THE SAME?			/(142)
	.ENDC							/(142)
	JMP* DEVCHK	/SAME  EXIT
NOGO	ISZ DEVCHK	/BUMP TO NOT SAME EXIT
	JMP* DEVCHK	/EXIT
/
/
/SUBROUTINE CHDAT, CHANGE DAT SLOTS AROUND.
CHDAT	0
	LAC DIRSW
	CMA
	DAC DIRSW
	LAC OUTPCL
	DAC RENAME
	LAC INPTCL
	DAC OUTPCL
	LAC RENAME
	DAC INPTCL
	DZM OUTPSW
	JMS IOINIT
	JMP* CHDAT
/
/
	.LTORG
	.IFDEF RSX						/(142)
MAXBUF	0							/(142)
EDTSIZ	.SIZE							/(142)
	.ENDC							/(142)
	.TITLE PATCH BLOCK
/
/
/37(8) WORD AREA
/
	.IFDEF %DEBUG						/(142)
	.REPT 36
PATCHF	0		/FIRST PATCH LOCATION
PATCHL	0		/LAST PATCH LOCATION
	.ENDC							/(142)
/
/
/
/
/DEFINE BUFFERS USED BY THE EDITOR
/
EDLIN=.			/CURRENT COMMAND STRING ARRAY.
INLINE=EDLIN+LINSIZ	/CURRENT INPUT LINE FROM FILE OR KEYBOARD.
TYLINE=INLINE+LINSIZ
/DEFINE TEMPORARY STORAGE REGISTERS RESIDING IN TYLINE AREA.
RNMFIL=TYLINE
RENMCT=RNMFIL+6
RNMWRD=RENMCT+1
CALDB1=RNMWRD+1
CALDB2=CALDB1+3
CALDAT=CALDB2+3
SBUFF=TYLINE+LINSIZ
	.IFUND EDITOR
TVLINE=SBUFF+BUFLEN	/DISPLAY LINE BUFFER
RDBUF1=TVLINE+BUFLEN
	.ENDC
	.IFDEF EDITOR
RDBUF1=SBUFF+BUFLEN
	.ENDC
RDBUF2=RDBUF1+BUFLEN	/..
WRBUF1=RDBUF2+BUFLEN
WRBUF2=WRBUF1+BUFLEN
LABUF=WRBUF2+BUFLEN-1
/
/
	.LOC LABUF
	0
/
/
	.TITLE ONE TIME SECTION
	.LOC EDLIN
/ONE-TIME SECTION TO SET UP CONSTANT ADDRESSES WITH EPC BITS
/TO REFERENCE PROPER (CURRENT) BANK; CALCULATE START OF BLOCK
/BUFFERS. CODING RESIDES IN READ-WRITE LINE BUFFER AREAS AND SETS "BEGIN"
/TO NOP TO AVOID FURTHER CALLS.
SETBNK	LAC NOPLIT
	DAC BEGIN
	.IFUND RSX						/(142)
	LAW -15
	TAD* INPDAT
	DAC OUTDAT
	DAC INPDAT
	ISZ INPDAT
	LAW -15
	TAD* INPUIC
	DAC OUTUIC
	DAC INPUIC
	ISZ INPUIC
	LAW ADRTBL
	JMS GETBNK
	DAC* (12)		/(RCHM-139)
ADRLP1	LAC* 12
	JMS GETBNK
	DAC POINTR
	LAC* POINTR
	JMS GETBNK
	DAC* POINTR
	ISZ ACOUNT
	JMP ADRLP1
	LAC* SCOM2
	.ENDC							/(142)
	.IFDEF RSX						/(142)
	CAL REDPAR	/ READ THE TDV BUFFER.			/(142)
	LAC TDVEV	/ CHECK XFRCMD EVENT VARIABLE.	/(142)
	SPA							/(142)
	JMP TDVER	/ ERROR FROM XFRCMD.			/(142)
	LAC EDTSIZ	/ PICK UP THE EDITOR SIZE.		/(142)
	.ENDC							/(142)
	DAC BBUF1
	.IFUND RSX						/(142)
	LAC*	SCOM3
	.ENDC							/(142)
	.IFDEF RSX						/(142)
	LAC (INLUN)	/ PREALLOCATE BUFFERS.			/(142)
	JMS PREAL						/(142)
	LAC (OUTLUN)	/ PREALLOCATE BUFFER.			/(142)
	JMS PREAL						/(142)
	LAC (ALTINP)	/ PREALLOCATE BUFFER.			/(142)
	JMS PREAL						/(142)
	LAC (ALTOUT)	/ PREALLOCATE BUFFER.			/(142)
	JMS PREAL						/(142)
	CAL PARSIZ	/ EXTRACT PARTITION SIZE.		/(142)
	LAC ENDPAR	/ FETCH EDN OF PARTITION.		/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
	JMS GETBNK
	.ENDC							/(142)
	CMA
	TAD BBUF1
	CMA
	RAR!CLL
	DAC BBUFX
	TAD BBUF1
	DAC BBUF2
	DZM BFPTSW
	.IFUND RSX						/(142)
	LAC*	SCOM3
	JMS GETBNK
	.ENDC							/(142)
	.IFDEF RSX						/(142)
	LAC BBUFX	/ FETCH THE BUFFER SIZE.		/(142)
	CLL		/ SET UP FOR IDIV.			/(142)
	IDIV		/ CALCULATE THE NUMBER OF LINES IN THE	/(142)
	BUFLEN		/ BUFFER.				/(142)
	LACQ		/ FETCH NUMBER OF LINES.		/(142)
	AAC -1		/ WILL AT LEAST 1 LIN FIT?		/(142)
	SPA							/(142)
	JMP LDERR	/ NO, NOT ENOUGH CORE.			/(142)
	TCA		/ CALCULATE BUFSIZ DEFAULT.		/(142)
	DAC BUFSIZ						/(142)
	DAC MAXBUF	/ SET UP FOR MAXIMUM COMPARISON.	/(142)
	LAC ENDPAR	/ FETCH END OF THE PARTITION.		/(142)
	.ENDC							/(142)
	CMA
	.IFUND RSX						/(142)
	TAD* SCOM2
	.ENDC							/(142)
	.IFDEF RSX						/(142)
	TAD EDTSIZ						/(142)
	.ENDC							/8142)
	SPA!SNA
	JMP OK
	.IFDEF RSX						/(142)
LDERR=.								/8142)
	.ENDC							/(142)
	LAW LOAD1
	JMS TYPOUT
	.IFDEF RSX						/(142)
	LAC (2)							/(142)
	DAC TDVEV	/ FORCE TDV TO BE CALLED.		/(142)
	.ENDC							/(142)
	JMP EXIT1
LOAD1	ENDLD1-.*400+2
	0
	.IFUND RSX						/(142)
	.ASCII '.SYSLD 1'<15>
	.ENDC							/(142)
	.IFDEF RSX						/(142)
	.ASCII 'EDT-PARTITION TOO SMALL'<15>			/(142)
	.ENDC							/(142)
ENDLD1=.
OK	JMS CHBUFF
	.IFDEF EDITVT
	LAW -3	/GET ADDRESS OF EDITVT
	TAD* (.SCOM+23	/MONITOR ^X INTERCONNECTION
	DAC CTRLX		/LOCATED AT TTA.-2
	LAW -2
	TAD* CTRLX
	DAC CTRLX
	LAC* CTRLX
	DAC CTRLX		/WAS VT ON TYPED NON ZERO IF SO
	SNA
	JMP OK1		/NO--DON'T SET SWITCH
	LAC* (.SCOM+52	/IF IN BOSS15 MODE
	SPA			/DON'T SET SWITCH
	JMP OK1
	LAC SKPLIT
	DAC CTRLSW
OK1	LAC* SCOMCX	/SAVE ENTRY STATE OF ^X
	AND (1
	DAC CTRLSV
	.ENDC
	.IFDEF RSX						/(142)
	CAL SPY		/ FETCH USER NUMBER.			/(142)
	LAC SPY+3	/ FETCH USER NUMBER FROM CPB.		/(142)
	LRSS 3		/ CONSTRUCT FILE NAME.			/(142)
	ALS 3							/(142)
	LLS 3							/(142)
	TAD (566060)	/ CONVERT TO .NN			/(142)
	DAC TFILE1+1	/ STORE NEW 2ND HALF OF FILE NAME.	/(142)
	.ENDC							/(142)
	JMP BEGIN+1
	.IFDEF RSX						/(142)
								/(142)
/ SUBROUTINE TO PREALLOCATE BUFFERS FOR I/O DEVICES.		/(142)
								/(142)
PREAL	XX		/ ENTRY POINT.				/(142)
	DAC PRECPB+2	/ SET UP LUN.				/(142)
	CAL PRECPB	/ ISSUE PREALLOCATE.			/(142)
	CAL WFEVA	/ WAIT FOR PREAL TO FINISH.		/(142)
	LAC EVA		/ CHECK TO SEE IF IT SUCCEEDED	/8142)
	SMA		/ MIGHT BE AN ERROR.			/(142)
	JMP* PREAL	/ NOPE, EVERYTHING IS OK.		/(142)
	SAD (-6)	/ UNIMPLEMENTED FUNCTION IS OK TOO.	/(142)
	JMP* PREAL						/(142)
	JMS IOERR	/ EVERYTHING ELSE ISN'T OK.		/(142)
	LAC PRECPB+2	/ LUN NUMBER				/(142)
/
PRECPB	2300		/ PREALLOCATE CPB.			/(142)
	EVA							/(142)
	XX		/ SET UP BY PREAL			/(142)
/
PARSIZ	27		/ PARTITION SIZE (RAISE BOUND)		/(142)
	ENDPAR							/(142)
/
SPY	31		/ SPY DIRECTIVE TO GENERATE UNIQUE	/(142)
	0		/ FILE NAMES.				/(142)
	223		/ USER NUMBER FROM SCOM.			/(142)
	0		/ RETURN VALUE.			/(142)
/
TDVER	CAL	WRTDVE	/TDV ERROR EXIT
	CAL	WFEVA	/WAIT FOR MESSAGE
	LAC	(2)	/FORCE TDV TO BE CALLED
	DAC	TDVEV
	JMP	EXIT1
/
WRTDVE	2700	/WRITE ERROR MESSAGE
	EVA	/EVENT VARIABLE ADDRESS
	TTOLUN							/(142)
	2	/IOPS ASCII
	TDVERM	/BUFFER ADDRESS
/
TDVERM	TDVEN-TDVERM/2*1000+2	/HEADER
	0
	.ASCII	/EDI-TDV ERR/<15>
TDVEN=.
/
REDPAR	37		/ XFRCMD				/(142)
	TDVEV							/(142)
	LAONCE+2						/(142)
	44							/(142)
	.ENDC							/(142)
	.IFUND RSX						/(142)
ADRTBL=.
	CWDLIT
	CWDTOP
	INLADR
	EDLADR
	EDLAD1
	RDCAL2
	RDALTB
	WRPAK2
	WRALTB
	DEB1
	CKNM1
	CKNM2
	CKNM2+1
	ADR002
	ADR002+1
	ADR003
	ADR004
	ADR004+1
	ADR005
	ADR005+1
	ADR006
	ADR006+1
	ADR008
	ADR008+1
	ADR009
	ADR010
	ADR010+1
	ADR011
	ADR011+1
	ADR013
	ADR013+1
	ADR014
	ADR014+1
	ADR015
	ADR015+1
	ADR016
	ADR016+1
	ADR017
	ADR017+1
	ADR018
	ADR018+1
ACOUNT	ADRTBL-.+1
	.ENDC							/(142)
	.LTORG
LAONCE=.-1
	.END BEGIN
