
PDP7/9 SYMBOLIC TAPE EDITOR - REVISED 8/21/67


/57 ASSIGNMENT FOR 4K CANUTE

MCD=707042

	JMS CLFLAG
	PUNSET
	TTYSET
	LAC (NOP
	DAC TTOSWT
	DAC TISW
	JMP CONTROL

/CANUTE - PART I

LUON=20	LN=40	TN=40	PN=300
DOLLAR=45

/CONTROL STATEMENT "HANDLER"

CONTROL,	CLC
	DAC ARGC#NT
	DZM  ARG#2	/ARG2=SECOND  ARG IF ANY
	DZM ARG#0	/ARG0=FIRST
	CLC
	DAC ARG#1	/ARG0-ARG2
	LAC (NOP
	DAC CRSWT
	DAC DLYSWT
	LAC (SKP
CON0,	DAC N#ARG	/BECOMES  NOP IF ANY ARGS IN
	DZM ARG#S	/SIGN OF NEXT NUMBER
	DZM N#UM	/WILL CONTAIN VALUE
	DZM LUI#NIN	/COUNTS DIGITS IN

CON1,	CLL
	SETDEC
	JMS DECLUI	/LINK CONTAINS MODE
	LAC LUICHR
	SAD (CHAR R.
	JMP CONPER
	SAD (CHAR R/
	JMP CONSLA

CON2,	LAC LUINUM
	XOR ARGS
	ADD NUM
	DAC NUM
	DZM ARGS
	LAC LUICHR	/CONTAINS FIRST NON-DIGIT CHAR
	SAD (CHAR R-
	JMP CONMIN
	SAD (CHAR R,
	JMP CONAG	/END OF ARGUMENT
	SAD (CHAR R=	/TO PRINT VALUE
	JMP PRNVAL
	RCR		/REMOVE  CASE  BIT
	SNA
	JMP CONLF
	SAD (2
	JMP CONTROL
	SAD (10
	JMP CONLF	/LINE  FEED SEEN
	SAD (4
	JMP CON1	/SPACE MEANS PLUS
	SZL
	JMP CONERR	/NOT LOWER CASE, ERROR
	ADD (LAC DSPTCH
	DAC .+1
	XX
	DAC  CONOUT	/SAVE  ENTRY FOR LATER DISPATCH
	SNA
	JMP CONERR

/MORE CONTROL STATEMENT INPUT

CON3,	LAC ARGCNT
	SZA
	JMP CON4	/NON-ZERO MEANS NO ARGUMENTS
	LAC NUM		/ZERO MEANS 1, SET  UP SECOND
	DAC ARG2
	CMA
	ADD ARG0
	SMA
	CLC
	DAC ARG1
	LAC LUININ
	SNA
	JMP CONERR

/WAIT FOR CARRIAGE RETURN TERMINATION

CON5,	CLL
	JMS LUI
	RCR
	SAD (10
	JMP CONERS	/LINE FEED MEANS ERASE
	SAD (2
	SKP
	JMP CONERR

CONOUT,	XX	/CALL FUNCTION, RETURN HERE
	JMP CONTROL

/COME HERE IF ONLY  ONE ARGUMENT IN

CON4,	LAC LUININ
	SNA
	JMP CON5
	LAC NUM	/ONE ARGUMENT
	DAC ARG0
	DAC ARG2
	LAC (NOP
	DAC NARG
	JMP CON5

/ERASE AFTER LINE FEED

CONERS,	LAW 4
	JMS TYPCHR
	JMP CONTROL

/ERROR ROUTINE

CONERR,	LAW CHAR R?
	JMS TYPCHR
	JMS TCR
	JMP CONTROL 

/SOME SPECIAL ROUTINES

CONSLA,	LAC LASTN
	SKP
CONPER,	LAC THISN
	DAC LUINUM
	ISZ LUININ	/SIMULATE NUMBER IN
	CLL		/ZERO LINK FOR NODE
	JMS LUI
	JMP CON2

/SET TO SUBTRACT NEXT ELEMENT

CONMIN,	CLC
	DAC ARGS
	JMP CON1

/ARGUMENT IN

CONAG,	ISZ ARGCNT
	JMP CONERR
	LAC LUININ
	SNA
	JMP CONERR
	LAC NUM
	DAC ARG0
	LAC (NOP	/SET ARGUMENT IN SWITCH
	JMP CON0

/CHECK THE VALUE OF AN ARGUMENT FOR RANGE

CHKVAL,	0
	DAC VAL#TEM
	SMA!SZA!CMA
	SKP
	JMP CONERR
	TAD (1
	TAD LASTN
	SPA
	JMP CONERR
	LAC VALTEM
	JMP I CHKVAL

/CHECK FOR ZER ONE OR TWO ARGUMENTS. RETURN . 1 WITH ZERO
/RETURN . 2 WITH ONE OR TWO LEGAL ARGS

CHKARG=JMS .
	0
	XCT NARG
	SKP
	XT  CHKARG	/NO ARGS
	LAC ARG0
	JMS CHKVAL
	LAC ARG2
	JMS CHKVAL
	LAC ARG2
	CMA
	ADD ARG0
	SMA
	JMP CONERR
	ISZ CHKARG-JMS
	XT  CHKARG

/CHECK FOR CONE AND ONLY ONE ARGUMENT
/RETURN . 1 IF NO ARGS, RETURN . 2 WITH -N 1  IN AC IF ONE

CHKONE=JMS .
	0
	XCT NARG
	SKP
	XT CHKONE
	LAC ARGCNT
	TAD (1
	SZA
	XT CHKONE
	LAC ARG0
	CMA
	TAD (1
	SZA
	ISZ CHKONE-JMS
	XT CHKONE

/SIMULATE NO ARGUMENTS

NOARG,	0
	CLC
	DAC ARG1
	DZM ARG0
	DZM ARG2
	LAC (SKP
	DAC NARG
	JMP I NOARG


/LINE FEED IN - PRINT NEXT LINE

CONLF,	LAC LUININ
	SZA
	JMP CONERS
	LAC THISN
	ADD (1
CONLF1,	JMS CHKVAL
	DAC ARG0
	DAC ARG2
	LAC (NOP
	DAC NARG
	JMS LIST
	JMP CONTROL

/PRINT THE VALUE OF THE ARGUMENT

PRNVAL,	SETDEC
	LAC (33
	DAC BTACAS
	LAC NUM
	DECPNT
	JMS TCR
	JMP CONTROL

/BACKUP AND PRINT LINE

BACKUP,	0
	LAC LUININ
	SZA
	JMP CONERR
	CLC
	TAD THISN
	JMP CONLF1

/LIST 1 OR N PAGES

WRIT,	0
	CHKONE
	SKP
	JMP WRIT1
	JMS WRITE
	JMP I WRIT

/W HAS ARGUMENTS

WRIT1,	DAC W#CNT

WRIT2,	JMS KILL
	JMS NOARG
	JMS READ
	JMS WRITE
	LAC LASTN
	TAD (-102 1
	SMA
	JMP .-2
	DAC F#CNT
	LAW 10
	JMS LUO
	ISZ FCNT
	JMP .-3
	ISZ WCNT
	JMP WRIT2
	JMS KILL
	JMP I WRIT

/FIODEC TO TELETYPE AND OUTPUT

TTO=JMS .	0
	AND (77
	DAC T#OCH
TTOSWT,	NOP
	SAD (72
	JMP TOLC
	SAD (74
	JMP TOUC
	SAD (77
	JMP TOCR
	SAD (36
	JMP TOTB
	SAD (76
	703301
	SKP
	JMP TQUEST
	ADD (LAC TABLE
	DAC .+1
	XX

FIOCAS,	NOP
	JMS RAR9		/LOWER CASE CHAR IN LEFT HALF
	AND (177
	SNA
	JMP TOSC
	TAD (777700
	SMA
	JMP TODOL
TQU,	JMS TYPCHR
	XT  TTO

TOLC,	LAC (NOP
	SKP

TOUC,	LAC (SKP
	DAC FIOCAS
	XT  TTO

TOCR,	JMS TCR
	XT  TTO

TQUEST,	LAC (47
	JMP TQU

/A TAB IS OUTPUT

TOTB,	JMS TTAB
	XT  TTO

/CHAR WITH NO CORRESPONDENCE

TOSC,	LAW DOLLAR
	JMS TYPCHR
	SETOCT
	LAC FIOCAS
	XOR (SKP
	SZA!CLA
	LAC (100
	TAD TOCH
	DECPNT
	XT  TTO

/REMAINDER OF OUTPUT CONVERSION ROUTINE

TODOL,	DAC TO#TEM
	SAD (17	/CHECK FOR CENTER DOT
	JMP TOCEN
	LAW DOLLAR
	JMS TYPCHR
	LAC TOTEM
	JMS TYPCHR
	XT  TTO

/SET TO PROCESS AFTER A CENTER DOT

TOCEN,	LAC (JMP TOCHK
	DAC TTOSWT
	XT  TTO

/CHECK CHARACTER AFTER A CENTER DOT

FIODEC

TOCHK,	SAD (CHAR R.
	JMP TOPER
	SAD (CHAR R,
	JMP TOCOM

TELETYPE

	LAW DOLLAR
	JMS TYPCHR
	LAC TOTEM
	JMS TYPCHR
	LAC (NOP
	DAC TTOSWT
	LAC TOCH
	JMP TTOSWT 1

TOPER,	LAW 35
	SKP
TOCOM,	LAW 37
	JMS TYPCHR
	LAC (NOP
	DAC TTOSWT
	XT  TTO

/TELETYPE INPUT AND CONVERSION TO FIODEC

TTI=JMS .	0
TISW,	NOP
	STL
	JMS LUI		/SIX BIT BAUDOT RETURNED FROM LUI
	SAD (DOLLAR
	JMP TIST		/DOLLAR SIGN CHARACTERS
	SAD (35
	JMP TICOL		/COLON
	SAD (37
	JMP TISEM		/SEMICOLON
	RCR		/BACK TO 5-BIT BAUDOT,-CASE BIT GOES TO LINK
	SAD (10
	JMP TTILF		/LINE FEED
	SAD (2)
CRSWT,	NOP		/MODIFIED FOR Y COMMAND,-ON C. R.
	SNA
	JMP BLANK		/DELETE OR TERMINATION CHARATER
	TAD (LAC TELFIO
	DAC  Z
TTIB,	LAC (SKP
	SNL		/LINK=0 FOR LOWER CASE BAUDOT
	LAC (NOP
	DAC  Z 1
TTIC,	LAC FOCS
	RAL
Z,	XX		/LOAD CORRECT FRODEC CODE
	XX		/SKIP IF UPPER CASE BAUDOT,-NOP IF LOWER CASE
	JMS RAR9		/LEFT HALF OF FRODEC TABLE IS LOWER CASE IS BAUDOT CHARS
	AND (177		/RIGHT HALF CONTAINS CONVERSION FOR UPPER CASE BAUDOT CHARS
	TAD (377700
	SMA		/UPPER CASE FRODEC?
	JMP FOTC		/NO, CHECK LOWER CASE
	SNL		/IS UPPER CASE ALREADY TAKE CARE OF?
	JMP FOUC		/NO, THEN OUTPUT IT.
CASEOK,	AND (77
	XT  TTI

/LINE FEED - TYPE CARRIAGE RETURN AND LOWER CASE

TTILF,	LAW 4		/CARRIAGE RETURN
	JMS TYPCHR
	JMP SPECXT

/INPUT AND UPPER CASE LETTER, OR A NUMERIC CODE

TIST,	LAM -2
	DAC LUININ
	SETOCT
	STL		/SET MODE INTO LINK
	JMS DECLUI
	LAC LUININ
	SAD (-2
	JMP TLET
	LAC LUINUM
TISTS,	AND (177
	DAC S#V
	LAC (LAC SV
	DAC Z
	STL
	JMP TTIB

/FIODEC CASE HANDLING

FOUC,	LAC (400074		/UPPER CASE
	JMP FOTC 3
FOTC,	SNL
	JMP CASEOK
	LAC (72		/LOWER CASE
	DAC F#OCS
	LAC TISW		/SAVE OLD VALUE OF TISW
	DAC TISWSV#
	LAC (JMP FOXT	/MODIFY FLOW AFTER OUTPUT A FRODEC CASE CHAR.
	DAC TISW
	LAC FOCS
	JMP CASEOK

FOXT,	LAC TISWSV		/RESTORE TISW
	DAC TISW		/NOW CASE OK, SO CAN OUTPUT THE CHARACTER
	JMP TTIC

RAR9,	0
	RTR
	RTR
	RTR
	RTR
	RAR
	DAC RAR#TEM
	LAC RAR9
	RAL
	LAC RARTEM
	JMP I RAR9

/HANDLE DOLLAR SIGN TYPE INPUT

TLET,	LAC LUICHR		/CONTAINS CHAR OFTEN DOLLAR SIGN
	RCR		/LINK CONTAINS BOUDOT CASE
	SAD (10		/D FOR LOWER CASE
	JMP TTILF		/LINE FEED
	SAD (2
	JMP DOLCAR		/CARRIAGE RETURN
	SNA
	JMP TISW 1
	SZL
	JMP TPNC		/UPPER CASE CHAR.
	TAD (LAC TELFIO	/LOWER CASE,-USE OLD TABLE
	DAC .+1
	XX
	TAD (100000
	DAC SV
	LAC (LAC SV
	DAC Z
	JMP TTIB

TPNC,	TAD (LAC TELPNC	/NEW TABLE FOR UPPER CASE
	DAC Z		/BOUDOT DOLLAR SIGN CHARS
	JMP TTIB

/MAKE COLONS AND SEMI-COLONS INTO CENTER DOT ETC

FIODEC

TICEN,	0
	LAC TISW	/SAVE RESTORE FOR SWITCH
	DAC TI#SWV
	LAC (JMP TICENA	/MODIFY FLOW FOR DBLE CHARS
	DAC TISW
	LAW 40		/CENTER DOT
	JMP TISTS
TICENA,	LAC TISWV
	DAC TISW
	JMP I TICEN

TICOL,	JMS TICEN
	LAW CHAR R.
	JMP TISTS

TISEM,	JMS TICEN
	LAW CHAR R,
	JMP TISTS

TELETYPE

/DOLLAR SIGN- CARRIAGE RETURN ADD TO NEXT LINE

DOLCAR,	LAC (JMP DSET
	DAC TISW
	LAC (NOP
	DAC DLYSWT
	LAC (77
	JMP CASEOK

/SET UP TO PRINT AND COPY THE NEXT LINE

DSET,	LAC (JMP I DSUB
	DAC TISW		/EXIT FROM GET NEXT CHARACTER
	LAC (JMS DSUB	/COME TO PRINT AND USE NEXT CHARACTER
	DAC OUTPUT
	LAC (SKP
	DAC SUPSW
	LAC (NOP
	DAC CRSWT
	LAC THISN
	ADD (1
	DAC ARG0
	DAC ARG2
	JMS CHKVAL
	CLC
	DAC ARG1
	JMS UNPACK
	HLT

/GET THE NEXT CHARACTER FROM THD LINE, PRINT IT, AND APPEND IT TO THE NEW LINE

DSUB,	0
	SAD (277
	JMP DSUB1
DLYSWT,	NOP	/SKIP IF Y FORMAT
	JMP DSUBA
	TTO
	LAC (-52		/0.7 SEC DELAY
	DAC 7		/BETWEEN CHARS
	CLON		/(Y COMMAND)
	JMP .
	LAC LUICCT
	SAD (-0		/CHECK FOR TYPE IN
	JMP DSUB0
	JMS LUI
	RCR
	SZA
	JMP CONERR
	LAC (JMP DSUBCR
	DAC CRSWT
	LAC (NOP		/SET TO APPEND TYPED CHARACTERS TO LINE
	DAC TISW		/AND RETURN (DSUBCR) WHEN CR IS TYPED
	JMP DSUB0

/SET TO APPEND REMAINING CHARACTERS IN ORIGINAL LINE
/TO LINE, BUT NOT TYPE THEM OUT
DSUBCR,	LAC (JMP DSUB0+1
	DAC DLYSWT
	LAC (JMP I DSUB
	DAC TISW
	LAC (NOP
	DAC CRSWT
	JMP I DSUB

DSUBA,	TTO
DSUB0,	LAC TOCH
	SAD (72
	JMP DLC
	SAD (74
	JMP DUC
	JMP CASEOK	/APPEND THE CHARACTER

/DELETE THE ORIGINAL LINE
DSUB1,	LAC THISN
	DAC ARG0
	DAC ARG2
	CLC
	DAC ARG1
	JMS DELETE	/DELETE THE OLD VERSION OF THE LINE
	LAC (NOP
	DAC TISW
	LAC DLYSWT		/IF  CR ONLY APPEND CHARS
	SAD (JMP DSUB0+1	/IF Y FORMAT AND CR TYPED FINISH LINE.
	SKP
	JMP TISW+1		/RETURN TO APPEND TO THE LINE
	LAC (277
	JMP CASEOK

DUC,	LAC (400074
DLC,	DAC FOCS
	JMP CASEOK

/DISPATCH TABLES FOR CONTROL LETTERS

DSPTCH,	0
	JMS TAPE
	0
	JMS OALL
	0
	0
	JMS NEXT
	0
	0
	JMS LIST
	JMS READ
	JMS TAG
	JMS INSERT
	JMS PUN
	JMS CHANGE
	0
	0
	JMS SKIP
	JMS DELETE
	JMS BACKUP
	JMS STOP
	JMS Y
	JMS FEED
	JMS X
	JMS APPEND
	JMS WRIT
	0
	0
	0
	JMS Q
	JMS KILL
	0

/TELETYPE 28 TO FIODEC CONVERSION
/FIRST TWO DIGITS FOR LOWER CASE, LAST 3 FOR UPPER CASE BAUDOT
/FIODEC CODE CONVERSION WHICH IS ITSELF UPPER CASE IS INDICATED BY AN OCTAL
/DIGIT 1 PRECEDING THE 6 BIT FIODEC CODE

TELFIO,	0	23005	77077	46011	/NULL; T,5; CR,CR; S,9;
	0	70173	45033	44073	/SPACE; H,#; ETC.
	0	43055	51004	67154
	71010	47020	63000	25000
	65003	31140	64000	62121	/X,T,+,-,?,^ = UPPERCASE FIODEC CHARS
	22036	30006	66111	27021
	61054	26002	41056	0
	24007	50001	42057	0

/CONVERSION FOR DOLLAR SIGN CHARACTERS

TELPNC,	0	0	0	0
	0	106	104	40
	0	155	0	110
	0	0	133	120
	0	101	0	103
	0	0	156	105
	107	0	102	0
	0	0	157	0

/FIODEC TO TELETYPE

TABLE,	010010	073143	063165	041147
	025115	003157	053113	071161
	031127	007055	0	0
	0	0	0	0

	033137	057047	050150	002102
	070170	036136	062162	056156
	052152	042142	0	015135
	0	0	0	0

	117043	064164	074174	022122
	016116	014114	006106	032132
	072172	024124	0	0
	061027	023123	065155	075175

	0	060160	046146	034134
	044144	040140	054154	026126
	012112	030130	0	017013
	0	0	100100	0

START
