Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap1_198111 - decus/20-0015/alvine.mac
There are 5 other files named alvine.mac in the archive. Click here to see a list.
	TITLE ALVINE ,SON OF,


MLON
INTERNAL ALVINE
P=14
ALVINE:	INIT 17
	SIXBIT /DSK/
	0
	HALT
	ENTER NAME
	HALT
	OUTPUT [IOWD 1,LST	;OUTPUT LENGTH OF FILE
		0]
	OUTPUT LST
	STATZ 740000
	HALT
	RELEASE 
	POPJ P,

LST:	IOWD EDEND-EDX+1,EDXX
	0
NAME:	SIXBIT /LISP/
	SIXBIT /ED/
	0
	0
	0

VAR
LIT
EDXX:




TENEX==0
DECUS==1-TENEX		;SOLELY FOR PROPER ALTMODE...

IFN DECUS,<ALTMOD=33>
IFN TENEX,<ALTMOD=175>

PHASE 0
EDX:	JRST ED(R)
	JRST RD2(R)	;RETURN FOR BELL
	JRST GRNDEF(R)

MESS:	0

CMER1:	ASCII /   ? /
MER7:	ASCII /*UDI /
MER1:	ASCII /*EDR /
MER2:	ASCII /*EDN /
MER4:	ASCII /*UBP /
MER5:	ASCII /*IPF /
MER6:	ASCII /*UBP /
MER3:	ASCII /*NSM /
MER8:	ASCII /*FNF /
LPNAME:	ASCII / %LP /
RPNAME:	ASCII / %RP /
DT:	ASCII /  %D /
LMBD:	ASCII /   LAMBDA /
PRG:	ASCII /PROG /
LAMB=LMBD+1
LPS:	ASCII / LPS /
RPS:	ASCII / RPS /
BAL:	ASCII / BAL /
PC:	ASCII /   % /
STR:	ASCII /%STR /
PCL:	ASCII /%%%L /
TRC:	ASCII /    TRACE /
DEF:	ASCII /  DEFPROP /
GRI:	ASCII /  GRINDEF /
SPR:	ASCII /   SPRINT /
	ASCII /%DPSPRINT /
DPYSPR=.-1
VALU:	ASCII /    VALUE /
VALUE=VALU+1
FEXP:	ASCII /    FEXPR /
FEXPR=FEXP+1
EXPR:	ASCII/EXPR /
FSUBA:	ASCII /    FSUBR /
FSUBR=FSUBA+1
SUBR:	ASCII /SUBR /

GLS:	ASCII /(FEXPR EXPR VALUE MACRO SPECIAL   )/
FLO:	ASCII /   FLONUM /
FLONUM=FLO+1
FIX:	ASCII /   FIXNUM /
SETQ:	ASCII /SETQ /
QUO:	ASCII /    QUOTE /
	ASCII /NIL /

EXTERN NCONC,PRINT,READ,READP1,TYO,ATOM,PUTPROP,GETL
EXTERN XCONS,RATOM,APPEND,OUTC,EVAL,OUTPUT,TYO
EXTERN INC,INPUT,SET,GET,TERPRI,UNBOUND,MEMQ
EXTERN PRIN1,FLATSIZE,CHRCT,LENGTH,LAST,TYI
EXTERN PSAV1

QUOTE=	QUO+1
FIXNUM=	FIX+1
DEFPROP=DEF+1
GRINDEF=GRI+1
SPRENT=	SPR+1
GLST=	FLO-1
TRACE=	TRC+1
NCONS=	XCONS-1

	A=	1
	B=	2
	C=	3
	AR1=	4
	AR2A=	5
	T=	6
	R=	10
	S=	11
	P=	14
	F=	15
	SP=	17

INTERN ED

ED:	PUSH P,A
RD1:	MOVEI A,TTYI(R)
	PUSHJ P,READP1
	JUMPE A,RD2A(R)
	MOVEM A,@J(R)
	JRST RD1(R)

TTYI:	ILDB A,J(R)
	POPJ P,0

J:	POINT 7,MESS(R)

RD2A:	MOVE C,SUBR(R)
	MOVEI B,SPRINT(R)
	MOVE A,SPRENT(R)
	PUSHJ P,PUTPROP
	MOVEI B,DPSPR(R)
	MOVE C,SUBR(R)
	MOVE A,DPYSPR(R)
	PUSHJ P,PUTPROP
RD2B:	MOVE B,GLST(R)
	MOVE A,PCL(R)
	PUSHJ P,SET
	MOVE B,[JRST EDN(R)](R)
	MOVEM B,ED(R)
	POP P,A
EDN:	JUMPN A,FALSE(R)
	MOVEM P,PSAV2#(R)
	PUSH P,[0](R)	;%B
	PUSH P,[0](R)	;SRCH STRNG
	PUSH P,[0](R)	;%STR
	PUSH P,[0](R)	;%1
	PUSH P,[0](R)	;%2
	PUSH P,[0](R)	;%REM
	PUSH P,[0](R)	;%NEW
	SETZM BK1#(R)
	MOVE A,STR(R)
	MOVE B,VALUE(R)
	PUSHJ P,GET
	JUMPE A,.+4(R)
	HRRZ A,(A)
	MOVEM A,-6(P)
	MOVEM A,-4(P)
	MOVE B,VALUE(R)
	MOVE A,PCL(R)
	PUSHJ P,GET
	HRRZ A,(A)
	MOVEM A,GLST(R)
	MOVEM P,PSAV1

RD2:
	PUSHJ P,TERPRI
RD3:	SETZM OLDCH
	PUSHJ P,TYI
	CAIN A,"^"
	JRST UPARR(R)
	CAIE A,12
	CAIN A,15
	JRST RD3(R)
	CAIN A,ALTMOD
	JRST RD3(R)
	CAIN A,"G"
	JRST ED1(R)
	CAIN A,"P"
	JRST ED2(R)
	CAIN A,"Q"
	JRST ED2X(R)
	CAIN A,"B"
	JRST ED5(R)
	CAIN A,"W"
	JRST ED14(R)
	CAIN A,"A"
	JRST ED4(R)
	CAIN A,"V"
	JRST ED13(R)
	CAIN A,"U"
	JRST ED16(R)
	CAIN A,"F"
	JRST ED9(R)

	MOVEI B,1
	MOVEM B,CNT#(R)
DSP1:	CAIN A,"S"
	JRST ED10(R)
	CAIN A,"I"
	JRST ED8(R)
	CAIN A,"R"
	JRST ED3(R)
	CAIN A,"M"
	JRST ED15(R)
	CAIN A,"E"
	JRST EDEX(R)
	CAIN A,"D"
	JRST EDDL(R)
	CAIN A,">"
	JRST ED11(R)
	CAIN A,"<"
	JRST ED12(R)
	CAIN A,"C"
	JRST SPC(R)
	CAIG A,"9"
	CAIGE A,"0"
	JRST ER1(R)
	JRST NMB(R)


ER1:	MOVE A,CMER1(R)
	PUSHJ P,PRINT
	JRST RD2(R)

SPC:	MOVE A,CNT(R)	;C - COUNT
	MOVEM A,PCNT(R)
	JRST RD2(R)
PCNT:	3
NMB:	SETZM CNT(R)
NM1:	SUBI A,"0"
	MOVE B,CNT(R)
	MULI B,12
	ADD A,C
	MOVEM A,CNT(R)
	PUSHJ P,TYI
	CAIG A,"9"
	CAIGE A,"0"
	JRST DSP1(R)
	JRST NM1(R)


ERED1:	MOVE A,MER7(R)
	JRST ER1+1(R)

UPARR:	SETZM PSAV1
	MOVE P,PSAV2(R)
	JRST FALSE(R)

ED1:	PUSHJ P,READ	;G - GET
	JUMPE A,RD2(R)
	PUSH P,A
	MOVE B,TRACE(R)
	PUSHJ P,GET
	JUMPE A,ED1D(R)
	HRRZ A,(A)
	MOVEM A,(P)
ED1D:	MOVE A,(P)
	MOVE B,GLST(R)
	PUSHJ P,GETL
	JUMPE A,ERED1(R)
	HRRZ C,(A)
	HLRZ A,(A)
	CAME A,VALUE(R)
	JRST ED1B(R)
	HLRZ A,(C)
	HRRZ A,(A)
	PUSHJ P,NCONS
	MOVE B,QUOTE(R)
	PUSHJ P,XCONS
	PUSHJ P,NCONS
	POP P,B
	PUSHJ P,XCONS
	MOVE B,SETQ(R)
	JRST ED1C(R)
ED1B:	PUSHJ P,NCONS
	HLRZ B,(C)
	PUSHJ P,XCONS
	POP P,B
	PUSHJ P,XCONS
	MOVE B,DEFPROP(R)
ED1C:	PUSHJ P,XCONS
	PUSHJ P,MKLPRP(R)
ED1A:	MOVEM A,-4(P)
	MOVEM A,-6(P)
	SETZM BK1(R)
	MOVE B,A
	MOVE A,STR(R)
	PUSHJ P,SET
	JRST RD2(R)

ED2X:	MOVE A,-4(P)	;Q -- PUT ON ORIGINAL NAME
	HRRZ A,(A)
	HRRZ A,(A)
	HLRZ A,(A)
	JRST ED2+1(R)

ED2:	PUSHJ P,READ
	PUSH P,A	;P -- PUT
	MOVE B,TRACE(R)
	PUSHJ P,GET
	JUMPE A,ED2A(R)
	HRRZ A,(A)
	MOVEM A,(P)
ED2A:	MOVE A,-5(P)
	PUSHJ P,UNMK(R)
	JUMPE A,RD2(R)
	HRRZ B,(A)
	POP P,C
	HRLM C,(B)
	PUSHJ P,EVAL
	JRST RD2(R)

ED3A:	SETZM -2(P)
	JRST EDB(R)

ED3R:	MOVE C,T
	JUMPN C,ED3R2(R)
	MOVE A,(P)
	JRST ED1A(R)

ED3R2:	CAME T,BK1(R)
	JRST ED3R1(R)
	MOVE B,(P)
	MOVEM B,-6(P)
	JRST ED3R3(R)

ED8A:	SKIPE RSW#(R)
	JRST ER1(R)
	PUSHJ P,EDREAD(R)
	MOVE B,-6(P)
ED85:	PUSHJ P,.NCONC(R)
	MOVEM A,-6(P)
	SOSLE CNT(R)
	JRST EDB1(R)
	SKIPN BK1(R)
	JRST ED1A(R)
	HRRM A,@BK1(R)
	JRST RD2(R)

EDB1:	MOVE A,(P)
	JRST EDB(R)

EDE1:	HRRM A,-4(P)
	JRST ED1A+2(R)
ED8C:	SKIPE RSW(R)
	JRST ER1(R)
	PUSHJ P,EDREAD(R)
	JRST ED1A(R)
ED8:	TDZA C,C	;I - INSERT
ED3:	SETOM C		;R - REPLACE
	MOVEM C,RSW(R)
	SETZM NEWFLG#(R)
	PUSHJ P,EDREAD(R)
	JUMPE A,ED8A(R)
	MOVEM A,-3(P)
	HLRZ A,(A)
	CAMN A,PC(R)
	JRST ED8C(R)
	PUSHJ P,EDREAD(R)
	JUMPN A,ED3A(R)
	PUSHJ P,EDREAD(R)
	MOVEM A,-2(P)
	PUSHJ P,EDREAD(R)

EDB:	MOVEM A,(P)
	MOVEM A,LNEW#(R)
	HRRZ A,(A)
	JUMPN A,.-2(R)

	HLRZ A,@(P)	;was hlrz@ a,(p)
	CAMN A,PC(R)
ED3N:	SETOM NEWFLG(R)
	MOVE A,-6(P)
	MOVE B,-3(P)
	MOVE T,BK1(R)
	PUSHJ P,SRCH(R)
	JUMPE A,ED33(R)
	MOVE B,-2(P)
	JUMPE B,ED31(R)
	MOVEM T,BK2#(R)
	PUSHJ P,SRCH(R)
	JUMPE A,ED34(R)
	MOVE T,BK2(R)
ED31:	SKIPE NEWFLG(R)
	JRST ED32(R)
	HRRM A,@LNEW(R)	;was hrrm@ a,lnew(r)
ED34:	MOVE C,BK3(R)
	SKIPE RSW(R)
	JRST ED3R(R)
ED3R1:	MOVE B,(P)
ED3R3:	HRRM B,@C
	JRST RD2(R)
ED32:	JUMPE T,ED1A(R)
	HRRM A,@T
	JRST RD2(R)
ED33:	SKIPE -2(P)
	JRST SER1(R)
	SKIPN NEWFLG(R)
	JRST ED34(R)
	HRRZ T,(T)
	MOVEM T,BK3(R)
	JRST ED37(R)

ED4:	MOVE A,-4(P)	;A - ALL
	PUSH P,A
	PUSHJ P,TERPRI
	POP P,A
	PUSHJ P,EDGRIN(R)
	JRST RD2(R)

EDDL:	MOVE A,-6(P)	;D - DELETE
	MOVEM A,BK3(R)
	HRRZ A,(A)
	JUMPE A,EDDL2(R)
	SOSLE CNT(R)
	JRST EDDL+1(R)
EDDL1:	PUSH P,A
	PUSHJ P,PRINTC(R)
	POP P,A
	JRST ED85+1(R)

ED5:	MOVE A,-4(P)	;B - BALANCED
	PUSHJ P,PARSRCH(R)
	CAMN A,B
	JRST ED51(R)
	PUSH P,B
	ADDI A,MAGNO
	PUSHJ P,PRINT
	MOVE A,LPS(R)
	PUSHJ P,PRIN1
	POP P,A
	ADDI A,MAGNO
	PUSHJ P,PRINT
	MOVE A,RPS(R)
	PUSHJ P,PRIN1
	JRST RD2(R)
ED51:	MOVE A,BAL(R)
	JRST ED51-2(R)

EDDL2:	MOVEI A,07
	PUSHJ P,TYO
	SKIPN BK1(R)
	JRST ER1(R)
	MOVE A,-6(P)
	MOVEM A,BK3(R)
	MOVE A,-4(P)
	HRRZ C,(A)
	CAMN C,BK3(R)
	JRST ED37B(R)
	JUMPE C,RD2(R)
	TDZA AR1,AR1
ED37:	SETOM AR1
	MOVE A,-4(P)
	MOVEM A,BK2(R)
	HRRZ A,(A)
	HRRZ C,(A)
	CAME C,BK3(R)
	JRST .-4(R)
ED37A:	HLRM A,(A)
	JUMPN AR1,RD2(R)
	MOVEM A,-6(P)
	PUSHJ P,PRINTC(R)
	MOVE A,BK2(R)
	MOVEM A,BK1(R)
	JRST RD2(R)

ED37B:	HLRM A,(A)
	JRST ED1A(R)


ED11:	MOVE A,-6(P)	;> - RIGHT
	MOVE B,CNT(R)
	SKIPN B
	MOVEI B,7777
	MOVEM A,C
	HRRZ A,(A)
	JUMPE A,ED11A(R)
	MOVEM A,-6(P)
	MOVEM C,BK1(R)
	SOJG B,.-5(R)
	JRST ED11B(R)
ED11A:	MOVEI A,07
	PUSHJ P,TYO
	JRST RD2(R)

ED11B:
	PUSHJ P,PRINTC(R)
	JRST RD2(R)

ED12:	SETZM C		;< - LEFT
	SKIPN CNT(R)
	JRST ED12C(R)
	MOVE A,-4(P)
ED12A:	CAMN A,-6(P)
	JRST ED12B(R)
	AOS C
	HRRZ A,(A)
	JUMPN A,ED12A(R)
	JRST ERR3(R)
ED12B:	MOVE A,CNT(R)
	SUBM A,C
	SKIPL C
	JRST ED12C(R)
	MOVE A,-4(P)
	MOVEM A,BK1(R)
	HRRZ A,(A)
	AOJL C,.-2(R)
	MOVEM A,-6(P)
	JRST ED12D(R)
ED12C:	MOVEI A,07
	PUSHJ P,TYO
	MOVE A,-4(P)
	MOVEM A,-6(P)
	SETZM BK1(R)
ED12D:	PUSHJ P,PRINTC(R)
	JRST RD2(R)

ED14:	MOVE A,-6(P)	;W - WHERE
	JRST ED12D(R)

ERR3:	MOVE A,MER1(R)
	JRST ER1+1(R)

ED10:	PUSHJ P,EDREAD(R)	;S - SEARCH
	SKIPN A
	MOVE A,-5(P)
	MOVEM A,-5(P)
	MOVE B,A
	MOVE A,-6(P)
	MOVE T,BK1(R)
ED10C:	PUSHJ P,SRCH1(R)
	JUMPE A,ED10B(R)
	MOVEM A,-6(P)
	MOVE B,BK3(R)
	MOVEM B,BK1(R)
	SOSG CNT(R)
	JRST ED10D(R)
	MOVE B,-5(P)
	JRST ED10C(R)
ED10B:	MOVEI A,07
	PUSHJ P,TYO
ED10D:	MOVE A,-6(P)
	PUSHJ P,PRINTC(R)
	JRST RD2(R)

;SRCH RETURNS END IN A
;SETS T AND BK3
;STARTS WITH STRING IN A
;AND SEARCH-STRING IN B
;STRING-1 IN T
;SRCH1 RETURNS 0 IN A IF NOT FOUND,SRCH CALL ERROR

SRCH1:	TDZA AR2A,AR2A
SRCH:	SETOM AR2A
	MOVEM B,STRB#(R)

SR1:	HLRZ AR1,(B)
	HLRZ C,(A)
	CAMN AR1,C
	JRST SR2(R)
	PUSHJ P,SRNUM(R)
	MOVEM A,T
	HRRZ A,(A)
	JUMPN A,SR1+1(R)
SR3:	SKIPN AR2A
	POPJ P,
	POP P,A
SER1:	MOVE A,MER3(R)
	JRST ER1+1(R)

SR2:	MOVEM A,BK3#(R)
	HRRZ A,(A)
	HRRZ B,(B)
	JUMPE A,SR4(R)
	SKIPN B
	POPJ P,
	HLRZ C,(A)
	HLRZ AR1,(B)
	CAMN C,AR1
	JRST SR2(R)
	PUSHJ P,SRNUM(R)
	MOVE T,BK3(R)
	MOVE B,STRB(R)
	JRST SR1(R)

SR4:	JUMPN B,SR3(R)
	POPJ P,
EDEX1:	MOVE A,-7(P)


	HLRZ B,(A)
	CAMN B,LPNAME(R)
	JRST ED15B(R)
	CAME B,RPNAME(R)
	CAMN B,DT(R)
	JRST ED15A-1(R)
	POPJ P,0

ED15:	PUSHJ P,EDEX1(R)	;M - MATCH
ED15D:	MOVEM A,B
	HRRZ A,(A)
	JUMPE A,ED15A(R)
	MOVEM B,BK1(R)
	MOVEM A,-6(P)
	SOSLE CNT(R)
	JRST ED15(R)
	PUSHJ P,PRINTC(R)
	JRST RD2(R)

ED15B:	SETZM AR1
ED15C:	AOS AR1
ED15E:	HRRZ A,(A)
	JUMPE A,ED15A-1(R)
	HLRZ B,(A)
	CAMN B,LPNAME(R)
	JRST ED15C(R)
	CAMN B,RPNAME(R)
	SOJE AR1,ED15-1(R)
	JRST ED15E(R)
	POP P,A
ED15A:	MOVEI A,07
	PUSHJ P,TYO
	JRST RD2(R)

ED13:	MOVE A,-6(P)	;V - VOMIT
	PUSHJ P,PARSRCH(R)
	MOVE A,-6(P)
	CAMGE B,AR1
	JRST ED4+1(R)
	HLRZ B,(A)
	CAME B,LPNAME(R)
	JRST ED4+1(R)
	HRRZ A,@-6(P)	;was hrrz@ a,-6(p)
	MOVEM A,AR2A
	PUSHJ P,UNMK1(R)
OPDEF CALLF [36B8]
	CALLF 1,@DPYSPR(R)
	JRST RD2(R)

DPSPR:	MOVEI C,0
	MOVEI B,2
	PUSHJ P,SPRNT2(R)
	JRST TERPRI

UNER1A:
UNER1B:	MOVE A,MER2(R)
	JRST EDGER+1(R)

	MOVEM A,-6(P)
EDEX:	PUSHJ P,EDEX1(R)	;E - EXPLUGE
	HRRZ A,(A)
	JUMPE A,ED15A(R)
	SOSLE CNT(R)
	JRST EDEX-1(R)
	JRST EDDL1(R)

UNMK1:	PUSHJ P,EDGET(R)
	CAMN A,LPNAME(R)
	JRST UN3(R)
	CAMN A,RPNAME(R)
	JRST UN2(R)
	CAMN A,DT(R)
	JRST UN1(R)
	PUSH P,A
	PUSHJ P,UNMK1(R)
	POP P,B
	PUSHJ P,XCONS
	POPJ P,
UN1:	PUSHJ P,EDGET(R)
	CAMN A,LPNAME(R)
	JRST UN4(R)
	CAME A,RPNAME(R)
	CAMN A,DT(R)
	JRST UNER1A(R)
UN5:	PUSH P,A
	PUSHJ P,EDGET(R)
	CAME A,RPNAME(R)
	JRST UNER1B(R)
	POP P,A
	POPJ P,0
UN3:	PUSHJ P,UNMK1(R)
	PUSH P,A
	PUSHJ P,UNMK1(R)
	POP P,B
	PUSHJ P,XCONS
	POPJ P,
UN2:	SETZM A
	POPJ P,
UN4:	PUSHJ P,UNMK1(R)
	JRST UN5(R)


EDGET:	SKIPN AR2A
	JRST EDGER(R)
	HLRZ A,(AR2A)
	HRRZ AR2A,(AR2A)
	POPJ P,
EDGER:	MOVE A,MER4(R)
	PUSHJ P,PRINT
	MOVE P,PSAV(R)
	SUB P,[XWD 2,2](R)
	JRST RD2(R)

CNT1:	0

PRINTC:	PUSH P,A
	PUSHJ P,TERPRI
	POP P,A
	MOVE C,PCNT(R)
	MOVEM C,CNT1(R)
	JUMPE A,PRN3(R)
PRN1:	PUSH P,A
	SETZM AR1
	HLRZ A,(A)
	CAM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)
MLP1:	POP P,A
	PUSHJ P,NCONS
	MOVE B,A
	POP P,A
	PUSHJ P,.NCONC(R)
	POPJ P,0
MLP2:	MOVE A,RPNAME(R)
	PUSHJ P,NCONS
MLP4:	POP P,B
	MOVE B,A
	POP P,A
	JRST .NCONC(R)
MLP3:	MOVE A,RPNAME(R)
	PUSHJ P,NCONS
	HRRZ B,@(P)	;was hrrz@ b,(p)
	PUSHJ P,XCONS
	MOVE B,DT(R)
	PUSHJ P,XCONS
	JRST MLP4(R)

PSAV:	0
UNMK:	MOVEM P,PSAV(R)
	HLRZ B,(A)
	CAME B,LPNAME(R)
	JRST UNER1(R)
	HRRZ A,(A)
	MOVEM A,AR2A
	PUSHJ P,UNMK1(R)
	SKIPE AR2A
	JRST UNER2(R)
	POPJ P,

UNER1:	MOVE A,MER5(R)
	PUSHJ P,PRINT
	MOVE P,PSAV1
	JRST RD2(R)
UNER2:	MOVE A,MER6(R)
	JRST UNER1+1(R)

.NCONC:	MOVNI 6,2
	PUSH P,A
	PUSH P,B
	JRST NCONC

ED16:	PUSHJ P,READ	;U - UNFILE
	PUSH P,A
	PUSHJ P,READ
	PUSH P,A
	PUSHJ P,READ
	PUSHJ P,NCONS
	POP P,B
	PUSHJ P,XCONS
	PUSHJ P,INPUT
	PUSHJ P,INC
	MOVE A,(P)
	PUSHJ P,ATOM
	JUMPE A,ED16A(R)
	MOVE B,VALUE(R)
	MOVE A,(P)
	PUSHJ P,GET
	HRRZ A,(A)
ED16D:	MOVEM A,(P)
ED16A:	PUSHJ P,READ
	MOVE T,A
	PUSHJ P,ATOM
	JUMPN A,ED16A(R)
	HRRZ A,(T)
	HLRZ A,(A)
	SKIPE B,(P)
	PUSHJ P,MEMQ
	JUMPE A,ED16A(R)
	MOVE A,T
	PUSHJ P,EVAL
	SKIPE (P)
	PUSHJ P,PRINT
	JRST ED16A(R)
	JRST ER1+1(R)
	TT=7
	D=12
SRNUM:	CAIGE C,INUMIN	;NUMBER COMPARES
	CAIL AR1,INUMIN
	POPJ P,
	HRRZ C,(C)
	HLRZ TT,(C)
	CAME TT,FIXNUM(R)
	CAMN TT,FLONUM(R)
	SKIPA D,(AR1)
	POPJ P,0
	HLRZ S,(D)
	CAME TT,S
	POPJ P,0
	HRRZ C,(C)
	HRRZ D,(D)
	MOVE D,(D)
	MOVE C,(C)
	CAME D,C
	POPJ P,0
	POP P,TT
	JRST SR2(R)
EXTERN OLDCH,LINL,CHCT

EDRD1:	CLEARB A,...FLG(R)
	POPJ P,0
...FLG:	0
EDREAD:	SKIPE ...FLG(R)
	JRST EDRD1(R)
	PUSHJ P,READ1(R)
	JUMPL A,.-1(R)
	POPJ P,0

READ1:	PUSHJ P,RATOM
	JRST READ1A(R)
READ2:	ADDI B,(R)
	XCT EDTAB(B)
READ1A:	PUSH P,A
	PUSHJ P,READ1(R)
READ3:	POP P,B
	JUMPL A,READ1(R)	;RUBOUT
	JRST XCONS

EDTAB:	MOVE A,LPNAME(R)	;0 (
	MOVE A,RPNAME(R)	;1 )
	MOVE A,LPNAME(R)	;2 [
	JRST READ4(R)	;3 ],$
	JRST EDRD3(R)	;4 .
	SKIP
	SETOM A		;6 RUBOUT
	POPJ P,

READ4:	CAIN A,ALTMOD
	JRST FALSE(R)	;ALTMODE
	MOVE A,RPNAME(R)
	JRST READ1A(R)

EDRD5:	SUB P,[XWD 2,2](R)
	JRST EDRD32(R)

EDRD4:	SUB P,[XWD 2,2](R)
	JRST READ1(R)

EDRD3:	PUSH P,DT(R)
	PUSH P,[READ3](R)
	ADDM R,(P)
EDRD32:	PUSHJ P,RATOM
	JRST READ1A(R)	;ATOM
	CAIN A,177
	JRST EDRD4(R)	;RUBOUT
	CAIE A,"."
	JRST READ2(R)
	PUSH P,DT(R)
	PUSH P,[READ3](R)
	ADDM R,(P)
	PUSHJ P,RATOM
	JRST READ1A(R)	;ATOM
	CAIN A,177
	JRST EDRD5(R)	;RUBOUT
	CAIE A,"."
	JRST READ2(R)
	SUB P,[XWD 4,4](R)
	MOVEM A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