/COPYWRITE 1969 DIGITAL EQUIPMENT CORP.
/EDTRAN MAR 23, 1969 MURRAY RUBEN

*1
	0
V1,	0
V2,	0


*10
AXCOMB,	0
AXFILE,	0
AXTEM,	0
AXNAME,	0
AXTAR,	0
AXOUT,	0
AXIN,	0

*20
LINK,	0
NUMB1,	0
CTAB,	211
LIST5=.
C240,	240
LIST6=.
C337,	337
C214,	214
BELL=.
CBELL,	207
CLF=.
C212,	212
CRO,	377
LIST3=.
CCR=.
C215,	215
	0
M240,	-240
M37,	-37
C10=.
C7,	7
C100,	100
ARG0,	0
ARG1,	0
C20,	20
C200,	200
C2000,	2000
C260,	260
C37,	37
C440,	440
C4000,	4000
C77,	77
M100,	-100
M2,	-2
M237,	-237
M3,	-3
M4,	-4
M41,	-41
LINEFD,	-14
C1777,	1777
MCR=.
M215,	-215
LOW=.
LSTN,	0
THSN1,	0
FRST,	0
THSN,	0
XSAV,	0
THIS,	0
CHAR,	0
PACKIN,	0
PACKOT,	0
ECHOSW,	1
NOSW,	0
SEQSW,	0
ZSW,	0
WDCTSW,	0
*100
/VEC1,2,AND 3 MUST BEGIN AT 100
VEC1,	0
VEC2,	0
VEC3,	0
A,	0
B,	0
C,	0	/TEMP USED BY CHAR GEN.
H,	0
ARGIN,	0
XCTIN,	0
XCT,	0
TEMP,	0
STATUS,	0
VECSW,	0
XCPR,	0
YCPR,	0
COMSW,	0
VIEWSW,	OUTL
TE1,	START
VRSTR2,	INITAL
TCNT,	0
ESCAPE=JMS I .
	XCAPE
APP1,	APP
INDEV,	I33
READ1=.
CHI1,	CHIN
COMBEG,	BUFBEG
BINBEG,	BUFBEG+100
BINST,	BUFBEG+100
BINEND,	BUFBEG+101
END,	BUFBEG+142
BUFR,	BUFBEG+142
ENDLNI,	ENDLN
FIN1,	FIND
KILL1,	KILL
LIS,	LIST
L2I,	L2
OUTDEV,	OUTL
OUT1,	OUT
OUTL1,	OUTL
VPRNT,	OUTL
PRNT2,	PRNT1
PACK1,	PACBUF
UTR1,	UTRA
ROT6RI,	ROT6R
SETUP1,	SETUP2
COMAN1,	COMAND
SORTJ,	SORTB
SORTF,	SEARCH
OUTCH1,	OUTCHM
DSPYI,	DSPY
WSAV1,	0	/RESET BY KILL
C6064,	6064
FULL1,	FULL
LISTX1,	LISTX
LISTX2,	LISTX+1
C273,	273
INLOW,	I33


*200	/INITIAL START ADDRESS
	6064	/RAISE SCOPE FLAG
	TLS	/RAISE TTY FLAG
	JMP I VRSTR2	/RETURNS TO START

START,	KCC	/CLEAR KB FLAG FOLLOWING OUTPUT OPERATION
	TAD VIEWSW	/EITHER OUTL OR DSPY
	DCA OUTDEV	/INIT OUTPUT
	TAD INLOW	/INIT INPUT
	DCA INDEV
	DCA LIST3+1
	TAD SXS1	/INIT LIST
	DCA L2I
	ISZ ECHOSW	/SET ECHO - ( "DCA ECHOSW" FOR HALF-DUPLEX)
GSTART,	TAD CCR /POSITION PRINT
	JMS I OUT1
	TAD COMBEG	/SET COMMAND BUFR PTR
	DCA AXCOMB
	TAD C77
	DCA ARGIN	/INIT ARGS
	DCA VEC3
	DCA VEC2	/CLEAR 
	DCA ZSW	/INIT Z
GTOP,	ISZ ARGIN	/NEXT ARG
	TAD ARGIN	/TEST FOR TOO MANY COMMAS
	TAD M103
	SMA CLA
	ESCAPE	/ARGIN=103 OR GREATER
	DCA I ARGIN	/CLEAR
GEXP,	TAD M41
GMIN,	TAD C7041 	/NOP OR CIA
	DCA G2
DBCV2,	DCA TEMP3
	JMS I CHI1	/(CHIN)
	JMS I COMAN1	/LOAD COMMAND BUFR
	TAD CHAR
	TAD NUMB
	SMA
	JMP GLOM	/CONTINUED ARGUEMENTS
	TAD NINE
	SMA
	JMP COUNT	/CONTINUED NUMBER
GLOM,	CLA
	TAD TEMP3
G2,	HLT	/(NOP) OR (CIA)
	TAD I ARGIN
	DCA I ARGIN
	JMS I SORTJ
		LIST1-1
		OPS1-LIST1	/HANG ON TO COMMAND.
	TAD VEC2	/IF VEC2=0, VEC2=VEC1
	SNA
	TAD VEC1
	CMA
	TAD VEC1	/ARG1=VEC1-VEC2-1
	SMA
	ESCAPE	/.AND.
	DCA ARG1	/ARG0 .LE. ARG2
	TAD VEC1
	SPA	/ARG0 .GE. 0
	ESCAPE
	DCA ARG0
	TAD CHAR
	DCA SAVE
	JMS I CHI1	/GET CR
	TAD MCR
	SZA CLA	/C.R. MUST FOLLOW
	ESCAPE
	TAD SAVE
	JMS I SORTJ
		LIST2-1
		OPS2-LIST2
ERRORS,	ESCAPE

COUNT,	DCA AXTEM	/DECIMAL TO OCTAL
	TAD TEMP3
	RTL CLL
	RAL
	DCA SAVE
	TAD TEMP3
	RAL
	TAD SAVE
	TAD AXTEM
	JMP DBCV2	/GET NEXT DIGIT

SXS1,	L2
NINE,	12
NUMB,	-272
M103,	-103
C7041,	7041
ASTER,	CMA CLL /SET SIGN TEST FLAG
	DCA ZSW
	TAD C2000	/INTENSIFY=+2000
	TAD I ARGIN
	SZL
	TAD C2000
	DCA I ARGIN
	JMP GEXP

EXLAS,	TAD M2
EXNEX,	IAC
PERI,	TAD THSN	/.
	SKP
SLAS,	TAD LSTN	//
	DCA TEMP3
	DCA CHAR
	JMP GLOM



PRNT1,	0	/BINARY TO BCD
	DCA VAL	
	TAD M3
	DCA CNT1
	TAD ADDR
	DCA XYZ+2
	DCA BOX
	JMP .+3
	ISZ BOX
XYZ,	DCA VAL
	TAD VAL
	HLT	/(TAD CON + (DX) )
	SMA
	JMP XYZ-1
	CLA
	TAD BOX
	TAD C260
	JMS I VPRNT	/PRNT CHAR OR WRITE CHAR
	ISZ XYZ+2
	ISZ CNT1
	JMP XYZ-3
	JMP I PRNT1


ADDR,	TAD CON
CON,	7634
	7766
	7777

INLIST=.
	SPACES	/SPCS
	AONE	/B.A.
	FULL	/F.F.
	FULL	/BELL
	CHIN+1	/L.F.
	RUB1	/R.O.
	EOL	/C.R.


/UNPACKING SUBROUTINE UNPACKS 6BIT ASCII ALL CODES 200 TO
/377 XCEPT 337 AND 237, WHICH ARE NOT PACKED BY PACBUF

/XCTEM IS A TEMP SWITCH USED TO COUNT OFF SPECIAL CHARS.

UTRA,	0	/ENTER W AC=0
	CLA CMA
UP1,	DCA XCTEM	/SET SPEC CHAR SW
	TAD XCT	/XCT IS 0 FOR LH, IS +1 FOR RH
	SNA
	ISZ PACKOT	/XCT=0, INCR WD PTR FOR LH
	CIA
	DCA XCT	/IF 0, REMAINS 0. IF +1, BECOMES -1
	TAD I PACKOT	/GET DATA
	ISZ XCT
	JMS I ROT6RI	/HERE FOR LH
	AND C77
	TAD M37
	ISZ XCTEM	/TEST IF PREV PASS FOUND 37
	JMP UP4	/HERE IF PREV PASS WAS 37
UP2,	SMA SZA
	TAD M100	/GREATER THAN 37
	SNA
UP3,	JMP UP1	/EQUALS 37, PASS AGAIN
	TAD C337
	JMP I UTRA	/EXIT WITH 240 TO 336,200 TO 336,337 TO 377
UP4,	SMA	/HERE IF PREV PASS WAS 37
	JMP UP3+1	/337 TO 377
	JMP UP2+1	/200 THRU 236

NUMSGN,	DCA BOX
	TAD BUFEND
	TAD BUFR
	CIA
	DCA VEC1
	TAD VEC1
	TAD C6020
	SPA
	JMP .+3
	ISZ BOX
	JMP .-6
	CLA
	TAD BOX
	TAD C260
	JMS I OUT1
	JMP I .+1
	PRNT
C6020,	6020
/BASIC CHAR PACKING ROUTINE. 337 AND 237 NOT PACKED
/ALL CHARS FROM 240 TO 336 PACKED 6BIT, CHARS 200 TO 236
/AND 340 TO 377 PACKED 37XX. 3737 IS ILLEGAL AND NOT PACKED.

PACBUF,	0	/ENTER W	CHAR SET, AC=0
	SNA
	TAD CHAR
	DCA TEMP7
	TAD TEMP7
	TAD M237
	SPA SNA
	JMP PB1	/L.E. 237
	TAD M100
	SMA
	JMP PB1	/G.E. 337
	TAD C337	/BETWEEN 240 AND 336, RESTORE
PB3,	JMS PACK	/PACK IT
	JMP I PACBUF

/////
PB1,	AND C77
	SNA CLA	/BETWEEN 200 TO 237 AND 337 TO 377
	JMP I PACBUF	/EQUAL TO 237 OR 337, DONT PACK IT
	TAD C337	/200 TO 236,340 TO 377 PACKED 37XX
	JMS PACK	/PACK 37 LEADER
	TAD TEMP7
	JMP PB3	/PACK REST OF WD

///////
PACK,	0	/SETS PACK PTRS AND PACKS CHAR
	AND C77	/MASK 6BIT
	ISZ XCTIN	/TEST SW:
	JMP PB2	/0=LH
	TAD I PACKIN	/-1= LOAD RH
	DCA I PACKIN
	JMP I PACK	/AND EXIT
PB2,	JMS I ROT6RI
	RAR	/ROTATE TO LH
	ISZ PACKIN	/INCR WORD PTR
	DCA I PACKIN	/LOAD
	CLL CMA
	DCA XCTIN	/RESET WDSW
	TAD BUFEND
	TAD PACKIN
	SNL CLA	/TEST FOR END OF BUFFER. BUFEND IS A NEG QTY
	JMP I PACK
	ESCAPE	/BUFR OVERFLOW
BUFEND,	-STOP+2
/PARALLEL LIST SORT AND BRANCH. CALL JMS SORTB FOLLOWED BY
/LIST-1 (PTR TO SORT LIST OF CHARACTERS) AND THEN BY
/BRANCH-LIST (THE LIST OF BRANCH LOCATIONS)
/EXIT IS EITHER TO A FOUND BRANCH LOCATION OR TO LOCATION
/FOLLOWING THE BRANCH-LIST PTR.
SORTB,	0	/SORT AND BRANCH ROUTINE.
	SNA 
	TAD CHAR	/CHAR IS ASSUMED IF CALLED WITH AC=0
	DCA TEMP6	/SAVE SEARCH CHAR
	TAD I SORTB
	DCA AXTEM
	ISZ SORTB
	TAD I AXTEM
	SPA	/NEG ENTRY ENDS LIST
	JMP SEX
	CIA
	TAD TEMP6	
	SZA CLA
	JMP .-6
	TAD AXTEM	/MATCH FOUND.
	TAD I SORTB
	DCA TEMP1
	TAD I TEMP1
	DCA TEMP1
	JMP I TEMP1	/DOUBLE INDIRECT JUMP
/////
SEX,	CLA	/MATCH NOT FOUND.
	ISZ SORTB
	JMP I SORTB

COMAND,	0	/LOAD COMMAND BUFR AND TEST OVERFLOW
	DCA I AXCOMB
	TAD BINST
	CIA CLL
	TAD AXCOMB
	SZL CLA
	ESCAPE
	JMP I COMAND


OUTLIS=.
	OUTALT	/CONVERT ALT TO DOLLAR SIGN
	OUTX+1	/LF
	OUTTAB	/TAB
	OUTX+1	/377 OR 257 TO TRIM COMMENTS
	OUTCRL	/CR
SPACES,	TAD ECHOSW	/SPACE READIN
	SNA CLA	/TEST READ MODE
	OSR	/BIT0 UP TO COMPRESS SPACES TO TABS
	SMA CLA
	JMP MOR+4	/PACK
	CMA	/SET 1 SPACE
SP2,	DCA CNT
	JMS I READ1	/(CHIN)
	TAD M240
	SNA CLA
	JMP SP2	/IGNORE EXTRA SPACES.
	ISZ CNT
	TAD M27	/TAB
	TAD C240	/SPACE
	JMS I PACK1	/(PACBUF)
	JMP MOR+1	/SORT - (MOR+1)
M27,	-27

APP,	TAD LSTN	/APPEND
	DCA ARG0
	JMP INS
/////
CNGE,	JMS DELP	/CHANGE
XNS,	TAD ARG0	/INSERT
	SNA CLA	/TEST FOR TOP
INS,	ISZ ARG0	/SET TO TOP
	TAD ARG0
	JMS I FIN1	/FIND THE POINTER
	DCA THIS
	TAD I THIS
	DCA XSAV
	CMA
	TAD ARG0
	DCA THSN
AONE,	TAD BUFR	/BEGIN LINE
	DCA PACKIN
	DCA XCTIN
MOR,	JMS I READ1 
	JMS I SORTJ
		LIST5-1
		INLIST-LIST5
	JMS I PACK1
	JMP MOR

/////
EOL,	JMS I ENDLNI	/END LINE
	ISZ LSTN	/ADD LINE
	ISZ THSN
	JMP MOR
/(ISZ ECHOSW) - FOR HALF-DUPLEX
LIST,	TAD ARG0	/LIST
	SZA CLA	/TEST ARGS
	JMP L0
	ISZ ARG0	/SET TO #1
	TAD LSTN	/SET FULL RANGE
	CIA
	DCA ARG1
L0,	TAD ARG0
	CIA	/PROTECT OUTPUT
	TAD LSTN
	SPA CLA
	ESCAPE	/LINE NUMBER DOES NOT EXIST IN BUFR
	TAD ARG0
	JMS I FIN1
	DCA THIS	/SAVE POINTER
	TAD I THIS	/GET START
	DCA PACKOT
	TAD I PACKOT	/SAVE POINTER FOR SEARCH,
	DCA XSAV
	DCA XCT
	TAD ARG0	/SET POINTER
	DCA THSN
	JMP I L2I	/TO SLOOK OR L2 OR GSTART (IN COMPILER MODE)
L2,	JMS I UTR1	/UNPACK
	JMS I OUT1	/PRINT
L3,	TAD CHAR
	TAD MCR
	SZA CLA	/TEST FOR EOL
	JMP L2
	ISZ ARG0	/SET NEXT LINE. COMPILER RETURNS HERE.
	ISZ ARG1	/TEST LINE COUNT
	JMP L0	/GET NEXT LINE
	JMP I TE1	/CLEAR ALL PATCHES
DELP,	0
	TAD ARG0
	JMS I FIN1
	DCA THIS	/DECREASE TOTAL.
	TAD ARG1
	TAD LSTN
	DCA LSTN
	TAD LSTN
	SPA SNA CLA	/TEST FOR OVERKILL
	JMP I KILL1
	CMA
	TAD ARG0
	SNA	/PROTECT #1
	IAC
	DCA THSN	/ARGS AOK
DEL0,	TAD I THIS
	DCA DTEM
	TAD I DTEM	/CHAIN TOGETHER
	DCA I THIS
	ISZ ARG1
	JMP DEL0
	JMP I DELP

DELE,	JMS DELP	/DELETE
	JMP I TE1



SCONT,	JMS I INDEV /S=BELL
	DCA LIST3+1

SLOOK,	JMS I UTR1	/UNPACK
	JMS I OUT1	/PRINT
	JMS I SORTJ	/TEST PRINTED CHARS.
		LIST3-1
		LISTGO-LIST3
	JMS I PACK1	/PACK SEARCHED CHARS.
	JMP SLOOK	/CONTINUE SEARCH


/SEARCH ROUTINES

SRETN,	TAD LIST3+1
	TAD MCR	/TEST FOR CR=SEARCH CHAR
	SZA CLA
	JMP SRETN1
	TAD XSAV
	SNA
	JMP SRETN1
	DCA PACKOT	/SET THE NEW INPUT PTR
	DCA XCT
	TAD I XSAV
	DCA XSAV	/INCREMENT THE CHAIN
	TAD C240
	JMS I PACK1	/PACK A SPACE
	CMA
	TAD LSTN
	DCA LSTN	/DECREMENT LINE COUNT
	JMP SCONT
SRETN1,	ISZ ARG0	/SET NEXT LINE
	JMS I ENDLNI	/END OF SEARCHED LINE
	ISZ ARG1	/TEST COUNT
	JMP I LIS	/CONTINUE
	TAD VEC1	/TEST FOR ENTIRITY
	SZA CLA
	JMP I FULL1	/TERMINATE
	ISZ VEC1	/COMPRESS
	DCA ARG0	/CLEAR COUNT
	DCA ECHOSW	/NON-PRINT
	TAD END
	DCA BUFR	/RESET BUFFER
	JMP XCRET+1


SLINE,	TAD CCR	/TYPE CR.LF
	JMS I OUT1	/SET CHAR
	JMS I ENDLNI	/END LINE
	ISZ ARG0	/MOVE POINT
	ISZ LSTN	/ADD A LINE.
SBAR,	TAD BUFR	/RESTART PACK BUFFER
	DCA PACKIN
	DCA XCTIN
SFOUND,	JMS I CHI1	/(CHIN)
	JMS I SORTJ	/TEST INSERTS
		LIST6-1
		SRNLST-LIST6
SGOT,	JMS I PACK1	/PACK INSERTS
	JMP SFOUND	/MORE INPUT

M220,	-220
OUT,	0	/OUTPUT A CHARACTER
	DCA CHAR
	KSF	/TEST FOR CONTROL P STOPS ALL OUTPUT
	JMP .+4
	KRS
	TAD M220
	SZA CLA
	TAD ECHOSW
	SNA CLA /TEST PRINT CONTROL
	JMP I OUT
	JMS I SORTJ
		LIST4-1
		OUTLIS-LIST4
	ISZ TCNT	/COUNT ONE LETTER
	TAD CHAR
OUTX,	JMS I OUTDEV
	JMP I OUT
/////
OUTCRL,	TAD CCR
	JMS I OUTDEV
	DCA TCNT
	TAD CLF
	JMP OUTX
/////
OUTTAB,	OSR	/BIT1 DOWN FOR SPACES.
	RAL
	SPA CLA
	JMP OUTRT
	TAD TCNT
	TAD LINEFD
	SMA
	JMP .-2
	DCA TCNT
	TAD C240
	JMS I OUTDEV
	ISZ TCNT
	JMP .-3
	JMP I OUT
/////
OUTRT,	TAD CTAB	/BIT1 UP FOR TAB-R.O.
	JMS I OUTDEV
	TAD CRO
	JMP OUTX


OUTALT,	TAD C273	/CONVERT ALT TO SEMICOLON
	DCA CHAR
	JMP OUTX-2
RUB1,	TAD PACKIN
	CIA
	TAD BUFR
	SZA CLA	/TEST NULL LINE
	TAD ECHOSW
	SNA CLA	/TEST INPUT
	JMP CHIN+1	/NULL LINE
	TAD SPLAT
	JMS I OUT1
	ISZ XCTIN	/IS -1 IF NEX IS RH
	JMP RUB4	/LH NEXT
RUB2,	CMA	/RH WAS NEXT
	TAD PACKIN
	DCA PACKIN	/BACKUP
	TAD I PACKIN
	TAD M37	/TEST 
	AND C77	
	SZA CLA
	JMP RUB3	/LH
RUB5,	TAD I PACKIN
	AND M100
	DCA I PACKIN	/CLEAR RH
	CMA	/WAS 37, REWRITE RH:XCTIN=-1
RUB3,	DCA XCTIN	/OK, 0 WILL WRITE LH OF PRESENT WD
	JMP CHIN+1	/BACK TO CHIN
RUB4,	TAD I PACKIN
	AND M100
	TAD C4100
	SZA CLA	/M100=7700, MASKS LH. 4100+3700=0
	JMP RUB5	/NOT 37, XCTIN=-1,REWRITE RH
	JMP RUB2	/IS 37, XCTIN=0, REWRITE PREV WD

C4100,	4100
SPLAT,	334

CHIN,	0	/READ IN A CHARACTER SUBR.
	JMS I INDEV	/INPUT
	AND P177	/MASK PARITY
	SNA	/IGNORE BLANK AND L/T
	JMP CHIN+1
	TAD C200
	JMS I OUT1	/ECHO INPUT
	TAD CHAR
	JMP I CHIN
P177,	177
SRNLST=.
	SBAR	/B.A.
SXS2, 	SLOOK	/F.F. PATCH LIST
	SCONT	/BELL
	SLINE	/L.F.
	RUB1	/R.O.
LISTGO=.
	SRETN	/C.R.
	SGOT	/SEARCH CHARACTER

XCRET,	JMS I INDEV
	DCA LIST3+1	/SAVE SEARCH CHARACTER
	TAD SXS2
	DCA  L2I	/PATCH TO "SLOOK"
	TAD BUFR	/SET PACK POINTER.
	DCA PACKIN
	DCA XCTIN
	JMP I LIS

KILL,	TAD END
	DCA BUFR
	DCA LSTN
	DCA THSN
	DCA FRST
	DCA WSAV1
	JMP I TE1
PAUSE

