% - - - more crufty debugging version - - -

rbase← rbase[TSP];
LTEMP0← Link;


TOP LEVEL;

rbase← rbase[InstCount];
InstBreakCheck:
T← InstCount← (InstCount) + 1;
branch[.+2, carry’], pd← T - (InstBreak);
branch[.nextok];

branch[.+2, alu#0];
:if[BreakPoints];
nop, breakpoint;
:else;
RESCHEDULE;
:endif;

nop;
.nextok:
call[CHECKREGS];

rbase← rbase[RANDNUM], call[.Random];

LTEMP0← T, call[.Random];
LTEMP1← T, call[.Random];
Q← T, call[.Random];
LTEMP2← T, call[.Random];
LTEMP3← T, call[.Random];
LTEMP4← T, call[.Random];
NARGS← T, call[.Random];
DEFHI← T, call[.Random];
DEFLO← T, call[.Random];
Cnt← T;

- - - - - end crufty debugging version

%
SUBROUTINE;

CHECKREGS:
rbase← rbase[LTEMP1];
LTEMP1← Link;

TOP LEVEL;

branch[.+2, R even], TSP, memBase← StackBR;
UCodeCheck[TSPODD];

T← (PVAR) - (FX.PVAR);
fetch← T;
T← Md;
T← T and (StackMask);
pd← T xor (FxtnBlock);
branch[.+2, alu=0];
uCodeCheck[BadFrame];

T← ESP;
T← T - (TSP);
T ← T rsh 1;
T← T - (LEFTOffset);
pd← (LEFT) - T;
branch[.+2, alu=0];
UCodeCheck[LEFTWRONG];
pd← (PSTATE) and not (PS.PCXBAD);
branch[.+2, alu=0];
UCodeCheck[PSTATEWRONG];

T← (PVAR) - (FXBACK[IVAR]);
fetch← T;
pd← (IVAR) - (Md);
branch[.+2, alu=0];
UCodeCheck[IVARMISMATCH];

SUBROUTINE;
Link← LTEMP1;
return;

SCANSTACK:
rbase← rbase[LTEMP1];
LTEMP1← Link;

TOP LEVEL;

pd← (PVAR) - (10000c);
branch[.+2, carry];
branch[.endcheck];
LTEMP2← A0, memBase← StackBR;
LTEMP3← A0, branch[.scanstk0];

.scanstack:
T← LTEMP2;* new frame
pd← T - (LTEMP3);* old frame
branch[.+2, carry]; * new must be greater than old
ucodecheck[BadFrame];

LTEMP3← T;

.scanstk0:
branch[.+2, R even], LTEMP2← (fetch← LTEMP2) + 1;
ucodecheck[BadFrame];
T← Md;
LTEMP2← (fetch← LTEMP2) - 1;
T← (T) and (StackMask);
pd← T - (FreeStackBlock);
branch[.scanfree, alu=0], pd← T - (BFBlock);
branch[.scanbf, alu=0], pd← T - (FxtnBlock);
branch[.scanfx, alu=0], pd← T - (GuardBlock);
branch[.scanend, alu=0];
branch[.scanbf];

.scanfree:
LTEMP2← (LTEMP2) + (Md), branch[.scanstack];

.scanfx:
* LTEMP2 points to a FX. Could check it here
T← (PVAR) - (FX.PVAR);
pd← (LTEMP2) - T;
branch[.+2, alu#0];
LTEMP2← ESP, branch[.scanstack];* was current frame

T← (LTEMP2) + (FX.NEXT);
fetch← T;
LTEMP2← Md, branch[.scanstack];

.scanbf:
LTEMP2← (fetch← LTEMP2) + 1;
LTEMP4← Md;* flags
LTEMP2← (fetch← LTEMP2) + 1;
T← (LTEMP4) and (StackMask);
pd← T - (BFBlock);
branch[.scanbfend, alu=0], T← Md, pd← T;
branch[.+2, alu=0];
.bfbad:
uCodeCheck[StackBad];
branch[.scanbf];

.scanbfend:
pd← (LTEMP4) and (BFResidual);
branch[.scanresid, alu#0], pd← T - (LTEMP3);
branch[.scanstack, alu=0];

.scanbadstack:
uCodeCheck[StackBad];

.scanresid:
T← (LTEMP3) + (2c);
pd← T - (LTEMP2);
branch[.+2, alu#0];
branch[.scanstack];

.badresid:
ucodecheck[StackBad];

.scanend:
memBase← InterfaceBR;
fetch← 7s;
pd← (LTEMP2) - (Md);
branch[.endcheck, alu=0], memBase← StackBR;
T← (LTEMP2) + 1;
fetch← T, branch[.scanfree];


SUBROUTINE;
.endcheck:
Link← LTEMP1;
return;


KnowRBase[
RANDNUM];

.Random:
T← LSH[RANDNUM, 11];* T← 2↑9 * R
T← T+(RANDNUM);* (2↑9 + 2↑0)* R
T← LSH[T, 2];* (2↑11 + 2↑2)* R
T← T+(RANDNUM);* (2↑11 + 2↑2 + 2↑0)* R
T← T + (33000c);
T← RANDNUM← T+(31c), Return;* +13849


:endif;* end of checking code