Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-02 - 43,50225/editor.0
There are no other files named editor.0 in the archive.
TITLE EDITOR   V.003	1 APRIL 1968
SUBTTL DECEDIT PARAMETERS

DEFINE ERR (A) <	JSR A,ERRORX>
DEFINE TSTRIN (A) <	EXP "A"+"A"+1>

S0=1
S1=2
S2=4
S3=10
S4=40
S5=20
S6=100
S7=200
S8=400
PDP=3
FL=4
INDEX=11
WC=12
C=13
COTP=14
IPT=5
TPT=6
P=10
SINDEX=15
CINDEX=16
LAST=17
TYP=2
DT=3
OPDEF EXIT [POPJ PDP,]
OPDEF CAL [PUSHJ PDP,]
OPDEF SAVE [PUSH PDP,]
OPDEF UNSAVE [POP PDP,]
EXTERNAL JOBFF
SUBTTL DECTAPE IO - AUGUST 25, 1965

FOPEN=1000
AC1=1
AC2=2
AC3=5
AC4=6

FILLB:	TLNN FL,1;	IS BUFFER LOADED
	JRST FILLB1;	NO, SO LOAD IT
	MOVE C,WBC;	GET BUFFER COUNT
	CAIG C,177;	IS IT GETTIN FULL
ATSALL:	EXIT;	NO
	TRZ FL,S8;	SET FIRST BLOCK FLAG TO FALSE
	TRO FL,S3;	AND MODIFIED FLAG TO TRUE
	MOVEI AC2,WB;	GET WORKING BUFFER ADDRESS
	MOVEI AC3,1;	SEQUENCE NUMBER TEST
	ADDI AC2,125;	DUMP ABOUT 2/3 OF BUFFER
	TDNN AC3,0(AC2);	BUT NOT A FRACTIONAL LINE
	SOJA AC2,.-1;	HUNT FOR BEGIN OF LINE
	HRRZ P,THSBLK;	UPDATE PREVIOUS BLOCK NUMBER
	UGETF DT,IAMTEM;	NEXT FREE BLOCK
	USETO DT,0(P);	PREPARE TO DUMP THIS BLOCK
	MOVE P,IAMTEM;	AND PREPARE NEXT BLOCK
	MOVE AC3,DTOBUF;	SET UP BLT
	HRLZM P,1(AC3);	LINK TO NEXT DECTAPE BLOCK
	HRLI AC3,WB;	SOURCE
	ADDI AC3,2;	+2
	MOVE AC1,AC2;	LAST
	SUBI AC1,WB;	AND MAKE A COUNT OF IT
	SUB C,AC1;	TOTAL REMAINING WORDS
	MOVEM C,WBC;	SET NEW COUNT
	ADDI AC1,-1(AC3);	SETUP FOR BLT
	CAL DUMX;	TRANSFER AND DUMP BLOCK
	MOVEI AC3,WB;	GET DEST FOR MOVE UP
	HRL AC3,AC2;	AND SOURCE
	MOVE AC1,AC3;	GENERATE LAST ADDRESS
	ADDI AC1,(C);	FROM COUNT
	BLT AC3,(AC1);	ON TOAST
	EXCH P,THSBLK;	SET NEW BLOCK
	JRST FILLB;	GO AGAIN

FILLB1:	TLNN FL,FOPEN;	IS A FILE OPEN
	ERR 7;		NO, SO *NFO*
	TLO FL,1;	SET TO FILLED BUFFER
	JRST GETF;	AND GET THE FIRST BLOCK
GET:	TRNE FL,S0;	FORWARD OR REVERSE
	JRST GETL;	REVERSE

GETN:	TRNE FL,S5;	IS THERE ANY MORE
	EXIT;		NO
	HLRZ WBF;	GET LINK
	CAL DUMPB;	OUTPUT BLOCK
	MOVE P,THSBLK;	SAVE PREVIOUS FLOCK NUMBER
	TRZ FL,S8;	SET FIRST BLOCK FLAG TO FALSE
GET0:	HRRZM THSBLK;	SAVE CURRENT BLOCK NUMBER
	USETO DT,@THSBLK;	SER OUTPUT FOR PRESENT BLOCK

SLURP:	INPUT DT,0;	INPUT A NEW BLOCK
	HLRZ WBF;	GET LINK
	SKIPN;		WE DONT LIKE ZERO LINKS
	TRO FL,S5;	SO WE SET A FLAG TO REMIND US
	HRRZ WBF;	GET COUNT
	MOVEM WBC;	AND SAVE IT
	TRNN FL,S5;	WAS IT END OF FILE
	SKIPE;		EMPTY BLOCK
	EXIT;		END OF FILE OR NON-EMPTY BLOCK
	HLRZ WBF;	EMPTY BLOCK - GET LINK
	TRNN FL,S0;	DIRECTION CHECK
	JRST GET0;	FORWARD

GETL:	CAL DUMPB;	REVERSE - GET LAST BLOCK-SAVE THIS ONE
	JUMPN P,GETL1;	IS LAST BLOCK AVAILABLE
GETF:	HRRZ P,FBNUM;	NO, SO GET FIRST ONE
	TRZ FL,S0+S5;	SET FORWARD AND END
	TROA FL,S8;	SET FIRST BLOCK AND SKIP
GETL1:	TRZ FL,S5+S8;	SET NON-END AND NON-FIRST
	USETI DT,(P);	ESTABLISH INPUT BLOCK NUMBER
	USETO DT,(P);	AND OUTPUT BLOCK NUMBER
	MOVEM P,THSBLK;	UPDATE CURRENT BLOCK NUMBER
	SETZM P;	AND ZERO PREVIOUS BLOCK NUMBER
	JRST SLURP;	AND INPUT THE BLOCK
DUMPB:	CAL FILLB;	SPLIT BLOCKS IF THE OVER-RUN
	TRZN FL,S3;	ANY MODS MADE
	EXIT;		NO
	MOVE AC2,DTOBUF;	POINTER TO BUFFERS
	MOVEI AC3,2(AC2);	FIRST WORD ADDRESS
	HRLI AC3,WB;	FIRST DATA WORD
	HLRZ AC1,WBF;	BLOCK NUMBER
	SKIPN AC1;	LAST BLOCK
	SOS AC1;	YES, SO EXTEND
	HRLM AC1,1(AC2);	INTO LINK
	MOVEI AC1,1(AC2);	PREPARE BLT
	ADD AC1,WBC;	SIZE OF BLT
DUMX:	BLT AC3,(AC1);	BLOCK UP SUBROUTINE
	HRRM AC1,DTOBF1;	LAST ADDRESS
	OUTPUT DT,0;	DUMP IT
	STATO DT,740000;	CHECK FOR DEVICE ERROR
	EXIT;		ALL IS GOOD
	SETOM FL     ; DDE ERROR
	ERR 12;		*DDE*

FINISH:	TLNE FL,FOPEN;	IF A FILE IS OPEN
	CAL DUMPB;	DUMP IT
FINIS2:	RELEAS DT,0;	RELEASE THE TAPE
	JRST INITIX;	AND GO BACK TO SETUP

THSBLK:	0;		PRESENT BLOCK NUMBER
IAMTEM:	0;		TEMPORARY
SUBTTL CONTROL - AUGUST 25, 1965
			;MAIN LISTEN AND DISPATCH FOR EDITOR CONTROL MODE
OUTTER:	CAL GETCHR;	GET ONE CHARACTER
	CAIN C,15;	INITIAL CARRIAGE RETURNS
	JRST OUTTER;	ARE IGNORED
	CAIN C,"I"
	JRST INSE
	CAIN C,"D"
	JRST DELETE
	CAIN C,"P"
	JRST PRINT
	CAIN C,"E"
	JRST FINISH
	CAIE C,33;	ALTERNATE ALTMOD
	CAIN C,175;	THE REGULAR ALTMOD
	JRST PNEXT
	CAIN C,"S"
	JRST DECINI
	ERR 1;		ILLEGAL COMMAND
;OUTPUT A CARRIAGE RETURN
CRT:	MOVEI INDEX,CRM;	PICK UP THE POINTER
	JRST OTLINE;	OUTPUT CRT-LF-*

;ERROR PRINT
ERRORX:	0;		CALLED BY JSR X,ERRORX
	HRRZ INDEX,ERRORX;	WHERE X IS THE ERROR NUMBER
	LDB INDEX,EPT;	EXTRACT THE X
	MOVEI INDEX,ERT-1(INDEX)
ERROX1:	MOVEI PDP,PDSTAK;	INITIALIZE PUSHDOWN
ERROX2:	CAL OTLINE;	OUTPUT ERROR MESSAGE
	JRST COMLEV;	AND A CARRIAGE RETURN - EXIT
;ERROR MESSAGES ET.AL.  THESE MUST NOT BE MOVED ABOUT
;SINCE THE PRINT ROUTINE DEPENDS ON THE BIT 35 OF THE
;NEXT MESSAGE TO TERMINATE THE PRESENT ONE

CRM:	OCT 64245200000;	THE CARRIAGE RETURN-LINE FEED-*
ERT:	TSTRIN <*ILC*>;	ILLEGAL COMMAND
	TSTRIN <*NLN*>;	NON-EXISTENT LINE
	TSTRIN <*ILS*>;	ILLEGAL SEQUENCE
	TSTRIN <*ILR*>;	ILLEGAL REFERENCE
	TSTRIN <*UNA*>;	UNIT NOT AVAILABLE
	TSTRIN <*DCE*>;	DIRECTORY CAPACITY EXCEEDED
	TSTRIN <*NFO*>;	NO FILE OPEN
	TSTRIN <*FAU*>;	FILE NAME ALREADY IN USE
	TSTRIN <*NCF*>;	NOT A CURRENT FILE
	TSTRIN <*DDE*>;	DEVICE DATA ERROR
EPT:	POINT 4,-1(INDEX),12;	THE ERROR PRINT DEPENDS
			;ON THE 1 IN BIT 35 HERE
;COMMUNICATIONS
SUBTTL EDITOR - AUGUST 25, 1965

;INSERT LINE(S)
INSE:	CAL GETSEQ;	GET THE SEQUENCE NUMBER AND STEP
	MOVEM CINDEX;	THIS INSTR SKIPED IF ONLY ONE ARG
	JRST INSE3;	PROCESS IT
INSE2:	CAL FIND;	TOP OF THE LOOP - SEARCH FOR THE LINE
	CAMN SINDEX,(INDEX);	EXACT MATCH?
	ERR 4;		YES, *ILR*
	CAL BACK1;	BACKUP TO LAST LINE
	CAME LAST;	IS IT INDEED THE LAST ONE WE PUT IN
	ERR 3;		NO, *ILS*
INSE3:	CAL FIND;	GET THE LINE
	CAL OTSEQ;	OUTPUT THE SEQUENCE NUMBER
	CAL GETLIN;	GET THE INPUT LINE
	JRST OUTTER;	ALT MODE
	CAL INSED;	INSERT AND DELETE
	MOVEM SINDEX,LAST;	SAVE AWAY THIS LINE NUMBER
	MOVEM SINDEX,FIRST
	CAL ASCIA;	STEP SEQUENCE
	JRST INSE2;	LOOP BACK FOR NEXT LINE

INSED:	HRRZ COTP;	GET THE SIZE OF THE LINE
	MOVEI 1,0;	SETUP DIRECTION FLAG
	CAML WC;	IF LINE SIZE IS GREATER-EQUAL THAN NEW
	MOVEI 1,1;	SET FLAG TO 1
	CAME WC;	IF OLD LINE IS NON-NULL
	JRST INSEG;	DELETE IT
INSE1:	JUMPE WC,INSE16;	NULL SIZE TO INPUT
	HLRZ INDEX,COTP;	GET LINE ADDRESS
	ADD INDEX,WC;	AND SIZE
	HLRS COTP;	AND COUNT
	HRLI COTP,TTB;	SET SOURCE
	MOVE 1,COTP;	READY FOR BLT
	BLT COTP,-1(INDEX);	MOVE IN THE NEW LINE
	MOVE COTP,1;	RESTORE COTP
INSE16:	TRO FL,S3+S6;	SET MOD FLAGS - GENERAL EXIT
CLEARE:	MOVEI 1,WB;	CLEAR LAST BUFFER WORD
	ADD 1,WBC;	END OF BUFFER
	SETZM (1);	SET TO ZERO
	EXIT;		GO AWAY

;BACK UP LINE POINTER
BACK1:	CAIE INDEX,WB;	IS THIS THE FIRST LINE IN THE BUFFER
	JRST BACK;	NO, SO NORMAL PROCESS
	TRO FL,S0;	WE MUST GET THE PREVIOUS BLOCK
	CAL GET;	INPUT IT - THIS WILL ALWAYS WORK
	ADD INDEX,WBC;	LAST LINE
	JRST BACK;	NOW WE BACK IT UP
	MOVE (INDEX);	TOP OF LOOP - PICK UP DATA WORD
	TRNN 1;		BIT ONE MAKES IT A SEQUENCE N
BACK:	SOJA INDEX,.-2;	COUNT IT BACK
	EXIT
INSEG:	CAL CSIZE;	COMPUTE SIZE OF XFER
	JUMPE INSEX;	ZERO SIZE XFER
	JUMPN 1,INSER;	FORWARD BLT
	HRLS 0;		REVERSE XFER
	ADD INDEX,0;	SET UP POINTER WORD
	HRRZS 0;	READY TO GO
INSER:	MOVEM INDEX,C;	PROTECT XFER WORD
	BLT C,(INDEX);	XFER ONE WORD
	XCT ITAB(1);	STEP UP OR DOWN
	SOJGE INSER;	IF NOT DONE, LOOP BACK
INSEX:	HRRZ COTP;	SETUP SIZE
	SUB WC;		OF NEW BLOCK
	EXCH WBC;
	SUBM WBC;	NOW NEW BLOCK SIZE IS IN WBC
	JRST INSE1;	ALL DONE - GO BACK

ITAB:	SUB INDEX,K5;	SHRINK
	ADD INDEX,K5;	GROW

;THE ASCII ADDER

ASCIA:	SAVE CINDEX;	PROTECT THE STEP
	MOVE 7,SINDEX
	AND CINDEX,K2;	MASK OUT 60S
	LSH CINDEX,1;
	IOR SINDEX,K4;
	ADD SINDEX,K1;
	ADD CINDEX,SINDEX;	EXCESS 166 ADDITION
	AND CINDEX,K3;	MASK OUT CARRY BITS
	MOVE SINDEX,K4;
	AND SINDEX,CINDEX;
	ASH SINDEX,-3;	GIVES 000 WHERE CARRY HAPPENED, 006
	SUBM CINDEX,SINDEX;	CONVERT TO EXCESS 0 OR 60
	IOR SINDEX,K4;	CONVERT TO EXCESS 60
	UNSAVE CINDEX;	RESTORE THE STEP
	CAML 7,SINDEX;	IF 99999, DON'T GO TO 00009
	ERR 3
	EXIT;		LEAVE

K1:	OCT 432150643214;	106
K2:	OCT 036170743617;	017
K3:	OCT 375767737576;	077
K4:	TSTRIN <00000>
K5:	XWD 1,1;	+,- ONE TO BOTH HALVES
FIND:	CAL FILLB;	FILL THE BUFFER
FIND1:	TRZ FL,S0+S4;	FORWARD SEARCH AND INITIAL SEARCH
FIND2:	HRRZ WBC;	GET THE BUFFER SIZE
	JUMPE FINDA;	EMPTY BLOCK
	MOVEI INDEX,WB;	GET THE DATA ADDRESS
	MOVE WB;	GET THE FIRST DATA WORD
	CAMLE SINDEX;	ARE WE PAST THE LINE
	JRST FINDA;	YES, REVERSE
	CAMN SINDEX;	EXACT MATCH
	JRST FINDEQ;	YES, BE HAPPY
	ADD INDEX,WBC;	FORM ADDRESS OF LAST DATA WORD
	CAL BACK;	FIND ITS SEQUENCE NUMBER
	CAMLE SINDEX;	IT THE LINE IN THIS BLOCK
	JRST FIND3A;	YES, INVESTIGATE FURTHER
	CAMN SINDEX;	EXACT MATCH
	JRST FINDEQ;	YES
FINDX:	TRNE FL,S5;	IS THIS LAST BLOCK
	JRST FINDC;	YES, SO EXIT WITH THIS ADDRESS
	TRO FL,S4;	SCANNING HAS STARTED
	TRZ FL,S0;	AND GO FORWARD
	JRST FIND4;	AWAY WE GO

FINDA:	MOVEI INDEX,0;	SETUP FOR REVERSE
	TRNN FL,S4;	HAVE WE BEEN HERE BEFORE
	TRNE FL,S8;	OR IS IT THE FIRST BLOCK
	JRST FINDR;	YES, SO USE THIS ADDRESS
	TRO FL,S0;	OTHERWISE, GO BACK ONE BLOCK
FIND4:	CAL GET;	GET THE BLOCK
	JRST FIND2;	SEARCH FOR IT

FINDC:	HRRZ INDEX,WBC;	TAIL OF BLOCK IF ENTERED HERE
FINDR:	ADDI INDEX,WB;	HEAD OF BLOCK IF ENTERED HERE
	JRST FIND3;	AND RETURN

FIND3A:	MOVEI INDEX,WBC;	WE WISH TO SCAN THIS BLOCK FOR
	CAL FINDES;	THIS LINE - COMPUTE LINE SIZE
	CAMN SINDEX;	EXACT MATCH
	JRST FINDEQ;	YES, WELL, GOOD
	CAMG SINDEX;	HAVE WE PASSED IT
	AOJA INDEX,FIND3A+1;	NO, SO CONTINUE
FIND3:	HRLZ COTP,INDEX;	RETURN THE ADDRESS OF THE LINE
	JRST CLEARE;	EXIT

FINDEQ:	HRLZ COTP,INDEX;	FOUND THE DESIRED LINE
	CAL FINDES;	COMPUTE ITS SIZE
	HLRZ INDEX,COTP;	SET UP INDEX
	JRST CLEARE;	AND EXIT
FINDES:	AOS COTP;	FIND SIZE OF LINE
	MOVE 1(INDEX);	FIND NEXT SEQUENCE NUMBER
	AOS INDEX;
	TRNN 1;		SEQUENCE NUMBER?
	JUMPN FINDES;	NO, BUT ZERO ALSO DENOTES END
	EXIT;		DONE

CSIZE:	HRRZ COTP;	COMPUTE SIZE OF TRANSFER
	HLRZ INDEX,COTP;	SIZE OF THIS LINE
	ADD INDEX;	AND THIS LOCATION
	ADD INDEX,WC;	PLUS THE NEW LINE SIZE
	HRL INDEX,0;	IN LEFT HALF IS OLD SIZE
	SUBI WB;	AND TURN IT INTO A COUNT
	HRRZ C,WBC;	FOR A SUBTRACT
	SUBM C,0;	AND NOW ZERO HAS THE XFER SIZE
	EXIT;


DELETE:	CAL GE2SEQ;	GET THE RANGE TO BE EXCISED
DELOOP:	HRRZ INDEX,WBC;	GET THE WORD COUNT
	ADDI INDEX,WB;	FORM THE END ADDRESS
	CAL BACK;	GET THE LAST SEQUENCE IN THE BLOCK
	CAMN LAST;	IS THE LAST LINE THE END OF THE RANGE
	JRST DEQ;	YES
	CAML LAST;	DO WE WANT TO DELETE THIS ONE TOO
	JRST DINB;	NO,DELETE TERMINATES IN THE BUFFER
	CAL DREST;	ERASE THE REST OF THE BUFFER
EMPT:	TRNE FL,S5;	LAST BLOCK
	JRST COMLEV;	YES, DONE
	TRZ FL,S0;	FORWARD
	CAL GET;	INPUT NEXT BLOCK
	MOVE SINDEX,WB;	GET FIRST LINE
	TRNN SINDEX,1;	IF NOT A ONE, BLOCK IS EMPTY
	JRST EMPT;	SO GET THE NEXT ONE
	CAL FIND;	NEW SINDEX IS THE FIRST LINE - THIS CAL
	JRST DELOOP;	SETS UP THE COUNTS, ETC.

DEQ:	CAL DREST;	DELETE THE REST OF THE BUFFER
DEX:	JRST COMLEV;	EXIT
DINB:	MOVEI INDEX,WBF;	GET INITIAL ADDRESS
	CAL FINDES;	SCAN THE LINE
	JUMPE .+3;	END OF BUFFER
	CAMG LAST;	LAST LINE DONE
	AOJA INDEX,DINB+1;	NO, GO AGAIN
	HLRZS COTP;	COMPUTE TOTAL SIZE
	SUB INDEX,COTP;	THIS MUCH SMALLER
	HRLZS COTP;	RESET LEFT HALF
	HRRM INDEX,COTP;	AND RIGHT HALF GET DELTA SIZE
	CLEARM WC;	SET FOR ZERO LENGTH INSERT
	CAL INSED;	INSERT THE NULL LINE
	JRST COMLEV;	AND EXIT

DREST:	HLRZ INDEX,COTP;	DELETE THE REMAINING BUFFER
	SUBI INDEX,WB;	JUST DECREMENT SIZE
	HRRM INDEX,WBC;	OF THE NEW BUFFER
	JRST INSE16;	DONE
PRINT:	CAL GE2SEQ;	GET THE RANGE
PRLOOP:	MOVE (INDEX);	GET A LINE
	JUMPE GETNEX;	ZERO IMPLIES END OF BUFFER - GET NEXT
	CAMLE LAST;	ARE WE STILL IN THE BALLPARK
	JRST COMLEV;	NO, ALL DONE
	CAL STEP;	PREPARE FOR NEXT HUNT
	CAL OTLINE;	PRINT THIS LINE
	CAL FIND;	FIND THE NEXT LINE
	JRST PRLOOP;	LOOK AT IT

GE2SEQ:	CAL GETSEQ;	GET A 2 NUMBER RANGE
	SKIPA;		THERE WERE TWO
	JRST GEX;	ONLY ONE
	LSH 1;		JUSTIFY IT
	TROA 1;		AND FLAG IT AS A SEQUENCE NUMBER
GEX:	MOVE SINDEX;	DUPLICATE THE INPUT NUMBER IF JUST ONE
	MOVEM LAST;	STORE THE END OF THE RANGE
	CAL FIND;	SEARCH FOR THE FIRST LINE
	CAMN LAST,FIRST;	BOTH THE SAME
	CAMN SINDEX,(INDEX);	BUT NO MATCH FOUNT
	EXIT;		WILL SKIP THIS ONE
	ERR 2;		AND *NLN*

STEP:	SAVE CINDEX	;PROTECT THE STEP
	MOVEI CINDEX,1;	PREPARE TO ADD ONE TO SINDEX
	MOVEM SINDEX;	WHICH WE LOAD FROM ZERO
	JRST ASCIA+1;	AWAY

PNEXT:	MOVE SINDEX,FIRST;	PRINT NEXT LINE
	MOVE SINDEX;	UPDATE THE LINE POINTER
	CAL STEP;	NEXT LINE
	CAL FIND;	WHERE IS IT
	SKIPN SINDEX,(INDEX);	ZERO IS END, ALSO LOAD SINDEX
	ERR 2;		*NLN*
	MOVEM SINDEX,FIRST;	STEP FIRST POINTER
	CAL OTLINE;	PRINT THE LINE
	JRST OUTTER;	BACK TO CONTROL

GETNEX:	TRNE FL,S5;	END OF FILE
	JRST COMLEV;	YES, EXIT
	TRZ FL,S0;	FORWARD
	CAL GET;	INPUT IT
	MOVEI INDEX,WB;	FIRST ADDRESS
	JRST PRLOOP;	RETURN TO PRINT SCAN
SUBTTL TELETYPE IO - AUGUST 25, 1965

;OUTPUT SEQUENCE NUMBER
OTSEQ:	AOS TYOBF1;	STEP THE WORD POINTER
	MOVEM SINDEX,@TYOBF1;	PUT THE SEQUENCE NO.
	MOVEI 1,211;	AND A TAB
	IDPB 1,TYOBF1;	INTO THE OUTPUT BUFFER
OTSEQ4:	OUTPUT TYP,0;	OUTPUT THE TELETYPE BUFFER
	EXIT

;INPUT ONE LINE FROM TELETYPE AND CONVERT TO SEQUENCED

GETLIN:	INPUT TYP,0;	READ THE LINE
	MOVEI 1,TTB1;	PREEPARE TO BLOCK IT UP
	HRLI 1,TTB;	DESTINATION
	CLEARM TTB
	BLT 1,TTB16;	BLOCK IT UP
	MOVE TPT,KKK1;	PREPARE THE CONVERSION POINTER
	MOVE IPT,TYIBF1;	AND READ POINTER
	MOVE 2,TYIBF2;	AND THE COUNT
	MOVEM SINDEX,(TPT);	PUT IN THE SEQUENCE
	MOVEI 1,211;	TAB
	AOJA TPT,EOMLOP+2;	START CONVERSION

EOMLOP:	SOJL 2,EOMOUT;	IF ALL OUT OF CHARACTERS
	ILDB 1,IPT;	READ ONE
	IDPB 1,TPT;	WRITE ONE
	CAIE 1,33;	ALTERNATE ALTMOD
	CAIN 1,175;	REGULAR ALTMOD
	JRST CRT;		MAKE EXIT
	JRST EOMLOP;	GET MORE

EOMOUT:	MOVE WC,TPT;	FORM WORD COUNT
	SUB WC,KKK1;	INITIAL VALUE
	HRRZS WC;		CLEAR LEFT
	CAIN 1,12;	LINE FEED
	ADDI WC,1;	MEANS STEP COUNT
STEPEX:	AOS (PDP);	SKIP EXIT
	EXIT
KKK1:	POINT 7,TTB;	INITIAL POINTER

;OUTPUT ONE LINE OF TEXT

OTLINE:	MOVE (INDEX);	FIRST WORD
	JRST OTL1
	MOVE (INDEX);	SUBSEQUENT WORDS
	JUMPE OTSEQ4;	ZERO IMPLIES THE END OF THE WORLD
	TRNE 1;		ONE IMPLIES THE END OF THE LINE
	JRST OTSEQ4
OTL1:	AOS TYOBF1;	PUT IT IN THE OUTPUT BUFFER
	MOVEM @TYOBF1
	AOJA INDEX,OTLINE+2;	GO FOR MORE
;GET ONE CHARACTER

GETCHR:	INPUT TYP,0;	GET A LINE
	MOVE IPT,TYIBF1;	PREPARE INPUT POINTER
	ILDB C,IPT;	LOAD THE FIRST CHARACTER
	EXIT

;GET A SEQUENCE PAIR

GETSEQ:	CLEARB 0,SINDEX;	MAKE BOTH ZERO
	ILDB C,IPT;	GET A CHARACTER
	CAIL C,60;	IT MUST BE A NUMBER
	CAILE C,71
	JRST ETEST;	OR A DELIMITER
	LSH SINDEX,7;	NUMBER
	ADD SINDEX,C;	NEW ONE
	JRST GETSEQ+1

ETEST:	CAIN C,56;	POINT?
	JRST PER
	CAIN C,54;	COMMA?
	JRST CMMA
	SKIPE SINDEX;	IF NOTHING INPUT YET
	CAIE C,15;	OR NOT A CARRET
COMERR:	ERR 1;		ILLEGAL COMMAND
	IOR SINDEX,KK4;	MAKE IT AN ASCII THING
	SKIPE 0;		IF TWO ARGS
	EXCH SINDEX,0;	SWAP EM BACK
	LSH SINDEX,1;	LEFT JUSTIFY
	TRO SINDEX,1;	AND FLAG IT
	MOVEM SINDEX,FIRST;	SAVE IT FOR .
	JUMPE STEPEX;	ONLY ONE ARG
	EXIT;		TWO ARGS

CMMA:	JUMPE SINDEX,COMERR;	THREE ARGS?
	JUMPN COMERR;	ONE ARG
	IOR SINDEX,KK4;	ASCII-IZE IT
	EXCH SINDEX,0;	SWAP EM
	JRST GETSEQ+1

PER:	JUMPN SINDEX,COMERR;	CANT BE THIRD ARG
	MOVE SINDEX,FIRST;	RETREIVE POINT
	LSH SINDEX,-1;	RIGHT JUSTIFY
	JRST GETSEQ+1

KK4:	OCT 140603014060;	00000
SUBTTL DECSET - AUGUST 25, 1965

FOPEN=1000

;SET FILE OPEN (*SN,NAME)

DECINI:	TLNE FL,FOPEN;	IF A FILE IS NOT ALREADY OPEN
			;	THEN GOTO NORMAL PROCESS
	ERR 1 ; IF FILE OPEN ,MUST CLOSE W. E
DECIN1:	SETZB FL,WBC;	ZERO FLAGS AND WORD COUNT
	CLEARM DTNAME;	FILE NAME
	CLEARM DTNAME+1;	AND EXTENSION
	CLEARM DTNAME+2;	AND DATE
	CAL GTCHAR;	GET UNIT NUMBER
	CAIL 60;		IT MUST BE A NUMBER
	CAILE 70;
	JRST .-3;		IGNORE ANYTHING ELSE
	DPB [POINT 5,PLUNK,23];	DUMP INTO INIT COMMAND
	CAL GTCHAR;	NEXT CHARACTER
	CAIE 54;		COMMA?
	JRST .-2;		IGNORE ALL ELSE
LOOP0:	MOVE 1,[POINT 6,DTNAME];	INITIALIZE NAME POINTER
	MOVEI C,6;	MAX NAME LENGTH
LOOP:	CAL GTCHAR;	GET A CHARACTER
	CAIL "0";		NUMBERS AND LETTERS ONLY COME HERE
	CAILE "9";	SO HERE FILTER NUMBERS
	JRST LOOP1;	IT IS A LETTER
LOOP2:	TRC 40;	NUMBER - MAKE IT SIXBIT
	IDPB 1;		STORE INTO NAME (OR EXTENSION)
	SOJG C,LOOP;	COUNT DOWN FOR SIZE
	CAL GTCHAR;	NEXT CHARACTER
	JRST .-1;

GTCHAR:	ILDB IPT;		LOAD ONE CHARACTER
	CAIN 15;		CRT
	JRST GET1;	SNEAK EXIT
	CAIN ".";	AN EXTENSION IS COMMING
	JRST GET2;	FIX IT UP
	CAIE 33;		THE FUNNY ALTMODE
	CAIN 175;		AND THE REAL ONE
	JRST 	GET11	;CAUSE EXIT TO OCCUR
	CAIN	0,12	;LF CHAR?
	JRST GET1	; YES TREAT AS CR
	CAIE 1;		CONTROL A
	EXIT;		NOTA SO EXIT HAPPY
	TLO FL,100;	SET CONTROL A FLAG
	JRST GTCHAR;	GET ANOTHER CHARACTER
GET11:	TLO	FL,2	;NEW FILE FLAG

GET1:	UNSAVE;	POP OFF EXIT
GO:	MOVEI DTOBUF;	THESE TWO INSTRUCTIONS REQUIRED
	HRLM PLUNK+1;	REQUIRED TO LINK LEFT HALF
	MOVE SJOBFF;	RESET JOB AREA
	MOVEM JOBFF;	TO PREVENT STORAGE EAT-UP
	INIT DT,0;	INITIALIZE DECTAPE
PLUNK:	SIXBIT /DTA/;	RIGHT HALF SET ABOVE
	XWD 0,DTIBUF;	LEFT HALF SET ABOVE
	ERR 5;		UNIT NOT AVAILABLE
	MOVSI 400000;	USE BIT
	ANDCAM DTB;	CLEAR IT
	HRRI DTB;		HEAD OF BUFFER
	MOVEM DTIBUF;	SETUP IN HEADER
	OUTBUF DT,1;	SET UP SINGLE BUFFER
	TLZE FL,100;	NEW DIRECTORY?
	CALLI DT,13;	YES, ZONK IT (UTPCLR)
	SKIPN DTNAME;	NO NAME MEANS JUST CLEAR, PROB
	JRST FINIS2;	SO EXIT AND CLOSE FILE
	LOOKUP DT,DTNAME;	IS THE NAME ALRRADY THERE
	JRST NEWFIL;	NO, SO WE ENTER IT
	TLNE FL,2;	ARE WE ASKING FOR A NEW FILE
	ERR 10;		YES, FAU

DOIT:	MOVE 2,DTNAME+1;	GET LINK
	USETI DT,(2);	SET IT UP
	OUTPUT DT,;	MAKE SYSTEM HAPPY
	USETO DT,(2);	SET UP OUTPUT ALSO
	TLZN FL,10;	NEW FILE?
	JRST DOIT1;	NO, ALMOST DONE
	SETZM WBF;	WE MUST FORCE AN EMPTY BLOCK
	TLO FL,1;		SET BUFFER FULL FLAG
	SETZM WBC;	ZERO LENGTH
	TRO FL,S3+S5+S6+S8;	INITIAL STATE, FIRST BLOCK MODIFIED
DOIT1:	MOVEM 2,THSBLK;	SETUP CURRENT BLOCK NUMBER
	TLO FL,FOPEN;	SET FILE STATUS TO OPEN
	JRST COMLEV;	ALL DONE
NEWFIL:	TLNN FL,2;	WAS ALTMOD STRUCK
	ERR 11;		NO, NCF
	ENTER DT,DTNAME;	PUT IN DI
	ERR 6;		DCE
	TLO FL,10;	SET NEW FILE FLAG
	JRST DOIT;

LOOP1:	CAIL "A";	LETTER CHECK
	CAILE "Z";	IT MUST VERILY BE A LETTER
	JRST LOOP;	WE IGNORE IT
	JRST LOOP2;	WE PROCESS IT

GET2:	SKIPE DTEXTN;	EXTENSION?
	ERR 1;		ALREADY GOT ONE, CANT HAVE TWO
	TLZ 1,770000;	MAGIC TO BYTE POINTER TO POINT TO NEXT
	MOVEI C,3;	ONLY 3 LETTERS IN EXTENSION
	UNSAVE;		POP OF SOME GARBAGE
	JRST LOOP;	RETURN TO LISTEN

DTNAME:	0;	FILE NAME
DTEXTN:	0;	FILE EXTENSION
DTDATE:	0;	DATE
	0;		DUMMY

FBNUM=DTEXTN

SUBTTL INITIA - AUGUST 25, 1965
AL=1
INITIA:	CALLI 0,0;	RESET SYSTEM
	INIT TYP,AL;	RESET CONCOLE
	SIXBIT /TTY/
	XWD TYOBUF,TYIBUF
	HALT
	INBUF TYP,1;	SET UP ONE INPUT BUFFER
	OUTBUF TYP,2;	AND TWO OUTPUT BUFFERS
	MOVE JOBFF;	SAVE FIRST FREE
	MOVEM SJOBFF;	FOR LATER RESTART
	OUTPUT TYP,0;	MAKE SYSTEM HAPPY
INITIX:	MOVE CINDEX,KK1;	INITIALIZE STEP TO 10
	MOVEI PDP,PDSTAK-1;	INITIALIZE PUSHDOWN POINTER
	CLEARB SINDEX,FL;	FLAGS AND SEQUENCE INDEX
	MOVNI P,1;	AND FIRST BLOCK POINTER
	CLEARM WBC;	WORD COUNT
COMLEV:	CAL CRT;	A COMMON RETURN
	CAIL FL,0 ; DDE ERROR
	JRST OUTTER    ; NO, SO OFF TO LISTEN CONTROL
	JRST INITIA   ; YES GO RESET WORLD

;BUFFERS, ET. AL.
KK1:	OCT 140603014260;	00010
TYOBUF:	BLOCK 3
TYIBUF:	BLOCK 3

DTOBUF:	BLOCK 3
DTIBUF:	0
	XWD 700,0;	SELF ASSIGNED BUFFERS, ETC.
	0

FIRST:	0
SJOBFF:	0

WBC:	0;		WORKING BUFFER COUNT
	0
DTB:	XWD 200,DTB;	DECTAPE HEADER
WBF:	0
WB:	BLOCK 217;	THE WORKING BUFFER
RESTT:	SIXBIT .RESET.

PDSTAK:	BLOCK 7;	PUSHDOWN STAK
TTB:	BLOCK 23;	TELETYPE BUFFER-BUFFER
TTB16:	0

TTB1=TTB+1
TYIBF1=TYIBUF+1
TYIBF2=TYIBUF+2
TYOBF1=TYOBUF+1
DTOBF1=DTOBUF+1

EXTERNAL JOBFF
EDEND:

END INITIA