	.TITLE	EDITVP - V9 UOW
/*
/*  12 DEC 72 - CHANGE PACK & UNPACK TO FASTER ROUTINES
/*  19 AUG 71 - PAUL HENDERSON: CONVERT TO B/F AT UOW
/*
/EDITVP -- 9-11-70   EDIT-8
/COPYRIGHT 1970, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
/PDP-9/15 TEXT EDITOR, VERSION 9A.
///
///	VP STORAGE SCOPE VERSION
///
/ASSEMBLY PARAMETER ASSIGNMENTS:
/*
/*  THE ONLY PARAMETERS OF SIGNIFICANCE ARE BF, SINCE THIS VERSION
/*  HAS ALL PDP-9 CONDITIONALS EDITED OUT
/*
/   I.   PDP-9/15 BULK STORAGE SYSTEMS --
/        A.    PDP9=1 FOR PDP-9 VERSION.
/       NO OTHER PARAMETER ASSIGNMENTS ARE ALLOWED.
/  II.  PAPER TAPE SYSTEMS
/	A. PTP=1.
/       B. PDP9=1 FOR PDP-9 VERSION.
/       NO OTHER PARAMETER ASSIGNMENTS ARE ALLOWED.
/* III.	BACKGROUND/FOREGROUND SYSTEMS
/*	THE SYMBOL BF 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
/*	.IFUND	PDP9
/*	.EBREL
/*	.ENDC
/*	.IFUND .DAT
/*	.IFUND PTP
/*	.IFUND PDP9
.DAT=141
/*	.ENDC
/*	.IFDEF PDP9
/*.DAT=135
/*	.ENDC
/*	.ENDC
/*	.IFDEF PTP
/*	.IFUND PDP9
/*.DAT=136
/*	.ENDC
/*	.IFDEF PDP9
/*.DAT=135
/*	.ENDC
/*	.ENDC
/*	.ENDC
	.IFUND PTP
	.IODEV	-10,-14,-15,10	/DAT SLOT 10: VP09 DISPLAY
TTICAL=2776		/DAT SLOT -2: KEYBOARD INPUT
TTOCAL=2775		/DAT SLOT -3: TELEPRINTER OUTPUT
INPCAL=2764		/DAT SLOT -14: EDIT FILE INPUT
OUTCAL=2763		/DAT SLOT -15: EDIT FILE OUTPUT
IN2CAL=2770		/DAT SLOT -10: AUXILIARY INPUT
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.
	.ENDC
	.IFDEF PTP
	.IODEV 3,5,6,10
TTICAL=2776		/DAT SLOT -2: KEYBOARD INPUT.
TTOCAL=2775		/DAT SLOT -3: TELEPRINTER OUTPUT.
INPCAL=2003		/DAT SLOT 3: EDIT FILE INPUT.
OUTCAL=2005		/DAT SLOT 5: EDIT FILE OUTPUT.
IN2CAL=2006		/DAT SLOT 6: AUXILIARY INPUT.
OPOCAL=1005		/DAT SLOT 5: OPEN OUTPUT FILE.
OPICAL=3			/DAT SLOT 3: OPEN INPUT FILE.
DATM14=.DAT+3		/ABSOLUTE DAT 3.
DATM15=.DAT+5		/ABSOLUTE DAT 5.
	.ENDC
.SCOM=100			/SYSTEM COMMUNICATION AREA.
BUFLEN=46			/READ-WRITE LINE BUFFER SIZE.
LINSIZ=BUFLEN-2/2*5+1	/MAXIMUM CHARACTERS PER LINE.
QUESMK=77			/QUESTION MARK.
BEGIN	JMP SETBNK	/SET EPC BITS FOR CURRENT BANK.
	LAC	ALTXIT	/WAS LAST CLOSE COMMAND TERMINATED WITH ALTMODE
	SPA
	JMP	EXIT1	/YES.  RETURN TO MONITOR
	TTOCAL		/INITIALIZE TELETYPE.
ONE	1		/..
ADR001	RECOUP		/RETURN FROM CONTROL P.
LOOPCT	0		/TEMPORARY STORAGE.
POINTR=LOOPCT		/..
	DZM BUFEMP
	DZM OUTPSW	/SET OUTPUT AND
/	DZM VERISW	/VERIFY TO "ON".
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	EXIT	/ENABLE .EXIT CAL
	DAC SAVESW	/TURN OFF SAVE OPTION.
	DAC OUTSW1	/INDICATE NOTHING IN OUTPUT FILE.
	DZM RLFACT	/ZERO CURRENT RELOCATION FACTOR FOR PA AND PL.
	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.
	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.
	DZM DIRSW		/INITIAL TRANSFER DIRECTION (READ -14, WRITE -15).
	LAC TFILE1	/SET UP DEFAULT EDIT FILE NAME (.TFIL2 EDT).
	DAC INNAME	/..
	LAC TFILE1+1	/..
	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.
	LAW EDTMES
	JMS TYPOUT	/PRINT "EDITVP 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).
MOVE	JMP ILLCWD	/MOVE IS NOT IMPLEMENTED.
/TURN ON INPUT MODE.
INPUT	LAW INPTM		/TYPE CONTROL MODE NOW IN EFFECT.
	JMS TYPOUT	/"INPUT"
/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.
	CLA		/WAS CONTROL P STRUCK DURING TYPEIN?
	SAD QUIT		/SKIP IF NOT.
	JMP TTRS		/IF SO, GO RETURN CARRIAGE, CHANGE MODES.
	JMS UNPACK	/NORMAL INPUT LINE, GO UNPACK IT.
EDLAD1	TYLINE		/FROM TYLINE...
EDLADR	EDLIN		/TO EDLIN.
	SNA		/LENGTH COMES BACK IN AC.
	JMP EDIT		/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.
	DZM LENGTH	/ZERO TOTAL CHARACTERS IN CURRENT LINE.
	JMS APPEND	/THEN GO MOVE TYPED INPUT LINE TO INLINE ARRAY.
	JMP RDNPUT	/READ ANOTHER INPUT LINE.
/TURN ON EDIT MODE.
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	DZM QUIT		/INDICATE NO FILE PROCESSING GOING ON NOW.
	LAW TYLINE	/READ NEXT REQUEST FROM TELETYPE.
	JMS TYPEIN	/INPUT-LINE AREA.
	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.
	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* C12		/...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).
QUIT=CWDXCT		/QUIT .NE. 0, COMMAND PROCESSING IS IN PROGRESS.
	JMP FND4		/IN CASE TABLE ENTRY WAS A JMS.
	.EJECT
/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 'NEXT'<15>
	.ASCII 'FIND'<15>
	.ASCII 'LOCATE'<15>
	.LOC .-1
C122	122
	.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 'VERIFY'<15>
STR1=.-1
	.ASCII 'TOP'<15>
	.ASCII 'TV'<15>
	.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 'MOVE'<15>
	.ASCII 'PL'<15>
	.ASCII 'PA'<15>
	.ASCII 'CALL'<15>
	.ASCII 'FORM'<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 'ICLOSE'<15>
BUFEND=.-1
	.ASCII 'SCLOSE'<15>
FBUFSW=.-1
	.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 NEXT		/YES -- "N"
	JMP FIND		/YES -- "F"
	JMP LOCATE	/YES -- "L"
	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 VERIFY	/YES -- "V"
	JMP TOP		/YES -- "T"
	JMP TV		/NO!
	JMP BOTTOM	/YES -- "B"
	JMP BRIEF		/NO!
	JMP RETYPE	/YES -- "R"
	JMS APPEND	/YES -- "A"
	JMP KEEP		/YES -- "K"
	JMP RENEW		/NO!
	JMS READ		/NO!
	JMS WRITE		/COULD BE, BUT THIS FACT IS NOT ADVERTISED.
	JMP MOVE		/NOT IMPLEMENTED 10/25/67.
	JMP PRTLOC	/NOT ADVERTISED -- PRINT CONTENTS OF CORE LOCATION.
	JMP PATLOC	/NOT ADVERTISED -- PATCH CORE LOCATION.
	JMP CALL		/NO!
	JMP FORM		/NO!
	JMP BLOCK		/NO!
	JMP OUTPUT	/NO!
	JMP EXIT		/COULD BE, BUT NOT ADVERTISED.
	JMP OPEN		/NO!
	JMP CLOSE		/NO!
	JMP ICLOSE	/NOT ADVERTISED -- CLOSE INPUT FILE, LEAVE OUT FILE OPEN.
	JMP SCLOSE	/NOT ADVERTISED -- CLOSE LEAVING OUT FILE ON SCRATCH DEVICE.
TABEND	CAL TABEND	/13-BIT END-OF-TABLE DEFINITION.
	.EJECT
/PRINT N LINES FROM EDIT FILE.
PRINT	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.
	JMS TYPOUT	/..
PRT1	ISZ LOOPCT	/COUNT LINES TO BE PRINTED.
	SKP		/MORE TO DO.
	JMP FND4		/ALL DONE, RETURN TO COMMAND READER.
	JMS PUTLIN	/WRITE OUT THIS LINE.
	JMP FULBUF	/NO MORE ROOM.
	JMS GETLIN	/GET NEXT LINE.
	INLINE
	JMP EOF		/RETURN IF EOF ENCOUNTERED.
	JMS	TVCL	/DISPLAY NEW CURRENT LINE.
	JMP PRLIN		/GO PRINT NEW CURRENT LINE.
/DELETE N OR 1 LINES.
DELETE	JMS	TVXUT	/CROSS OUT CURRENT LINE ON DISPLAY
	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	/..
	JMS GETLIN	/GET NEXT LINE.
	INLINE		/..
	JMP EOF		/..
	LAC	DELSW	/IF CURRENT OPERATION IS DELETE
	SZA		/DO NOT
	JMS	TVCL	/DISPLAY CURRENT LINE.
	ISZ LOOPCT	/COUNT LINES CONSIDERED.
	JMP NXTLIN	/MORE LINES TO SKIP.
	LAC	DELSW	/IF CURRENT OPERATION IS 'NEXT'
	SNA		/THE CURRENT LINE HAS ALREADY
	JMS	TVCL	/BEEN DISPLAYED.
	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	/..
	JMS GETLIN	/GET NEXT LINE.
	INLINE		/..
	JMP EOF		/IF END-OF-FILE.
	JMS	TVCL	/DISPLAY CURRENT LINE.
	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
	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 TAB
	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	LAC QUIT
	SNA
	JMP TTRS
FND6	LAW 76
	JMS TYONCH
	JMP RDLIN
/COME HERE ON BUFFER OVERFLOW
FULBUF	LAW BOVFLM
	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.
	JMS GETLIN	/READ THE NEXT LINE.
	INLINE		/TO CURRENT-LINE AREA.
	JMP EOF		/END-OF-FILE RETURN.
	JMS	TVCL	/DISPLAY CURRENT LINE.
	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.
/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
/SET DISPLAY-WANTED INDICATOR.
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.
	JMS	TVST	/START OR STOP DISPLAY.
	LAC	TVSW	/IF TV WAS TURNED ON,
TV2	SZA
	JMP	FND4
	CMA		/TURN OFF VERIFY SWITCH.
	DAC	VERISW
	LAC	LENGTH	/IF THERE IS ONE,
	SZA
	JMS	TVCL	/DISPLAY THE CURRENT LINE.
	JMP FND4
/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.
	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,
	JMS	TVXUT	/CROSS OUT CURRENT LINE ON DISPLAY.
	JMS APPEND	/...THEN PERFORM A NORMAL APPEND.
	JMP FND4		/GO GET NEXT COMMAND.
/ADD SOME DATA TO THE CURRENT LINE.
APPEND	0		/APPEND IS REACHED VIA JMS.
	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.
APPND1	LAC INLADR	/GET START OF CURRENT LINE.
	ADD LENGTH	/BUMP BY TOTAL DATA CHARACTERS.
	DAC POINTR	/GIVE TO NEXT-CHARACTER INDICATOR
	LAW -2		/ENSURE THAT THIS CHAR WILL FIT.
	TAD MAXLEN	/MAXLEN=(LINSIZ.
	CMA
	TAD LENGTH
	SPA!CLA!CMA	/AC POSITIVE IF LENGTH .GE. MAXLEN-1.
	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	.+3	/YES, RETURN TO CALLER.
	ISZ LENGTH	/NO, BUMP TOTAL CHARACTERS.
	JMP APPND1	/GO GET ANOTHER CHARACTER.
	JMS	TVCL	/DISPLAY CURRENT LINE.
	JMP*	APPEND	/RETURN.
/REPLACE STRING 1 WITH STRING 2.
CHANGE	DZM LOOPCT
	JMS NXTCHR	/GET NEXT CHARACTER FROM COMMAND LINE.
	JMP FND3		/NO MORE CHARACTERS, IGNORE CHANGE REQUEST.
	DAC QUOTE		/USE AS QUOTE CHARACTER.
	LAC NXTPTR	/GET POINTER TO NEXT CHARACTER.
	DAC CHSCN1	/USE AS ARG1 TO SCAN.
CHLP1	JMS NXTCHR	/GET NEXT CHARACTER IN STRING 1.
	JMP FND3		/NO MORE CHARACTERS, NO CHANGE POSSIBLE.
	SAD QUOTE		/SECOND APPEARANCE OF QUOTE CHARACTER?
	JMP CHGE1		/YES, ENTER SEARCH LOOP FOR STRING 1.
	ISZ LOOPCT	/NO, COUNT ANOTHER CHARACTER IN STRING 1.
	JMP CHLP1		/GO CHECK MORE CHARS FOR QUOTE.
CHGE1	LAC CHSCN1
	ADD LOOPCT
	DAC STR1
	CLA!CMA
	DAC* STR1
	LAC INLADR
	DAC CHSCN2
CHSCN	JMS SCAN
CHSCN1	0
CHSCN2	0
	JMP RESCAN
	SKP!CLA!CMA
	JMP FND3
	TAD LOOPCT
	CMA
	TAD STR2
	DAC STR1
	LAC EDLAD1
	DAC POINTR
CHLP2	LAC* STR2
	DAC* POINTR
	ISZ STR2
	ISZ POINTR
	SMA
	JMP CHLP2
CHLP3	JMS NXTCHR
	JMP CHDON
	SAD QUOTE
	JMP CHDON
	DAC* STR1
	ISZ STR1
	JMP CHLP3
CHDON	LAC EDLAD1
	DAC STR2
	LAC STR1
	DAC APPEND
CHLP4	LAC* STR2
	DAC* STR1
	ISZ STR2
	ISZ STR1
	SMA!CLA!CMA
	JMP CHLP4
	XOR INLADR	/FORM 1'S COMPLEMENT OF START ADDRESS OF LINE.
	TAD STR1		/LESS ADDRESS+1 OF LAST CHARACTER IN LINE.
	DAC LENGTH	/GIVES NEW TOTAL DATA CHARACTERS.
	LAC* APPEND
	DAC LOC2
	LAC BRFSW
	SMA!CLA!CMA
	DAC* APPEND
	JMS	TVXUT	/CROSS OUT CURRENT LINE ON DISPLAY.
	JMS	TVCL	/DISPLAY NEW CURRENT LINE.
	JMP FND5
RESCAN	ISZ CHSCN2
	JMP CHSCN
/SET N LINES IN BLOCK BUFFER.
SIZE	JMS GETNUM	/GET DECIMAL ARGUMENT.
	SAD FENCE		/-1?
	JMP ILLCWD	/ILLEGAL IF SO.
	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.
	JMS	TVXUT	/CROSS OUT CURRENT LINE ON DISPLAY.
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.
/PRINT CONTENTS OF SPECIFIED CORE LOCATION.
PRTLOC	JMS GETOCT	/GET ADDRESS OF LOCATION TO DUMP.
	ADD RLFACT	/ADD RELOCATION FACTOR.
	DAC OCTNUM	/SAVE AS POINTER.
	LAW -6		/SET UP TO PRINT SIX CHARACTERS.
	DAC LOOPCT	/..
	LAC* OCTNUM	/GET CELL TO DUMP.
	DAC OCTNUM	/AND SAVE.
PRTLP1	LAC OCTNUM	/GET NEXT DIGIT, PICK UP CURRENT NUMBER.
	RTL		/..
	RAL
	DAC OCTNUM	/SAVE NEXT NUMBER.
	RAL		/GET THIRD BIT.
	AND C7		/MASK OFF JUNK.
	ADD C60		/INSERT ZONE BITS.
	JMS TYONCH	/GO TYPE THIS DIGIT.
	ISZ LOOPCT	/COUNT SIX CHARACTERS TYPED.
	JMP PRTLP1	/MORE TO DO, GET NEXT DIGIT.
	JMS TYPRTN	/ALL DONE, GO RETURN CARRIAGE.
	JMP FND6		/THEN RETURN TO MAIN LINE.
/PATCH SPECIFIED CORE LOCATION.
PATLOC	JMS GETOCT	/GET ADDRESS OF LOCATION TO PATCH.
	ADD RLFACT	/PLUS RELOCATION FACTOR.
	DAC POINTR	/SAVE ABSOLUTE ADDRESS.
	JMS GETOCT	/THEN GET NEW CONTENTS.
	DAC* POINTR	/PATCH CELL SPECIFIED.
	JMP FND6		/AND RETURN.
/SERVICE CALL REQUEST.
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!CLA!CMA
	JMP CDEL1
	JMS PK6BT
	CWD
	CALDB1+2
CDEL1	LAC CALLDB
	ADD CALDAT
	DAC CDEL2+1
CDEL2	JMS DELFIL
	0
	JMP IOSET
/CALL RENAME..
CREN	JMS GETDAT
	JMS GETCOM
	SNA
	JMP ILLCWD
	LAW -2
	JMS PK6BT
	CWD
	CALDB1
	JMS GETCOM
	SNA!CLA!CMA
	JMP ILLCWD
	JMS PK6BT
	CWD
	CALDB1+2
	JMS GETCOM
	SNA
	JMP ILLCWD
	LAW -2
	JMS PK6BT
	CWD
	CALDB2
	LAC CALDB1+2
	DAC CALDB2+2
	JMS GETCOM
	SNA!CLA!CMA
	JMP CREN2
	JMS PK6BT
	CWD
	CALDB2+2
CREN2	LAC CALLDB
	ADD CALDAT
	DAC CREN1
	JMS RENAME
CREN1	0
	CALDB2
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
/PRODUCE A FORM FEED ON PAPER TAPE TO KEEP THE PDP7
/EDITOR HAPPY.
FORM	LAC OUTDEV
	SMA
	JMP FND6
	OUTCAL
	11		/WRITE
FEED	FORMFD
	-4
	JMP FND4
FORMFD	002002
BLANK	40		/CHECKSUM -- IGNORED BY PUNCH HANDLER.
BNKMSK	.ASCII <14>
RECOUP=.
	.IFDEF	BF
	DAC	SAVEAC	/SAVE AC
	.ENDC
	LAC QUIT
	SNA
	JMP BEGIN
	DZM QUIT
	.IFUND	BF
	LAC* SCOM16	/RESTORE LINK.
	.ENDC
	.IFDEF	BF
	LAC*	SCOM10	/RESTORE LINK
	.ENDC
	DAC QRETN		/SAVE RETURN.
	RAL		/..
	.IFUND	BF
	LAC* SCOM17	/RESTORE AC.
	.ENDC
	.IFDEF	BF
	LAC	SAVEAC	/RESTORE AC
	.ENDC
	JMP* QRETN	/REENTER INTERRUPTED SEGMENT.
	.IFDEF	BF
SAVEAC	0
	.ENDC
TTRS	JMS TYPRTN
	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.
	DAC	EXIT	/AND ALSO EXIT
	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	/INHIBIT CALL OF .EXIT CAL
	DAC	EXIT
	DAC	OPEN	/ALSO SHUT OFF OPEN AND
	DAC	CALL	/CALL COMMANDS
	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.
	LAC* INPDAT	/SEE IF SAME UNIT AND DEVICE FOR -14 AND -15.
	XOR* OUTDAT	/..
	SNA		/SKIP IF NOT SAME UNIT.
	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.
	LAW -2		/PACK 2-WORD FILE NAME.
	JMS PK6BT		/..
	CWD		/FILE NAME IS IN CWD.
SVADR	SAVNAM		/PUT IT IN SAVNAM.
	LAC SRCNAM	/GET DEFAULT EXTENSION.
	DAC SAVNAM+2	/SAVE IN DIRECTORY ENTRY.
	JMS GETCOM	/THEN GO SEE IF AN EXTENSION WAS TYPED, TOO.
	SNA!CLA!CMA	/SKIP IF AN EXTENSION IS THERE.
	JMP SETSAV	/NO EXTENSION.
	JMS PK6BT		/PACK A ONE-WORD EXTENSION.
	CWD		/TYPED EXTENSION IS IN CWD.
	SAVNAM+2		/EXTENSION WORD IN DEB.
SETSAV	DZM SAVESW	/INDICATE A SAVE IS WANTED.
	JMP FND6		/THEN REENTER MAIN LINE.
/CLOSE INPUT FILE ONLY.
ICLOSE	CLA		/INDICATE CURRENT INPUT DAT SLOT IS TO BE REFERENCED.
	DAC	ICLSW	/SET ICLOSE SWITCH
	JMS CLSFIL	/GO CLOSE THE INPUT FILE.
	LAC NOPLIT	/GET A NOP CODE.
	DAC OPEN		/ALLOW ENTRY TO "OPEN" SEQUENCE.
	DAC RDFNOP	/AND SET UP TO FILL BOTH INPUT BUFFERS ON NEXT READ.
	DAC NAMSW		/INDICATE NO FILE NAME HAS BEEN PROVIDED.
	LAC INDEV		/IS INPUT DEVICE FILE-STRUCTURED?
	SPA!CMA		/INDEV .G. 0, YES; SET AC NEGATIVE.
	CLA		/INDEV .L. 0, NO; SET AC POSITIVE.
	DAC INFILE	/INFILE NEGATIVE MEANS NO INPUT FILE PRESENT.
	JMP FND4		/GO READ NEXT COMMAND.
SCLOSE	LAW -1
	DAC DIRSW
CLOSE	LAC	TOTCHR
	TAD	(EDLIN	/POINT TO LINE TERMINATOR
	DAC	ALTXIT
	LAC*	ALTXIT	/GET LINE TERMINATOR
	SAD	ALTMOD	/IS IT ALT MODE?
	DAC	ALTXIT	/SET -VE IF LINE TERMINATOR WAS ALT MODE
	LAC OUTDEV
	SMA
	JMP CLOSE2
JMSCLS	JMS CLSOUT
	JMP BEGIN
CLOSE2	JMS GETCOM
	DZM NAMSW1
	SZA!CLA		/SKIP IF NO NAME TYPED IN CLOSE REQUEST.
	JMP NAMEIN	/A NAME WAS TYPED.
	SAD NAMSW		/SKIP IF NO NAME GIVEN IN OPEN REQUEST.
	JMP CLOSE1	/AT LEAST ONE NAME HAS BEEN PROVIDED.
	LAW NOFLNM
	JMS TYPOUT
	JMP FND4
NAMEIN	LAW -2		/PACK TWO WORDS...
	JMS PK6BT		/...IN SIX-BIT FORMAT.
	CWD		/FROM CWD.
	NEWNAM		/TO NEWNAM.
	LAC SRCNAM	/GET "SRC".
	DAC NEWNAM+2	/USE AS DEFAULT EXTENSION.
	DAC NAMSW1	/INDICATE A NAME WAS GIVEN IN THIS CLOSE REQUEST.
	JMS GETCOM	/SEE IF AN EXTENSION WAS TYPED.
	SNA!CLA!CMA	/SKIP IF AN EXTENSION WAS IN FACT TYPED.
	JMP CLOSE1	/NO EXTENSION, USE "SRC".
	JMS PK6BT		/EXTENSION GIVEN, GO PACK IT UP (AC = 777777 NOW).
	CWD		/EXTENSION IS IN CWD.
	NEWNAM+2		/PUT IT IN DEB.
CLOSE1	JMS CLSOUT
	LAC INDEV
	SPA
	JMP GETNM2
	LAC* INPDAT
	XOR* OUTDAT
	SNA
	JMP GETNM2
	LAC DIRSW
	SMA
	JMP GETNM2
	JMS SEEK
	INNAME
	JMP CLOSE1
GETNM2	LAC NAMSW1
	SNA
	JMP BEGIN
CKNAM	LAC INDEV
	RAL
	LAC CKNM1
	AND CL0777
	SZL
	ADD XCTZRO
	DAC CKNM1
	LAC CKNM2
	AND CL0777
	SZL
	ADD XCTZRO
	DAC CKNM2
	LAC NAMSW
	SNA!CLA!CMA
	JMP CKNM3
CKNM0	JMS FSTAT
CKNM1	NEWNAM
	SZA
	JMP NMERR2
RNM2	JMS RENAME
CKNM2	INNAME
	NEWNAM
	JMP BEGIN
NMERR2	LAW BADNAM
	JMS TYPOUT
	LAC NOPLIT
	DAC CLOSE1
	JMP FND4
/NAMES GIVEN BOTH IN OPEN AND CLOSE REQUESTS. FIND OUT IF TWO
/NAMES ARE IDENTICAL. IF SO, ACCEPT CLOSE REQUEST.
CKNM3	TAD CKNM1
	DAC* C12
	CLA!CMA
	TAD CKNM2
	DAC* C15
	LAW -3
	DAC WRITE
CKNM4	LAC* 12
	SAD* 15
	SKP
	JMP CKNM0
	ISZ WRITE
	JMP CKNM4
	JMP BEGIN
NEWNAM	.BLOCK 3
/SERVICE TOP COMMAND.
TOP	LAC PBLKSW
	SZA
	JMP TOPFIL
	JMS RSBUFF
	JMS CHBUFF
	JMP FND4
TOPFIL	LAC FILSTR
	SPA
	JMP ILLCWD
	LAC RDFNOP
	SAD RDFJMP
	JMP TOPFL1
	AND OUTSW1
	SPA
	JMP FND4
TOPFL1	JMS CLSOUT
	JMS SEEK
	INNAME
	JMP FND4
	.EJECT
/MOVE POINTER TO LAST LINE OF FILE OR BUFFER.
BOTTOM	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
	JMP BOTTOM
/READ SOME LINES FROM SUBSIDIARY DEVICE.
GET	JMS GETNUM
	DAC LOOPCT
SBREAD	IN2CAL
	10
SBADR	SBUFF
	-BUFLEN
	IN2CAL
	12
	LAC SBUFF
	AND C7
	SAD C5
	SKP
	SAD C6
	JMP GETEOF
	JMS PUTLIN
	JMP FULBUF
	JMS UNPACK
ADR008	SBUFF
	INLINE
	DAC LENGTH
	JMS	TVCL	/DISPLAY NEW CURRENT LINE.
	ISZ LOOPCT
	JMP SBREAD
	JMP FND4
GETEOF	LAW EOMRM
	JMS TYPOUT
	JMP EOFCOM
SBUFF	.BLOCK BUFLEN
/SERVICE RENEW REQUEST.
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.
	.EJECT
/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
/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
	.EJECT
/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.
/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.
	LAC	TVSW	/SAVE PRESENT STATUS OF TV SWITCH.
	DAC	TVCL
	SZA		/IF IT WAS ON,
	JMP	TVOFF
	LAW	-1	/TURN OFF
	DAC	TVSW	/THE DISPLAY SWITCH
	JMS	TVST	/AND THE DISPLAY.
TVOFF	LAC	TVCL	/THEN RESET THE
	DAC	TVSW	/DISPLAY SWITCH.
	JMP* CHBUFF	/RETURN TO CALLER.
C5	5
C777	777
C175	175
BFPTSW	0
	.EJECT
/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.
	JMS GETBNK	/INSERT BANK BITS.
	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	/..
INPTCL	INPCAL		/ISSUE READ.
	10
RDCAL2	RDBUF2		/MODIFIED AT EACH CALL.
	-BUFLEN
RDFNOP	NOP		/MODIFIED AFTER FIRST TIME THROUGH.
	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 C6		/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
	.EJECT
/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.
	DAC	TVWRFL	/ADD TO DISPLAY BUFFERS.
	LAC RDFILE	/NOW GET THE FIRST BUFFER AGAIN.
	DAC WRALTB	/AND SAVE AS ALT BUFFER FOR NEXT TIME.
	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.
	JMS	TVVP	/ADD A LINE TO THE DISPLAY RING BUFFERS.
TVWRFL	0		/THIS LINE.
	LAC OUTSW1
	SNA
	JMP OUTPCL
	JMS ENTER
	TFILE1
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.
	DZM OUTSW1	/INDICATE SOMETHING WRITTEN INTO OUTPUT FILE.
	JMP* WRFILE	/NO WAIT REQUIRED AFTER WRITING.
WRALTB	WRBUF1		/MODIFIED EACH TIME TO POINT TO "OTHER" BUFFER.
EDLIN	.BLOCK LINSIZ	/CURRENT COMMAND STRING ARRAY.
INLINE	.BLOCK LINSIZ	/CURRENT INPUT LINE FROM FILE OR KEYBOARD.
WRBUF1	.BLOCK	BUFLEN
	.EJECT
TYLINE	.BLOCK	133
/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
RDBUF1	.BLOCK BUFLEN	/READ BUFFERS.
RDBUF2	.BLOCK .-RDBUF1	/..
WRBUF2	.BLOCK BUFLEN
/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
	.EJECT
/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
	JMS GETBNK
	DAC STR1
	ISZ SCAN
	LAC* SCAN
	JMS GETBNK
	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
	.EJECT
/SUBROUTINE PUTLIN, INSERT A LINE EITHER IN THE CURRENT OUT BUFFER
/OR IN THE OUTPUT FILE ITSELF.
/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.
	.EJECT
PKCAL	JMS PACK
ADR009	INLINE
NXTPUT	0		/WHERE TO BEGIN WRITING NEXT LINE.
	LAC	NXTPUT	/GET ADDRESS OF
	DAC	.+2
	JMS	TVVP	/A LINE TO ADD TO THE DISPLAY RING BUFFERS.
	0
	LAC NXTPUT
	SAD CURPUT
	SKP
	DAC* CURPUT
	ADD ONE
	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
	.EJECT
/GETLIN, RETURN NEXT LINE FROM CURRENT BUFFER OR FROM INPUT FILE.
/CALL:	JMS GETLIN
/	.DSA BUFF
/	RETURN IF NO MORE LINES TO GET.
/	NORMAL RETURN
GETLIN	0
	LAC QUIT
	SNA
	JMP TTRS
	LAC* GETLIN	/GET LINE ADDRESS.
	JMS GETBNK	/INSERT HIGH-ORDER BITS.
	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 ERRSW
	SAD C60
	JMP TYTRN
	SNA
	JMP EMPBUF-1
TYPAR	LAW PRTYMS
	JMS TYPOUT
	JMP FND3
TYTRN	LAW TRNMES
	JMS TYPOUT
	JMP FND3
	.EJECT
/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 6 (LOCATIONS 12 AND 15)
/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		/PK6BT: POINTER TO NEXT CHARACTER IN INPUT ARRAY.
PACKTO=UNPACK		/PACK: POINTER TO OUTPUT ASCII ARRAY
	LAC* UNPACK	/GET ADDRESS OF INPUT LINE.
	DAC* C12		/SAVE AS INPUT POINTER (IN LOC 12).
	ISZ* C12		/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* C15		/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.
	LAC	(UNFRT		/INITIALIZE G.UNPK ROUTINE
	DAC	HINGE
/
/  NOW ENTER LOOP TO EXTRACT THE CHARACTERS, ONE BY ONE, AUTOMATICALLY
/  INCREMENTING THROUGH THE WORD PAIRS.
/
UNPLP1	JMS	G.UNPK		/UNPACK ONE CHARACTER
	SNA		/ACCEPT ONLY IF NON-NULL.
	JMP UNPLP1	/NULL CHARACTER, IGNORE.
	SAD C12		/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* 15		/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.
	ADD ONE		/WILL WE OVERFLOW NEXT TIME?
	SAD MAXLEN	/SKIP IF NOT.
	JMP UNPOFL	/OTHERWISE, STOP NOW.
	JMP	UNPLP1		/GET NEXT CHARACTER
UNPOFL	LAC C15		/TOO MANY CHARS, GET CARRIAGE RETURN.
UNPCR	CMA		/LINE FINISHED, GET TERMINATOR.
	DAC* 15		/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. HAVE WE SEEN ANY BEFORE?
	SNA		/SKIP IF NOT.
	JMP UNPLP1	/YES, SO TREAT AS NORMAL DATA CHARACTER.
	LAC C12		/NO, SET TO ACCEPT LATER ONES.
	JMP UNPDAC	/THEN GO IGNORE THIS ONE.
  
/  SUBROUTINE G.UNPK:  MUST BE INITIALIZED SO THAT 'HINGE' POINTS
/  TO 'UNFRT'.  SUBROUTINE USES AUTO-INDEX REGISTER 12 WHICH MUST
/  BE INITIALIZED TO POINT TO INPUT 5/7 ASCII.
/  *** NOTE ***: THE MQ MUST REMAIN UNCHANGED BETWEEN CALLS
/
G.UNPK	XX
WORDCT=G.UNPK			/PACK: WORD COUNT OF # OF PACKED 5/7 WORDS
	JMP*	HINGE		/RETURN TO LAST PROCESSING POINT
HINGE	UNFRT
	AND	(177		/TRIM TO 7 BITS
	JMP*	G.UNPK
/
UNFRT	LAC*	12		/FETCH 1ST WORD OF NEXT WORD PAIR
	DAC	OBJECT		/SAVE IT
	LMQ
	LAC*	12		/FETCH 2ND WORD AT THIS TIME BECAUSE WE MUST
	DAC	PWRD2		/USE AUTO-INDEX REGISTER IN 2'S
	LLS	7		/EXTRACT 1ST CHARACTER
	JMS	HINGE
/
	LLS	7		/ 2ND CHARACTER
	JMS	HINGE
/
	LAC	PWRD2		/RETRIEVE 2ND WORD OF PAIR
	LMQ
	LAC	OBJECT		/RETRIEVE 1ST WORD
	LLS	3		/EXTRACT 3RD CHARACTER
	JMS	HINGE
/
	LLS	7		/ 4TH CHARACTER
	JMS	HINGE
/
	LLS	7		/ 5TH CHARACTER
	JMS	HINGE
	JMP	UNFRT		/BEGIN ON NEXT WORD PAIR
/
/  SUBROUTINE G.PACK:  MUST BE INITIALIZED SO THAT 'SWING' POINTS
/  TO 'LEFT' ON THE FIRST CALL. WORDCT MUST BE ZEROED INITIALLY.
/  *** NOTE ***: G.PACK CLEARS THE MQ
/
G.PACK	XX
OBJECT=G.PACK			/TEMPORARY STORAGE FOR 'G.UNPK'
	CLQ!020000		/ CLQ!CLL
	JMP*	SWING		/RETURN TO LAST PROCESSING POINT
SWING	LEFT
	XOR*	PACKTO		/INCORPORATE THIS CHARACTER WITH
	DAC*	PACKTO		/PREVIOUS ONES (IF ANY)
	JMP*	G.PACK
/
LEFT	ISZ	WORDCT		/COUNT NUMBER OF WORDS PACKED
	RTR; RTR; RTR; RTR	/SHIFT TO AC 0-6 (1ST CHARACTER)
	DZM*	PACKTO		/CLEAR 1ST WORD OF PAIR
	JMS	SWING
/
	RTL; RTL		/SHIFT TO AC 7-13 (2ND CHAR)
	JMS	SWING
/
	LRS	3		/MOVE TO AC 14-17 & MQ 0-3
	XOR*	PACKTO
	DAC*	PACKTO		/PUT OUT FINAL PART OF 1ST WORD OF PAIR
	ISZ	PACKTO		/POINT TO 2ND WORD OF PAIR
	ISZ	WORDCT		/COUNT NUMBER OF WORDS
	DZM*	PACKTO		/CLEAR 2ND WORD
	LACQ			/MOVE BITS TO AC 0-3 (3RD CHAR)
	JMS	SWING
/
	RTL; RTL; RTL; RTL	/MOVE TO AC 3-9 (4TH CHAR)
	JMS	SWING
/
	RAL			/SHIFT TO AC 10-16 (5TH CHAR)
	JMS	SWING
	ISZ	PACKTO		/POINT TO 1ST WORD OF NEXT PAIR
	JMP	LEFT
/
/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
/INPUT 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.
	LAW	-1
	TAD* PACK		/PICK UP START OF INPUT ARRAY.
	DAC*	C12		/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.
	TAD	(2		/AND ALSO IN OUTPUT POINTER.
	DAC	PACKTO
	LAC	(LEFT		/INITIALIZE G.PACK ROUTINE
	DAC	SWING
	DZM	WORDCT		/INITIALIZE WORD COUNTER
	ISZ PACK		/BUMP TO RETURN.
/  GET NEXT CHARACTER FROM INPUT LINE, CHECK FOR
/  COMPLETION, AND INSERT IN CURRENT PAIR.
PLOOP1	LAC*	12	/GET NEXT CHARACTER FROM INPUT ARRAY.
	SPA		/TERMINATOR? (NEGATIVE IF SO.)
	JMP PCLOSE	/YES, GO TRY TO CLOSE THE OUTPUT LINE.
	JMS	G.PACK		/PACK IT UP
	JMP	PLOOP1
/COME HERE ON TERMINATOR FOUND IN INPUT ARRAY.
PCLOSE	CMA			/INVERT TERMINATOR.
	SNA		/IS IT NOW A NULL CHARACTER?
	LAC C15		/IF SO, GET CARRIAGE RETURN.
PKNULL	JMS	G.PACK	/GO PUT CARRIAGE RETURN OR ALT MODE AWAY.
/COME HERE TO PAD WORD-PAIR WITH NULLS AFTER TERMINATING CHARACTER
/HAS BEEN INSERTED.
	LAC	WORDCT		/IS WORD COUNT ODD OR EVEN?
	RAR
	SZL!CLA
	JMP	PKNULL		/PACK WITH NULLS UNTIL WORD COUNT IS EVEN
	LAC	WORDCT
	TAD	(2		/DON'T FORGET THE HEADER WORDS
	ALSS	10		/GENERATE HEADER
	XOR	(2
	DAC* PLBH		/RESTORE HEADER IN LINE BUFFER AREA.
	JMP* PACK		/ALL DONE, EXIT.
  
/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.
	JMS GETBNK	/MAKE IT A 15-BIT ADDRESS.
	DAC PKFROM	/GIVE TO INPUT POINTER.
	ISZ PK6BT		/BUMP TO OUTPUT ADDRESS.
	LAC* PK6BT	/GET START OF OUTPUT ARRAY.
	JMS GETBNK	/MAKE IT 15 BITS LONG ALSO.
	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
	.EJECT
/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
	AND C777
	ADD C1000
	DAC ENTCAL
	LAC* ENTER
	JMS GETBNK
	DAC ENTCAL+2
	ISZ ENTER
ENTCAL	0
	4
	0
	JMP* ENTER
/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 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* C15
RNMLP1	LAW -3
	DAC RNMWRD
	CLA!CMA
	TAD* RENAME
	ISZ RENAME
	JMS GETBNK
	DAC* C12
RNMLP2	LAC* 12
	DAC* 15
	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
/SUBROUTINE CLSOUT, CLOSE INPUT AND OUTPUT FILES.
CLSOUT	0
	JMS PUTLIN
	JMP FULBUF
	LAW -1
	DAC BLOKSW
	JMS RSBUFF
	LAC PBLKSW
	SZA
	JMP CLS01
	JMS CHBUFF
	LAW -1
	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		/..
	JMS GETLIN
	INLINE
	SKP!CLA
	JMP CLS01B	/MORE TO DO, GO WRITE THIS LINE.
	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.
	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	JMS FSTAT
	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 OUTPCL-1	/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.
	LAC* INPDAT	/FILES ON SAME UNIT AND DEVICE?
	XOR* OUTDAT	/..
	SNA		/SKIP IF FILES ON DIFFERENT UNITS OR DEVICES.
	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 ONE
	JMS TYONCH
	LAW NUFIL2
	JMS TYPOUT
	LAC CLSENT
	JMS TYNAME
	JMS TYPRTN
	LAW OLDEL
	JMS TYPOUT
	JMP BEGIN
SAVERR	JMS RENAME
	INNAME
	SAVNM2
	LAW SAVNAM
	JMS TYNAME
	LAW TWOFL1
	JMS TYPOUT
	LAW SVNMES
	JMS TYPOUT
	JMP CLS03
EMPFIL	LAW EMPFLM
	JMS TYPOUT
	JMP BEGIN		/START AGAIN.
SAVNAM	.BLOCK 3
SAVNM2	.SIXBT 'SAVFILEDT'
/COMMON EXIT ROUTINE.
EXIT	NOP		/ASSEMBLE NOP FOR ALL SYSTEMS.
/	.IFUND BULKST
/	.LOC EXIT
/	JMP ILLCWD	/IF PAPER TAPE SYSTEM, DON'T ALLOW EXIT.
/	.ENDC
EXIT1	CAL
C15	15
ALTXIT
	.EJECT
/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		/INSERT 15-BIT ADDRESS IN CAL SEQUENCE.
	TTOCAL		/IOPS MODE WRITE TO TTY.
TAB	11		/..
TTOUT	0		/START OF LINE BUFFER.
SRCNAM	.SIXBT 'SRC'	/WORD COUNT -- IGNORED BY TELETYPE HANDLER.
	TTOCAL		/WAIT FOR PRINTING TO FINISH.
C12	12		/..
	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 GETBNK	/INSERT EXTENDED-MEMORY BITS.
	DAC TTIN		/GIVE TRUE (15-BIT) ADDRESS TO CAL SEQUENCE.
	TTICAL		/ISSUE CAL.
	10		/READ.
TTIN	0		/ADDRESS OF LINE BUFFER.
	-BUFLEN		/DON'T OVERFLOW BUFFER.
	TTICAL		/WAIT FOR USER TO FINISH.
	12		/..
	JMP* TYPEIN	/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.
STARSW=TYNAME			/GETOCT: INDIRECTION-WANTED INDICATOR.
	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.
	TTOCAL+1000	/IMAGE MODE WRITE TO TTY.
	11		/..
ADR000	CHRMS		/ADDRESS OF OUTPUT MESSAGE.
CHRCT	0		/WORD COUNT -- IGNORED BY TELETYPE HANDLER.
	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.
  
/SUBROUTINE TYPRTN, PRODUCE CARRIAGE-RETURN AND LINE-FEED ON TELETYPE.
/CALL:	JMS TYPRTN
TYPRTN	0		/ENTRY TO TYPRTN.
OCTNUM=TYPRTN		/GETOCT: RESULTS REGISTER.
	TTOCAL		/OUTPUT CAL TO TELETYPE HANDLER.
C6	6		/.CLOSE WILL GENERATE CR/LF.
	JMP* TYPRTN	/RETURN TO CALLER.
	.EJECT
/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.
GETBNK	0		/ENTRY TO GETBNK.
CWCHRC=GETBNK		/GETCOM: MAXIMUM CHARACTERS POSSIBLE IN LEGAL COMMAND WORD.
	AND ADRMSK	/EXTRACT 13-BIT ADDRESS FROM AC. (ADRMSK=017777)
	DAC GBADR		/SAVE TEMPORARILY.
	LAC GETBNK	/GET ENTRY.
	AND BNKMSK	/EXTRACT EPC BITS. (BNKMSK=060000)
	ADD GBADR		/NOW RETRIEVE 13-BIT ADDRESS.
	JMP* GETBNK	/EXIT WITH 15-BIT ADDRESS IN AC.
	.EJECT
/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
/INITIALIZE AND RESET DISPLAY.
TVST10	.INIT	TVDAT,1,0		/INIT DISPLAY
	DZM	TVLCT		/RESET COUNT OF DISPLAYED LINES
	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	LAC*	TVCPTR		/GET BUFFER POINTER.
	SNA
	JMP*	TVST		/NO MORE LINES IF 0, RETURN.
	DAC	TVTEMP
	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
	ISZ	TVLCT		/INCREMENT LINE COUNT.
	LAC	TVTEMP		/RESET POINTER
	DAC	TVCPTR		/TO NEXT BUFFER.
	ISZ	TVCNT		/CHECK BUFFER COUNT.
	JMP	TVST12		/RECYCLE.
	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
	JMS	PACK		/SACK INTO IOPS ASCII
	INLINE			/FROM (CURRENT LINE)
	TYLINE			/TO
/DISPLAY IS RUNNING,ADD THE LINE TO IT.
	LAW	-40		/CHECK IF SCREEN IS FULL (32 LINES)
	TAD	TVLCT
	SMA
	JMS	TVST		/FULL SCREEN,GO RESTART DISPLAY.
	ISZ	TVLCT		/INCREMENT LINE COUNT.
	.WRITE	TVDAT,2,TYLINE,0	/WRITE THE LINE.
	.WAIT	TVDAT	/WAIT TO AVOID CATCHING UP WITH DISPLAY.
	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.
/
/
/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 ACTION
	.WRITE	TVDAT,2,TVNOLF,0
	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.
	.WRITE	TVDAT,2,TVDASH,0	/CROSS OUT LINE.
	JMP*	TVXUT		/RETURN
/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
TVLCT				/LINES ON THE SCREEN
TVON	-1			/DISPLAY ON INDICATOR
TVLF=22				/VP09 LINE FEED, RASTER UNITS
TVDAT=10				/VP09 .DAT SLOT
TVNOLF	TVNO-.*400+2
	0
	.ASCII	<20><35><175>
TVNO=.
TVDASH	TVDEND-.*400+2
TVTEMP	0			/TEMPORARY STORE
	.ASCII	'----------------------------------------'
	.ASCII	'------------------------------'<15>
TVDEND=.
	.EJECT
/MESSAGES OUT.
EDTMES	ENDED1-.*400+2
BUFSIZ	-67	/LINES PER BLOCK MODE BUFFER LOAD (INITALLY 55(10)).
	.IFUND	BF
	.ASCII ' EDITVP V9UOW'<15>
	.ENDC
	.IFDEF	BF
	.ASCII	' EDITVP BF9UOW'<15>
	.ENDC
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
	.IFUND	BF
SCOM16	.SCOM+16
	.ENDC
	.IFDEF	BF
SCOM10	.SCOM+10
	.ENDC
	.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
RLFACT	0	/RELOCATION AUGMENT FOR PA AND PL.
	.ASCII 'TOP REQUEST NEEDED.'<15>
ENDTRQ=.
TWOFIL	ENDTF-.*400+2
GBADR	0
	.ASCII 'IS PRESENT ON OUTPUT DEVICE.'<15>
ENDTF=.
TWOFL0	ENDTF0-.*400+2
STAR	52	/GETOCT: ASTERISK.
	.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 USE 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
	0
	.ASCII 'READ ERROR:'<15>
	.LOC .-1
ADRMSK	17777
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
	0
	.ASCII 'YOUR EDITED FILE IS ON .DAT -1'<175>
ENDNF1=.
OLDEL	ENDOLD-.*400+2
	0
	.ASCII 'ORIGINAL FILE DELETED.'<15>
ENDOLD=.
NUFIL2	ENDNF2-.*400+2
	0
	.ASCII ' AS '<175>
ENDNF2=.
SVNMES	ENDSVM-.*400+2
SLASH	57	/SLASH (/) FOR BRIEF MODE SERVICER.
	.ASCII 'DATA PRESERVED IN SAVFIL EDT.'<15>
ENDSVM=.
TFILE1	.SIXBT '.TFIL1'
EDNAM	.SIXBT 'EDT'
EDTM	002002
LENGTH	0	/TOTAL DATA CHARACTERS IN CURRENT LINE.
	.ASCII 'EDIT'<15>
/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.
	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 100.
	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 ONE		/IF BNUM .G. 0, FORM 2'S COMPLEMENT.
	JMP* GETNUM	/RETURN TO CALLER WITH RESULT IN AC.
/SUBROUTINE GETOCT, RETURN BINARY VALUE OF OCTAL ARGUMENT IN CONTROL WORD
/STRING. BINARY NUMBER IS RETURNED IN AC.
GETOCT	0		/ENTRY TO GETOCT.
	DZM OCTNUM	/ZERO RESULTS REGISTER.
	DZM STARSW	/ZERO INDIRECT INDICATOR.
GETOC1	JMS GETCOM	/MOVE ARGUMENT TO CWD.
	LAC CWD		/GET ARGUMENT.
	SAD STAR		/IS IT AN ASTERISK?
	SKP		/YES, SKIP.
	JMP GETOC2	/NO, ARGUMENT IS DIRECT ADDRESS.
	DAC STARSW	/INDIRECTION WANTED, SO INDICATE.
	JMP GETOC1	/THEN GET THE NEXT STRING.
GETOC2	LAC CWDLIT	/GET START OF CWD ARRAY.
	DAC NUMPTR	/USE AS INPUT POINTER.
GETOC3	LAC* NUMPTR	/GET NEXT DIGIT.
	SPA		/SKIP IF NOT TERMINATOR.
	JMP GETOCR	/TERMINATOR, GO TO RETURN.
	AND C7		/DATA CHARACTER, EXTRACT NUMERICS.
	DAC* NUMPTR	/AND SAVE.
	LAC OCTNUM	/GET RESULTS SO FAR.
	CLL!RAL		/MAKE ROOM FOR THIS DIGIT.
	RTL		/..
	ADD* NUMPTR	/AND INSERT IT.
	DAC OCTNUM	/SAVE NEW RESULT.
	ISZ NUMPTR	/BUMP INPUT POINTER.
	JMP GETOC3	/AND GO FOR NEXT DIGIT.
GETOCR	LAC STARSW	/ALL DONE, WAS INDIRECTION WANTED?
	SZA		/SKIP IF NOT.
	JMP .+3		/IF SO, GO GET RIGHT WORD.
	LAC OCTNUM	/GET NUMBER WANTED.
	JMP* GETOCT	/AND RETURN TO CALLER.
	LAC* OCTNUM	/WORD WANTED IS SPECIFIED BY OCTNUM.
	JMP* GETOCT	/RETURN.
/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
	LAC INPTCL
	AND C777
	DAC .+1
	OPICAL		/INPUT DEVICE.
UNIT1	1
	0
INDEV	0
	DZM LENGTH
	LAC	ICLSW	/CHECK IF ICLOSE
	SMA!CLC
	JMP	OUTDEV+3	/SKIP .INIT TO OUTPUT DEVICE
	LAC OUTPCL
	AND C777
	ADD C1000
	DAC .+1
	OPOCAL		/SCRATCH DEVICE.
UNIT2	1
	0
OUTDEV	0
	LAW -1
	DAC	OUTSW1	/INDICATE NOTHING WRITTEN YET IN OUTPUT FILE
	DAC INFILE
	DAC OWFLSW
	DAC	RDFNOP
	LAW -377
	TAD INDEV
	DAC INDEV
	SPA
	DZM INFILE
	LAC	ICLSW	/WAS ICLOSE REQUESTED
	SZA		/YES IF ZERO
	LAW -377
	TAD OUTDEV
	SPA
	DZM OWFLSW
	DAC OUTDEV
	LAC INFILE
	TAD OWFLSW
	SAD NAMEIN
	SKP!CLA
	CLA!CMA
	DAC FILSTR
	CMA
	DAC BLOKSW
	DAC PBLKSW
	CLC
	DAC	ICLSW	/RESET ICLOSE SWITCH
	DZM BFPTSW
	JMS CHBUFF
	JMP* IOINIT
INFILE	-1
OWFLSW	-1
ICLSW	-1
FILSTR	0
BBUF1	0		/START OF BLOCK BUFFER 1.
BBUF2	0		/START OF BLOCK BUFFER 2.
BBUFX	0		/LENGTH OF EACH BLOCK BUFFER.
INPDAT	.SCOM+23
OUTDAT	DATM15
/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
	.EJECT
	.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
	.IFDEF	BF
	LAC*	(.SCOM+26	/ 0 = FGD; 1 = BGD
	TAD	(.SCOM+16	/POINT TO CORRECT .DAT TABLE
	DAC	INPDAT
	.ENDC
	LAW -15
	TAD* INPDAT
	DAC OUTDAT
	DAC INPDAT
	ISZ INPDAT
	LAW ADRTBL
	JMS GETBNK
	DAC* C12
ADRLP1	LAC* 12
	JMS GETBNK
	DAC POINTR
	LAC* POINTR
	JMS GETBNK
	DAC* POINTR
	ISZ ACOUNT
	JMP ADRLP1
	LAC* SCOM2
	DAC BBUF1
	LAC*	SCOM3
	JMS GETBNK
	CMA
	TAD BBUF1
	CMA
	RAR!CLL
	DAC BBUFX
	TAD BBUF1
	DAC BBUF2
	DZM BFPTSW
	.IFUND	BF
	LAC*	SCOM3
	JMS GETBNK
	CMA
	TAD* SCOM2
	SPA!SNA
	JMP OK
	LAW LOAD1
	JMS TYPOUT
	JMP EXIT1
LOAD1	ENDLD1-.*400+2
	0
	.ASCII '.SYSLD 1'<15>
ENDLD1=.
	.ENDC
OK	JMS CHBUFF
	TTICAL
	1
ADR012	RECOUP
	0
	IN2CAL
	1
	0
SBSIZ	0
	LAW -377
	TAD SBSIZ
	SPA
	JMP BEGIN+1
	LAW FSDERM
	JMS TYPOUT
	LAW FSDER1
	JMS TYPOUT
	LAW TYLINE
	JMS TYPEIN
	LAC TYLINE+2
	XOR YES
	SNA
	JMP BEGIN+5
	JMP EXIT1
FSDERM	ENDFSD-.*400+2
	0
	.ASCII '.DAT -10 IS FILE-ORIENTED.'<15>
ENDFSD=.
FSDER1	ENDFR1-.*400+2
	0
	.ASCII 'DO YOU WISH TO CONTINUE'<77><15>
ENDFR1=.
YES	.ASCII 'YES'
	.LOC .-1
SCOM2	.SCOM+2
ADRTBL=.-1
	CWDLIT
	CWDTOP
	INLADR
	EDLADR
	EDLAD1
	FEED
	SBADR
	RDCAL2
	RDALTB
	WRPAK2
	WRALTB
	DEB1
	CKNM1
	CKNM2
	CKNM2+1
	ADR000
	ADR001
	ADR002
	ADR002+1
	ADR003
	ADR004
	ADR004+1
	ADR005
	ADR005+1
	ADR006
	ADR006+1
	ADR008
	ADR008+1
	ADR009
	ADR010
	ADR010+1
	ADR011
	ADR011+1
	ADR012
ACOUNT	ADRTBL-.+1
SCOM3	.SCOM+3
	.END	BEGIN
