perm filename NINT[S,PMP] blob sn#008152 filedate 1972-10-10 generic text, type T, neo UTF8
COMMENT ⊗   VALID 00011 PAGES 
RECORD PAGE   DESCRIPTION
 00001 00001
 00002 00002		TITLE NINT ERPRETER
 00005 00003	MAIN:	
 00010 00004	FLAGS:: -- RIGHT HALF
 00012 00005	PRINT THINGS::::
 00018 00006	MBOX:	MOVEI B,1
 00023 00007	ITAB FLAGS::
 00027 00008	IBOX:	JRST @.+1
 00035 00009		HRRZM B,MA
 00038 00010	IFN CHKSW,
 00045 00011	ESSW←←1000
 00047 ENDMK
⊗;
	TITLE NINT ERPRETER

;AC'S::

	P←17
	M←16
	A←15
	B←2
	C←3
	D←4
	E←5
	F←6
	G←7
	H←10

Q1←13 Q2←14

PRTSW←←1
CHKSW←←0
LPTCHN←←17	;IO CHANNEL FOR OUTPUT, AVOID CONFLICTS WITH OBJECT PRGM

ACTIM←←4
WRTTIM←←6
MITIM1←←2
MITIM2←←1
EXTERN JOBSA

DEFINE CORFIX(A,B)
<	MOVEI C,A
	MOVEM C,B+1
>
DEFINE EPT (A)
<FOR I IN (CURTIM,MNULL,MDOUT,MD2CY,MRACY,MMSTCY,MEFTCY,MSTCCY,<MIFCY>
,MESTCY,INULL,I0CY,I0SKP,IACWT,IINDR,ISMAT,IEFWT,IEMWT,IEBWT,<IBJMPC>
,IBXCTC,IEBLTW,ENULL,E0CY,E1CY,ESTWT,ESTCWT)
<	A (I)
>>

STRT:	MOVE P,[XWD -PDLEN,PDL-1]
	MOVE M,[XWD -MPLEN,MPDL-1]
	PUSH M,[MCEND]
	CALLI
	FOR I IN (MIOCY,<EBCNT>
	,IWSJSW,ESKPSW,EJMPT,UFLAGS)
<	SETZM I#
>
	FOR I IN (<ICSTRT,IFCON>,<MISTRT,MEMINT>,<IBSTRT,IBOX>,<EBSTRT,EBOX>)
<	CORFIX (I)
>
	SETZM EPTAB
	MOVE A,[XWD EPTAB,EPTAB+1]
	BLT A,EPEND
	SETZM OPTAB
	MOVE A,[XWD OPTAB,OPTAB+1]
	BLT A,OPTAB+777
	MOVEI B,777
	SETOM CMEM(B)
	LDB C,[POINT 2,B,28]
	DPB C,[POINT 2,CMEM(B),17]
	SOJGE B,.-3
	SETZB 1
	MOVE A,JOBSA
	HRRZM A,IBPC
	HRRZM A,APCL
	HRRZM A,CHKPC#
IFE PRTSW,<JSR LINIT>
	JRST MAIN


LINIT:	0
	INIT LPTCHN,1
	SIXBIT /LPT/
	XWD LOB,0
	JRST 4,.
	SETZM ETHNG+1
	SETZM ETHNG+2
	SETZM ETHNG+3
	ENTER LPTCHN,ETHNG
	JRST 4,.
	OUTBUF LPTCHN,2
	JRST @LINIT

ETHNG:	SIXBIT /INOUT/
	BLOCK 3
LOB:	BLOCK 4
MAIN:	
IFN PRTSW,
<	PUSHJ P,PFLGS>
	PUSHJ P,EBOX
	PUSHJ P,IBOX
	PUSHJ P,IFCON
IFN PRTSW,<PUSHJ P,PRQS>
	PUSHJ P,MBOX
	PUSHJ P,MEMINT
	TLNN MEMINR
	JRST .+3
	TLZ SEHOLD+SEVAL
	TLO ISEP
	PUSHJ P,MCALL
	PUSHJ P,STBOX
	TLZ MISS+BADMIS
	TRZ 7777
	OR 1
	MOVEI 1,
	AOS CURTIM
	JRST MAIN

STBOX:	TLNE SEHOLD+ESTDO
	JRST SBCON
	TLNN SEDO
	JRST SBCON
	MOVE C,SMA
	MOVE D,STCAD
	MOVEM C,STCAD
	TRZ C,3↔TRZ D,3
	TLNE SEVAL
	CAME C,D
	TROA 1,STCRQ
	TLC SEHOLD+SEDO
SBCON:	TLNN ESTDO
	POPJ P,
	TLNN SEHOLD
	TROA 1,STCRQ
	TRO 1,ESTRQ
	POPJ P,

MCALL:	MOVN A,0
	AND A,0
MCALLL:	PUSHJ P,[POPJ M,]
	JRST MCALLL
	PUSHJ M,[POPJ P,]
MCEND:	POP P,A
	JRST .-2

IFCON:	JRST @.+1
	ICSTRT
	POPJ P,
IFCRET:	JSR IFCON+1
ICSTRT:	TLNN IAFULL
	JRST IFC1
	TLNE IBFULL	;IB FULL?
	JRST IFCRET	;NO
	MOVE A,APCL	;GET ADDRS OF NEXT TO GET
	TRNN A,1	;ODD?
	JRST 4,IFCRET	;NO
	JRST IFCDO	;YES, LOAD IT
IFC1:	MOVE A,APCL	;GET ADDRS
	TLNN IBFULL	;IB ALSO EMPTY?
	JRST IFC2	;YES
	TRNE A,1	;NO, ODD?
	JRST 4,IFCRET	;YES
	JRST IFCDO	;NO, DO IT
IFC2:	TRNN A,1	;ODD?
	TRO IF2RQ	;NO, GET TWO
IFCDO:	TRO IF1RQ	;REQUEST I-FET
	PUSHJ M,[POPJ P,];COME BACK AFTER M-BOX HAS RUN
	TRNN A,IF1RQ+IF2RQ;I-FET THIS CYCLE?
	JRST IFCRET	;NO, TRY AGAIN NEXT TIME
	TLNE MISS	;YES, MISS?
	JRST IFMISS	;YES
IFCC1:	AOS B,APCL	;NO MISS, UPDATE ADDRS
	TRNN B,1	;WAS IT ODD?
	TLOA IBFULL	;YES, IT WAS ODD
	TLOA IAFULL	;EVEN
	JRST IFCRET	;NO
	TRNE A,RARQ
	JRST IFCRET
	TLON IBFULL	;IB ALREADY FULL?
	AOS APCL	; NO
	JRST IFCRET
IFMISS:	TLNE BADMIS	;BAD MISS?
	JRST IFBM	;YES
	JSR IFCON+1	;NO
	PUSHJ M,[POPJ P,]
	TRNN A,RARQ	;READ-AROUND THIS TIME?
	JRST .-3	;NO
	JRST IFCC1	;YES, LOAD 1
IFBM:	JSR IFCON+1
	PUSHJ M,[POPJ P,]
	TRNE A,MSTRQ	;M-STO THIS TIME?
	JRST IFCRET	;YES, TRY AGAIN
	TLNN MEMINU	;MEM INT BUSY?
	JRST IFCRET	;NO, TRY AGAIN
	JRST IFBM

MEMINT:	JRST @.+1
	MISTRT
	POPJ P,
MIRET:	JSR MEMINT+1
MISTRT:	TLNN STMRD+STMWRT;ANY MEM ACTIVITY?
	JRST MIRET	;NO
	TLO MEMINU	;YES, MARK IT BUSY
	MOVEI A,ACTIM	;GET ACCESS TIME
	MOVEM A,MCCNT
	TLNN STMRD	;READ STARTING?
	JRST NOTRD	;NO
	TLO MEMINR
	JSR CNTWT	;WAIT FOR COUNT TO RUN OUT
	MOVEI A,MITIM1	;GET NEXT TIME (TIME FROM RQ TO MST)
	MOVEM A,MCCNT
MIL1:	PUSHJ M,[POPJ P,]
	TRNE A,RARQ	;READ AROUND DONE?
	JRST MIP1	;YES
	TRO 1,RARQ	;NO, DO IT
	JSR MEMINT+1
	SOS MCCNT
	JRST MIL1
CNTWT:	0
	SKIPG MCCNT
	JRST @CNTWT
	JSR MEMINT+1
	SOSLE MCCNT
	JRST .-2
	JRST @CNTWT
MIP1:	JSR CNTWT
	TLO MSTO1
	MOVEI A,MITIM2
	MOVEM A,MCCNT
MIL2:	TRO 1,MSTRQ	;REQUEST M-STO
	JSR MEMINT+1
	SOS MCCNT
	PUSHJ M,[POPJ P,]
	TRNN A,MSTRQ	;M-STO DONE?
	JRST MIL2	;NO
	JSR CNTWT	;YES, WAIT FOR COUNT
	TLZ MSTO1
MIL3:	TRO 1,MSTRQ
	JSR MEMINT+1
	PUSHJ M,[POPJ P,]
	TRNN A,MSTRQ
	JRST MIL3
	TLNE STMWRT
	JRST NOTRD
	TLZ STMWRT+STMRD+MEMINU+MEMINR
	JRST MIRET
NOTRD:	MOVEI A,WRTTIM	;GET WRITE TIME
	TLZ MEMINR
	MOVEM A,MCCNT
	AOS MDOUT
	JSR CNTWT
	TLZ STMWRT+STMRD+MEMINU
	JRST MIRET

;FLAGS:: -- RIGHT HALF

TNUM←←1;
DEFINE MBTHINGS (MBDO)
<	FOR I IN (D2,IOF,RA,MST,EFT,STC,IF2,EST,IF1,IOS)
<	MBDO (I)
>>
	DEFINE X $ (A)
<	A$RQ←←TNUM
	TNUM←←TNUM+TNUM
>
	MBTHINGS (X)
	MAXRQ←←TNUM⊗-1
FSTF←←200000
EFDUB←←400000


;LEFT HALF:::

MISS←←1
MEMINU←←2
DBLFET←←4
STMRD←←10
STMWRT←←20
BADMIS←←40
IBRDY←←100
ITEMP1←←200
IAFULL←←400
IBFULL←←1000
MSTO1←←2000
ISEP←←4000
SEHOLD←←10000
SEVAL←←20000
SEDO←←40000
ESTDO←←100000
MEMINR←←200000



;LEFT HALF CACHE FLAGS:::

NDWRT←←10
INVAL←←400

	DEFINE IACP
<	MOVE P,PSAV
	MOVE M,MSAV
	MOVE SAV0
	MOVE 1,SAV1
	MOVE A,ASAV
	MOVE D,DSAV
>

DEFINE IAC
<	MOVEM 17,UACSTO+17
	MOVEI 17,UACSTO
	BLT 17,UACSTO+16
	JSP B,.+1
	MOVEM B,UFLAGS
	MOVE P,PSAV
	MOVE M,MSAV
	MOVE SAV0
	MOVE 1,SAV1
>
DEFINE UAC
<	MOVEM SAV0
	MOVEM 1,SAV1
	MOVEM M,MSAV
	MOVEM P,PSAV
	MOVEM A,ASAV
	MOVEM D,DSAV
	MOVE B,UFLAGS
	HRRI B,.+2
	JRST 2,@B
	MOVSI 17,UACSTO
	BLT 17,17>

	FOR MJW IN (FETR,EBPC,IBPC,EIR,SAV0,SAV1,MSAV,PSAV,APCL,<MCCNT>
	,SAC1,SAC2,SMA,ASAV,DSAV)
<MJW:	0
>

CMEM:	BLOCK 1000
PDLEN←←40
MPLEN←←40
PDL:	BLOCK PDLEN
MPDL:	BLOCK MPLEN
UACSTO:	BLOCK 20

;PRINT THINGS::::


LOUT:	0
	SOSG LOB+2
	OUTPUT LPTCHN,
	IDPB Q2,LOB+1
	JRST @LOUT

PSTR:	HRLI Q1,440700
	ILDB Q2,Q1
	JUMPE Q2,CPOPJ
	JSR LOUT
	JRST .-3
PCRLF:	MOVEI Q2,15
	JSR LOUT
	MOVEI Q2,12
	JSR LOUT
	POPJ P,
PDNUM:	MOVEI Q2,12
	MOVEM Q2,PQR#
	JRST PNUM
PONUM:	MOVEI Q2,10
	MOVEM Q2,PQR
PNUM:	IDIV Q1,PQR
	JUMPE Q1,.+4
	HRLM Q2,(P)
	PUSHJ P,PNUM
	HLRZ Q2,(P)
	ORI Q2,60
	JSR LOUT
	POPJ P,
PFLGS:	FOR @$ I IN (CURTIM,IBPC,EBPC,APCL,SMA,MA)
<	MOVEI Q1,[ASCIZ /I= /]
	PUSHJ P,PSTR
	MOVE Q1,I
	PUSHJ P,PONUM
	MOVEI Q2,11
	JSR LOUT
>
	PUSHJ P,PCRLF
	PUSH P,A
	PUSH P,B
	MOVEI A,200000
	MOVEI B,
	MOVEI Q2,11
	JSR LOUT
PFL1:	TDNN A
	JRST .+3
	MOVE Q1,FTAB(B)
	PUSHJ P,PSTR
	LSH A,1
	JUMPE A,.+2
	AOJA B,PFL1
	POP P,B
	POP P,A
	JRST PCRLF
FTAB:	FOR I IN (FSTF,EFDUB,MISS,<MEMINU>
	,DBLFET,STMRD,STMWRT,BADMIS,<IBRDY>
	,ITEMP1,IAFULL,IBFULL,MSTO1,ISEP,SEHOLD,SEVAL,<SEDO>
	,ESTDO,MEMINR)
<	[ASCIZ /I,/]
>
RQTAB:	DEFINE PQZLN(A)
<	[ASCIZ /A,/]
>
	MBTHINGS(PQZLN)

PRQS:	MOVEI Q1,[ASCIZ /	RQS→ /]
	PUSHJ P,PSTR
	PUSH P,A
	PUSH P,B
	MOVEI A,1
	MOVEI B,
PFL2:	TDNN A
	JRST .+3
	MOVE Q1,RQTAB(B)
	PUSHJ P,PSTR
	LSH A,1
	TRNE A,7777
	AOJA B,PFL2
	POP P,B
	POP P,A
	JRST PCRLF

	DEFINE X1 (A)
<A:	0
>
EPTAB:
	EPT (X1)
	QCNT←.-EPTAB   EPEND←.-1
EPCTAB:	DEFINE X2 (A)
<	[ASCIZ /A/]
>
FOR I IN (TOTAL CYCLES,,M DUMP-OUT,DUMP-2,READ-AROUND,M-STO,E-FET,ST-CHK,<I-FET>
,E-STO,,,I0 OF SKIPPED INST,I WAIT FOR INDEX AC,<I-INDIRECT FETCH>
,E-FET -- STORE MATCH WAIT,E-FET -- NOT EF CY WAIT,<E-FET -- MISS WAIT>
,I WAIT FOR E-BOX,I JUMP CY,I XCT CY,<I WAIT FOR E ON BLT>
,,,,E -- STORE WAIT,E -- ST-CHK WAIT)
<X2 (I)
>
DEFINE X3 (A)
<	SIXBIT /A/
>
EPNTAB:	EPT (X3)

PSSTR:	MOVEI Q2,
	ROTC Q1,6
	ADDI Q2,40
	JSR LOUT
	JUMPN Q1,PSSTR
	POPJ P,

PRINT:	JSR LINIT
	MOVEI A,QCNT
	MOVEI B,
PRLP1:	MOVE Q1,EPNTAB(B)
	PUSHJ P,PSSTR
	MOVEI Q2,11
	JSR LOUT
	MOVE Q1,EPTAB(B)
	PUSHJ P,PDNUM
	MOVEI Q2,11
	JSR LOUT
	MOVE Q1,EPCTAB(B)
	PUSHJ P,PSTR
	PUSHJ P,PCRLF
	ADDI B,1
	SOJG A,PRLP1
	MOVEI Q2,14
	JSR LOUT
	MOVEI A,100
	SETZB B,C
PRLP2:	SKIPE E,OPLN(A)
	JRST LNDO
PRLP4:	MOVE Q1,OPNT(C)
	JSR OPPP
	MOVE Q1,OPNT(C)
	JSR OPPP
	PUSHJ P,PCRLF
	SOJG A,PRLP2
	CLOSE LPTCHN,
	RELEAS LPTCHN,
	POPJ P,

OPTAB:	BLOCK 1000
OPPP:	0
	PUSHJ P,PSSTR
	MOVEI Q2,11
	JSR LOUT
	MOVEI D,4
PRLP3:	MOVE Q1,OPTAB(B)
	PUSHJ P,PDNUM
	MOVEI Q2,11
	JSR LOUT
	ADDI B,1
	SOJG D,PRLP3
	ADDI C,1
	JRST @OPPP
LNDO:	PUSHJ P,PCRLF
	JUMPL E,PRLP4
	MOVE Q1,E
	PUSHJ P,PSTR
	PUSHJ P,PCRLF
	JRST PRLP4

PL1:	ASCIZ /	0	1	2	3		4	5	6	7/
PL2:	ASCIZ /	UFA	DFN	FSC	IBP		ILDB	LDB	IDPB	DPB/
PL3:	ASCIZ /		L	M	B		R	RI	RM	RB/
PL4:	ASCIZ /		I	M	S			I	M	S/
PL5:	ASCIZ /		I	M	B			I	M	B/
PL6:	ASCIZ /	ASH	ROT	LSH	JFFO		ASHC	ROTC	LSHC/
PL7:	ASCIZ /	EXCH	BLT	AOBJP	AOBJN		JRST	JFCL	XCT/
PL8:	ASCIZ /	PUSHJ	PUSH	POP	POPJ		JSR	JSP	JSA	JRA/
PL9:	ASCIZ /		L	E	LE		A	GE	N	G/
PL10:	ASCIZ /	R(D)	L(S)	R-E	L-E		R-A	L-A	R-N	L-N/

DEFINE Z (A)
<REPEAT A,<0>
>
OPLN:	0
	Z(7)
	PL1
	Z(7)
	PL10
	Z(17)
	PL5
	Z(7)
	PL9
	PL5
	PL8
	PL7
	PL6
	0
	PL5
	0
	PL4
	Z(3)
	PL3
	PL2
	Z(12)
	PL1

OPNT:	FOR I←0,124,4
<	X3(I)
>
	FOR I IN (UFA--,LDB--,FAD, ,FSB, ,FMP, ,FDV, ,MOVE,MOVS,<MOVN>
,MOVM,IMUL,MUL,IDIV,DIV)
<	X3(I)
>
	FOR I IN (ASH, ,EXCH,JRST,PUSH,JSR,ADD,SUB)
<	X3(I)
>
	FOR I IN(CAI,CAM,JUMP,SKIP,AOJ,AOS,SOJ,SOS)
<	X3(I)
	X3( )
>
	FOR I IN (SETZ,AND,ANDCA,SETM,ANDCM,SETA,XOR,OR,<ANDCB>
,EQV,SETCA,ORCA,SETCM,ORCM,ORCB,SETO)
<	X3(I)
>
	FOR @E I IN (,Z,O,E)
<	FOR @G IJ IN (L,R)
<	X3(HGIJGLEI)
>
>
	FOR @P J IN (,Z,O,E)
<	FOR @K M IN (R,L)
<	X3 (HKMKRPJ)
>
>
	FOR HKMKRPJ IN (TRN,TDN,TRZ,TDZ,TRC,TDC,TRO,TDO)
<	X3 (HKMKRPJ)
	X3( )
>
	FOR ZTPOP ← 700,774,4
<	X3(ZTPOP)
>

MBOX:	MOVEI B,1
	MOVEI C,
	TLNE MEMINR
	TRZ ESTRQ+STCRQ
MBL1:	TDNE B
	JRST @MBDTAB(C)
	LSH B,1
	TRNN B,MAXRQ+MAXRQ
	AOJA C,MBL1
NULMDO:	AOS MNULL
	POPJ P,
MBDTAB:	DEFINE MX $(A)
<	JFCL A$MDO>
	MBTHINGS (MX)
D2MDO:	AOS MD2CY
	POPJ P,
IOFMDO:
IOSMDO:	AOS MIOCY
	POPJ P,

RAMDO:	AOS MRACY
	POPJ P,

EFTMDO:	MOVE A,MA
	TRNE EFDUB	;DOUBLE?
	TLO DBLFET
	PUSHJ P,FETM
	MOVEM B,SAVFWR#
	TLZ DBLFET
	AOS MEFTCY
	POPJ P,

IF1MDO:
IF2MDO:	TLO DBLFET
	MOVE A,APCL	;GET ADDRS
	PUSHJ P,FETM	;DO THE FETCH
	TLZ DBLFET
	AOS MIFCY
	POPJ P,

FETM:	TLNN MEMINU	;MEM INT FREE??
	MOVEM A,FETR	;YES, SAVE ADDRS
	MOVE B,A
	ANDI B,777
	LSH A,-11
	MOVE C,B
	LSH B,-2	;GET HASH
	ANDI C,3	;GET LOW 2 BITS
	MOVSI E,INVAL	;CHECK INVALID BIT FOR WORD
	TLNE DBLFET	;FETCH 2 WORDS?
	TLO E,INVAL*2	;YES, CHECK BOTH INVAL BITS
	LSH E,(C)	;...
	FOR I←1,4
<	MOVE D,CMEM(B)	;GET CACHE ENTRY
	ADDI B,200
	JUMPL D,.+3	;INVALID?
	CAIN A,(D)	;ADDRS MATCH?
	JRST FOUND
>
	ANDI B,177
	FOR I←1,3
<	SETCM D,CMEM(B)
	ADDI B,200
	TLNN D,3
	JRST UBFND
>
	ADDI B,200
UBFND:	TLO MISS+BADMIS
	SUBI B,200
	MOVE D,CMEM(B)
	JSR UBLUP
	TLNE MEMINU	;MEM INT BUSY?
	POPJ P,		;YES
	MOVEM B,SAVWHR#
	TLZ BADMIS
	TLO STMRD	;START READ
	JUMPL D,CPOPJ
	TLNE D,NDWRT*17	;ANY NEEDWRITE?
	TLO STMWRT	;YES, START WRITE
	MOVSI E,NDWRT*3
	TRNN C,2
	LSH E,2
	TDNE E,D
	TRO 1,D2RQ
CPOPJ:	POPJ P,

UBLUP:	;UPDATE USE BITS
	0
	LDB E,[POINT 2,D,17];GET USE BITS
	JUMPE E,@UBLUP	;ORIGINAL WAS 0 -- DONT UPDATE
	MOVSI F,1
	LDB G,[POINT 7,B,35];GET HASH
	MOVSI H,2
	TLC D,3
	TLCN D,3
	MOVEI H,0
ULOP1:	TDNN H,CMEM(G)
	ADDM F,CMEM(G)
	ADDI G,200
	TRNN G,1000
	JRST ULOP1
	TLZ D,7
	MOVEM D,CMEM(B)
	JRST @UBLUP
FOUND:	TDNN D,E	;THIS WORD VALID?
	JRST FARN	;YES
	PUSHJ P,UBFND
	TLNN MEMINU	;MEM STARTED?
	TLZ STMWRT	;YES, DONT WRITE
	TRZ 1,D2RQ
	POPJ P,
FARN:
	TLZ MISS+BADMIS
	SUBI B,200
	JSR UBLUP
	POPJ P,

MSTMDO:	HRRZ A,FETR	;GET ADDRS
	LSH A,-11	;GET HIGH BITS
	MOVE B,SAVWHR
	MOVE C,CMEM(B)
	JUMPL C,.+3
	CAIN A,(C)	;SAME ADDRS?
	JRST .+3	;YES
	TLZ C,777770	;NO LOAD ALL NEW BITS(EXCEPT USE)
	TLO C,INVAL*17
	HRR C,A
	TLNE MSTO1	;TYPE 1 M-STO
	TLZA C,INVAL*3	;YES
	TLZ C,INVAL*14
	MOVEM C,CMEM(B)
	AOS MMSTCY
	POPJ P,

STCMDO:	TLNE ESTDO
	SKIPA A,ESMA#
	MOVE A,SMA
	MOVEM A,STCAD#
	PUSHJ P,FETM
	TLZ STMRD
	MOVEM B,SAVSWR
	AOS MSTCCY
	TLNN BADMIS
	JRST .+4
	JUMPL D,.+3
	TLNE D,NDWRT*17
	POPJ P,
	TLO SEHOLD+SEVAL
	TLZ SEDO
	POPJ P,
ESTMDO:	HRRZ A,STCAD
	LSH A,-11
	MOVE B,SAVSWR#
	MOVE C,CMEM(B)
	JUMPL C,.+3
	CAIN A,(C)
	JRST .+3
	TLZ C,777770
	TLO C,INVAL*17
	HRR C,A
	MOVE D,STCAD
	ANDI D,3
	MOVEI E,INVAL
	LSH E,(D)
	TSZ C,E
	MOVEI E,NDWRT
	LSH E,(D)
	TSO C,E
	MOVEM C,CMEM(B)
	TLZ ESTDO+SEHOLD
	SETOM ESMA
	AOS MESTCY
	POPJ P,

;ITAB FLAGS::
;RH -- DISPATCH ADDRS

;LH -- FLAGS::
STAC←←1
STACP1←←2
FEF←←4
FSTEF←←10
STEF←←20
IJMP←←40
ISKP←←100
DFEF←←200
IPOP←←400
IJSR←←1000
IJRA←←2000
IBYT←←4000
IUO←←10000






ITAB:	ILUUO
	FOR I←1,37
<	XWD IUO+STEF+IJSR,IDUO
>
	XWD ISKP,NORM
	XWD ISKP,IINIT
	FOR I←42,127
<	XWD ISKP,NORM
>
	XWD FEF+STACP1,NORM	;UFA
	XWD STAC+FSTEF,NORM	;DFN
	XWD STAC,NORM	;FSC
	XWD FSTEF,NORM	;IBP
	FOR I IN (FSTEF+STAC,FEF+STAC,FSTEF,FEF)
<	XWD I+IBYT,IDOBYT
>
	FOR I←1,3
<	FOR Q IN (STAC+FEF,STAC+STACP1+FEF,FSTEF,STAC+FSTEF,<STAC+FEF>
	,STAC,FSTEF,STAC+FSTEF)
<	XWD Q,NORM
>>
	FOR Q IN (FEF+STAC,STAC+STACP1+FEF,FSTEF,STAC+FSTEF,<STAC+FEF>
	,STAC,FSTEF,STAC+FSTEF)
<	XWD Q,NORM
>
	FOR I←1,4
<	FOR Q IN (STAC+FEF,STAC,STEF,FSTEF)
<	XWD Q,NORM
>>
	FOR I IN (FEF+STAC,STAC,FSTEF,FSTEF+STAC,FEF+STAC+STACP1,<STAC+STACP1>
	,FSTEF,FSTEF+STAC+STACP1,FEF+STAC+STACP1,STAC+STACP1,<FSTEF>
	,FSTEF+STAC+STACP1,FEF+STAC+STACP1,STAC+STACP1,FSTEF,STEF+STAC+STACP1)
<	XWD I,NORM
>
	FOR I←1,3
<	XWD STAC,NORM
>
	XWD STACP1+IJMP,NORM	;JFFO
	FOR I←1,3
<	XWD STAC+STACP1,NORM
>
	ILINST
	XWD STAC+FSTEF,NORM	;EXCH
	IDOBLT
	FOR I IN (STAC+IJMP,STAC+IJMP,IJMP,IJMP)
<	XWD I,NORM
>
	XWD FEF,IDOXCT
	ILINST
	XWD FEF+STEF+STAC+DFEF,IDPUSJ
	XWD FEF+STAC+STEF,IDPUSH
	XWD STAC+IPOP+STEF,NORM
	XWD STAC+IPOP+IJMP,IDPOPJ
	XWD IJSR+STEF+DFEF,IDJSAR
	XWD STAC+IJMP,NORM
	XWD STAC+IJSR+DFEF+STEF,IDJSAR
	XWD IJRA+IJMP+STAC,NORM
	REPEAT 2,< FOR I IN (STAC+FEF,STAC,FSTEF,STAC+FSTEF)
<	XWD I,NORM
>>
	DEFINE XX1 (A,B)
<	XWD B,NORM
	REPEAT 7,<XWD A+B,NORM>>
	FOR I IN (<ISKP,0>,<ISKP,FEF>,<IJMP,0>
	,<ISKP,FEF+STAC>,<IJMP,STAC>,<ISKP,FSTEF+STAC>
	,<IJMP,STAC>,<ISKP,FSTEF+STAC>)
<	XX1(I)
>



 DEFINE XX2 (A)
< IFE A,<FOR Q IN (STAC,STAC,STEF,STAC+STEF)
<	XWD Q,NORM
>>
 IFN A,<FOR Q IN (STAC+FEF,STAC,FSTEF,STAC+FSTEF)
<	XWD Q,NORM
>>>
FOR I E <0111101111011110>
<	XX2(I)
>

FOR I IN (FSTEF,STEF,STEF,STEF,FSTEF,STEF,STEF,STEF)
<REPEAT 2,
<FOR Q IN (STAC+FSTEF,STAC,I,FSTEF)
<	XWD Q,NORM
>>>
FOR A IN (0,STAC,STAC,STAC)
<FOR B IN (0,FEF)
<FOR C IN (0,ISKP,ISKP,ISKP)
<REPEAT 2,<XWD A+B+C,NORM>
>>>
REPEAT =64,<XWD ISKP,NORM>

IBOX:	JRST @.+1
	IBSTRT
	POPJ P,
INUL:	AOS INULL
IBRET:	JSR IBOX+1
IBSTRT:	SKIPE IWSJSW
	JRST IBRET
	MOVE A,IBPC	;GET PC
	TRNN A,1	;ODD ADDRS?
	JRST .+4	;NO, EVEN
	TLZN IBFULL	;WORD THERE?
	JRST INUL	;NO
	JRST .+3
	TLZN IAFULL
	JRST INUL
	MOVE B,(A)
IXCON:	TLO ITEMP1
	AOS I0CY
	TLZ ISEP
	MOVEM B,IILH#

IFN PRTSW,
<	MOVEI Q1,[ASCIZ /	IBOX STARTS /]
	PUSHJ P,PSTR
	LDB Q1,[POINT 9,B,8]
	PUSHJ P,PONUM
	PUSHJ P,PCRLF
>
	SKIPE ESKPSW
	JRST [SETZM ESKPSW
		AOS I0SKP
		AOS IBPC
		JRST IBRET]
	LDB Q1,[POINT 9,B,8]
	AOS OPTAB(Q1)
	JSR IBDO
	JRST (C)
IBDO:	0
INDL1:	LDB C,[POINT 4,B,17]
	JUMPE C,NOIX	;NO INDEX
	PUSHJ P,ACCOMP	;AC MATCH??
	JRST [AOS INULL
		MOVEM B,IIR
		AOS IACWT
		JSR IBOX+1
		MOVE B,IIR
		JRST INDL1]
	TLZ B,17	;NO
	MOVE D,UACSTO(C)
	MOVEM D,IILH
	ADD D,B
	HRR B,D
	TLZ ITEMP1
NOIX:	TLNN B,20	;@?
	JRST NOIND	;NO
	AOS IINDR
	HRRZM B,MA#
	MOVEM B,IIR
	JSR EFCOR	;DO E FETCH
	MOVE B,IIR	;GET INST
	DPB C,[POINT 23,B,35]
	MOVEM C,IILH
	MOVEM B,IIR#
	JSR IBOX+1
	MOVE B,IIR
	TLZ ITEMP1
	JRST INDL1
ACCOMP:	CAME C,SAC1
	CAMN C,SAC2
	POPJ P,
	CAME C,SMA
	AOS (P)
	POPJ P,
EFCOR:	0
EFL22:	HRRZ A,MA
	SETZM IRARSW#
	CAIG A,17	;AC?
	JRST EFAC
	CAME A,SMA
	CAMN A,ESMA
	JRST [	JSR IBOX+1
		AOS ISMAT
		JRST EFL22]
	TRO 1,EFTRQ	;REQUEST E-FET
EFL1:	JSR IBOX+1	;WAIT A CYCLE
EFENT:	PUSHJ M,[POPJ P,]	;WAIT TILL M-BOX HAS RUN. A HAS TYPE OF CYCLE
	TRNE A,EFTRQ	;E-FET?
	JRST .+4	;YES
	TRO 1,EFTRQ	;NO, REQUEST AGAIN
	AOS IEFWT
	JRST EFL1
	MOVE C,@MA
	TLNN MISS	;MISS?
	JRST EFL3	;NO, RETURN IT
	TLNN BADMIS	;BAD MISS?
	JRST NBMEC	;NO
EFL2:	TRNE A,MSTRQ	;M-STO?
	JRST EFCOR+1	;YES, TRY AGAIN
	TLNN MEMINU	;MEM INT BUSY?
	JRST EFCOR+1	;NO, TRY AGAIN
	JSR IBOX+1	;WAIT
	PUSHJ M,[POPJ P,]
	AOS IEMWT
	JRST EFL2
NBMEC:	JSR IBOX+1	;WAIT
	PUSHJ M,[POPJ P,]
	AOS IEMWT
	TRNN A,RARQ	;READ AROUND?
	JRST NBMEC	;NO, TRY AGAIN
	SETOM IRARSW
	TRZE FSTF
	TLO ISEP
	MOVE C,@MA
	JRST @EFCOR	;YES, RETURN
EFL4:	TLOA ISEP
EFL3:	TRNN FSTF
	JRST @EFCOR
	TLNE SEHOLD+MEMINR+ESTDO+SEDO
	JRST EFL4
	TLZ ISEP
	MOVE A,MA
	MOVEM A,STCAD
	MOVE B,SAVFWR
	MOVEM B,SAVSWR
	JRST @EFCOR
EFAC:	TLNN ITEMP1
	JSR IBOX+1
	MOVE A,MA
	MOVE C,UACSTO(A)
	JRST @EFCOR
NOIND:	MOVEM B,IIR
	LDB D,[POINT 9,B,8]
	MOVE E,ITAB(D)
	TLNE E,IPOP+IJRA+IJSR
	JRST IDPP
	TLNN E,FEF+FSTEF;FETCH EF. ADDRS?
	JRST NOFEF	;NO
	HRRZM B,MA
	TLNE E,FSTEF
	TRO FSTF
IDPP1:	TLNE E,DFEF
	TRO EFDUB
	JSR EFCOR
	TRZ FSTF+EFDUB
	MOVEM C,SAVEF#
NOFEF:	LDB C,[POINT 9,IIR,8]
	MOVE C,ITAB(C)
	JRST @IBDO
IDPP:	TLNN E,IPOP
	JRST IDJS
	LDB F,[POINT 4,IIR,12]
	MOVE G,UACSTO(F)
	HRRZM G,MA
	JRST IDPP1
IDJS:	TLNN E,IJSR
	JRST IDJRAP
	TLNE E,IUO
	JRST [	MOVEM B,BISAV
		HRRI B,40
		JRST .+1]
	MOVEI G,1(B)
	HRRZM G,MA
	JRST IDPP1
IDJRAP:	LDB F,[POINT 4,IIR,12]
	MOVS G,UACSTO(F)
	HRRZM G,MA
	JRST IDPP1
NORM:	TLNE IBRDY	;E BOX READY?
	JRST [JSR IBOX+1;NO
		AOS IEBWT
		JRST NORM]
	MOVE A,IBPC	;YES, GET PC
	LDB C,[POINT 9,IIR,8]
	MOVE C,ITAB(C)
	MOVEM A,EBPC
	MOVE B,IIR
	TLNE C,IBYT
	HLL B,BISAV
	MOVEM B,EIR
	MOVE G,IILH
	MOVEM G,EILH#
	MOVE G,BISAV
	MOVEM G,EBI#
	LDB D,[POINT 4,B,12]
	HRRZS B
	MOVEI E,1(D)
	TLNN C,STAC
	MOVNI D,1
	TLNN C,STACP1
	MOVNI E,1
	TLNN C,FSTEF+STEF
	MOVNI B,1
	MOVEM B,SMA
	MOVEM D,SAC1
	MOVEM E,SAC2
	AOS IBPC
	TLO IBRDY
	TLNE C,ISKP
	SETOM IWSJSW
	TLNE C,IJMP
	JRST IDJMP
	TLNN C,FSTEF+STEF
	JRST IBRET
	TRNN B,777760
	JRST IBRET
	TLNE C,FSTEF
	TLNE ISEP
	JRST .+3
	TLO SEHOLD+SEVAL
	JRST IBRET
	TLNE SEHOLD+ESTDO
	TLOA SEDO
	TROA 1,STCRQ
	JRST IBRET
	MOVE G,STCAD
	MOVEM B,STCAD
	TRZ G,3
	TRZ B,3
	CAMN B,G
	TLNN SEVAL
	TLOA SEDO
	TLO SEHOLD
	JRST IBRET

IDJMP:	TRO 1,EFTRQ	;FETCH TARGET
	MOVE B,IIR
	HRRZM B,MA
	TRO EFDUB	;DOUBLE FETCH
	JSR IBOX+1
	TRZ EFDUB
	SKIPN EJMPT	;DID IT JUMP?
	JRST IBSTRT	;NO
	TRO EFDUB
	SETZM EJMPT
	MOVEI A,EJRET
	MOVEM A,EFCOR
	SETZM IRARSW
	JRST EFENT
EJRET:	MOVE B,MA
	MOVEM B,IBPC
	AOS IBJMPC
	TRZ EFDUB
	TLZ IAFULL+IBFULL
	MOVEM B,APCL
	AOS APCL
	TRNE B,1	;ODD?
	JRST IJC1	;YES
	TLO IAFULL
	SKIPE IRARSW
	JRST IBRET
	AOS APCL
IJC1:	TLO IBFULL
	JRST IBRET

IDOXCT:	JSR IBOX+1
	AOS IBXCTC
	MOVE B,SAVEF
	MOVEM B,IIR
IFN PRTSW,
<	MOVEI Q1,[ASCIZ /	IBOX XCT /]
	PUSHJ P,PSTR
	LDB Q1,[POINT 9,B,8]
	PUSHJ P,PONUM
	PUSHJ P,PCRLF
>
	JRST IXCON

IDPUSJ:	LDB E,[POINT 4,IIR,12]
	MOVE D,UACSTO(E)
	ADDI D,1
	HRRM D,IIR
IDJSAR:	TLNE IBRDY
	JRST [ JSR IBOX+1
		AOS IEBWT
		JRST .-1]
	PUSHJ P,NORM
	JRST EJRET

IDPUSH:	LDB E,[POINT 4,IIR,12]
	MOVE D,UACSTO(E)
	ADDI D,1
	HRRM D,IIR
	JRST NORM
IDPOPJ:	LDB E,[POINT 4,IIR,12]
	MOVE D,UACSTO(E)
	MOVE D,(D)
	HRRM D,IIR
	JRST NORM

IDBSP1:	TLNN IBRDY
	JRST .+3
	HRR B,E
	JRST IDBC1
	TRNN B,777760
	JRST .-3
	TLNE B,37
	JRST .-5
	HRRZM B,MA
	TRO 1,EFTRQ
	HRR B,E
	MOVEM B,IIR
	JSR IBOX+1
	MOVE B,IIR
	JRST IDBC1
IDOBYT:	MOVE D,IIR
	MOVEM D,BISAV#
	TRNN D,777760
	ADDI D,UACSTO
	MOVE B,(D)
	MOVE E,B
	TLZ B,777774
	TLO B,(<DPB>)
	TLNN C,STAC+FSTEF
	SUB B,[XWD 1000,0]
	TLNE C,FSTEF
	IBP E
	HRRZS E
	CAIE E,(B)
	JRST IDBSP1
IDBC1:	MOVEM B,IIR
	TLNE IBRDY
	JRST [JSR IBOX+1
		AOS IEBWT
		JRST .-1]
	MOVE B,IIR
	JSR IBDO
	MOVE D,BISAV
	MOVE B,IIR
	HLL B,D
	MOVEM B,BISAV
	TLNE C,FSTEF
	JRST [ HRR D,B
		SUB D,[XWD 1000,0]
		JRST .+1]
	MOVEM D,IIR
	JRST NORM

IDUO:	TLNE IBRDY
	JRST [	JSR IBOX+1
		AOS IEBWT
		JRST .-1]
	MOVEI B,40
	HRRM B,IIR
	PUSHJ P,NORM
	TRZ EFDUB
	SOS IBPC
	JRST IDOXCT
IDOBLT:	LDB E,[POINT 4,IIR,12]
	AOS CHKPC
	MOVE F,UACSTO(E)
	HRRZM F,BSPN#
	HLRZM F,BFPN#
	MOVE B,IIR
	HRRZM B,BEPN#
	MOVE C,IBPC
	MOVEM C,IBPCSV#
IDBLP:	HRRZ A,BFPN
	MOVEM A,MA
	JSR EFCOR
	MOVE B,@MA
	MOVEM B,BLDAT#
	MOVSI E,(<BLT>)
	HRR E,BSPN
	MOVEM E,IIR
	TRNN E,777760
	ADDI E,UACSTO
	HRLI E,(<MOVEM G,>)
	MOVEM E,IBPC
	AOS BFPN
	TLO SEDO
	TLNE IBRDY
	JRST [	JSR IBOX+1
		AOS IEBLTW
		JRST .-1]
	PUSHJ P,NORM
	MOVE F,BLDAT
	MOVEM F,BLTDAT#
	MOVE E,IIR
	HRRZM E,SMA
	AOS A,BSPN
	CAMG A,BEPN
	JRST IDBLP
	AOS A,IBPCSV
	MOVEM A,IBPC
	JRST IBRET
IINIT:	AOS IBPC
	AOS IBPC
	SETOM IICNT#
	TLZE IAFULL
	AOSG IICNT
	TLZE IBFULL
	AOS IICNT
	SKIPLE IICNT
	JRST NORM
	JSR IBOX+1
	JRST .-7

ILUUO:
ILINST:	JRST 4,.
IFN CHKSW,
<	DEFINE CHJ (A)
<	MOVE G,CSVEF
	A
	MOVEM G,CHKPC>>

EBOX:	JRST @.+1
	EBSTRT
	POPJ P,
ENUL:	AOS ENULL
EBRET:	JSR EBOX+1
EBSTRT:	TLNN IBRDY
	JRST ENUL
	LDB D,[POINT 9,EIR,8]
IFN PRTSW,
<	MOVEI Q1,[ASCIZ /	EBOX DOES /]
	PUSHJ P,PSTR
	MOVE Q1,D
	PUSHJ P,PONUM
	PUSHJ P,PCRLF
>
	MOVE A,ETAB(D)
	MOVEM A,ETSAV#
IFN CHKSW,<MOVE F,CTSTOP#
	CAMG F,CURTIM
	JFCL>
	AOS E0CY
IFN CHKSW,
<	MOVE F,@CHKPC
	MOVE G,CHKPC
	MOVEM G,CPSV#
	MOVE G,UFLAGS
	MOVEM G,UFSAV#
CXCON:	LDB G,[POINT 9,F,8]
	CAMN G,D
	JRST CARN1
	CAIN D,(<BLT>⊗-11)
	JRST CARN1
	CAIN G,(<XCT>⊗-11)
	JRST CXCT
	JSR CERR
CARN1:	LDB E,[POINT 4,F,12]
	MOVEM E,CSVAC#
	MOVE B,UACSTO(E)
	MOVEM B,CSVACC#
	MOVE B,UACSTO+1(E)
	MOVEM B,UACPSV#
	MOVEM F,CFSV#
	UAC
	MOVEI E,@CFSV
	MOVEM E,CSVEF#
	IACP
	TLNN A,ESSW
	JRST CHP1
	CAIG E,17
	ADDI E,UACSTO
	MOVE E,(E)
	MOVEM E,CSVEFC#
CHP1:
>
	JRST (A)
ENOR:	HLRS A
	TRZ A,777700
	HRRZM A,EBCNT
	SETOM ESKPSW
IFN CHKSW,
<	MOVE C,CHKPC
	CAME C,EBPC
	JSR CERR>
	UAC
	XCT @EBPC
	SETZM ESKPSW
	IAC
	MOVE A,ETSAV
	TLNE A,ESKP
	SETZM IWSJSW
IFN CHKSW,
<	JSR CHKDO
	AOS CHKPC
	SKIPE ESKPSW
	AOS CHKPC>
EBWL1:	SOSLE EBCNT
	JRST EBWT
EBWCON:	MOVE A,ETSAV
	TLNN A,ESSW
	JRST ECON1
	MOVE B,SMA
	TRNN B,777760
	JRST [ TLZ A,ESSW
		MOVEM A,ETSAV
		JRST ECON1]
	TLON ESTDO
	JRST .+4
	AOS ESTWT
	JSR EBOX+1
	JRST .-4
	TLNE SEHOLD
	TRO ESTRQ
	MOVE C,SMA
	MOVEM C,ESMA
ECON1:	FOR I IN (SAC1,SAC2,SMA)
<	SETOM I
>
	MOVE A,ETSAV
IFN CHKSW,<MOVE G,CPSV
	MOVEM G,SAVCP#>
	MOVE G,CURTIM
	MOVEM G,SAVCT#
	TLNE A,ESSW
	TLNE SEHOLD
	JRST .+4
	AOS ESTCWT
	JSR EBOX+1
	JRST .-4
	MOVE A,ETSAV
	TLNE A,EBYT
	JRST EDBYT2
	TLZ IBRDY
	JRST EBRET
EBWT:	JSR EBOX+1
	AOS E1CY
	JRST EBWL1

EJMPS:	MOVE A,EIR
	TLZ A,37
	HRRI A,EJMP1
	MOVEM A,EJMP2
	UAC
EJMP2:	0
	IAC
	SETZM EJMPT
IFN CHKSW,<AOS CHKPC>
	JRST EBWCON
EJMP1:	SETOM EJMPT
	IAC
IFN CHKSW,<CHJ ()>
	JRST EBWCON

EDJRST:	MOVE A,EIR
	TLZ A,37
	TLO A,20
	HRRI A,B
	MOVE B,EILH
	TLZ B,37
IFN CHKSW,<CHJ ()>
	HRRI B,EDJP1
	SETOM EJMPT
	XCT A
EDJP1:	TLNE A,2⊗5
	MOVEM B,UFLAGS
	JRST EBWCON
EDPUSJ:	LDB C,[POINT 4,EIR,12]
	MOVE D,UACSTO(C)
	AOS E,EBPC
	HLL E,UFLAGS
	PUSH D,E
	MOVEM D,UACSTO(C)
IFN CHKSW,<CHJ ()>
EJSCON:	TLZ E,20000
	MOVEM E,UFLAGS
	JRST EBWCON

EDPOPJ:	LDB C,[POINT 4,EIR,12]
	MOVE D,UACSTO(C)
	POP D,E
IFN CHKSW,<CHJ (<HRRZ G,E>)>
	MOVEM D,UACSTO(C)
	SETOM EJMPT
	JRST EBWCON

EDJSR:	MOVE B,EIR
	AOS E,EBPC
	HLL E,UFLAGS
	MOVEM E,(B)
IFN CHKSW,<CHJ (<ADDI G,1>)>
	JRST EJSCON
EDJSP:	LDB C,[POINT 4,EIR,12]
	AOS E,EBPC
	HLL E,UFLAGS
	MOVEM E,UACSTO(C)
IFN CHKSW,<CHJ ()>
	JRST EJSCON
EDJSA:	MOVE B,EIR
	AOS E,EBPC
	HLL E,UFLAGS
	LDB C,[POINT 4,EIR,12]
	MOVE F,UACSTO(C)
	MOVEM E,UACSTO(C)
	MOVEM F,(B)
IFN CHKSW,<CHJ(<ADDI G,1>)>
	JRST EJSCON

EDBYT2:	MOVE D,EBI
	HRRZM D,SMA
	MOVSI E,ESSW
	MOVEM E,ETSAV
	JRST EBWCON

EBLT:	MOVE G,BLTDAT
	XCT EBPC
	JRST EBWCON
EUUUO:	MOVE E,EBI
	MOVEM E,40
IFN CHKSW,<CHJ (<MOVEI G,41>)>
	JRST EBWCON
EINIT:	MOVS E,EBPC
	SUB E,[XWD 2,0]
	HRRI E,EIN1
	BLT E,EIN1+2
	SETOM ESKPSW
	UAC
EIN1:	0
	0
	0
	SETZM ESKPSW
	IAC
	SETZM IWSJSW
IFN CHKSW,
<	AOS CHKPC
	AOS CHKPC
	AOS CHKPC
	SKIPE ESKPSW
	AOS CHKPC>
	JRST EBWCON

IFN CHKSW,
<CHKDO:	0
	LDB D,[POINT 9,EIR,8]
	CAIG D,100
	JRST @CHKDO
	MOVE C,CSVAC
	MOVE D,CSVACC
	MOVE G,UACSTO(C)
	MOVEM G,CSVACN#
	MOVE E,CSVEF
	CAIG E,17
	ADDI E,UACSTO
	MOVE F,CSVEFC
	MOVEM E,CSVA#
	TLNE A,ESSW
	EXCH F,(E)
	MOVEM D,UACSTO(C)
	MOVEM F,CSVEFN#
	MOVE G,UFSAV
	EXCH G,UFLAGS
	MOVEM G,UFSAVN#
	MOVE G,UACPSV
	MOVEM G,UACSTO+1(C)
	UAC
	XCT @CHKPC
	JFCL
	IAC
	MOVE A,ASAV
	MOVE C,CSVAC
	MOVE D,UACSTO(C)
	MOVE E,CSVA
	TLNN A,ESSW
	JRST .+4
	MOVE F,(E)
	CAME F,CSVEFN
	JSR CERR
	CAME D,CSVACN
	JSR CERR
	HLRZ G,UFLAGS
	TRZ G,740000
	HLRZ B,UFSAVN
	TRZ B,740000
	CAME G,B
	JSR CERR
	JRST @CHKDO
CXCT:	MOVEM F,CFSV
	UAC
	MOVEI E,@CFSV
	IACP
	MOVE F,(E)
	JRST CXCON
CERR:	0
	JRST .
>

ESSW←←1000
ESKP←←2000
EBYT←←4000
ETAB:	0
	FOR I←1,37
<	XWD ESSW+1,EUUUO
>
	XWD 1+ESKP,ENOR
	XWD 1,EINIT
	FOR I←42,0127
<	XWD 1+ESKP,ENOR
>
	FOR I IN(5,2,2,1,2+ESSW,2,2+ESSW+EBYT,2+ESSW)
<	XWD I,ENOR
>
	REPEAT 2,<FOR I IN (5,6,5,5,5,5,5,5)
<	XWD I,ENOR
>>
	REPEAT 10,<XWD =15,ENOR>
	REPEAT 10,<XWD =22,ENOR>
	FOR I←1,4
<	FOR Q IN (1,1,1+ESSW,1+ESSW)
<	XWD Q,ENOR
>>
	REPEAT 10,<XWD =13,ENOR>
	REPEAT 10,<XWD =20,ENOR>
	FOR I E <211>
<	XWD I,ENOR
>
	XWD 2,EJMPS	;JFFO
	FOR I E <2211>
<	XWD I,ENOR
>
	XWD 1+ESSW,ENOR	;EXCH
	XWD ESSW,EBLT
	REPEAT 2,<XWD 1,EJMPS>
	XWD 1,EDJRST
	XWD 1,EJMPS
	0
	0
	XWD ESSW,EDPUSJ
	XWD ESSW+1,ENOR
	XWD ESSW+1,ENOR
	XWD 1,EDPOPJ
	XWD ESSW,EDJSR
	XWD 1,EDJSP
	XWD ESSW,EDJSA
	XWD 1,EJMPS
	FOR I←1,2
<	FOR Q IN (1,1,1+ESSW,1+ESSW)
<	XWD Q,ENOR
>>
	DEFINE XX3(A,B)
<	XWD B+1,ENOR
  IFE A,<REPEAT 7,<XWD ESKP+B+1,ENOR>>
  IFN A,<REPEAT 7,<EJMPS>>
>
	FOR I IN (<0,0>,<0,0>,<1,0>,<0,0>
	,<1,0>,<0,ESSW>,<1,0>,<0,ESSW>)
<	XX3(I)
>

REPEAT =32,<FOR I IN (1,1,1+ESSW,1+ESSW)
<XWD I,ENOR
>>
REPEAT 10,
<FOR I IN (1,1+ESKP,1+ESKP,1+ESKP)
<REPEAT 2,<XWD I,ENOR>
>>
REPEAT =64,<XWD 1+ESKP,ENOR>

END STRT