Home » Archimedes archive » Zipped Apps » BCPL » BCPL/b/cgh

BCPL/b/cgh

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Zipped Apps » BCPL
Filename: BCPL/b/cgh
Read OK:
File size: 5CC2 bytes
Load address: 0000
Exec address: 0000
File contents
SECTION "CGH"

GET "b.CGheader"
GET "b.FPOps"	// for the register names

STATIC {
/* Version of 18 Mar 86 12:58:25
 */
   dummy = VersionMark;
   version = 1*256+14 }

/* The following procedures maintain a register memory.
   This remembers the place a register was loaded from,
   and anywhere it has been stored, and also whether
   the contents have been modified for use as an address.
*/

/* 1.8	17 Feb 86 17:20:08
     Incorporates floating point
   1.9	07 Mar 86 21:38:51
     k.static
   1.10  18 Mar 86 12:58:36
     post-increment fp instructions generated by StoreT must
     not have the  wb  bit set.
     Code improvement for !@thing
   1.11  21 Mar 86 11:19:13
     Deferred shifts
   1.12  20 May 87 11:09:36
     Bug fix: store to location forces loads from it to be done.
   1.13  30 Jun 87 15:52:16
     Bug fix: LoadAddress takes account of whether base to be loaded has an
     additive constant
*/

MANIFEST {
// register state description
   rsd.type=h1; rsd.shiftstate=h2; rsd.loc=h3;
   rsd.sl=h4; rsd.lock=h5;

// description of a saved register state
   srs.size = 4;
   srs.header = 4;
   srs.lab = 1; srs.tos = 2;
   srs.ps = 3;
   srs.blocksize = srs.size*(15+8)+srs.header;

   srsd.type=rsd.type; srsd.shiftstate=rsd.shiftstate;
   srsd.loc=rsd.loc; srsd.sl=rsd.sl };

STATIC {
   regList = 0; fregList = 0 };

LET InitialiseRegisterSlave() BE {
   regList := GetVector(RegSize*16);
   FOR i = 0 TO RegSize*16-1 DO regList!i := 0;
   fregList := GetVector(RegSize*8);
   FOR i = 0 TO RegSize*8-1 DO fregList!i := 0 }

LET ArgumentRegister(r) =
   reversedStack -> r.a4-r+1,
		    r

AND RegEntry(type, r) =
   type=k.reg -> regList+RegSize*r,
   type=k.freg -> fregList+RegSize*r,
		  CGError(TRUE, "bad type in RegEntry")


AND HasSlavedLoc(r, type) = VALOF {
   LET x = RegEntry(type, r);
   RESULTIS rsd.type!x~=0 -> TRUE,
	    rsd.sl!x~=0 -> TRUE,
			   FALSE }

AND DiscardRegs() BE {
   FOR i = r.0 TO r.14 DO DiscardReg(i, k.reg);
   Lock(r.nil, k.reg);
   FOR i = fr.0 TO fr.7 DO DiscardReg(i, k.freg) }

AND DiscardReg(r, type) BE {
   LET x = RegEntry(type, r);
   rsd.type!x, rsd.shiftstate!x := 0, 0;
   IF (r~=r.nil | type~=k.reg) THEN rsd.lock!x := 0;
   DiscardSL(@rsd.sl!x);
   IF type=k.reg THEN {
      FlushPendingUsesOfReg(r);
      x := LocHeldInRegister(r, type);
      IF x~=Null THEN {
	 MoveStoR(k.reg, r, k.loc, x);
	 Lock(r, type) } } }

AND DiscardNonLocalRegs() BE
   DiscardRegsIf(IsNonLocal)

AND DiscardNonConstRegs() BE
   DiscardRegsIf(IsNonConst)

AND IsNonLocal(t) = t~=k.number & t~=k.loc

AND IsNonConst(t) = t~=k.number

AND DiscardRegsIf(pred) BE {
   FOR r = r.0 TO r.14 DO DiscardIf(pred, r, k.reg)
   FOR r = fr.0 TO fr.7 DO DiscardIf(pred, r, k.freg) }

AND DiscardIf(pred, r, type) BE {
   LET p = RegEntry(type, r);
   LET q = @rsd.sl!p;
   LET x = !q;
   IF pred(rsd.type!p) THEN rsd.type!p, rsd.loc!p := 0, 0;
   WHILE x~=0 DO {
      TEST pred(sl.type!x) THEN
	 !q := FreeBlk(x, sl.size)
      ELSE
	 q := x;
      x := !q };
//   IF type=k.reg THEN FlushPendingUsesOfReg(r);
   IF rsd.type!p=0 & rsd.sl!p=0 THEN rsd.shiftstate!p := 0;
   IF type~=k.reg | (r~=r.nil & LocHeldInRegister(r)=Null)
      THEN rsd.lock!p := 0 }

AND LoadAddress(x) = VALOF {
   LET b, r, y = LookFor(x, ShiftedUp), -1, 0;
   TEST b>=0 THEN IF h4!x~=0 THEN {
      r := FindRegisterBetween(r.0, r.14, FALSE);
      IF r=Null THEN r := b;
      SetRToRPlusK(r, b, h4!x*4);
      y := RegEntry(k.reg, r);
      rsd.shiftstate!y := 2;
      RESULTIS r }
   ELSE {
      b := IsInARegister(x);
      TEST b>=0 THEN
	 TEST Locked(b, k.reg) THEN {
	    r := NextR();
	    MoveRtoR(k.reg, b, k.reg, r) }

	 ELSE {
	    LET n = FindRegisterBetween(r.0, r.14, FALSE);
	    IF n~=Null THEN {
	       r := n;
	       MoveRtoR(k.reg, b, k.reg, r) } }
      ELSE
	 b := MoveToAnyR(x) };

   IF r<0 THEN r := b;
   y := RegEntry(k.reg, r);

   IF rsd.shiftstate!y=0 THEN {
      FlushPendingUsesOfReg(r);
      FlushPendingLoadsForReg(b);
      ShiftRegisterDS(r, b, sh.asl, 2);
      rsd.shiftstate!y := 2 };

   RESULTIS r }

AND LoadCarAdd(x) = VALOF {
   LET b, r, y = LookFor(x, IsaCar), -1, 0;
   IF b<0 THEN {
      b := IsInARegister(x);
      TEST b>=0 THEN
	 TEST Locked(b, k.reg) THEN {
	    r := NextR();
	    MoveRtoR(k.reg, b, k.reg, r) }
	 ELSE {
	    LET n = FindRegisterBetween(r.0, r.14, FALSE);
	    IF n~=Null THEN {
	       r := n;
	       MoveRtoR(k.reg, b, k.reg, r) } }
      ELSE
	 b := MoveToAnyR(x) };

   IF r<0 THEN r := b;
   y := RegEntry(k.reg, r);

   IF rsd.shiftstate!y=0 THEN {
      FlushPendingUsesOfReg(r);
      FlushPendingLoadsForReg(b);
      GenF1K(f.bic, r, b, #xff000000);
      rsd.shiftstate!y := -1 };

   RESULTIS r }

AND MoveStoR(type, r, a, b) BE {
   LET x = RegEntry(type, r);
   rsd.type!x, rsd.shiftstate!x, rsd.loc!x := a, 0, b;
   DiscardSL(@rsd.sl!x) }

AND MoveRtoR(rtype, r, stype, s) BE {
   LET x, y = RegEntry(rtype, r), RegEntry(stype, s);
   rsd.type!y, rsd.shiftstate!y, rsd.loc!y :=
      rsd.type!x, rsd.shiftstate!x, rsd.loc!x
   CopySL(@rsd.sl!y, rsd.sl!x) }

AND StoreR(type, r, a, b) = VALOF {
   LET x = RegEntry(type, r);
   LET wastos = DiscardAddress(a, b);
   IF rsd.type!x=0 THEN rsd.type!x, rsd.shiftstate!x, rsd.loc!x := a, 0, b;
   AddLocToSL(@rsd.sl!x, a, b);
   RESULTIS wastos }

AND AddRegInfo(type, r, a, b) BE {
   LET x = RegEntry(type, r);
   IF rsd.type!x~=0 THEN AddLocToSL(@rsd.sl!x, rsd.type!x, rsd.loc!x)
   rsd.type!x, rsd.loc!x := a, b }

AND DiscardAddress(t, n) = VALOF {
   LET DiscardA(x, t, n) BE {
      IF rsd.type!x=t & rsd.loc!x=n THEN rsd.type!x := 0;
      DelLocFromSL(@rsd.sl!x, t, n) };
   FOR r = r.0 TO r.14 DO DiscardA(RegEntry(k.reg, r), t, n)
   FOR r = fr.0 TO fr.7 DO DiscardA(RegEntry(k.freg, r), t, n)
   FlushPendingLoadsForSLoc(t, n);
   RESULTIS DelSLocFromPendingList(@PendingStores, t, n) }

AND PrintRegList() BE {
   STATIC { nullState=FALSE };
   LET PrintR(type, r) BE {
      LET s = RegEntry(type, r);
      IF rsd.type!s~=0 | rsd.sl!s~=0 | rsd.lock!s~=0 THEN {
	 WrCh(rsd.lock!s=0 -> ' ', '**');
	 WrCh(type=k.reg -> 'R', 'F');
	 WriteF("%n: %n %n", r, rsd.type!s, rsd.loc!s);
	 IF rsd.shiftstate!s~=0 THEN WriteF(" [%n]", rsd.shiftstate!s);
	 PrintList(rsd.sl!s, 2, ": ", "", "*n");
	 NullState := FALSE } };
   nullState := TRUE;
   FOR r = r.0 TO r.14 DO PrintR(k.reg, r)
   FOR r = fr.0 TO fr.7 DO PrintR(k.freg, r)
   IF nullState THEN WriteS("Null*n") }

AND IsInaRegister(x) =
   (h2!x>=0 | h4!x~=0) -> Null,
   h1!x=k.reg	       -> h3!x,
			  LookFor(x, NotAddr)

AND LookFor(x, pred) = LookForSloc(pred, h1!x, h3!x)

AND LookForRegContainingType(t) = VALOF {
   FOR r = r.0 TO r.14 DO {
      LET v = RegEntry(k.reg, r);
      IF t=rsd.type!v & NotAddr(rsd.shiftstate!v) THEN
	 RESULTIS r };
   RESULTIS Null }

AND LocInRegister(r) = rsd.loc![RegEntry(k.reg, r)]

AND TurnIndIntoSLoc(x) = VALOF {
   LET k, r1, p, t = h4!x, ?, ?, ?;
   h4!x := 0;
   r1 := IsInARegister(x);
   IF r1=Null THEN RESULTIS FALSE;
   p := RegEntry(k.reg, r1);
   t := rsd.type!p;
   IF t~=k.lvloc & t~=k.lvglob & t~=k.lvstatic THEN
      RESULTIS FALSE;
   h1!x := t+k.loc-k.lvloc;
   h3!x := rsd.loc!p+k;
   RESULTIS TRUE }

AND RemoveFalseIndirection(x) BE {
   LET t, ind, n, k = h1!x, h2!x, h3!x, h4!x;
   TEST ind=0 & (t=k.lvloc | t=k.lvglob | t=k.lvstatic) THEN {
      h1!x := t+k.loc-k.lvloc;
      h2!x := -1;
      h3!x := n+k;
      h4!x := 0 }
   ELSE TEST ind=0 THEN {
      LET b = LookForSloc(ShiftedUp, t, n);
      IF b~=Null THEN {
	 LET p = OffsetInList(pendingStores, k.ireg, b, k)
	 IF p~=Null THEN {
	    h1!x := k.reg;
	    h2!x := -1;
	    h3!x := ps.reg!p;
	    h4!x := 0 } } }
   ELSE IF ind>=CarMark THEN {
      LET b = LookForSloc((ind=CarMark -> IsACar, NotAddr), t, n);
      IF b~=Null THEN {
	 LET p = OffsetInList(pendingStores, k.ireg, b, k/4)
	 IF p~=Null THEN {
	    h1!x := k.reg;
	    h2!x := -1;
	    h3!x := ps.reg!p;
	    h4!x := 0 } } } }

AND LookForSloc(pred, t, n) = VALOF {
   IF (CGDebugMode&db.regs)~=0 THEN {
      WriteF("Lookfor %n %n %s:*N", t, n,
		  pred=NotAddr -> "NotAddr",
		pred=ShiftedUp -> "ShiftedUp",
				  "IsACar");
      PrintRegList() };

   FOR r = r.0 TO r.14 DO {
      LET v = RegEntry(k.reg, r);
      IF [(t=rsd.type!v & n=rsd.loc!v) |
	  SlocInList(rsd.sl!v, t, n)~=Null] &
	 pred(rsd.shiftstate!v) THEN {
	 IF (CGDebugMode&db.regs)~=0 THEN WriteF("Found %n*n", r)
	 RESULTIS r } };

   t := SlocInList(PendingStores, t, n);
   IF t~=Null THEN {
      n := ps.reg!t;
      TEST pred(rsd.shiftstate![RegEntry(k.reg, n)]) THEN
	 t := n
      ELSE
	 t := Null };
   IF (CGDebugMode&db.regs)~=0 THEN WriteF("Found %n*n", t)
   RESULTIS t }

AND NotAddr(x) = x=0

AND ShiftedUp(x) = x>0

AND IsaCar(x) = x<0


AND LookForFR(t, n) = VALOF {
   IF (CGDebugMode&db.regs)~=0 THEN {
      WriteF("LookforF %n %n:*N", t, n);
      PrintRegList() };

   FOR r = fr.0 TO fr.7 DO {
      LET v = RegEntry(k.freg, r);
      IF [(t=rsd.type!v & n=rsd.loc!v) |
	  SlocInList(rsd.sl!v, t, n)~=Null] THEN {
	 IF (CGDebugMode&db.regs)~=0 THEN WriteF("Found %n*n", r)
	 RESULTIS r } };

   RESULTIS Null }


AND Lock(r, type) BE
   TEST type=k.reg THEN
      IF r.0<=r<=r.14
	 THEN rsd.lock![RegEntry(k.reg, r)] := -1
   ELSE TEST type=k.freg THEN
      IF fr.0<=r<=fr.7
	 THEN rsd.lock![RegEntry(k.freg, r)] := -1
   ELSE CGError(TRUE, "bad type in Lock")

AND Unlock(r, type) BE
   TEST type=k.reg THEN
      IF (r.0<=r<=r.14) & r~=r.nil & LocHeldInRegister(r)=Null
	 THEN rsd.lock![RegEntry(k.reg, r)] := 0
   ELSE TEST type=k.freg THEN
      IF fr.0<=r<=fr.7
	 THEN rsd.lock![RegEntry(k.freg, r)] := 0
   ELSE CGError(TRUE, "bad type in Lock")

AND Locked(r, type) = rsd.lock![RegEntry(type, r)] = -1

AND AddLocToSL(lvp, t, n) BE {
   LET v = FillBlk(sl.size, !lvp, t, n);
   !lvp := v }

AND CopySL(lvdest, source) BE
   WHILE source~=0 DO {
      AddLocToSL(lvdest, sl.type!source, sl.loc!source);
      source := !source }

AND DiscardSL(lvp) BE {
   DeleteList(!lvp, sl.size);
   !lvp := 0 }

AND DelLocFromSL(lvp, t, n) BE {
   LET p = !lvp;
   WHILE p~=0 DO {
      TEST sl.type!p=t & sl.loc!p=n THEN
	 !lvp := FreeBlk(p, sl.size)
      ELSE
	 lvp := p;
      p := !lvp } }

AND PrintRegisterState(s) BE {
   LET NullState = TRUE;
   WriteF("ss %n %n*n", srs.lab!s, srs.tos!s);
   s := s+srs.header;
   FOR r = r.0 TO r.14 DO {
      IF srsd.type!s~=0 | srsd.sl!s~=0 THEN {
	 WriteF("R%n: %n %n %n:", r, srsd.type!s, srsd.shiftstate!s, srsd.loc!s);
	 PrintList(srsd.sl!s, 2, "", "", "*n");
	 NullState := FALSE };
      s := s+srs.size };
   FOR r = fr.0 TO fr.7 DO {
      IF srsd.type!s~=0 | srsd.sl!s~=0 THEN {
	 WriteF("F%n: %n %n:", r, srsd.type!s, srsd.loc!s);
	 PrintList(srsd.sl!s, 2, "", "", "*n");
	 NullState := FALSE };
      s := s+srs.size };
   IF NullState THEN WriteS("Null*n") }

AND SaveRegisterState() = VALOF {
   LET CopyIn(type, r, y) = VALOF {
      LET x = RegEntry(type, r);
      srsd.shiftstate!y := rsd.shiftstate!x;
      srsd.sl!y := 0
      CopySL(@srsd.sl!y, rsd.sl!x);
      TEST k.loc<=rsd.type!x<=k.lab THEN {
	 LET t, n = rsd.type!x, rsd.loc!x;
	 srsd.type!y, srsd.loc!y := 0, 0;
	 IF SlocInList(srsd.sl!y, t, n)=Null
	    THEN AddLocToSL(@srsd.sl!y, t, n) }
      ELSE
	 srsd.type!y, srsd.loc!y := rsd.type!x, rsd.loc!x;
      RESULTIS y+srs.size };
   LET p = GetVector(srs.blocksize);
   LET y = p+srs.header;
   FOR r = r.0 TO r.14 DO y := CopyIn(k.reg, r, y)
   FOR r = fr.0 TO fr.7 DO y := CopyIn(k.freg, r, y)
   srs.tos!p := TOSOffset;
   srs.ps!p := CopyOfList(PendingStores, ps.size);
   RESULTIS p }

AND RestoreRegisterState(p) BE {
   LET CopyBack(type, r, y) = VALOF {
      LET x = RegEntry(type, r);
      rsd.type!x, rsd.shiftstate!x, rsd.loc!x, rsd.sl!x :=
	 srsd.type!y, srsd.shiftstate!y, srsd.loc!y, srsd.sl!y;
      IF rsd.type!x=0 & rsd.sl!x~=0 THEN {
	 LET q = rsd.sl!x;
	 rsd.type!x, rsd.loc!x := sl.type!q, sl.loc!q;
	 rsd.sl!x := FreeBlk(q, sl.size) };
      y := y+srs.size };
   LET y = p+srs.header;
   FOR r = r.0 TO r.14 DO y := CopyBack(k.reg, r, y);
   FOR r = fr.0 TO fr.7 DO y := CopyBack(k.freg, r, y);
   TOSOffset := srs.tos!p;
   PendingStores := srs.ps!p;
   FreeVector(p) }

AND IntersectionOfRegisterStates(p, q) = VALOF {
   LET res = GetVector(srs.blocksize);
   LET resy = res+srs.header;
   LET y1, y2 = p+srs.header, q+srs.header;

   IF (CGDebugMode&db.srs)~=0 THEN {
      WriteS("Forming intersection -- ");
      PrintRegisterState(p);
      PrintRegisterState(q) };
   FOR r = r.0 TO r.14+(fr.7-fr.0+1) DO {
      TEST srsd.shiftstate!y1~=srsd.shiftstate!y2 THEN
	 srsd.type!resy, srsd.shiftstate!resy, srsd.loc!resy, srsd.sl!resy :=
	       0, 0, 0, 0
      ELSE {
	 LET sl1, sl2 = srsd.sl!y1, srsd.sl!y2;
	 srsd.shiftstate!resy := srsd.shiftstate!y1;
	 TEST srsd.type!y1=srsd.type!y2 & srsd.loc!y1=srsd.loc!y2 THEN
	    srsd.type!resy, srsd.loc!resy := srsd.type!y1, srsd.loc!y1
	 ELSE
	    srsd.type!resy, srsd.loc!resy := 0, 0;
	 srsd.sl!resy := 0;
	 WHILE sl1~=0 DO {
	    LET t, n = sl.type!sl1, sl.loc!sl1;
	    IF SLocInList(sl2, t, n)~=Null
	       THEN AddLocToSL(@srsd.sl!resy, t, n);
	    sl1 := !sl1 } };
      DiscardSL(@srsd.sl!y1);
      DiscardSL(@srsd.sl!y2);
      y1, y2 := y1+srs.size, y2+srs.size;
      resy := resy+srs.size };
   srs.tos!res := srs.tos!p=srs.tos!q -> srs.tos!p,
					 -1;
   srs.ps!res := 0;
   FreeVector(p);
   FreeVector(q);

   IF (CGDebugMode&db.srs)~=0 THEN {
      WriteS("giving -- ");
      PrintRegisterState(res) };
   RESULTIS res }

AND FindSavedState(lab) = VALOF {
   LET q = @SavedStates;
   LET p = !q;
   WHILE p~=0 DO {
      IF srs.lab!p=lab THEN {
	 !q := !p; RESULTIS p }
      q := p; p := !p };
   RESULTIS Null }

AND SaveStateForLab(lab) BE {
   lab := TransferredLabel(lab);
   IF LabelFlagged(lab, lab.forwardjump) THEN {
      LET p = SaveRegisterState();
      LET s = FindSavedState(lab);
      IF s~=Null THEN
	 p := IntersectionOfRegisterStates(p, s);

      srs.lab!p := lab;
      !p := SavedStates;
      SavedStates := p;
      IF (CGDebugMode&db.srs)~=0 THEN {
	 WriteS("saving ");
	 PrintRegisterState(p) } } }

// Now some users of the register memory

AND MoveToAnyCRForStoreTo(x, t, n) = VALOF {
   LET r = MoveToAnyCRSomeTimeForStoreTo(x, t, n);
   FlushPendingLoadsForReg(r);
   RESULTIS r }

AND MoveToAnyCRSomeTimeForStoreTo(x, t, n) = VALOF {
   LET r =Null;
   IF h1!x=k.number & h2!x<0 THEN {
      TEST t=k.loc THEN {
	 LET p = SlocInList(pendingStores, t, n-1)
	 IF p~=Null THEN r := ps.reg!p }

      ELSE {
	 r := LookFor(n, t);
	 IF r~=Null THEN {
	    LET p = @pendingStores;
	    LET offset = h4!n;
	    {  p := SlocInList(!p, k.ireg, r);
	       TEST p=Null THEN {
		  r := Null; BREAK }
	       ELSE IF pl.offset!p=offset-1 THEN {
		  r := ps.reg!p; BREAK }
	    } REPEAT } };

      IF r~=Null THEN {
	 LET s = Null;
	 IF (CGDebugMode&db.regs)~=0
	    THEN WriteF("r%n adjacent", r);
	 s := LookFor(x, NotAddr);
	 IF s>r THEN RESULTIS s;
	 r := FindRegisterBetween(r+1, r.14, FALSE);
	 IF r~=Null THEN {
	    MoveToRSomeTime(r, x);
	    RESULTIS r } } };

   RESULTIS MoveToAnyCRSomeTime(x) }

AND MoveToAnyCR(x) = VALOF {
   LET r = MoveToAnyCRSomeTime(x);
   FlushPendingLoadsForReg(r);
   RESULTIS r }

AND MoveToAnyCRSomeTime(x) =
   // Ensure that the simulated stack item x is in a register.
   // The user of this routine guarantees that the contents of
   // the register will not be updated (so if the value is already
   // in a locked register, that will do.
      MoveAux(x, (~IsConst(x) & h4!x~=0) | h2!x>=0)

AND MoveToAnyR(x) = VALOF {
   LET r = MoveToAnyRSomeTime(x);
   FlushPendingLoadsForReg(r);
   RESULTIS r }

AND MoveToAnyRSomeTime(x) = MoveAux(x, TRUE)

AND MoveAux(x, copyLocked) = VALOF {
   LET t, n, loc = ?, ?, ?;
   RemoveFalseIndirection(x);
   t, n, loc := h1!x, -1, h3!x;
   TEST 1<=ArgumentNumber<=4 THEN {
      n := ArgumentRegister(ArgumentNumber);
      ArgumentNumber := Null }

   ELSE TEST t=k.reg | t=k.shreg THEN
      TEST copyLocked &
	   [Locked(loc, k.reg) |
	    RegInPendingList(PendingStores, loc)~=Null] THEN
	 n := NextR()
      ELSE
	 n := loc

   ELSE IF h2!x<0 THEN {
      n := LookFor(x, NotAddr);
      TEST n>=0 THEN
	 TEST [copyLocked | h4!x~=0] &
	      [Locked(n, k.reg) |
	       RegInPendingList(PendingStores, n)~=Null] THEN
	    n := NextR()
	 ELSE
	    h1!x, h3!x := k.reg, n
      ELSE {
	 LET pp = SlocInList(pendingLoads, t, loc-1)
	 TEST pp~=Null THEN {
	    LET otherR = ps.reg!pp;
	    n := FindRegisterBetween(r.0, r.14, FALSE);
	    TEST n=Null THEN {
	       n := FindRegisterBetween(otherR+1, r.14, TRUE);
	       IF n=Null THEN n := FindR() }
	    ELSE IF n<=otherR THEN {
	       LET r = FindRegisterBetween(otherR+1, r.14, FALSE);
	       IF r~=Null THEN n := r } }

	 ELSE TEST (VALOF {
	       pp := SlocInList(pendingLoads, t, loc+1);
	       RESULTIS pp })~=Null THEN {
	    LET otherR = ps.reg!pp;
	    n := FindRegisterBetween(r.0, r.14, FALSE);
	    TEST n=Null THEN {
	       n := FindRegisterBetween(r.0, otherR-1, TRUE);
	       IF n=Null THEN n := FindR() }
	    ELSE IF n>=otherR THEN {
	       LET r = FindRegisterBetween(r.0, otherR-1, FALSE);
	       IF r~=Null THEN n := r } }
	 ELSE
	    n := FindR();
	 FlushPendingUsesOfReg(n) } };
   MoveToRSomeTime(n, x);
   RESULTIS h3!x }

AND Using(r) = VALOF {
   FOR t = tempv TO arg1 BY SSSize DO
      IF (h1!t=k.reg | h1!t=k.shreg) & h3!t=r
	 THEN RESULTIS r;

   RESULTIS 0 }

AND NextR() = VALOF {
   LET r = FindR();
   FlushPendingUsesOfReg(r);
   RESULTIS r }

AND FindRegisterBetween(low, high, discard) = VALOF {
   STATIC { possibleR = 0; possibleR2 = 0 };
   LET IsItFree(r, low, high) = VALOF {
      LET x = RegEntry(k.reg, r);
      IF ~(low<=r<=high) THEN RESULTIS FALSE;
      IF Using(r)=0 THEN {
	 IF Locked(r, k.reg) THEN RESULTIS FALSE;
	 IF possibleR<0 THEN
	    TEST rsd.shiftstate!x~=0
	       THEN possibleR2 := r
	       ELSE possibleR := r;
	 IF (r=r.b | r=r.14) & linkageNotStored
	    THEN RESULTIS FALSE;
	 IF RegInPendingList(PendingStores, r)=Null &
	    RegInPendingList(PendingLoads, r)=Null &
	    rsd.type!x=0 & rsd.sl!x=0 THEN RESULTIS TRUE };
      RESULTIS FALSE };

   possibleR, possibleR2 := -1, -1;
   IF IsItFree(ArgumentRegister(1), low, high)
      THEN RESULTIS ArgumentRegister(1);
   IF IsItFree(ArgumentRegister(2), low, high)
      THEN RESULTIS ArgumentRegister(2);
   IF IsItFree(ArgumentRegister(3), low, high)
      THEN RESULTIS ArgumentRegister(3);
   IF IsItFree(ArgumentRegister(4), low, high)
      THEN RESULTIS ArgumentRegister(4);
   TEST ~reversedStack | linkageNotStored THEN {
      IF IsItFree(r.w1, low, high) THEN RESULTIS r.w1;
      IF IsItFree(r.b, low, high)  THEN RESULTIS r.b;
      IF UsesFrame & IsItFree(r.14, low, high) THEN RESULTIS r.14 }
   ELSE {
      IF UsesFrame & IsItFree(r.14, low, high) THEN RESULTIS r.14;
      IF IsItFree(r.b, low, high)  THEN RESULTIS r.b;
      IF IsItFree(r.w1, low, high) THEN RESULTIS r.w1 };

   IF discard THEN
      TEST possibleR>=0 THEN {
	 DiscardReg(possibleR, k.reg); RESULTIS possibleR }
      ELSE IF possibleR2>=0 THEN {
	 DiscardReg(possibleR2, k.reg); RESULTIS possibleR2 };

   RESULTIS Null }

AND FindR() = VALOF {
   LET r = FindRegisterBetween(r.0, r.14, TRUE);
   IF r~=Null THEN RESULTIS r;

   FOR t = tempv TO arg1 BY SSSize DO
      IF h1!t=k.reg & ~Locked(h3!t, k.reg) THEN {
	 r := h3!t; StoreT(t); DiscardReg(r, k.reg); RESULTIS r };

   BackTrace();
   PrintSimulatedStack();
   PrintRegList();
   CGError(FALSE, "No free register found in NextR");
   RESULTIS 0 }

AND Lose(r, type) BE {
   ssp := ssp-1;
   TEST arg2=tempv THEN {
      h1!arg2, h2!arg2, h4!arg2 := k.loc, -1, 0;
      h3!arg2, h5!arg2 := ssp-2, ssp-2 }
   ELSE
      arg1, arg2 := arg2, arg2-SSSize;

   h1!arg1, h2!arg1, h3!arg1, h4!arg1 := type, -1, r, 0;
   h5!arg1 := ssp-1;
   DiscardReg(r, type) }

AND LoseR(r, d) BE {
   Lose(r, k.reg);
   IF d~=Null THEN h1!arg1, h4!arg1 := k.shreg, d }

AND PrintSimulatedStack() BE
   FOR p = tempv TO arg1 BY SSSize DO {
      WriteF("%n: ", p);
      FOR i = 0 TO SSSize-1 DO WriteF(" %n", p!i);
      NewLine() }

AND SSEntry(n) = VALOF {
   LET base = h5!tempv;
   LET top = h5!arg1;
   RESULTIS base<=n<=top -> tempv+[SSSize*(n-base)],
			    Null }

AND InitStack(s) BE {
   arg2, arg1 := tempv, tempv+SSSize;
   ssp := s
   h1!arg2, h2!arg2, h4!arg2 := k.loc, -1, 0;
   h3!arg2, h5!arg2 := ssp-2, ssp-2;
   h1!arg1, h2!arg1, h4!arg1 := k.loc, -1, 0;
   h3!arg1, h5!arg1 := ssp-1, ssp-1 }

AND Load(a, b) BE {
   arg2 := arg1;
   arg1 := arg1+SSSize;
   h1!arg1, h2!arg1, h3!arg1 := a, -1, b;
   h4!arg1, h5!arg1 := 0, ssp;
   ssp := ssp+1 }

AND SwapSS(x, y) BE {
   LET a, b, c, d = h1!y, h2!y, h3!y, h4!y;
   h1!y, h2!y, h3!y, h4!y := h1!x, h2!x, h3!x, h4!x;
   h1!x, h2!x, h3!x, h4!x := a, b, c, d }

AND Stack(n) BE {
   DelLocsAbove(n+1, TRUE);

   IF n>=ssp+4 THEN {
      Store(0, ssp);
      InitStack(n);
      RETURN };

   WHILE n>ssp DO Load(k.loc, ssp);

l: IF n=ssp THEN RETURN;
   IF arg2~=tempv THEN {
      arg1 := arg2;
      arg2 := arg2-SSSize;
      ssp := ssp-1;
      GOTO l };

   IF n=ssp-1 THEN {
      FOR h = h1 TO h5 DO h!arg1 := h!arg2;
      ssp := n;
      h1!arg2, h2!arg2, h4!arg2 := k.loc, -1, 0;
      h3!arg2, h5!arg2 := ssp-2, ssp-2;
      RETURN };

   InitStack(n) }

AND Store(p, r) BE
   FOR t = tempv TO arg1 BY SSSize DO {
      LET s = h5!t;
      IF s>r THEN RETURN;
      IF s>=p THEN StoreT(t) }

AND StoreT(x) BE {
   LET h5x = h5!x;
   LET t, i, loc, o = h1!x, h2!x, h3!x, h4!x
   UNLESS t=k.loc & i<0 & o=0 & loc=h5x THEN {
      LET n = RegisterDedicatedToLoc(h5x);
      LET storeNeeded, inFR = TRUE, FALSE;
      LET wastos = ?;
      LET d = n;

      TEST t=k.freg & i<0 & o=0 THEN
	 inFR := TRUE
      ELSE TEST n=Null THEN
	 n := MoveToAnyCRSomeTimeForStoreTo(x, k.loc, h5x)
      ELSE {
	 MoveToRSomeTime(n, x);
	 storeNeeded := FALSE };

      TEST inFR THEN
	 TEST d~=Null THEN
	    MoveFRToR(loc, d, x)
	 ELSE {
	    LET b, n = r.p, h5x;
	    TEST usesFrame THEN
	       IF linkageNotStored THEN b := r.ts
	    ELSE
	       b, n := r.ts, n-saveSpaceSize;
	    n := (nextStackWord/BytesPerWord)*n;
	    wastos := DiscardAddress(k.loc, h5x);
	    TEST wastos | h5x=TOSOffset THEN {
	       FOR n = h5x-1 TO 4 BY -1 DO {
		  LET p = SlocInList(PendingStores, k.loc, n);
		  IF p~=Null THEN {
		     FlushPendingStoresUpTo(p);
		     BREAK } };
	       IF h5x=TOSOffset THEN TOSOffset := TOSOffset+1
	       StoreFR(loc, r.ts, f.post/*f.wb implied*/, 1) }
	    ELSE
	       StoreFR(loc, b, f.pre, n);
	 wastos := StoreR(k.freg, loc, k.loc, h5x) }
      ELSE {
	 wastos := StoreR(k.reg, n, k.loc, h5x);
	 IF StoreNeeded THEN
	    TEST h5x=TOSOffset THEN {
	       AddToPendingStores(n, k.loc, h5x, TRUE, 0);
	       TOSOffset := TOSOffset+1 }
	    ELSE
	       AddToPendingStores(n, k.loc, h5x, wastos, 0) };
      h1!x, h2!x, h3!x, h4!x := k.loc, -1, h5x, 0 } }

AND IsSimpleStoreLoc(x) = VALOF {
   LET type = h1!x;
   RESULTIS h2!x<0 &
	    (type=k.loc | type=k.lab | type=k.static | type=k.glob) }

AND IsInTheStack(x) = h1!x=k.loc & h2!x<0 & h4!x=0

AND Class(x, FindCopy) = VALOF
   TEST h2!x>=0 THEN
      RESULTIS atype
   ELSE SWITCHON h1!x INTO
   {  CASE k.number: RESULTIS ktype
      CASE k.loc:
      CASE k.glob:
      CASE k.static:
      CASE k.lab:    IF h4!x=0 THEN
			IF ~FindCopy | LookFor(x, NotAddr)<0 THEN
			   RESULTIS atype
      DEFAULT:	     RESULTIS rtype
      CASE k.shreg:  RESULTIS shiftedrtype
      CASE k.reg:    RESULTIS locked(h3!x, k.reg) -> lockedrtype,
					      rtype }

AND IsConst(x) = VALOF
   TEST h1!x=k.number & h2!x<0 THEN {
      h3!x := h3!x+h4!x; h4!x := 0;
      RESULTIS TRUE }
   ELSE
      RESULTIS FALSE
00000000  53 45 43 54 49 4f 4e 20  22 43 47 48 22 0a 0a 47  |SECTION "CGH"..G|
00000010  45 54 20 22 62 2e 43 47  68 65 61 64 65 72 22 0a  |ET "b.CGheader".|
00000020  47 45 54 20 22 62 2e 46  50 4f 70 73 22 09 2f 2f  |GET "b.FPOps".//|
00000030  20 66 6f 72 20 74 68 65  20 72 65 67 69 73 74 65  | for the registe|
00000040  72 20 6e 61 6d 65 73 0a  0a 53 54 41 54 49 43 20  |r names..STATIC |
00000050  7b 0a 2f 2a 20 56 65 72  73 69 6f 6e 20 6f 66 20  |{./* Version of |
00000060  31 38 20 4d 61 72 20 38  36 20 31 32 3a 35 38 3a  |18 Mar 86 12:58:|
00000070  32 35 0a 20 2a 2f 0a 20  20 20 64 75 6d 6d 79 20  |25. */.   dummy |
00000080  3d 20 56 65 72 73 69 6f  6e 4d 61 72 6b 3b 0a 20  |= VersionMark;. |
00000090  20 20 76 65 72 73 69 6f  6e 20 3d 20 31 2a 32 35  |  version = 1*25|
000000a0  36 2b 31 34 20 7d 0a 0a  2f 2a 20 54 68 65 20 66  |6+14 }../* The f|
000000b0  6f 6c 6c 6f 77 69 6e 67  20 70 72 6f 63 65 64 75  |ollowing procedu|
000000c0  72 65 73 20 6d 61 69 6e  74 61 69 6e 20 61 20 72  |res maintain a r|
000000d0  65 67 69 73 74 65 72 20  6d 65 6d 6f 72 79 2e 0a  |egister memory..|
000000e0  20 20 20 54 68 69 73 20  72 65 6d 65 6d 62 65 72  |   This remember|
000000f0  73 20 74 68 65 20 70 6c  61 63 65 20 61 20 72 65  |s the place a re|
00000100  67 69 73 74 65 72 20 77  61 73 20 6c 6f 61 64 65  |gister was loade|
00000110  64 20 66 72 6f 6d 2c 0a  20 20 20 61 6e 64 20 61  |d from,.   and a|
00000120  6e 79 77 68 65 72 65 20  69 74 20 68 61 73 20 62  |nywhere it has b|
00000130  65 65 6e 20 73 74 6f 72  65 64 2c 20 61 6e 64 20  |een stored, and |
00000140  61 6c 73 6f 20 77 68 65  74 68 65 72 0a 20 20 20  |also whether.   |
00000150  74 68 65 20 63 6f 6e 74  65 6e 74 73 20 68 61 76  |the contents hav|
00000160  65 20 62 65 65 6e 20 6d  6f 64 69 66 69 65 64 20  |e been modified |
00000170  66 6f 72 20 75 73 65 20  61 73 20 61 6e 20 61 64  |for use as an ad|
00000180  64 72 65 73 73 2e 0a 2a  2f 0a 0a 2f 2a 20 31 2e  |dress..*/../* 1.|
00000190  38 09 31 37 20 46 65 62  20 38 36 20 31 37 3a 32  |8.17 Feb 86 17:2|
000001a0  30 3a 30 38 0a 20 20 20  20 20 49 6e 63 6f 72 70  |0:08.     Incorp|
000001b0  6f 72 61 74 65 73 20 66  6c 6f 61 74 69 6e 67 20  |orates floating |
000001c0  70 6f 69 6e 74 0a 20 20  20 31 2e 39 09 30 37 20  |point.   1.9.07 |
000001d0  4d 61 72 20 38 36 20 32  31 3a 33 38 3a 35 31 0a  |Mar 86 21:38:51.|
000001e0  20 20 20 20 20 6b 2e 73  74 61 74 69 63 0a 20 20  |     k.static.  |
000001f0  20 31 2e 31 30 20 20 31  38 20 4d 61 72 20 38 36  | 1.10  18 Mar 86|
00000200  20 31 32 3a 35 38 3a 33  36 0a 20 20 20 20 20 70  | 12:58:36.     p|
00000210  6f 73 74 2d 69 6e 63 72  65 6d 65 6e 74 20 66 70  |ost-increment fp|
00000220  20 69 6e 73 74 72 75 63  74 69 6f 6e 73 20 67 65  | instructions ge|
00000230  6e 65 72 61 74 65 64 20  62 79 20 53 74 6f 72 65  |nerated by Store|
00000240  54 20 6d 75 73 74 0a 20  20 20 20 20 6e 6f 74 20  |T must.     not |
00000250  68 61 76 65 20 74 68 65  20 20 77 62 20 20 62 69  |have the  wb  bi|
00000260  74 20 73 65 74 2e 0a 20  20 20 20 20 43 6f 64 65  |t set..     Code|
00000270  20 69 6d 70 72 6f 76 65  6d 65 6e 74 20 66 6f 72  | improvement for|
00000280  20 21 40 74 68 69 6e 67  0a 20 20 20 31 2e 31 31  | !@thing.   1.11|
00000290  20 20 32 31 20 4d 61 72  20 38 36 20 31 31 3a 31  |  21 Mar 86 11:1|
000002a0  39 3a 31 33 0a 20 20 20  20 20 44 65 66 65 72 72  |9:13.     Deferr|
000002b0  65 64 20 73 68 69 66 74  73 0a 20 20 20 31 2e 31  |ed shifts.   1.1|
000002c0  32 20 20 32 30 20 4d 61  79 20 38 37 20 31 31 3a  |2  20 May 87 11:|
000002d0  30 39 3a 33 36 0a 20 20  20 20 20 42 75 67 20 66  |09:36.     Bug f|
000002e0  69 78 3a 20 73 74 6f 72  65 20 74 6f 20 6c 6f 63  |ix: store to loc|
000002f0  61 74 69 6f 6e 20 66 6f  72 63 65 73 20 6c 6f 61  |ation forces loa|
00000300  64 73 20 66 72 6f 6d 20  69 74 20 74 6f 20 62 65  |ds from it to be|
00000310  20 64 6f 6e 65 2e 0a 20  20 20 31 2e 31 33 20 20  | done..   1.13  |
00000320  33 30 20 4a 75 6e 20 38  37 20 31 35 3a 35 32 3a  |30 Jun 87 15:52:|
00000330  31 36 0a 20 20 20 20 20  42 75 67 20 66 69 78 3a  |16.     Bug fix:|
00000340  20 4c 6f 61 64 41 64 64  72 65 73 73 20 74 61 6b  | LoadAddress tak|
00000350  65 73 20 61 63 63 6f 75  6e 74 20 6f 66 20 77 68  |es account of wh|
00000360  65 74 68 65 72 20 62 61  73 65 20 74 6f 20 62 65  |ether base to be|
00000370  20 6c 6f 61 64 65 64 20  68 61 73 20 61 6e 0a 20  | loaded has an. |
00000380  20 20 20 20 61 64 64 69  74 69 76 65 20 63 6f 6e  |    additive con|
00000390  73 74 61 6e 74 0a 2a 2f  0a 0a 4d 41 4e 49 46 45  |stant.*/..MANIFE|
000003a0  53 54 20 7b 0a 2f 2f 20  72 65 67 69 73 74 65 72  |ST {.// register|
000003b0  20 73 74 61 74 65 20 64  65 73 63 72 69 70 74 69  | state descripti|
000003c0  6f 6e 0a 20 20 20 72 73  64 2e 74 79 70 65 3d 68  |on.   rsd.type=h|
000003d0  31 3b 20 72 73 64 2e 73  68 69 66 74 73 74 61 74  |1; rsd.shiftstat|
000003e0  65 3d 68 32 3b 20 72 73  64 2e 6c 6f 63 3d 68 33  |e=h2; rsd.loc=h3|
000003f0  3b 0a 20 20 20 72 73 64  2e 73 6c 3d 68 34 3b 20  |;.   rsd.sl=h4; |
00000400  72 73 64 2e 6c 6f 63 6b  3d 68 35 3b 0a 0a 2f 2f  |rsd.lock=h5;..//|
00000410  20 64 65 73 63 72 69 70  74 69 6f 6e 20 6f 66 20  | description of |
00000420  61 20 73 61 76 65 64 20  72 65 67 69 73 74 65 72  |a saved register|
00000430  20 73 74 61 74 65 0a 20  20 20 73 72 73 2e 73 69  | state.   srs.si|
00000440  7a 65 20 3d 20 34 3b 0a  20 20 20 73 72 73 2e 68  |ze = 4;.   srs.h|
00000450  65 61 64 65 72 20 3d 20  34 3b 0a 20 20 20 73 72  |eader = 4;.   sr|
00000460  73 2e 6c 61 62 20 3d 20  31 3b 20 73 72 73 2e 74  |s.lab = 1; srs.t|
00000470  6f 73 20 3d 20 32 3b 0a  20 20 20 73 72 73 2e 70  |os = 2;.   srs.p|
00000480  73 20 3d 20 33 3b 0a 20  20 20 73 72 73 2e 62 6c  |s = 3;.   srs.bl|
00000490  6f 63 6b 73 69 7a 65 20  3d 20 73 72 73 2e 73 69  |ocksize = srs.si|
000004a0  7a 65 2a 28 31 35 2b 38  29 2b 73 72 73 2e 68 65  |ze*(15+8)+srs.he|
000004b0  61 64 65 72 3b 0a 0a 20  20 20 73 72 73 64 2e 74  |ader;..   srsd.t|
000004c0  79 70 65 3d 72 73 64 2e  74 79 70 65 3b 20 73 72  |ype=rsd.type; sr|
000004d0  73 64 2e 73 68 69 66 74  73 74 61 74 65 3d 72 73  |sd.shiftstate=rs|
000004e0  64 2e 73 68 69 66 74 73  74 61 74 65 3b 0a 20 20  |d.shiftstate;.  |
000004f0  20 73 72 73 64 2e 6c 6f  63 3d 72 73 64 2e 6c 6f  | srsd.loc=rsd.lo|
00000500  63 3b 20 73 72 73 64 2e  73 6c 3d 72 73 64 2e 73  |c; srsd.sl=rsd.s|
00000510  6c 20 7d 3b 0a 0a 53 54  41 54 49 43 20 7b 0a 20  |l };..STATIC {. |
00000520  20 20 72 65 67 4c 69 73  74 20 3d 20 30 3b 20 66  |  regList = 0; f|
00000530  72 65 67 4c 69 73 74 20  3d 20 30 20 7d 3b 0a 0a  |regList = 0 };..|
00000540  4c 45 54 20 49 6e 69 74  69 61 6c 69 73 65 52 65  |LET InitialiseRe|
00000550  67 69 73 74 65 72 53 6c  61 76 65 28 29 20 42 45  |gisterSlave() BE|
00000560  20 7b 0a 20 20 20 72 65  67 4c 69 73 74 20 3a 3d  | {.   regList :=|
00000570  20 47 65 74 56 65 63 74  6f 72 28 52 65 67 53 69  | GetVector(RegSi|
00000580  7a 65 2a 31 36 29 3b 0a  20 20 20 46 4f 52 20 69  |ze*16);.   FOR i|
00000590  20 3d 20 30 20 54 4f 20  52 65 67 53 69 7a 65 2a  | = 0 TO RegSize*|
000005a0  31 36 2d 31 20 44 4f 20  72 65 67 4c 69 73 74 21  |16-1 DO regList!|
000005b0  69 20 3a 3d 20 30 3b 0a  20 20 20 66 72 65 67 4c  |i := 0;.   fregL|
000005c0  69 73 74 20 3a 3d 20 47  65 74 56 65 63 74 6f 72  |ist := GetVector|
000005d0  28 52 65 67 53 69 7a 65  2a 38 29 3b 0a 20 20 20  |(RegSize*8);.   |
000005e0  46 4f 52 20 69 20 3d 20  30 20 54 4f 20 52 65 67  |FOR i = 0 TO Reg|
000005f0  53 69 7a 65 2a 38 2d 31  20 44 4f 20 66 72 65 67  |Size*8-1 DO freg|
00000600  4c 69 73 74 21 69 20 3a  3d 20 30 20 7d 0a 0a 4c  |List!i := 0 }..L|
00000610  45 54 20 41 72 67 75 6d  65 6e 74 52 65 67 69 73  |ET ArgumentRegis|
00000620  74 65 72 28 72 29 20 3d  0a 20 20 20 72 65 76 65  |ter(r) =.   reve|
00000630  72 73 65 64 53 74 61 63  6b 20 2d 3e 20 72 2e 61  |rsedStack -> r.a|
00000640  34 2d 72 2b 31 2c 0a 09  09 20 20 20 20 72 0a 0a  |4-r+1,...    r..|
00000650  41 4e 44 20 52 65 67 45  6e 74 72 79 28 74 79 70  |AND RegEntry(typ|
00000660  65 2c 20 72 29 20 3d 0a  20 20 20 74 79 70 65 3d  |e, r) =.   type=|
00000670  6b 2e 72 65 67 20 2d 3e  20 72 65 67 4c 69 73 74  |k.reg -> regList|
00000680  2b 52 65 67 53 69 7a 65  2a 72 2c 0a 20 20 20 74  |+RegSize*r,.   t|
00000690  79 70 65 3d 6b 2e 66 72  65 67 20 2d 3e 20 66 72  |ype=k.freg -> fr|
000006a0  65 67 4c 69 73 74 2b 52  65 67 53 69 7a 65 2a 72  |egList+RegSize*r|
000006b0  2c 0a 09 09 20 20 43 47  45 72 72 6f 72 28 54 52  |,...  CGError(TR|
000006c0  55 45 2c 20 22 62 61 64  20 74 79 70 65 20 69 6e  |UE, "bad type in|
000006d0  20 52 65 67 45 6e 74 72  79 22 29 0a 0a 0a 41 4e  | RegEntry")...AN|
000006e0  44 20 48 61 73 53 6c 61  76 65 64 4c 6f 63 28 72  |D HasSlavedLoc(r|
000006f0  2c 20 74 79 70 65 29 20  3d 20 56 41 4c 4f 46 20  |, type) = VALOF |
00000700  7b 0a 20 20 20 4c 45 54  20 78 20 3d 20 52 65 67  |{.   LET x = Reg|
00000710  45 6e 74 72 79 28 74 79  70 65 2c 20 72 29 3b 0a  |Entry(type, r);.|
00000720  20 20 20 52 45 53 55 4c  54 49 53 20 72 73 64 2e  |   RESULTIS rsd.|
00000730  74 79 70 65 21 78 7e 3d  30 20 2d 3e 20 54 52 55  |type!x~=0 -> TRU|
00000740  45 2c 0a 09 20 20 20 20  72 73 64 2e 73 6c 21 78  |E,..    rsd.sl!x|
00000750  7e 3d 30 20 2d 3e 20 54  52 55 45 2c 0a 09 09 09  |~=0 -> TRUE,....|
00000760  20 20 20 46 41 4c 53 45  20 7d 0a 0a 41 4e 44 20  |   FALSE }..AND |
00000770  44 69 73 63 61 72 64 52  65 67 73 28 29 20 42 45  |DiscardRegs() BE|
00000780  20 7b 0a 20 20 20 46 4f  52 20 69 20 3d 20 72 2e  | {.   FOR i = r.|
00000790  30 20 54 4f 20 72 2e 31  34 20 44 4f 20 44 69 73  |0 TO r.14 DO Dis|
000007a0  63 61 72 64 52 65 67 28  69 2c 20 6b 2e 72 65 67  |cardReg(i, k.reg|
000007b0  29 3b 0a 20 20 20 4c 6f  63 6b 28 72 2e 6e 69 6c  |);.   Lock(r.nil|
000007c0  2c 20 6b 2e 72 65 67 29  3b 0a 20 20 20 46 4f 52  |, k.reg);.   FOR|
000007d0  20 69 20 3d 20 66 72 2e  30 20 54 4f 20 66 72 2e  | i = fr.0 TO fr.|
000007e0  37 20 44 4f 20 44 69 73  63 61 72 64 52 65 67 28  |7 DO DiscardReg(|
000007f0  69 2c 20 6b 2e 66 72 65  67 29 20 7d 0a 0a 41 4e  |i, k.freg) }..AN|
00000800  44 20 44 69 73 63 61 72  64 52 65 67 28 72 2c 20  |D DiscardReg(r, |
00000810  74 79 70 65 29 20 42 45  20 7b 0a 20 20 20 4c 45  |type) BE {.   LE|
00000820  54 20 78 20 3d 20 52 65  67 45 6e 74 72 79 28 74  |T x = RegEntry(t|
00000830  79 70 65 2c 20 72 29 3b  0a 20 20 20 72 73 64 2e  |ype, r);.   rsd.|
00000840  74 79 70 65 21 78 2c 20  72 73 64 2e 73 68 69 66  |type!x, rsd.shif|
00000850  74 73 74 61 74 65 21 78  20 3a 3d 20 30 2c 20 30  |tstate!x := 0, 0|
00000860  3b 0a 20 20 20 49 46 20  28 72 7e 3d 72 2e 6e 69  |;.   IF (r~=r.ni|
00000870  6c 20 7c 20 74 79 70 65  7e 3d 6b 2e 72 65 67 29  |l | type~=k.reg)|
00000880  20 54 48 45 4e 20 72 73  64 2e 6c 6f 63 6b 21 78  | THEN rsd.lock!x|
00000890  20 3a 3d 20 30 3b 0a 20  20 20 44 69 73 63 61 72  | := 0;.   Discar|
000008a0  64 53 4c 28 40 72 73 64  2e 73 6c 21 78 29 3b 0a  |dSL(@rsd.sl!x);.|
000008b0  20 20 20 49 46 20 74 79  70 65 3d 6b 2e 72 65 67  |   IF type=k.reg|
000008c0  20 54 48 45 4e 20 7b 0a  20 20 20 20 20 20 46 6c  | THEN {.      Fl|
000008d0  75 73 68 50 65 6e 64 69  6e 67 55 73 65 73 4f 66  |ushPendingUsesOf|
000008e0  52 65 67 28 72 29 3b 0a  20 20 20 20 20 20 78 20  |Reg(r);.      x |
000008f0  3a 3d 20 4c 6f 63 48 65  6c 64 49 6e 52 65 67 69  |:= LocHeldInRegi|
00000900  73 74 65 72 28 72 2c 20  74 79 70 65 29 3b 0a 20  |ster(r, type);. |
00000910  20 20 20 20 20 49 46 20  78 7e 3d 4e 75 6c 6c 20  |     IF x~=Null |
00000920  54 48 45 4e 20 7b 0a 09  20 4d 6f 76 65 53 74 6f  |THEN {.. MoveSto|
00000930  52 28 6b 2e 72 65 67 2c  20 72 2c 20 6b 2e 6c 6f  |R(k.reg, r, k.lo|
00000940  63 2c 20 78 29 3b 0a 09  20 4c 6f 63 6b 28 72 2c  |c, x);.. Lock(r,|
00000950  20 74 79 70 65 29 20 7d  20 7d 20 7d 0a 0a 41 4e  | type) } } }..AN|
00000960  44 20 44 69 73 63 61 72  64 4e 6f 6e 4c 6f 63 61  |D DiscardNonLoca|
00000970  6c 52 65 67 73 28 29 20  42 45 0a 20 20 20 44 69  |lRegs() BE.   Di|
00000980  73 63 61 72 64 52 65 67  73 49 66 28 49 73 4e 6f  |scardRegsIf(IsNo|
00000990  6e 4c 6f 63 61 6c 29 0a  0a 41 4e 44 20 44 69 73  |nLocal)..AND Dis|
000009a0  63 61 72 64 4e 6f 6e 43  6f 6e 73 74 52 65 67 73  |cardNonConstRegs|
000009b0  28 29 20 42 45 0a 20 20  20 44 69 73 63 61 72 64  |() BE.   Discard|
000009c0  52 65 67 73 49 66 28 49  73 4e 6f 6e 43 6f 6e 73  |RegsIf(IsNonCons|
000009d0  74 29 0a 0a 41 4e 44 20  49 73 4e 6f 6e 4c 6f 63  |t)..AND IsNonLoc|
000009e0  61 6c 28 74 29 20 3d 20  74 7e 3d 6b 2e 6e 75 6d  |al(t) = t~=k.num|
000009f0  62 65 72 20 26 20 74 7e  3d 6b 2e 6c 6f 63 0a 0a  |ber & t~=k.loc..|
00000a00  41 4e 44 20 49 73 4e 6f  6e 43 6f 6e 73 74 28 74  |AND IsNonConst(t|
00000a10  29 20 3d 20 74 7e 3d 6b  2e 6e 75 6d 62 65 72 0a  |) = t~=k.number.|
00000a20  0a 41 4e 44 20 44 69 73  63 61 72 64 52 65 67 73  |.AND DiscardRegs|
00000a30  49 66 28 70 72 65 64 29  20 42 45 20 7b 0a 20 20  |If(pred) BE {.  |
00000a40  20 46 4f 52 20 72 20 3d  20 72 2e 30 20 54 4f 20  | FOR r = r.0 TO |
00000a50  72 2e 31 34 20 44 4f 20  44 69 73 63 61 72 64 49  |r.14 DO DiscardI|
00000a60  66 28 70 72 65 64 2c 20  72 2c 20 6b 2e 72 65 67  |f(pred, r, k.reg|
00000a70  29 0a 20 20 20 46 4f 52  20 72 20 3d 20 66 72 2e  |).   FOR r = fr.|
00000a80  30 20 54 4f 20 66 72 2e  37 20 44 4f 20 44 69 73  |0 TO fr.7 DO Dis|
00000a90  63 61 72 64 49 66 28 70  72 65 64 2c 20 72 2c 20  |cardIf(pred, r, |
00000aa0  6b 2e 66 72 65 67 29 20  7d 0a 0a 41 4e 44 20 44  |k.freg) }..AND D|
00000ab0  69 73 63 61 72 64 49 66  28 70 72 65 64 2c 20 72  |iscardIf(pred, r|
00000ac0  2c 20 74 79 70 65 29 20  42 45 20 7b 0a 20 20 20  |, type) BE {.   |
00000ad0  4c 45 54 20 70 20 3d 20  52 65 67 45 6e 74 72 79  |LET p = RegEntry|
00000ae0  28 74 79 70 65 2c 20 72  29 3b 0a 20 20 20 4c 45  |(type, r);.   LE|
00000af0  54 20 71 20 3d 20 40 72  73 64 2e 73 6c 21 70 3b  |T q = @rsd.sl!p;|
00000b00  0a 20 20 20 4c 45 54 20  78 20 3d 20 21 71 3b 0a  |.   LET x = !q;.|
00000b10  20 20 20 49 46 20 70 72  65 64 28 72 73 64 2e 74  |   IF pred(rsd.t|
00000b20  79 70 65 21 70 29 20 54  48 45 4e 20 72 73 64 2e  |ype!p) THEN rsd.|
00000b30  74 79 70 65 21 70 2c 20  72 73 64 2e 6c 6f 63 21  |type!p, rsd.loc!|
00000b40  70 20 3a 3d 20 30 2c 20  30 3b 0a 20 20 20 57 48  |p := 0, 0;.   WH|
00000b50  49 4c 45 20 78 7e 3d 30  20 44 4f 20 7b 0a 20 20  |ILE x~=0 DO {.  |
00000b60  20 20 20 20 54 45 53 54  20 70 72 65 64 28 73 6c  |    TEST pred(sl|
00000b70  2e 74 79 70 65 21 78 29  20 54 48 45 4e 0a 09 20  |.type!x) THEN.. |
00000b80  21 71 20 3a 3d 20 46 72  65 65 42 6c 6b 28 78 2c  |!q := FreeBlk(x,|
00000b90  20 73 6c 2e 73 69 7a 65  29 0a 20 20 20 20 20 20  | sl.size).      |
00000ba0  45 4c 53 45 0a 09 20 71  20 3a 3d 20 78 3b 0a 20  |ELSE.. q := x;. |
00000bb0  20 20 20 20 20 78 20 3a  3d 20 21 71 20 7d 3b 0a  |     x := !q };.|
00000bc0  2f 2f 20 20 20 49 46 20  74 79 70 65 3d 6b 2e 72  |//   IF type=k.r|
00000bd0  65 67 20 54 48 45 4e 20  46 6c 75 73 68 50 65 6e  |eg THEN FlushPen|
00000be0  64 69 6e 67 55 73 65 73  4f 66 52 65 67 28 72 29  |dingUsesOfReg(r)|
00000bf0  3b 0a 20 20 20 49 46 20  72 73 64 2e 74 79 70 65  |;.   IF rsd.type|
00000c00  21 70 3d 30 20 26 20 72  73 64 2e 73 6c 21 70 3d  |!p=0 & rsd.sl!p=|
00000c10  30 20 54 48 45 4e 20 72  73 64 2e 73 68 69 66 74  |0 THEN rsd.shift|
00000c20  73 74 61 74 65 21 70 20  3a 3d 20 30 3b 0a 20 20  |state!p := 0;.  |
00000c30  20 49 46 20 74 79 70 65  7e 3d 6b 2e 72 65 67 20  | IF type~=k.reg |
00000c40  7c 20 28 72 7e 3d 72 2e  6e 69 6c 20 26 20 4c 6f  || (r~=r.nil & Lo|
00000c50  63 48 65 6c 64 49 6e 52  65 67 69 73 74 65 72 28  |cHeldInRegister(|
00000c60  72 29 3d 4e 75 6c 6c 29  0a 20 20 20 20 20 20 54  |r)=Null).      T|
00000c70  48 45 4e 20 72 73 64 2e  6c 6f 63 6b 21 70 20 3a  |HEN rsd.lock!p :|
00000c80  3d 20 30 20 7d 0a 0a 41  4e 44 20 4c 6f 61 64 41  |= 0 }..AND LoadA|
00000c90  64 64 72 65 73 73 28 78  29 20 3d 20 56 41 4c 4f  |ddress(x) = VALO|
00000ca0  46 20 7b 0a 20 20 20 4c  45 54 20 62 2c 20 72 2c  |F {.   LET b, r,|
00000cb0  20 79 20 3d 20 4c 6f 6f  6b 46 6f 72 28 78 2c 20  | y = LookFor(x, |
00000cc0  53 68 69 66 74 65 64 55  70 29 2c 20 2d 31 2c 20  |ShiftedUp), -1, |
00000cd0  30 3b 0a 20 20 20 54 45  53 54 20 62 3e 3d 30 20  |0;.   TEST b>=0 |
00000ce0  54 48 45 4e 20 49 46 20  68 34 21 78 7e 3d 30 20  |THEN IF h4!x~=0 |
00000cf0  54 48 45 4e 20 7b 0a 20  20 20 20 20 20 72 20 3a  |THEN {.      r :|
00000d00  3d 20 46 69 6e 64 52 65  67 69 73 74 65 72 42 65  |= FindRegisterBe|
00000d10  74 77 65 65 6e 28 72 2e  30 2c 20 72 2e 31 34 2c  |tween(r.0, r.14,|
00000d20  20 46 41 4c 53 45 29 3b  0a 20 20 20 20 20 20 49  | FALSE);.      I|
00000d30  46 20 72 3d 4e 75 6c 6c  20 54 48 45 4e 20 72 20  |F r=Null THEN r |
00000d40  3a 3d 20 62 3b 0a 20 20  20 20 20 20 53 65 74 52  |:= b;.      SetR|
00000d50  54 6f 52 50 6c 75 73 4b  28 72 2c 20 62 2c 20 68  |ToRPlusK(r, b, h|
00000d60  34 21 78 2a 34 29 3b 0a  20 20 20 20 20 20 79 20  |4!x*4);.      y |
00000d70  3a 3d 20 52 65 67 45 6e  74 72 79 28 6b 2e 72 65  |:= RegEntry(k.re|
00000d80  67 2c 20 72 29 3b 0a 20  20 20 20 20 20 72 73 64  |g, r);.      rsd|
00000d90  2e 73 68 69 66 74 73 74  61 74 65 21 79 20 3a 3d  |.shiftstate!y :=|
00000da0  20 32 3b 0a 20 20 20 20  20 20 52 45 53 55 4c 54  | 2;.      RESULT|
00000db0  49 53 20 72 20 7d 0a 20  20 20 45 4c 53 45 20 7b  |IS r }.   ELSE {|
00000dc0  0a 20 20 20 20 20 20 62  20 3a 3d 20 49 73 49 6e  |.      b := IsIn|
00000dd0  41 52 65 67 69 73 74 65  72 28 78 29 3b 0a 20 20  |ARegister(x);.  |
00000de0  20 20 20 20 54 45 53 54  20 62 3e 3d 30 20 54 48  |    TEST b>=0 TH|
00000df0  45 4e 0a 09 20 54 45 53  54 20 4c 6f 63 6b 65 64  |EN.. TEST Locked|
00000e00  28 62 2c 20 6b 2e 72 65  67 29 20 54 48 45 4e 20  |(b, k.reg) THEN |
00000e10  7b 0a 09 20 20 20 20 72  20 3a 3d 20 4e 65 78 74  |{..    r := Next|
00000e20  52 28 29 3b 0a 09 20 20  20 20 4d 6f 76 65 52 74  |R();..    MoveRt|
00000e30  6f 52 28 6b 2e 72 65 67  2c 20 62 2c 20 6b 2e 72  |oR(k.reg, b, k.r|
00000e40  65 67 2c 20 72 29 20 7d  0a 0a 09 20 45 4c 53 45  |eg, r) }... ELSE|
00000e50  20 7b 0a 09 20 20 20 20  4c 45 54 20 6e 20 3d 20  | {..    LET n = |
00000e60  46 69 6e 64 52 65 67 69  73 74 65 72 42 65 74 77  |FindRegisterBetw|
00000e70  65 65 6e 28 72 2e 30 2c  20 72 2e 31 34 2c 20 46  |een(r.0, r.14, F|
00000e80  41 4c 53 45 29 3b 0a 09  20 20 20 20 49 46 20 6e  |ALSE);..    IF n|
00000e90  7e 3d 4e 75 6c 6c 20 54  48 45 4e 20 7b 0a 09 20  |~=Null THEN {.. |
00000ea0  20 20 20 20 20 20 72 20  3a 3d 20 6e 3b 0a 09 20  |      r := n;.. |
00000eb0  20 20 20 20 20 20 4d 6f  76 65 52 74 6f 52 28 6b  |      MoveRtoR(k|
00000ec0  2e 72 65 67 2c 20 62 2c  20 6b 2e 72 65 67 2c 20  |.reg, b, k.reg, |
00000ed0  72 29 20 7d 20 7d 0a 20  20 20 20 20 20 45 4c 53  |r) } }.      ELS|
00000ee0  45 0a 09 20 62 20 3a 3d  20 4d 6f 76 65 54 6f 41  |E.. b := MoveToA|
00000ef0  6e 79 52 28 78 29 20 7d  3b 0a 0a 20 20 20 49 46  |nyR(x) };..   IF|
00000f00  20 72 3c 30 20 54 48 45  4e 20 72 20 3a 3d 20 62  | r<0 THEN r := b|
00000f10  3b 0a 20 20 20 79 20 3a  3d 20 52 65 67 45 6e 74  |;.   y := RegEnt|
00000f20  72 79 28 6b 2e 72 65 67  2c 20 72 29 3b 0a 0a 20  |ry(k.reg, r);.. |
00000f30  20 20 49 46 20 72 73 64  2e 73 68 69 66 74 73 74  |  IF rsd.shiftst|
00000f40  61 74 65 21 79 3d 30 20  54 48 45 4e 20 7b 0a 20  |ate!y=0 THEN {. |
00000f50  20 20 20 20 20 46 6c 75  73 68 50 65 6e 64 69 6e  |     FlushPendin|
00000f60  67 55 73 65 73 4f 66 52  65 67 28 72 29 3b 0a 20  |gUsesOfReg(r);. |
00000f70  20 20 20 20 20 46 6c 75  73 68 50 65 6e 64 69 6e  |     FlushPendin|
00000f80  67 4c 6f 61 64 73 46 6f  72 52 65 67 28 62 29 3b  |gLoadsForReg(b);|
00000f90  0a 20 20 20 20 20 20 53  68 69 66 74 52 65 67 69  |.      ShiftRegi|
00000fa0  73 74 65 72 44 53 28 72  2c 20 62 2c 20 73 68 2e  |sterDS(r, b, sh.|
00000fb0  61 73 6c 2c 20 32 29 3b  0a 20 20 20 20 20 20 72  |asl, 2);.      r|
00000fc0  73 64 2e 73 68 69 66 74  73 74 61 74 65 21 79 20  |sd.shiftstate!y |
00000fd0  3a 3d 20 32 20 7d 3b 0a  0a 20 20 20 52 45 53 55  |:= 2 };..   RESU|
00000fe0  4c 54 49 53 20 72 20 7d  0a 0a 41 4e 44 20 4c 6f  |LTIS r }..AND Lo|
00000ff0  61 64 43 61 72 41 64 64  28 78 29 20 3d 20 56 41  |adCarAdd(x) = VA|
00001000  4c 4f 46 20 7b 0a 20 20  20 4c 45 54 20 62 2c 20  |LOF {.   LET b, |
00001010  72 2c 20 79 20 3d 20 4c  6f 6f 6b 46 6f 72 28 78  |r, y = LookFor(x|
00001020  2c 20 49 73 61 43 61 72  29 2c 20 2d 31 2c 20 30  |, IsaCar), -1, 0|
00001030  3b 0a 20 20 20 49 46 20  62 3c 30 20 54 48 45 4e  |;.   IF b<0 THEN|
00001040  20 7b 0a 20 20 20 20 20  20 62 20 3a 3d 20 49 73  | {.      b := Is|
00001050  49 6e 41 52 65 67 69 73  74 65 72 28 78 29 3b 0a  |InARegister(x);.|
00001060  20 20 20 20 20 20 54 45  53 54 20 62 3e 3d 30 20  |      TEST b>=0 |
00001070  54 48 45 4e 0a 09 20 54  45 53 54 20 4c 6f 63 6b  |THEN.. TEST Lock|
00001080  65 64 28 62 2c 20 6b 2e  72 65 67 29 20 54 48 45  |ed(b, k.reg) THE|
00001090  4e 20 7b 0a 09 20 20 20  20 72 20 3a 3d 20 4e 65  |N {..    r := Ne|
000010a0  78 74 52 28 29 3b 0a 09  20 20 20 20 4d 6f 76 65  |xtR();..    Move|
000010b0  52 74 6f 52 28 6b 2e 72  65 67 2c 20 62 2c 20 6b  |RtoR(k.reg, b, k|
000010c0  2e 72 65 67 2c 20 72 29  20 7d 0a 09 20 45 4c 53  |.reg, r) }.. ELS|
000010d0  45 20 7b 0a 09 20 20 20  20 4c 45 54 20 6e 20 3d  |E {..    LET n =|
000010e0  20 46 69 6e 64 52 65 67  69 73 74 65 72 42 65 74  | FindRegisterBet|
000010f0  77 65 65 6e 28 72 2e 30  2c 20 72 2e 31 34 2c 20  |ween(r.0, r.14, |
00001100  46 41 4c 53 45 29 3b 0a  09 20 20 20 20 49 46 20  |FALSE);..    IF |
00001110  6e 7e 3d 4e 75 6c 6c 20  54 48 45 4e 20 7b 0a 09  |n~=Null THEN {..|
00001120  20 20 20 20 20 20 20 72  20 3a 3d 20 6e 3b 0a 09  |       r := n;..|
00001130  20 20 20 20 20 20 20 4d  6f 76 65 52 74 6f 52 28  |       MoveRtoR(|
00001140  6b 2e 72 65 67 2c 20 62  2c 20 6b 2e 72 65 67 2c  |k.reg, b, k.reg,|
00001150  20 72 29 20 7d 20 7d 0a  20 20 20 20 20 20 45 4c  | r) } }.      EL|
00001160  53 45 0a 09 20 62 20 3a  3d 20 4d 6f 76 65 54 6f  |SE.. b := MoveTo|
00001170  41 6e 79 52 28 78 29 20  7d 3b 0a 0a 20 20 20 49  |AnyR(x) };..   I|
00001180  46 20 72 3c 30 20 54 48  45 4e 20 72 20 3a 3d 20  |F r<0 THEN r := |
00001190  62 3b 0a 20 20 20 79 20  3a 3d 20 52 65 67 45 6e  |b;.   y := RegEn|
000011a0  74 72 79 28 6b 2e 72 65  67 2c 20 72 29 3b 0a 0a  |try(k.reg, r);..|
000011b0  20 20 20 49 46 20 72 73  64 2e 73 68 69 66 74 73  |   IF rsd.shifts|
000011c0  74 61 74 65 21 79 3d 30  20 54 48 45 4e 20 7b 0a  |tate!y=0 THEN {.|
000011d0  20 20 20 20 20 20 46 6c  75 73 68 50 65 6e 64 69  |      FlushPendi|
000011e0  6e 67 55 73 65 73 4f 66  52 65 67 28 72 29 3b 0a  |ngUsesOfReg(r);.|
000011f0  20 20 20 20 20 20 46 6c  75 73 68 50 65 6e 64 69  |      FlushPendi|
00001200  6e 67 4c 6f 61 64 73 46  6f 72 52 65 67 28 62 29  |ngLoadsForReg(b)|
00001210  3b 0a 20 20 20 20 20 20  47 65 6e 46 31 4b 28 66  |;.      GenF1K(f|
00001220  2e 62 69 63 2c 20 72 2c  20 62 2c 20 23 78 66 66  |.bic, r, b, #xff|
00001230  30 30 30 30 30 30 29 3b  0a 20 20 20 20 20 20 72  |000000);.      r|
00001240  73 64 2e 73 68 69 66 74  73 74 61 74 65 21 79 20  |sd.shiftstate!y |
00001250  3a 3d 20 2d 31 20 7d 3b  0a 0a 20 20 20 52 45 53  |:= -1 };..   RES|
00001260  55 4c 54 49 53 20 72 20  7d 0a 0a 41 4e 44 20 4d  |ULTIS r }..AND M|
00001270  6f 76 65 53 74 6f 52 28  74 79 70 65 2c 20 72 2c  |oveStoR(type, r,|
00001280  20 61 2c 20 62 29 20 42  45 20 7b 0a 20 20 20 4c  | a, b) BE {.   L|
00001290  45 54 20 78 20 3d 20 52  65 67 45 6e 74 72 79 28  |ET x = RegEntry(|
000012a0  74 79 70 65 2c 20 72 29  3b 0a 20 20 20 72 73 64  |type, r);.   rsd|
000012b0  2e 74 79 70 65 21 78 2c  20 72 73 64 2e 73 68 69  |.type!x, rsd.shi|
000012c0  66 74 73 74 61 74 65 21  78 2c 20 72 73 64 2e 6c  |ftstate!x, rsd.l|
000012d0  6f 63 21 78 20 3a 3d 20  61 2c 20 30 2c 20 62 3b  |oc!x := a, 0, b;|
000012e0  0a 20 20 20 44 69 73 63  61 72 64 53 4c 28 40 72  |.   DiscardSL(@r|
000012f0  73 64 2e 73 6c 21 78 29  20 7d 0a 0a 41 4e 44 20  |sd.sl!x) }..AND |
00001300  4d 6f 76 65 52 74 6f 52  28 72 74 79 70 65 2c 20  |MoveRtoR(rtype, |
00001310  72 2c 20 73 74 79 70 65  2c 20 73 29 20 42 45 20  |r, stype, s) BE |
00001320  7b 0a 20 20 20 4c 45 54  20 78 2c 20 79 20 3d 20  |{.   LET x, y = |
00001330  52 65 67 45 6e 74 72 79  28 72 74 79 70 65 2c 20  |RegEntry(rtype, |
00001340  72 29 2c 20 52 65 67 45  6e 74 72 79 28 73 74 79  |r), RegEntry(sty|
00001350  70 65 2c 20 73 29 3b 0a  20 20 20 72 73 64 2e 74  |pe, s);.   rsd.t|
00001360  79 70 65 21 79 2c 20 72  73 64 2e 73 68 69 66 74  |ype!y, rsd.shift|
00001370  73 74 61 74 65 21 79 2c  20 72 73 64 2e 6c 6f 63  |state!y, rsd.loc|
00001380  21 79 20 3a 3d 0a 20 20  20 20 20 20 72 73 64 2e  |!y :=.      rsd.|
00001390  74 79 70 65 21 78 2c 20  72 73 64 2e 73 68 69 66  |type!x, rsd.shif|
000013a0  74 73 74 61 74 65 21 78  2c 20 72 73 64 2e 6c 6f  |tstate!x, rsd.lo|
000013b0  63 21 78 0a 20 20 20 43  6f 70 79 53 4c 28 40 72  |c!x.   CopySL(@r|
000013c0  73 64 2e 73 6c 21 79 2c  20 72 73 64 2e 73 6c 21  |sd.sl!y, rsd.sl!|
000013d0  78 29 20 7d 0a 0a 41 4e  44 20 53 74 6f 72 65 52  |x) }..AND StoreR|
000013e0  28 74 79 70 65 2c 20 72  2c 20 61 2c 20 62 29 20  |(type, r, a, b) |
000013f0  3d 20 56 41 4c 4f 46 20  7b 0a 20 20 20 4c 45 54  |= VALOF {.   LET|
00001400  20 78 20 3d 20 52 65 67  45 6e 74 72 79 28 74 79  | x = RegEntry(ty|
00001410  70 65 2c 20 72 29 3b 0a  20 20 20 4c 45 54 20 77  |pe, r);.   LET w|
00001420  61 73 74 6f 73 20 3d 20  44 69 73 63 61 72 64 41  |astos = DiscardA|
00001430  64 64 72 65 73 73 28 61  2c 20 62 29 3b 0a 20 20  |ddress(a, b);.  |
00001440  20 49 46 20 72 73 64 2e  74 79 70 65 21 78 3d 30  | IF rsd.type!x=0|
00001450  20 54 48 45 4e 20 72 73  64 2e 74 79 70 65 21 78  | THEN rsd.type!x|
00001460  2c 20 72 73 64 2e 73 68  69 66 74 73 74 61 74 65  |, rsd.shiftstate|
00001470  21 78 2c 20 72 73 64 2e  6c 6f 63 21 78 20 3a 3d  |!x, rsd.loc!x :=|
00001480  20 61 2c 20 30 2c 20 62  3b 0a 20 20 20 41 64 64  | a, 0, b;.   Add|
00001490  4c 6f 63 54 6f 53 4c 28  40 72 73 64 2e 73 6c 21  |LocToSL(@rsd.sl!|
000014a0  78 2c 20 61 2c 20 62 29  3b 0a 20 20 20 52 45 53  |x, a, b);.   RES|
000014b0  55 4c 54 49 53 20 77 61  73 74 6f 73 20 7d 0a 0a  |ULTIS wastos }..|
000014c0  41 4e 44 20 41 64 64 52  65 67 49 6e 66 6f 28 74  |AND AddRegInfo(t|
000014d0  79 70 65 2c 20 72 2c 20  61 2c 20 62 29 20 42 45  |ype, r, a, b) BE|
000014e0  20 7b 0a 20 20 20 4c 45  54 20 78 20 3d 20 52 65  | {.   LET x = Re|
000014f0  67 45 6e 74 72 79 28 74  79 70 65 2c 20 72 29 3b  |gEntry(type, r);|
00001500  0a 20 20 20 49 46 20 72  73 64 2e 74 79 70 65 21  |.   IF rsd.type!|
00001510  78 7e 3d 30 20 54 48 45  4e 20 41 64 64 4c 6f 63  |x~=0 THEN AddLoc|
00001520  54 6f 53 4c 28 40 72 73  64 2e 73 6c 21 78 2c 20  |ToSL(@rsd.sl!x, |
00001530  72 73 64 2e 74 79 70 65  21 78 2c 20 72 73 64 2e  |rsd.type!x, rsd.|
00001540  6c 6f 63 21 78 29 0a 20  20 20 72 73 64 2e 74 79  |loc!x).   rsd.ty|
00001550  70 65 21 78 2c 20 72 73  64 2e 6c 6f 63 21 78 20  |pe!x, rsd.loc!x |
00001560  3a 3d 20 61 2c 20 62 20  7d 0a 0a 41 4e 44 20 44  |:= a, b }..AND D|
00001570  69 73 63 61 72 64 41 64  64 72 65 73 73 28 74 2c  |iscardAddress(t,|
00001580  20 6e 29 20 3d 20 56 41  4c 4f 46 20 7b 0a 20 20  | n) = VALOF {.  |
00001590  20 4c 45 54 20 44 69 73  63 61 72 64 41 28 78 2c  | LET DiscardA(x,|
000015a0  20 74 2c 20 6e 29 20 42  45 20 7b 0a 20 20 20 20  | t, n) BE {.    |
000015b0  20 20 49 46 20 72 73 64  2e 74 79 70 65 21 78 3d  |  IF rsd.type!x=|
000015c0  74 20 26 20 72 73 64 2e  6c 6f 63 21 78 3d 6e 20  |t & rsd.loc!x=n |
000015d0  54 48 45 4e 20 72 73 64  2e 74 79 70 65 21 78 20  |THEN rsd.type!x |
000015e0  3a 3d 20 30 3b 0a 20 20  20 20 20 20 44 65 6c 4c  |:= 0;.      DelL|
000015f0  6f 63 46 72 6f 6d 53 4c  28 40 72 73 64 2e 73 6c  |ocFromSL(@rsd.sl|
00001600  21 78 2c 20 74 2c 20 6e  29 20 7d 3b 0a 20 20 20  |!x, t, n) };.   |
00001610  46 4f 52 20 72 20 3d 20  72 2e 30 20 54 4f 20 72  |FOR r = r.0 TO r|
00001620  2e 31 34 20 44 4f 20 44  69 73 63 61 72 64 41 28  |.14 DO DiscardA(|
00001630  52 65 67 45 6e 74 72 79  28 6b 2e 72 65 67 2c 20  |RegEntry(k.reg, |
00001640  72 29 2c 20 74 2c 20 6e  29 0a 20 20 20 46 4f 52  |r), t, n).   FOR|
00001650  20 72 20 3d 20 66 72 2e  30 20 54 4f 20 66 72 2e  | r = fr.0 TO fr.|
00001660  37 20 44 4f 20 44 69 73  63 61 72 64 41 28 52 65  |7 DO DiscardA(Re|
00001670  67 45 6e 74 72 79 28 6b  2e 66 72 65 67 2c 20 72  |gEntry(k.freg, r|
00001680  29 2c 20 74 2c 20 6e 29  0a 20 20 20 46 6c 75 73  |), t, n).   Flus|
00001690  68 50 65 6e 64 69 6e 67  4c 6f 61 64 73 46 6f 72  |hPendingLoadsFor|
000016a0  53 4c 6f 63 28 74 2c 20  6e 29 3b 0a 20 20 20 52  |SLoc(t, n);.   R|
000016b0  45 53 55 4c 54 49 53 20  44 65 6c 53 4c 6f 63 46  |ESULTIS DelSLocF|
000016c0  72 6f 6d 50 65 6e 64 69  6e 67 4c 69 73 74 28 40  |romPendingList(@|
000016d0  50 65 6e 64 69 6e 67 53  74 6f 72 65 73 2c 20 74  |PendingStores, t|
000016e0  2c 20 6e 29 20 7d 0a 0a  41 4e 44 20 50 72 69 6e  |, n) }..AND Prin|
000016f0  74 52 65 67 4c 69 73 74  28 29 20 42 45 20 7b 0a  |tRegList() BE {.|
00001700  20 20 20 53 54 41 54 49  43 20 7b 20 6e 75 6c 6c  |   STATIC { null|
00001710  53 74 61 74 65 3d 46 41  4c 53 45 20 7d 3b 0a 20  |State=FALSE };. |
00001720  20 20 4c 45 54 20 50 72  69 6e 74 52 28 74 79 70  |  LET PrintR(typ|
00001730  65 2c 20 72 29 20 42 45  20 7b 0a 20 20 20 20 20  |e, r) BE {.     |
00001740  20 4c 45 54 20 73 20 3d  20 52 65 67 45 6e 74 72  | LET s = RegEntr|
00001750  79 28 74 79 70 65 2c 20  72 29 3b 0a 20 20 20 20  |y(type, r);.    |
00001760  20 20 49 46 20 72 73 64  2e 74 79 70 65 21 73 7e  |  IF rsd.type!s~|
00001770  3d 30 20 7c 20 72 73 64  2e 73 6c 21 73 7e 3d 30  |=0 | rsd.sl!s~=0|
00001780  20 7c 20 72 73 64 2e 6c  6f 63 6b 21 73 7e 3d 30  | | rsd.lock!s~=0|
00001790  20 54 48 45 4e 20 7b 0a  09 20 57 72 43 68 28 72  | THEN {.. WrCh(r|
000017a0  73 64 2e 6c 6f 63 6b 21  73 3d 30 20 2d 3e 20 27  |sd.lock!s=0 -> '|
000017b0  20 27 2c 20 27 2a 2a 27  29 3b 0a 09 20 57 72 43  | ', '**');.. WrC|
000017c0  68 28 74 79 70 65 3d 6b  2e 72 65 67 20 2d 3e 20  |h(type=k.reg -> |
000017d0  27 52 27 2c 20 27 46 27  29 3b 0a 09 20 57 72 69  |'R', 'F');.. Wri|
000017e0  74 65 46 28 22 25 6e 3a  20 25 6e 20 25 6e 22 2c  |teF("%n: %n %n",|
000017f0  20 72 2c 20 72 73 64 2e  74 79 70 65 21 73 2c 20  | r, rsd.type!s, |
00001800  72 73 64 2e 6c 6f 63 21  73 29 3b 0a 09 20 49 46  |rsd.loc!s);.. IF|
00001810  20 72 73 64 2e 73 68 69  66 74 73 74 61 74 65 21  | rsd.shiftstate!|
00001820  73 7e 3d 30 20 54 48 45  4e 20 57 72 69 74 65 46  |s~=0 THEN WriteF|
00001830  28 22 20 5b 25 6e 5d 22  2c 20 72 73 64 2e 73 68  |(" [%n]", rsd.sh|
00001840  69 66 74 73 74 61 74 65  21 73 29 3b 0a 09 20 50  |iftstate!s);.. P|
00001850  72 69 6e 74 4c 69 73 74  28 72 73 64 2e 73 6c 21  |rintList(rsd.sl!|
00001860  73 2c 20 32 2c 20 22 3a  20 22 2c 20 22 22 2c 20  |s, 2, ": ", "", |
00001870  22 2a 6e 22 29 3b 0a 09  20 4e 75 6c 6c 53 74 61  |"*n");.. NullSta|
00001880  74 65 20 3a 3d 20 46 41  4c 53 45 20 7d 20 7d 3b  |te := FALSE } };|
00001890  0a 20 20 20 6e 75 6c 6c  53 74 61 74 65 20 3a 3d  |.   nullState :=|
000018a0  20 54 52 55 45 3b 0a 20  20 20 46 4f 52 20 72 20  | TRUE;.   FOR r |
000018b0  3d 20 72 2e 30 20 54 4f  20 72 2e 31 34 20 44 4f  |= r.0 TO r.14 DO|
000018c0  20 50 72 69 6e 74 52 28  6b 2e 72 65 67 2c 20 72  | PrintR(k.reg, r|
000018d0  29 0a 20 20 20 46 4f 52  20 72 20 3d 20 66 72 2e  |).   FOR r = fr.|
000018e0  30 20 54 4f 20 66 72 2e  37 20 44 4f 20 50 72 69  |0 TO fr.7 DO Pri|
000018f0  6e 74 52 28 6b 2e 66 72  65 67 2c 20 72 29 0a 20  |ntR(k.freg, r). |
00001900  20 20 49 46 20 6e 75 6c  6c 53 74 61 74 65 20 54  |  IF nullState T|
00001910  48 45 4e 20 57 72 69 74  65 53 28 22 4e 75 6c 6c  |HEN WriteS("Null|
00001920  2a 6e 22 29 20 7d 0a 0a  41 4e 44 20 49 73 49 6e  |*n") }..AND IsIn|
00001930  61 52 65 67 69 73 74 65  72 28 78 29 20 3d 0a 20  |aRegister(x) =. |
00001940  20 20 28 68 32 21 78 3e  3d 30 20 7c 20 68 34 21  |  (h2!x>=0 | h4!|
00001950  78 7e 3d 30 29 20 2d 3e  20 4e 75 6c 6c 2c 0a 20  |x~=0) -> Null,. |
00001960  20 20 68 31 21 78 3d 6b  2e 72 65 67 09 20 20 20  |  h1!x=k.reg.   |
00001970  20 20 20 20 2d 3e 20 68  33 21 78 2c 0a 09 09 09  |    -> h3!x,....|
00001980  20 20 4c 6f 6f 6b 46 6f  72 28 78 2c 20 4e 6f 74  |  LookFor(x, Not|
00001990  41 64 64 72 29 0a 0a 41  4e 44 20 4c 6f 6f 6b 46  |Addr)..AND LookF|
000019a0  6f 72 28 78 2c 20 70 72  65 64 29 20 3d 20 4c 6f  |or(x, pred) = Lo|
000019b0  6f 6b 46 6f 72 53 6c 6f  63 28 70 72 65 64 2c 20  |okForSloc(pred, |
000019c0  68 31 21 78 2c 20 68 33  21 78 29 0a 0a 41 4e 44  |h1!x, h3!x)..AND|
000019d0  20 4c 6f 6f 6b 46 6f 72  52 65 67 43 6f 6e 74 61  | LookForRegConta|
000019e0  69 6e 69 6e 67 54 79 70  65 28 74 29 20 3d 20 56  |iningType(t) = V|
000019f0  41 4c 4f 46 20 7b 0a 20  20 20 46 4f 52 20 72 20  |ALOF {.   FOR r |
00001a00  3d 20 72 2e 30 20 54 4f  20 72 2e 31 34 20 44 4f  |= r.0 TO r.14 DO|
00001a10  20 7b 0a 20 20 20 20 20  20 4c 45 54 20 76 20 3d  | {.      LET v =|
00001a20  20 52 65 67 45 6e 74 72  79 28 6b 2e 72 65 67 2c  | RegEntry(k.reg,|
00001a30  20 72 29 3b 0a 20 20 20  20 20 20 49 46 20 74 3d  | r);.      IF t=|
00001a40  72 73 64 2e 74 79 70 65  21 76 20 26 20 4e 6f 74  |rsd.type!v & Not|
00001a50  41 64 64 72 28 72 73 64  2e 73 68 69 66 74 73 74  |Addr(rsd.shiftst|
00001a60  61 74 65 21 76 29 20 54  48 45 4e 0a 09 20 52 45  |ate!v) THEN.. RE|
00001a70  53 55 4c 54 49 53 20 72  20 7d 3b 0a 20 20 20 52  |SULTIS r };.   R|
00001a80  45 53 55 4c 54 49 53 20  4e 75 6c 6c 20 7d 0a 0a  |ESULTIS Null }..|
00001a90  41 4e 44 20 4c 6f 63 49  6e 52 65 67 69 73 74 65  |AND LocInRegiste|
00001aa0  72 28 72 29 20 3d 20 72  73 64 2e 6c 6f 63 21 5b  |r(r) = rsd.loc![|
00001ab0  52 65 67 45 6e 74 72 79  28 6b 2e 72 65 67 2c 20  |RegEntry(k.reg, |
00001ac0  72 29 5d 0a 0a 41 4e 44  20 54 75 72 6e 49 6e 64  |r)]..AND TurnInd|
00001ad0  49 6e 74 6f 53 4c 6f 63  28 78 29 20 3d 20 56 41  |IntoSLoc(x) = VA|
00001ae0  4c 4f 46 20 7b 0a 20 20  20 4c 45 54 20 6b 2c 20  |LOF {.   LET k, |
00001af0  72 31 2c 20 70 2c 20 74  20 3d 20 68 34 21 78 2c  |r1, p, t = h4!x,|
00001b00  20 3f 2c 20 3f 2c 20 3f  3b 0a 20 20 20 68 34 21  | ?, ?, ?;.   h4!|
00001b10  78 20 3a 3d 20 30 3b 0a  20 20 20 72 31 20 3a 3d  |x := 0;.   r1 :=|
00001b20  20 49 73 49 6e 41 52 65  67 69 73 74 65 72 28 78  | IsInARegister(x|
00001b30  29 3b 0a 20 20 20 49 46  20 72 31 3d 4e 75 6c 6c  |);.   IF r1=Null|
00001b40  20 54 48 45 4e 20 52 45  53 55 4c 54 49 53 20 46  | THEN RESULTIS F|
00001b50  41 4c 53 45 3b 0a 20 20  20 70 20 3a 3d 20 52 65  |ALSE;.   p := Re|
00001b60  67 45 6e 74 72 79 28 6b  2e 72 65 67 2c 20 72 31  |gEntry(k.reg, r1|
00001b70  29 3b 0a 20 20 20 74 20  3a 3d 20 72 73 64 2e 74  |);.   t := rsd.t|
00001b80  79 70 65 21 70 3b 0a 20  20 20 49 46 20 74 7e 3d  |ype!p;.   IF t~=|
00001b90  6b 2e 6c 76 6c 6f 63 20  26 20 74 7e 3d 6b 2e 6c  |k.lvloc & t~=k.l|
00001ba0  76 67 6c 6f 62 20 26 20  74 7e 3d 6b 2e 6c 76 73  |vglob & t~=k.lvs|
00001bb0  74 61 74 69 63 20 54 48  45 4e 0a 20 20 20 20 20  |tatic THEN.     |
00001bc0  20 52 45 53 55 4c 54 49  53 20 46 41 4c 53 45 3b  | RESULTIS FALSE;|
00001bd0  0a 20 20 20 68 31 21 78  20 3a 3d 20 74 2b 6b 2e  |.   h1!x := t+k.|
00001be0  6c 6f 63 2d 6b 2e 6c 76  6c 6f 63 3b 0a 20 20 20  |loc-k.lvloc;.   |
00001bf0  68 33 21 78 20 3a 3d 20  72 73 64 2e 6c 6f 63 21  |h3!x := rsd.loc!|
00001c00  70 2b 6b 3b 0a 20 20 20  52 45 53 55 4c 54 49 53  |p+k;.   RESULTIS|
00001c10  20 54 52 55 45 20 7d 0a  0a 41 4e 44 20 52 65 6d  | TRUE }..AND Rem|
00001c20  6f 76 65 46 61 6c 73 65  49 6e 64 69 72 65 63 74  |oveFalseIndirect|
00001c30  69 6f 6e 28 78 29 20 42  45 20 7b 0a 20 20 20 4c  |ion(x) BE {.   L|
00001c40  45 54 20 74 2c 20 69 6e  64 2c 20 6e 2c 20 6b 20  |ET t, ind, n, k |
00001c50  3d 20 68 31 21 78 2c 20  68 32 21 78 2c 20 68 33  |= h1!x, h2!x, h3|
00001c60  21 78 2c 20 68 34 21 78  3b 0a 20 20 20 54 45 53  |!x, h4!x;.   TES|
00001c70  54 20 69 6e 64 3d 30 20  26 20 28 74 3d 6b 2e 6c  |T ind=0 & (t=k.l|
00001c80  76 6c 6f 63 20 7c 20 74  3d 6b 2e 6c 76 67 6c 6f  |vloc | t=k.lvglo|
00001c90  62 20 7c 20 74 3d 6b 2e  6c 76 73 74 61 74 69 63  |b | t=k.lvstatic|
00001ca0  29 20 54 48 45 4e 20 7b  0a 20 20 20 20 20 20 68  |) THEN {.      h|
00001cb0  31 21 78 20 3a 3d 20 74  2b 6b 2e 6c 6f 63 2d 6b  |1!x := t+k.loc-k|
00001cc0  2e 6c 76 6c 6f 63 3b 0a  20 20 20 20 20 20 68 32  |.lvloc;.      h2|
00001cd0  21 78 20 3a 3d 20 2d 31  3b 0a 20 20 20 20 20 20  |!x := -1;.      |
00001ce0  68 33 21 78 20 3a 3d 20  6e 2b 6b 3b 0a 20 20 20  |h3!x := n+k;.   |
00001cf0  20 20 20 68 34 21 78 20  3a 3d 20 30 20 7d 0a 20  |   h4!x := 0 }. |
00001d00  20 20 45 4c 53 45 20 54  45 53 54 20 69 6e 64 3d  |  ELSE TEST ind=|
00001d10  30 20 54 48 45 4e 20 7b  0a 20 20 20 20 20 20 4c  |0 THEN {.      L|
00001d20  45 54 20 62 20 3d 20 4c  6f 6f 6b 46 6f 72 53 6c  |ET b = LookForSl|
00001d30  6f 63 28 53 68 69 66 74  65 64 55 70 2c 20 74 2c  |oc(ShiftedUp, t,|
00001d40  20 6e 29 3b 0a 20 20 20  20 20 20 49 46 20 62 7e  | n);.      IF b~|
00001d50  3d 4e 75 6c 6c 20 54 48  45 4e 20 7b 0a 09 20 4c  |=Null THEN {.. L|
00001d60  45 54 20 70 20 3d 20 4f  66 66 73 65 74 49 6e 4c  |ET p = OffsetInL|
00001d70  69 73 74 28 70 65 6e 64  69 6e 67 53 74 6f 72 65  |ist(pendingStore|
00001d80  73 2c 20 6b 2e 69 72 65  67 2c 20 62 2c 20 6b 29  |s, k.ireg, b, k)|
00001d90  0a 09 20 49 46 20 70 7e  3d 4e 75 6c 6c 20 54 48  |.. IF p~=Null TH|
00001da0  45 4e 20 7b 0a 09 20 20  20 20 68 31 21 78 20 3a  |EN {..    h1!x :|
00001db0  3d 20 6b 2e 72 65 67 3b  0a 09 20 20 20 20 68 32  |= k.reg;..    h2|
00001dc0  21 78 20 3a 3d 20 2d 31  3b 0a 09 20 20 20 20 68  |!x := -1;..    h|
00001dd0  33 21 78 20 3a 3d 20 70  73 2e 72 65 67 21 70 3b  |3!x := ps.reg!p;|
00001de0  0a 09 20 20 20 20 68 34  21 78 20 3a 3d 20 30 20  |..    h4!x := 0 |
00001df0  7d 20 7d 20 7d 0a 20 20  20 45 4c 53 45 20 49 46  |} } }.   ELSE IF|
00001e00  20 69 6e 64 3e 3d 43 61  72 4d 61 72 6b 20 54 48  | ind>=CarMark TH|
00001e10  45 4e 20 7b 0a 20 20 20  20 20 20 4c 45 54 20 62  |EN {.      LET b|
00001e20  20 3d 20 4c 6f 6f 6b 46  6f 72 53 6c 6f 63 28 28  | = LookForSloc((|
00001e30  69 6e 64 3d 43 61 72 4d  61 72 6b 20 2d 3e 20 49  |ind=CarMark -> I|
00001e40  73 41 43 61 72 2c 20 4e  6f 74 41 64 64 72 29 2c  |sACar, NotAddr),|
00001e50  20 74 2c 20 6e 29 3b 0a  20 20 20 20 20 20 49 46  | t, n);.      IF|
00001e60  20 62 7e 3d 4e 75 6c 6c  20 54 48 45 4e 20 7b 0a  | b~=Null THEN {.|
00001e70  09 20 4c 45 54 20 70 20  3d 20 4f 66 66 73 65 74  |. LET p = Offset|
00001e80  49 6e 4c 69 73 74 28 70  65 6e 64 69 6e 67 53 74  |InList(pendingSt|
00001e90  6f 72 65 73 2c 20 6b 2e  69 72 65 67 2c 20 62 2c  |ores, k.ireg, b,|
00001ea0  20 6b 2f 34 29 0a 09 20  49 46 20 70 7e 3d 4e 75  | k/4).. IF p~=Nu|
00001eb0  6c 6c 20 54 48 45 4e 20  7b 0a 09 20 20 20 20 68  |ll THEN {..    h|
00001ec0  31 21 78 20 3a 3d 20 6b  2e 72 65 67 3b 0a 09 20  |1!x := k.reg;.. |
00001ed0  20 20 20 68 32 21 78 20  3a 3d 20 2d 31 3b 0a 09  |   h2!x := -1;..|
00001ee0  20 20 20 20 68 33 21 78  20 3a 3d 20 70 73 2e 72  |    h3!x := ps.r|
00001ef0  65 67 21 70 3b 0a 09 20  20 20 20 68 34 21 78 20  |eg!p;..    h4!x |
00001f00  3a 3d 20 30 20 7d 20 7d  20 7d 20 7d 0a 0a 41 4e  |:= 0 } } } }..AN|
00001f10  44 20 4c 6f 6f 6b 46 6f  72 53 6c 6f 63 28 70 72  |D LookForSloc(pr|
00001f20  65 64 2c 20 74 2c 20 6e  29 20 3d 20 56 41 4c 4f  |ed, t, n) = VALO|
00001f30  46 20 7b 0a 20 20 20 49  46 20 28 43 47 44 65 62  |F {.   IF (CGDeb|
00001f40  75 67 4d 6f 64 65 26 64  62 2e 72 65 67 73 29 7e  |ugMode&db.regs)~|
00001f50  3d 30 20 54 48 45 4e 20  7b 0a 20 20 20 20 20 20  |=0 THEN {.      |
00001f60  57 72 69 74 65 46 28 22  4c 6f 6f 6b 66 6f 72 20  |WriteF("Lookfor |
00001f70  25 6e 20 25 6e 20 25 73  3a 2a 4e 22 2c 20 74 2c  |%n %n %s:*N", t,|
00001f80  20 6e 2c 0a 09 09 20 20  70 72 65 64 3d 4e 6f 74  | n,...  pred=Not|
00001f90  41 64 64 72 20 2d 3e 20  22 4e 6f 74 41 64 64 72  |Addr -> "NotAddr|
00001fa0  22 2c 0a 09 09 70 72 65  64 3d 53 68 69 66 74 65  |",...pred=Shifte|
00001fb0  64 55 70 20 2d 3e 20 22  53 68 69 66 74 65 64 55  |dUp -> "ShiftedU|
00001fc0  70 22 2c 0a 09 09 09 09  20 20 22 49 73 41 43 61  |p",.....  "IsACa|
00001fd0  72 22 29 3b 0a 20 20 20  20 20 20 50 72 69 6e 74  |r");.      Print|
00001fe0  52 65 67 4c 69 73 74 28  29 20 7d 3b 0a 0a 20 20  |RegList() };..  |
00001ff0  20 46 4f 52 20 72 20 3d  20 72 2e 30 20 54 4f 20  | FOR r = r.0 TO |
00002000  72 2e 31 34 20 44 4f 20  7b 0a 20 20 20 20 20 20  |r.14 DO {.      |
00002010  4c 45 54 20 76 20 3d 20  52 65 67 45 6e 74 72 79  |LET v = RegEntry|
00002020  28 6b 2e 72 65 67 2c 20  72 29 3b 0a 20 20 20 20  |(k.reg, r);.    |
00002030  20 20 49 46 20 5b 28 74  3d 72 73 64 2e 74 79 70  |  IF [(t=rsd.typ|
00002040  65 21 76 20 26 20 6e 3d  72 73 64 2e 6c 6f 63 21  |e!v & n=rsd.loc!|
00002050  76 29 20 7c 0a 09 20 20  53 6c 6f 63 49 6e 4c 69  |v) |..  SlocInLi|
00002060  73 74 28 72 73 64 2e 73  6c 21 76 2c 20 74 2c 20  |st(rsd.sl!v, t, |
00002070  6e 29 7e 3d 4e 75 6c 6c  5d 20 26 0a 09 20 70 72  |n)~=Null] &.. pr|
00002080  65 64 28 72 73 64 2e 73  68 69 66 74 73 74 61 74  |ed(rsd.shiftstat|
00002090  65 21 76 29 20 54 48 45  4e 20 7b 0a 09 20 49 46  |e!v) THEN {.. IF|
000020a0  20 28 43 47 44 65 62 75  67 4d 6f 64 65 26 64 62  | (CGDebugMode&db|
000020b0  2e 72 65 67 73 29 7e 3d  30 20 54 48 45 4e 20 57  |.regs)~=0 THEN W|
000020c0  72 69 74 65 46 28 22 46  6f 75 6e 64 20 25 6e 2a  |riteF("Found %n*|
000020d0  6e 22 2c 20 72 29 0a 09  20 52 45 53 55 4c 54 49  |n", r).. RESULTI|
000020e0  53 20 72 20 7d 20 7d 3b  0a 0a 20 20 20 74 20 3a  |S r } };..   t :|
000020f0  3d 20 53 6c 6f 63 49 6e  4c 69 73 74 28 50 65 6e  |= SlocInList(Pen|
00002100  64 69 6e 67 53 74 6f 72  65 73 2c 20 74 2c 20 6e  |dingStores, t, n|
00002110  29 3b 0a 20 20 20 49 46  20 74 7e 3d 4e 75 6c 6c  |);.   IF t~=Null|
00002120  20 54 48 45 4e 20 7b 0a  20 20 20 20 20 20 6e 20  | THEN {.      n |
00002130  3a 3d 20 70 73 2e 72 65  67 21 74 3b 0a 20 20 20  |:= ps.reg!t;.   |
00002140  20 20 20 54 45 53 54 20  70 72 65 64 28 72 73 64  |   TEST pred(rsd|
00002150  2e 73 68 69 66 74 73 74  61 74 65 21 5b 52 65 67  |.shiftstate![Reg|
00002160  45 6e 74 72 79 28 6b 2e  72 65 67 2c 20 6e 29 5d  |Entry(k.reg, n)]|
00002170  29 20 54 48 45 4e 0a 09  20 74 20 3a 3d 20 6e 0a  |) THEN.. t := n.|
00002180  20 20 20 20 20 20 45 4c  53 45 0a 09 20 74 20 3a  |      ELSE.. t :|
00002190  3d 20 4e 75 6c 6c 20 7d  3b 0a 20 20 20 49 46 20  |= Null };.   IF |
000021a0  28 43 47 44 65 62 75 67  4d 6f 64 65 26 64 62 2e  |(CGDebugMode&db.|
000021b0  72 65 67 73 29 7e 3d 30  20 54 48 45 4e 20 57 72  |regs)~=0 THEN Wr|
000021c0  69 74 65 46 28 22 46 6f  75 6e 64 20 25 6e 2a 6e  |iteF("Found %n*n|
000021d0  22 2c 20 74 29 0a 20 20  20 52 45 53 55 4c 54 49  |", t).   RESULTI|
000021e0  53 20 74 20 7d 0a 0a 41  4e 44 20 4e 6f 74 41 64  |S t }..AND NotAd|
000021f0  64 72 28 78 29 20 3d 20  78 3d 30 0a 0a 41 4e 44  |dr(x) = x=0..AND|
00002200  20 53 68 69 66 74 65 64  55 70 28 78 29 20 3d 20  | ShiftedUp(x) = |
00002210  78 3e 30 0a 0a 41 4e 44  20 49 73 61 43 61 72 28  |x>0..AND IsaCar(|
00002220  78 29 20 3d 20 78 3c 30  0a 0a 0a 41 4e 44 20 4c  |x) = x<0...AND L|
00002230  6f 6f 6b 46 6f 72 46 52  28 74 2c 20 6e 29 20 3d  |ookForFR(t, n) =|
00002240  20 56 41 4c 4f 46 20 7b  0a 20 20 20 49 46 20 28  | VALOF {.   IF (|
00002250  43 47 44 65 62 75 67 4d  6f 64 65 26 64 62 2e 72  |CGDebugMode&db.r|
00002260  65 67 73 29 7e 3d 30 20  54 48 45 4e 20 7b 0a 20  |egs)~=0 THEN {. |
00002270  20 20 20 20 20 57 72 69  74 65 46 28 22 4c 6f 6f  |     WriteF("Loo|
00002280  6b 66 6f 72 46 20 25 6e  20 25 6e 3a 2a 4e 22 2c  |kforF %n %n:*N",|
00002290  20 74 2c 20 6e 29 3b 0a  20 20 20 20 20 20 50 72  | t, n);.      Pr|
000022a0  69 6e 74 52 65 67 4c 69  73 74 28 29 20 7d 3b 0a  |intRegList() };.|
000022b0  0a 20 20 20 46 4f 52 20  72 20 3d 20 66 72 2e 30  |.   FOR r = fr.0|
000022c0  20 54 4f 20 66 72 2e 37  20 44 4f 20 7b 0a 20 20  | TO fr.7 DO {.  |
000022d0  20 20 20 20 4c 45 54 20  76 20 3d 20 52 65 67 45  |    LET v = RegE|
000022e0  6e 74 72 79 28 6b 2e 66  72 65 67 2c 20 72 29 3b  |ntry(k.freg, r);|
000022f0  0a 20 20 20 20 20 20 49  46 20 5b 28 74 3d 72 73  |.      IF [(t=rs|
00002300  64 2e 74 79 70 65 21 76  20 26 20 6e 3d 72 73 64  |d.type!v & n=rsd|
00002310  2e 6c 6f 63 21 76 29 20  7c 0a 09 20 20 53 6c 6f  |.loc!v) |..  Slo|
00002320  63 49 6e 4c 69 73 74 28  72 73 64 2e 73 6c 21 76  |cInList(rsd.sl!v|
00002330  2c 20 74 2c 20 6e 29 7e  3d 4e 75 6c 6c 5d 20 54  |, t, n)~=Null] T|
00002340  48 45 4e 20 7b 0a 09 20  49 46 20 28 43 47 44 65  |HEN {.. IF (CGDe|
00002350  62 75 67 4d 6f 64 65 26  64 62 2e 72 65 67 73 29  |bugMode&db.regs)|
00002360  7e 3d 30 20 54 48 45 4e  20 57 72 69 74 65 46 28  |~=0 THEN WriteF(|
00002370  22 46 6f 75 6e 64 20 25  6e 2a 6e 22 2c 20 72 29  |"Found %n*n", r)|
00002380  0a 09 20 52 45 53 55 4c  54 49 53 20 72 20 7d 20  |.. RESULTIS r } |
00002390  7d 3b 0a 0a 20 20 20 52  45 53 55 4c 54 49 53 20  |};..   RESULTIS |
000023a0  4e 75 6c 6c 20 7d 0a 0a  0a 41 4e 44 20 4c 6f 63  |Null }...AND Loc|
000023b0  6b 28 72 2c 20 74 79 70  65 29 20 42 45 0a 20 20  |k(r, type) BE.  |
000023c0  20 54 45 53 54 20 74 79  70 65 3d 6b 2e 72 65 67  | TEST type=k.reg|
000023d0  20 54 48 45 4e 0a 20 20  20 20 20 20 49 46 20 72  | THEN.      IF r|
000023e0  2e 30 3c 3d 72 3c 3d 72  2e 31 34 0a 09 20 54 48  |.0<=r<=r.14.. TH|
000023f0  45 4e 20 72 73 64 2e 6c  6f 63 6b 21 5b 52 65 67  |EN rsd.lock![Reg|
00002400  45 6e 74 72 79 28 6b 2e  72 65 67 2c 20 72 29 5d  |Entry(k.reg, r)]|
00002410  20 3a 3d 20 2d 31 0a 20  20 20 45 4c 53 45 20 54  | := -1.   ELSE T|
00002420  45 53 54 20 74 79 70 65  3d 6b 2e 66 72 65 67 20  |EST type=k.freg |
00002430  54 48 45 4e 0a 20 20 20  20 20 20 49 46 20 66 72  |THEN.      IF fr|
00002440  2e 30 3c 3d 72 3c 3d 66  72 2e 37 0a 09 20 54 48  |.0<=r<=fr.7.. TH|
00002450  45 4e 20 72 73 64 2e 6c  6f 63 6b 21 5b 52 65 67  |EN rsd.lock![Reg|
00002460  45 6e 74 72 79 28 6b 2e  66 72 65 67 2c 20 72 29  |Entry(k.freg, r)|
00002470  5d 20 3a 3d 20 2d 31 0a  20 20 20 45 4c 53 45 20  |] := -1.   ELSE |
00002480  43 47 45 72 72 6f 72 28  54 52 55 45 2c 20 22 62  |CGError(TRUE, "b|
00002490  61 64 20 74 79 70 65 20  69 6e 20 4c 6f 63 6b 22  |ad type in Lock"|
000024a0  29 0a 0a 41 4e 44 20 55  6e 6c 6f 63 6b 28 72 2c  |)..AND Unlock(r,|
000024b0  20 74 79 70 65 29 20 42  45 0a 20 20 20 54 45 53  | type) BE.   TES|
000024c0  54 20 74 79 70 65 3d 6b  2e 72 65 67 20 54 48 45  |T type=k.reg THE|
000024d0  4e 0a 20 20 20 20 20 20  49 46 20 28 72 2e 30 3c  |N.      IF (r.0<|
000024e0  3d 72 3c 3d 72 2e 31 34  29 20 26 20 72 7e 3d 72  |=r<=r.14) & r~=r|
000024f0  2e 6e 69 6c 20 26 20 4c  6f 63 48 65 6c 64 49 6e  |.nil & LocHeldIn|
00002500  52 65 67 69 73 74 65 72  28 72 29 3d 4e 75 6c 6c  |Register(r)=Null|
00002510  0a 09 20 54 48 45 4e 20  72 73 64 2e 6c 6f 63 6b  |.. THEN rsd.lock|
00002520  21 5b 52 65 67 45 6e 74  72 79 28 6b 2e 72 65 67  |![RegEntry(k.reg|
00002530  2c 20 72 29 5d 20 3a 3d  20 30 0a 20 20 20 45 4c  |, r)] := 0.   EL|
00002540  53 45 20 54 45 53 54 20  74 79 70 65 3d 6b 2e 66  |SE TEST type=k.f|
00002550  72 65 67 20 54 48 45 4e  0a 20 20 20 20 20 20 49  |reg THEN.      I|
00002560  46 20 66 72 2e 30 3c 3d  72 3c 3d 66 72 2e 37 0a  |F fr.0<=r<=fr.7.|
00002570  09 20 54 48 45 4e 20 72  73 64 2e 6c 6f 63 6b 21  |. THEN rsd.lock!|
00002580  5b 52 65 67 45 6e 74 72  79 28 6b 2e 66 72 65 67  |[RegEntry(k.freg|
00002590  2c 20 72 29 5d 20 3a 3d  20 30 0a 20 20 20 45 4c  |, r)] := 0.   EL|
000025a0  53 45 20 43 47 45 72 72  6f 72 28 54 52 55 45 2c  |SE CGError(TRUE,|
000025b0  20 22 62 61 64 20 74 79  70 65 20 69 6e 20 4c 6f  | "bad type in Lo|
000025c0  63 6b 22 29 0a 0a 41 4e  44 20 4c 6f 63 6b 65 64  |ck")..AND Locked|
000025d0  28 72 2c 20 74 79 70 65  29 20 3d 20 72 73 64 2e  |(r, type) = rsd.|
000025e0  6c 6f 63 6b 21 5b 52 65  67 45 6e 74 72 79 28 74  |lock![RegEntry(t|
000025f0  79 70 65 2c 20 72 29 5d  20 3d 20 2d 31 0a 0a 41  |ype, r)] = -1..A|
00002600  4e 44 20 41 64 64 4c 6f  63 54 6f 53 4c 28 6c 76  |ND AddLocToSL(lv|
00002610  70 2c 20 74 2c 20 6e 29  20 42 45 20 7b 0a 20 20  |p, t, n) BE {.  |
00002620  20 4c 45 54 20 76 20 3d  20 46 69 6c 6c 42 6c 6b  | LET v = FillBlk|
00002630  28 73 6c 2e 73 69 7a 65  2c 20 21 6c 76 70 2c 20  |(sl.size, !lvp, |
00002640  74 2c 20 6e 29 3b 0a 20  20 20 21 6c 76 70 20 3a  |t, n);.   !lvp :|
00002650  3d 20 76 20 7d 0a 0a 41  4e 44 20 43 6f 70 79 53  |= v }..AND CopyS|
00002660  4c 28 6c 76 64 65 73 74  2c 20 73 6f 75 72 63 65  |L(lvdest, source|
00002670  29 20 42 45 0a 20 20 20  57 48 49 4c 45 20 73 6f  |) BE.   WHILE so|
00002680  75 72 63 65 7e 3d 30 20  44 4f 20 7b 0a 20 20 20  |urce~=0 DO {.   |
00002690  20 20 20 41 64 64 4c 6f  63 54 6f 53 4c 28 6c 76  |   AddLocToSL(lv|
000026a0  64 65 73 74 2c 20 73 6c  2e 74 79 70 65 21 73 6f  |dest, sl.type!so|
000026b0  75 72 63 65 2c 20 73 6c  2e 6c 6f 63 21 73 6f 75  |urce, sl.loc!sou|
000026c0  72 63 65 29 3b 0a 20 20  20 20 20 20 73 6f 75 72  |rce);.      sour|
000026d0  63 65 20 3a 3d 20 21 73  6f 75 72 63 65 20 7d 0a  |ce := !source }.|
000026e0  0a 41 4e 44 20 44 69 73  63 61 72 64 53 4c 28 6c  |.AND DiscardSL(l|
000026f0  76 70 29 20 42 45 20 7b  0a 20 20 20 44 65 6c 65  |vp) BE {.   Dele|
00002700  74 65 4c 69 73 74 28 21  6c 76 70 2c 20 73 6c 2e  |teList(!lvp, sl.|
00002710  73 69 7a 65 29 3b 0a 20  20 20 21 6c 76 70 20 3a  |size);.   !lvp :|
00002720  3d 20 30 20 7d 0a 0a 41  4e 44 20 44 65 6c 4c 6f  |= 0 }..AND DelLo|
00002730  63 46 72 6f 6d 53 4c 28  6c 76 70 2c 20 74 2c 20  |cFromSL(lvp, t, |
00002740  6e 29 20 42 45 20 7b 0a  20 20 20 4c 45 54 20 70  |n) BE {.   LET p|
00002750  20 3d 20 21 6c 76 70 3b  0a 20 20 20 57 48 49 4c  | = !lvp;.   WHIL|
00002760  45 20 70 7e 3d 30 20 44  4f 20 7b 0a 20 20 20 20  |E p~=0 DO {.    |
00002770  20 20 54 45 53 54 20 73  6c 2e 74 79 70 65 21 70  |  TEST sl.type!p|
00002780  3d 74 20 26 20 73 6c 2e  6c 6f 63 21 70 3d 6e 20  |=t & sl.loc!p=n |
00002790  54 48 45 4e 0a 09 20 21  6c 76 70 20 3a 3d 20 46  |THEN.. !lvp := F|
000027a0  72 65 65 42 6c 6b 28 70  2c 20 73 6c 2e 73 69 7a  |reeBlk(p, sl.siz|
000027b0  65 29 0a 20 20 20 20 20  20 45 4c 53 45 0a 09 20  |e).      ELSE.. |
000027c0  6c 76 70 20 3a 3d 20 70  3b 0a 20 20 20 20 20 20  |lvp := p;.      |
000027d0  70 20 3a 3d 20 21 6c 76  70 20 7d 20 7d 0a 0a 41  |p := !lvp } }..A|
000027e0  4e 44 20 50 72 69 6e 74  52 65 67 69 73 74 65 72  |ND PrintRegister|
000027f0  53 74 61 74 65 28 73 29  20 42 45 20 7b 0a 20 20  |State(s) BE {.  |
00002800  20 4c 45 54 20 4e 75 6c  6c 53 74 61 74 65 20 3d  | LET NullState =|
00002810  20 54 52 55 45 3b 0a 20  20 20 57 72 69 74 65 46  | TRUE;.   WriteF|
00002820  28 22 73 73 20 25 6e 20  25 6e 2a 6e 22 2c 20 73  |("ss %n %n*n", s|
00002830  72 73 2e 6c 61 62 21 73  2c 20 73 72 73 2e 74 6f  |rs.lab!s, srs.to|
00002840  73 21 73 29 3b 0a 20 20  20 73 20 3a 3d 20 73 2b  |s!s);.   s := s+|
00002850  73 72 73 2e 68 65 61 64  65 72 3b 0a 20 20 20 46  |srs.header;.   F|
00002860  4f 52 20 72 20 3d 20 72  2e 30 20 54 4f 20 72 2e  |OR r = r.0 TO r.|
00002870  31 34 20 44 4f 20 7b 0a  20 20 20 20 20 20 49 46  |14 DO {.      IF|
00002880  20 73 72 73 64 2e 74 79  70 65 21 73 7e 3d 30 20  | srsd.type!s~=0 |
00002890  7c 20 73 72 73 64 2e 73  6c 21 73 7e 3d 30 20 54  || srsd.sl!s~=0 T|
000028a0  48 45 4e 20 7b 0a 09 20  57 72 69 74 65 46 28 22  |HEN {.. WriteF("|
000028b0  52 25 6e 3a 20 25 6e 20  25 6e 20 25 6e 3a 22 2c  |R%n: %n %n %n:",|
000028c0  20 72 2c 20 73 72 73 64  2e 74 79 70 65 21 73 2c  | r, srsd.type!s,|
000028d0  20 73 72 73 64 2e 73 68  69 66 74 73 74 61 74 65  | srsd.shiftstate|
000028e0  21 73 2c 20 73 72 73 64  2e 6c 6f 63 21 73 29 3b  |!s, srsd.loc!s);|
000028f0  0a 09 20 50 72 69 6e 74  4c 69 73 74 28 73 72 73  |.. PrintList(srs|
00002900  64 2e 73 6c 21 73 2c 20  32 2c 20 22 22 2c 20 22  |d.sl!s, 2, "", "|
00002910  22 2c 20 22 2a 6e 22 29  3b 0a 09 20 4e 75 6c 6c  |", "*n");.. Null|
00002920  53 74 61 74 65 20 3a 3d  20 46 41 4c 53 45 20 7d  |State := FALSE }|
00002930  3b 0a 20 20 20 20 20 20  73 20 3a 3d 20 73 2b 73  |;.      s := s+s|
00002940  72 73 2e 73 69 7a 65 20  7d 3b 0a 20 20 20 46 4f  |rs.size };.   FO|
00002950  52 20 72 20 3d 20 66 72  2e 30 20 54 4f 20 66 72  |R r = fr.0 TO fr|
00002960  2e 37 20 44 4f 20 7b 0a  20 20 20 20 20 20 49 46  |.7 DO {.      IF|
00002970  20 73 72 73 64 2e 74 79  70 65 21 73 7e 3d 30 20  | srsd.type!s~=0 |
00002980  7c 20 73 72 73 64 2e 73  6c 21 73 7e 3d 30 20 54  || srsd.sl!s~=0 T|
00002990  48 45 4e 20 7b 0a 09 20  57 72 69 74 65 46 28 22  |HEN {.. WriteF("|
000029a0  46 25 6e 3a 20 25 6e 20  25 6e 3a 22 2c 20 72 2c  |F%n: %n %n:", r,|
000029b0  20 73 72 73 64 2e 74 79  70 65 21 73 2c 20 73 72  | srsd.type!s, sr|
000029c0  73 64 2e 6c 6f 63 21 73  29 3b 0a 09 20 50 72 69  |sd.loc!s);.. Pri|
000029d0  6e 74 4c 69 73 74 28 73  72 73 64 2e 73 6c 21 73  |ntList(srsd.sl!s|
000029e0  2c 20 32 2c 20 22 22 2c  20 22 22 2c 20 22 2a 6e  |, 2, "", "", "*n|
000029f0  22 29 3b 0a 09 20 4e 75  6c 6c 53 74 61 74 65 20  |");.. NullState |
00002a00  3a 3d 20 46 41 4c 53 45  20 7d 3b 0a 20 20 20 20  |:= FALSE };.    |
00002a10  20 20 73 20 3a 3d 20 73  2b 73 72 73 2e 73 69 7a  |  s := s+srs.siz|
00002a20  65 20 7d 3b 0a 20 20 20  49 46 20 4e 75 6c 6c 53  |e };.   IF NullS|
00002a30  74 61 74 65 20 54 48 45  4e 20 57 72 69 74 65 53  |tate THEN WriteS|
00002a40  28 22 4e 75 6c 6c 2a 6e  22 29 20 7d 0a 0a 41 4e  |("Null*n") }..AN|
00002a50  44 20 53 61 76 65 52 65  67 69 73 74 65 72 53 74  |D SaveRegisterSt|
00002a60  61 74 65 28 29 20 3d 20  56 41 4c 4f 46 20 7b 0a  |ate() = VALOF {.|
00002a70  20 20 20 4c 45 54 20 43  6f 70 79 49 6e 28 74 79  |   LET CopyIn(ty|
00002a80  70 65 2c 20 72 2c 20 79  29 20 3d 20 56 41 4c 4f  |pe, r, y) = VALO|
00002a90  46 20 7b 0a 20 20 20 20  20 20 4c 45 54 20 78 20  |F {.      LET x |
00002aa0  3d 20 52 65 67 45 6e 74  72 79 28 74 79 70 65 2c  |= RegEntry(type,|
00002ab0  20 72 29 3b 0a 20 20 20  20 20 20 73 72 73 64 2e  | r);.      srsd.|
00002ac0  73 68 69 66 74 73 74 61  74 65 21 79 20 3a 3d 20  |shiftstate!y := |
00002ad0  72 73 64 2e 73 68 69 66  74 73 74 61 74 65 21 78  |rsd.shiftstate!x|
00002ae0  3b 0a 20 20 20 20 20 20  73 72 73 64 2e 73 6c 21  |;.      srsd.sl!|
00002af0  79 20 3a 3d 20 30 0a 20  20 20 20 20 20 43 6f 70  |y := 0.      Cop|
00002b00  79 53 4c 28 40 73 72 73  64 2e 73 6c 21 79 2c 20  |ySL(@srsd.sl!y, |
00002b10  72 73 64 2e 73 6c 21 78  29 3b 0a 20 20 20 20 20  |rsd.sl!x);.     |
00002b20  20 54 45 53 54 20 6b 2e  6c 6f 63 3c 3d 72 73 64  | TEST k.loc<=rsd|
00002b30  2e 74 79 70 65 21 78 3c  3d 6b 2e 6c 61 62 20 54  |.type!x<=k.lab T|
00002b40  48 45 4e 20 7b 0a 09 20  4c 45 54 20 74 2c 20 6e  |HEN {.. LET t, n|
00002b50  20 3d 20 72 73 64 2e 74  79 70 65 21 78 2c 20 72  | = rsd.type!x, r|
00002b60  73 64 2e 6c 6f 63 21 78  3b 0a 09 20 73 72 73 64  |sd.loc!x;.. srsd|
00002b70  2e 74 79 70 65 21 79 2c  20 73 72 73 64 2e 6c 6f  |.type!y, srsd.lo|
00002b80  63 21 79 20 3a 3d 20 30  2c 20 30 3b 0a 09 20 49  |c!y := 0, 0;.. I|
00002b90  46 20 53 6c 6f 63 49 6e  4c 69 73 74 28 73 72 73  |F SlocInList(srs|
00002ba0  64 2e 73 6c 21 79 2c 20  74 2c 20 6e 29 3d 4e 75  |d.sl!y, t, n)=Nu|
00002bb0  6c 6c 0a 09 20 20 20 20  54 48 45 4e 20 41 64 64  |ll..    THEN Add|
00002bc0  4c 6f 63 54 6f 53 4c 28  40 73 72 73 64 2e 73 6c  |LocToSL(@srsd.sl|
00002bd0  21 79 2c 20 74 2c 20 6e  29 20 7d 0a 20 20 20 20  |!y, t, n) }.    |
00002be0  20 20 45 4c 53 45 0a 09  20 73 72 73 64 2e 74 79  |  ELSE.. srsd.ty|
00002bf0  70 65 21 79 2c 20 73 72  73 64 2e 6c 6f 63 21 79  |pe!y, srsd.loc!y|
00002c00  20 3a 3d 20 72 73 64 2e  74 79 70 65 21 78 2c 20  | := rsd.type!x, |
00002c10  72 73 64 2e 6c 6f 63 21  78 3b 0a 20 20 20 20 20  |rsd.loc!x;.     |
00002c20  20 52 45 53 55 4c 54 49  53 20 79 2b 73 72 73 2e  | RESULTIS y+srs.|
00002c30  73 69 7a 65 20 7d 3b 0a  20 20 20 4c 45 54 20 70  |size };.   LET p|
00002c40  20 3d 20 47 65 74 56 65  63 74 6f 72 28 73 72 73  | = GetVector(srs|
00002c50  2e 62 6c 6f 63 6b 73 69  7a 65 29 3b 0a 20 20 20  |.blocksize);.   |
00002c60  4c 45 54 20 79 20 3d 20  70 2b 73 72 73 2e 68 65  |LET y = p+srs.he|
00002c70  61 64 65 72 3b 0a 20 20  20 46 4f 52 20 72 20 3d  |ader;.   FOR r =|
00002c80  20 72 2e 30 20 54 4f 20  72 2e 31 34 20 44 4f 20  | r.0 TO r.14 DO |
00002c90  79 20 3a 3d 20 43 6f 70  79 49 6e 28 6b 2e 72 65  |y := CopyIn(k.re|
00002ca0  67 2c 20 72 2c 20 79 29  0a 20 20 20 46 4f 52 20  |g, r, y).   FOR |
00002cb0  72 20 3d 20 66 72 2e 30  20 54 4f 20 66 72 2e 37  |r = fr.0 TO fr.7|
00002cc0  20 44 4f 20 79 20 3a 3d  20 43 6f 70 79 49 6e 28  | DO y := CopyIn(|
00002cd0  6b 2e 66 72 65 67 2c 20  72 2c 20 79 29 0a 20 20  |k.freg, r, y).  |
00002ce0  20 73 72 73 2e 74 6f 73  21 70 20 3a 3d 20 54 4f  | srs.tos!p := TO|
00002cf0  53 4f 66 66 73 65 74 3b  0a 20 20 20 73 72 73 2e  |SOffset;.   srs.|
00002d00  70 73 21 70 20 3a 3d 20  43 6f 70 79 4f 66 4c 69  |ps!p := CopyOfLi|
00002d10  73 74 28 50 65 6e 64 69  6e 67 53 74 6f 72 65 73  |st(PendingStores|
00002d20  2c 20 70 73 2e 73 69 7a  65 29 3b 0a 20 20 20 52  |, ps.size);.   R|
00002d30  45 53 55 4c 54 49 53 20  70 20 7d 0a 0a 41 4e 44  |ESULTIS p }..AND|
00002d40  20 52 65 73 74 6f 72 65  52 65 67 69 73 74 65 72  | RestoreRegister|
00002d50  53 74 61 74 65 28 70 29  20 42 45 20 7b 0a 20 20  |State(p) BE {.  |
00002d60  20 4c 45 54 20 43 6f 70  79 42 61 63 6b 28 74 79  | LET CopyBack(ty|
00002d70  70 65 2c 20 72 2c 20 79  29 20 3d 20 56 41 4c 4f  |pe, r, y) = VALO|
00002d80  46 20 7b 0a 20 20 20 20  20 20 4c 45 54 20 78 20  |F {.      LET x |
00002d90  3d 20 52 65 67 45 6e 74  72 79 28 74 79 70 65 2c  |= RegEntry(type,|
00002da0  20 72 29 3b 0a 20 20 20  20 20 20 72 73 64 2e 74  | r);.      rsd.t|
00002db0  79 70 65 21 78 2c 20 72  73 64 2e 73 68 69 66 74  |ype!x, rsd.shift|
00002dc0  73 74 61 74 65 21 78 2c  20 72 73 64 2e 6c 6f 63  |state!x, rsd.loc|
00002dd0  21 78 2c 20 72 73 64 2e  73 6c 21 78 20 3a 3d 0a  |!x, rsd.sl!x :=.|
00002de0  09 20 73 72 73 64 2e 74  79 70 65 21 79 2c 20 73  |. srsd.type!y, s|
00002df0  72 73 64 2e 73 68 69 66  74 73 74 61 74 65 21 79  |rsd.shiftstate!y|
00002e00  2c 20 73 72 73 64 2e 6c  6f 63 21 79 2c 20 73 72  |, srsd.loc!y, sr|
00002e10  73 64 2e 73 6c 21 79 3b  0a 20 20 20 20 20 20 49  |sd.sl!y;.      I|
00002e20  46 20 72 73 64 2e 74 79  70 65 21 78 3d 30 20 26  |F rsd.type!x=0 &|
00002e30  20 72 73 64 2e 73 6c 21  78 7e 3d 30 20 54 48 45  | rsd.sl!x~=0 THE|
00002e40  4e 20 7b 0a 09 20 4c 45  54 20 71 20 3d 20 72 73  |N {.. LET q = rs|
00002e50  64 2e 73 6c 21 78 3b 0a  09 20 72 73 64 2e 74 79  |d.sl!x;.. rsd.ty|
00002e60  70 65 21 78 2c 20 72 73  64 2e 6c 6f 63 21 78 20  |pe!x, rsd.loc!x |
00002e70  3a 3d 20 73 6c 2e 74 79  70 65 21 71 2c 20 73 6c  |:= sl.type!q, sl|
00002e80  2e 6c 6f 63 21 71 3b 0a  09 20 72 73 64 2e 73 6c  |.loc!q;.. rsd.sl|
00002e90  21 78 20 3a 3d 20 46 72  65 65 42 6c 6b 28 71 2c  |!x := FreeBlk(q,|
00002ea0  20 73 6c 2e 73 69 7a 65  29 20 7d 3b 0a 20 20 20  | sl.size) };.   |
00002eb0  20 20 20 79 20 3a 3d 20  79 2b 73 72 73 2e 73 69  |   y := y+srs.si|
00002ec0  7a 65 20 7d 3b 0a 20 20  20 4c 45 54 20 79 20 3d  |ze };.   LET y =|
00002ed0  20 70 2b 73 72 73 2e 68  65 61 64 65 72 3b 0a 20  | p+srs.header;. |
00002ee0  20 20 46 4f 52 20 72 20  3d 20 72 2e 30 20 54 4f  |  FOR r = r.0 TO|
00002ef0  20 72 2e 31 34 20 44 4f  20 79 20 3a 3d 20 43 6f  | r.14 DO y := Co|
00002f00  70 79 42 61 63 6b 28 6b  2e 72 65 67 2c 20 72 2c  |pyBack(k.reg, r,|
00002f10  20 79 29 3b 0a 20 20 20  46 4f 52 20 72 20 3d 20  | y);.   FOR r = |
00002f20  66 72 2e 30 20 54 4f 20  66 72 2e 37 20 44 4f 20  |fr.0 TO fr.7 DO |
00002f30  79 20 3a 3d 20 43 6f 70  79 42 61 63 6b 28 6b 2e  |y := CopyBack(k.|
00002f40  66 72 65 67 2c 20 72 2c  20 79 29 3b 0a 20 20 20  |freg, r, y);.   |
00002f50  54 4f 53 4f 66 66 73 65  74 20 3a 3d 20 73 72 73  |TOSOffset := srs|
00002f60  2e 74 6f 73 21 70 3b 0a  20 20 20 50 65 6e 64 69  |.tos!p;.   Pendi|
00002f70  6e 67 53 74 6f 72 65 73  20 3a 3d 20 73 72 73 2e  |ngStores := srs.|
00002f80  70 73 21 70 3b 0a 20 20  20 46 72 65 65 56 65 63  |ps!p;.   FreeVec|
00002f90  74 6f 72 28 70 29 20 7d  0a 0a 41 4e 44 20 49 6e  |tor(p) }..AND In|
00002fa0  74 65 72 73 65 63 74 69  6f 6e 4f 66 52 65 67 69  |tersectionOfRegi|
00002fb0  73 74 65 72 53 74 61 74  65 73 28 70 2c 20 71 29  |sterStates(p, q)|
00002fc0  20 3d 20 56 41 4c 4f 46  20 7b 0a 20 20 20 4c 45  | = VALOF {.   LE|
00002fd0  54 20 72 65 73 20 3d 20  47 65 74 56 65 63 74 6f  |T res = GetVecto|
00002fe0  72 28 73 72 73 2e 62 6c  6f 63 6b 73 69 7a 65 29  |r(srs.blocksize)|
00002ff0  3b 0a 20 20 20 4c 45 54  20 72 65 73 79 20 3d 20  |;.   LET resy = |
00003000  72 65 73 2b 73 72 73 2e  68 65 61 64 65 72 3b 0a  |res+srs.header;.|
00003010  20 20 20 4c 45 54 20 79  31 2c 20 79 32 20 3d 20  |   LET y1, y2 = |
00003020  70 2b 73 72 73 2e 68 65  61 64 65 72 2c 20 71 2b  |p+srs.header, q+|
00003030  73 72 73 2e 68 65 61 64  65 72 3b 0a 0a 20 20 20  |srs.header;..   |
00003040  49 46 20 28 43 47 44 65  62 75 67 4d 6f 64 65 26  |IF (CGDebugMode&|
00003050  64 62 2e 73 72 73 29 7e  3d 30 20 54 48 45 4e 20  |db.srs)~=0 THEN |
00003060  7b 0a 20 20 20 20 20 20  57 72 69 74 65 53 28 22  |{.      WriteS("|
00003070  46 6f 72 6d 69 6e 67 20  69 6e 74 65 72 73 65 63  |Forming intersec|
00003080  74 69 6f 6e 20 2d 2d 20  22 29 3b 0a 20 20 20 20  |tion -- ");.    |
00003090  20 20 50 72 69 6e 74 52  65 67 69 73 74 65 72 53  |  PrintRegisterS|
000030a0  74 61 74 65 28 70 29 3b  0a 20 20 20 20 20 20 50  |tate(p);.      P|
000030b0  72 69 6e 74 52 65 67 69  73 74 65 72 53 74 61 74  |rintRegisterStat|
000030c0  65 28 71 29 20 7d 3b 0a  20 20 20 46 4f 52 20 72  |e(q) };.   FOR r|
000030d0  20 3d 20 72 2e 30 20 54  4f 20 72 2e 31 34 2b 28  | = r.0 TO r.14+(|
000030e0  66 72 2e 37 2d 66 72 2e  30 2b 31 29 20 44 4f 20  |fr.7-fr.0+1) DO |
000030f0  7b 0a 20 20 20 20 20 20  54 45 53 54 20 73 72 73  |{.      TEST srs|
00003100  64 2e 73 68 69 66 74 73  74 61 74 65 21 79 31 7e  |d.shiftstate!y1~|
00003110  3d 73 72 73 64 2e 73 68  69 66 74 73 74 61 74 65  |=srsd.shiftstate|
00003120  21 79 32 20 54 48 45 4e  0a 09 20 73 72 73 64 2e  |!y2 THEN.. srsd.|
00003130  74 79 70 65 21 72 65 73  79 2c 20 73 72 73 64 2e  |type!resy, srsd.|
00003140  73 68 69 66 74 73 74 61  74 65 21 72 65 73 79 2c  |shiftstate!resy,|
00003150  20 73 72 73 64 2e 6c 6f  63 21 72 65 73 79 2c 20  | srsd.loc!resy, |
00003160  73 72 73 64 2e 73 6c 21  72 65 73 79 20 3a 3d 0a  |srsd.sl!resy :=.|
00003170  09 20 20 20 20 20 20 20  30 2c 20 30 2c 20 30 2c  |.       0, 0, 0,|
00003180  20 30 0a 20 20 20 20 20  20 45 4c 53 45 20 7b 0a  | 0.      ELSE {.|
00003190  09 20 4c 45 54 20 73 6c  31 2c 20 73 6c 32 20 3d  |. LET sl1, sl2 =|
000031a0  20 73 72 73 64 2e 73 6c  21 79 31 2c 20 73 72 73  | srsd.sl!y1, srs|
000031b0  64 2e 73 6c 21 79 32 3b  0a 09 20 73 72 73 64 2e  |d.sl!y2;.. srsd.|
000031c0  73 68 69 66 74 73 74 61  74 65 21 72 65 73 79 20  |shiftstate!resy |
000031d0  3a 3d 20 73 72 73 64 2e  73 68 69 66 74 73 74 61  |:= srsd.shiftsta|
000031e0  74 65 21 79 31 3b 0a 09  20 54 45 53 54 20 73 72  |te!y1;.. TEST sr|
000031f0  73 64 2e 74 79 70 65 21  79 31 3d 73 72 73 64 2e  |sd.type!y1=srsd.|
00003200  74 79 70 65 21 79 32 20  26 20 73 72 73 64 2e 6c  |type!y2 & srsd.l|
00003210  6f 63 21 79 31 3d 73 72  73 64 2e 6c 6f 63 21 79  |oc!y1=srsd.loc!y|
00003220  32 20 54 48 45 4e 0a 09  20 20 20 20 73 72 73 64  |2 THEN..    srsd|
00003230  2e 74 79 70 65 21 72 65  73 79 2c 20 73 72 73 64  |.type!resy, srsd|
00003240  2e 6c 6f 63 21 72 65 73  79 20 3a 3d 20 73 72 73  |.loc!resy := srs|
00003250  64 2e 74 79 70 65 21 79  31 2c 20 73 72 73 64 2e  |d.type!y1, srsd.|
00003260  6c 6f 63 21 79 31 0a 09  20 45 4c 53 45 0a 09 20  |loc!y1.. ELSE.. |
00003270  20 20 20 73 72 73 64 2e  74 79 70 65 21 72 65 73  |   srsd.type!res|
00003280  79 2c 20 73 72 73 64 2e  6c 6f 63 21 72 65 73 79  |y, srsd.loc!resy|
00003290  20 3a 3d 20 30 2c 20 30  3b 0a 09 20 73 72 73 64  | := 0, 0;.. srsd|
000032a0  2e 73 6c 21 72 65 73 79  20 3a 3d 20 30 3b 0a 09  |.sl!resy := 0;..|
000032b0  20 57 48 49 4c 45 20 73  6c 31 7e 3d 30 20 44 4f  | WHILE sl1~=0 DO|
000032c0  20 7b 0a 09 20 20 20 20  4c 45 54 20 74 2c 20 6e  | {..    LET t, n|
000032d0  20 3d 20 73 6c 2e 74 79  70 65 21 73 6c 31 2c 20  | = sl.type!sl1, |
000032e0  73 6c 2e 6c 6f 63 21 73  6c 31 3b 0a 09 20 20 20  |sl.loc!sl1;..   |
000032f0  20 49 46 20 53 4c 6f 63  49 6e 4c 69 73 74 28 73  | IF SLocInList(s|
00003300  6c 32 2c 20 74 2c 20 6e  29 7e 3d 4e 75 6c 6c 0a  |l2, t, n)~=Null.|
00003310  09 20 20 20 20 20 20 20  54 48 45 4e 20 41 64 64  |.       THEN Add|
00003320  4c 6f 63 54 6f 53 4c 28  40 73 72 73 64 2e 73 6c  |LocToSL(@srsd.sl|
00003330  21 72 65 73 79 2c 20 74  2c 20 6e 29 3b 0a 09 20  |!resy, t, n);.. |
00003340  20 20 20 73 6c 31 20 3a  3d 20 21 73 6c 31 20 7d  |   sl1 := !sl1 }|
00003350  20 7d 3b 0a 20 20 20 20  20 20 44 69 73 63 61 72  | };.      Discar|
00003360  64 53 4c 28 40 73 72 73  64 2e 73 6c 21 79 31 29  |dSL(@srsd.sl!y1)|
00003370  3b 0a 20 20 20 20 20 20  44 69 73 63 61 72 64 53  |;.      DiscardS|
00003380  4c 28 40 73 72 73 64 2e  73 6c 21 79 32 29 3b 0a  |L(@srsd.sl!y2);.|
00003390  20 20 20 20 20 20 79 31  2c 20 79 32 20 3a 3d 20  |      y1, y2 := |
000033a0  79 31 2b 73 72 73 2e 73  69 7a 65 2c 20 79 32 2b  |y1+srs.size, y2+|
000033b0  73 72 73 2e 73 69 7a 65  3b 0a 20 20 20 20 20 20  |srs.size;.      |
000033c0  72 65 73 79 20 3a 3d 20  72 65 73 79 2b 73 72 73  |resy := resy+srs|
000033d0  2e 73 69 7a 65 20 7d 3b  0a 20 20 20 73 72 73 2e  |.size };.   srs.|
000033e0  74 6f 73 21 72 65 73 20  3a 3d 20 73 72 73 2e 74  |tos!res := srs.t|
000033f0  6f 73 21 70 3d 73 72 73  2e 74 6f 73 21 71 20 2d  |os!p=srs.tos!q -|
00003400  3e 20 73 72 73 2e 74 6f  73 21 70 2c 0a 09 09 09  |> srs.tos!p,....|
00003410  09 09 20 2d 31 3b 0a 20  20 20 73 72 73 2e 70 73  |.. -1;.   srs.ps|
00003420  21 72 65 73 20 3a 3d 20  30 3b 0a 20 20 20 46 72  |!res := 0;.   Fr|
00003430  65 65 56 65 63 74 6f 72  28 70 29 3b 0a 20 20 20  |eeVector(p);.   |
00003440  46 72 65 65 56 65 63 74  6f 72 28 71 29 3b 0a 0a  |FreeVector(q);..|
00003450  20 20 20 49 46 20 28 43  47 44 65 62 75 67 4d 6f  |   IF (CGDebugMo|
00003460  64 65 26 64 62 2e 73 72  73 29 7e 3d 30 20 54 48  |de&db.srs)~=0 TH|
00003470  45 4e 20 7b 0a 20 20 20  20 20 20 57 72 69 74 65  |EN {.      Write|
00003480  53 28 22 67 69 76 69 6e  67 20 2d 2d 20 22 29 3b  |S("giving -- ");|
00003490  0a 20 20 20 20 20 20 50  72 69 6e 74 52 65 67 69  |.      PrintRegi|
000034a0  73 74 65 72 53 74 61 74  65 28 72 65 73 29 20 7d  |sterState(res) }|
000034b0  3b 0a 20 20 20 52 45 53  55 4c 54 49 53 20 72 65  |;.   RESULTIS re|
000034c0  73 20 7d 0a 0a 41 4e 44  20 46 69 6e 64 53 61 76  |s }..AND FindSav|
000034d0  65 64 53 74 61 74 65 28  6c 61 62 29 20 3d 20 56  |edState(lab) = V|
000034e0  41 4c 4f 46 20 7b 0a 20  20 20 4c 45 54 20 71 20  |ALOF {.   LET q |
000034f0  3d 20 40 53 61 76 65 64  53 74 61 74 65 73 3b 0a  |= @SavedStates;.|
00003500  20 20 20 4c 45 54 20 70  20 3d 20 21 71 3b 0a 20  |   LET p = !q;. |
00003510  20 20 57 48 49 4c 45 20  70 7e 3d 30 20 44 4f 20  |  WHILE p~=0 DO |
00003520  7b 0a 20 20 20 20 20 20  49 46 20 73 72 73 2e 6c  |{.      IF srs.l|
00003530  61 62 21 70 3d 6c 61 62  20 54 48 45 4e 20 7b 0a  |ab!p=lab THEN {.|
00003540  09 20 21 71 20 3a 3d 20  21 70 3b 20 52 45 53 55  |. !q := !p; RESU|
00003550  4c 54 49 53 20 70 20 7d  0a 20 20 20 20 20 20 71  |LTIS p }.      q|
00003560  20 3a 3d 20 70 3b 20 70  20 3a 3d 20 21 70 20 7d  | := p; p := !p }|
00003570  3b 0a 20 20 20 52 45 53  55 4c 54 49 53 20 4e 75  |;.   RESULTIS Nu|
00003580  6c 6c 20 7d 0a 0a 41 4e  44 20 53 61 76 65 53 74  |ll }..AND SaveSt|
00003590  61 74 65 46 6f 72 4c 61  62 28 6c 61 62 29 20 42  |ateForLab(lab) B|
000035a0  45 20 7b 0a 20 20 20 6c  61 62 20 3a 3d 20 54 72  |E {.   lab := Tr|
000035b0  61 6e 73 66 65 72 72 65  64 4c 61 62 65 6c 28 6c  |ansferredLabel(l|
000035c0  61 62 29 3b 0a 20 20 20  49 46 20 4c 61 62 65 6c  |ab);.   IF Label|
000035d0  46 6c 61 67 67 65 64 28  6c 61 62 2c 20 6c 61 62  |Flagged(lab, lab|
000035e0  2e 66 6f 72 77 61 72 64  6a 75 6d 70 29 20 54 48  |.forwardjump) TH|
000035f0  45 4e 20 7b 0a 20 20 20  20 20 20 4c 45 54 20 70  |EN {.      LET p|
00003600  20 3d 20 53 61 76 65 52  65 67 69 73 74 65 72 53  | = SaveRegisterS|
00003610  74 61 74 65 28 29 3b 0a  20 20 20 20 20 20 4c 45  |tate();.      LE|
00003620  54 20 73 20 3d 20 46 69  6e 64 53 61 76 65 64 53  |T s = FindSavedS|
00003630  74 61 74 65 28 6c 61 62  29 3b 0a 20 20 20 20 20  |tate(lab);.     |
00003640  20 49 46 20 73 7e 3d 4e  75 6c 6c 20 54 48 45 4e  | IF s~=Null THEN|
00003650  0a 09 20 70 20 3a 3d 20  49 6e 74 65 72 73 65 63  |.. p := Intersec|
00003660  74 69 6f 6e 4f 66 52 65  67 69 73 74 65 72 53 74  |tionOfRegisterSt|
00003670  61 74 65 73 28 70 2c 20  73 29 3b 0a 0a 20 20 20  |ates(p, s);..   |
00003680  20 20 20 73 72 73 2e 6c  61 62 21 70 20 3a 3d 20  |   srs.lab!p := |
00003690  6c 61 62 3b 0a 20 20 20  20 20 20 21 70 20 3a 3d  |lab;.      !p :=|
000036a0  20 53 61 76 65 64 53 74  61 74 65 73 3b 0a 20 20  | SavedStates;.  |
000036b0  20 20 20 20 53 61 76 65  64 53 74 61 74 65 73 20  |    SavedStates |
000036c0  3a 3d 20 70 3b 0a 20 20  20 20 20 20 49 46 20 28  |:= p;.      IF (|
000036d0  43 47 44 65 62 75 67 4d  6f 64 65 26 64 62 2e 73  |CGDebugMode&db.s|
000036e0  72 73 29 7e 3d 30 20 54  48 45 4e 20 7b 0a 09 20  |rs)~=0 THEN {.. |
000036f0  57 72 69 74 65 53 28 22  73 61 76 69 6e 67 20 22  |WriteS("saving "|
00003700  29 3b 0a 09 20 50 72 69  6e 74 52 65 67 69 73 74  |);.. PrintRegist|
00003710  65 72 53 74 61 74 65 28  70 29 20 7d 20 7d 20 7d  |erState(p) } } }|
00003720  0a 0a 2f 2f 20 4e 6f 77  20 73 6f 6d 65 20 75 73  |..// Now some us|
00003730  65 72 73 20 6f 66 20 74  68 65 20 72 65 67 69 73  |ers of the regis|
00003740  74 65 72 20 6d 65 6d 6f  72 79 0a 0a 41 4e 44 20  |ter memory..AND |
00003750  4d 6f 76 65 54 6f 41 6e  79 43 52 46 6f 72 53 74  |MoveToAnyCRForSt|
00003760  6f 72 65 54 6f 28 78 2c  20 74 2c 20 6e 29 20 3d  |oreTo(x, t, n) =|
00003770  20 56 41 4c 4f 46 20 7b  0a 20 20 20 4c 45 54 20  | VALOF {.   LET |
00003780  72 20 3d 20 4d 6f 76 65  54 6f 41 6e 79 43 52 53  |r = MoveToAnyCRS|
00003790  6f 6d 65 54 69 6d 65 46  6f 72 53 74 6f 72 65 54  |omeTimeForStoreT|
000037a0  6f 28 78 2c 20 74 2c 20  6e 29 3b 0a 20 20 20 46  |o(x, t, n);.   F|
000037b0  6c 75 73 68 50 65 6e 64  69 6e 67 4c 6f 61 64 73  |lushPendingLoads|
000037c0  46 6f 72 52 65 67 28 72  29 3b 0a 20 20 20 52 45  |ForReg(r);.   RE|
000037d0  53 55 4c 54 49 53 20 72  20 7d 0a 0a 41 4e 44 20  |SULTIS r }..AND |
000037e0  4d 6f 76 65 54 6f 41 6e  79 43 52 53 6f 6d 65 54  |MoveToAnyCRSomeT|
000037f0  69 6d 65 46 6f 72 53 74  6f 72 65 54 6f 28 78 2c  |imeForStoreTo(x,|
00003800  20 74 2c 20 6e 29 20 3d  20 56 41 4c 4f 46 20 7b  | t, n) = VALOF {|
00003810  0a 20 20 20 4c 45 54 20  72 20 3d 4e 75 6c 6c 3b  |.   LET r =Null;|
00003820  0a 20 20 20 49 46 20 68  31 21 78 3d 6b 2e 6e 75  |.   IF h1!x=k.nu|
00003830  6d 62 65 72 20 26 20 68  32 21 78 3c 30 20 54 48  |mber & h2!x<0 TH|
00003840  45 4e 20 7b 0a 20 20 20  20 20 20 54 45 53 54 20  |EN {.      TEST |
00003850  74 3d 6b 2e 6c 6f 63 20  54 48 45 4e 20 7b 0a 09  |t=k.loc THEN {..|
00003860  20 4c 45 54 20 70 20 3d  20 53 6c 6f 63 49 6e 4c  | LET p = SlocInL|
00003870  69 73 74 28 70 65 6e 64  69 6e 67 53 74 6f 72 65  |ist(pendingStore|
00003880  73 2c 20 74 2c 20 6e 2d  31 29 0a 09 20 49 46 20  |s, t, n-1).. IF |
00003890  70 7e 3d 4e 75 6c 6c 20  54 48 45 4e 20 72 20 3a  |p~=Null THEN r :|
000038a0  3d 20 70 73 2e 72 65 67  21 70 20 7d 0a 0a 20 20  |= ps.reg!p }..  |
000038b0  20 20 20 20 45 4c 53 45  20 7b 0a 09 20 72 20 3a  |    ELSE {.. r :|
000038c0  3d 20 4c 6f 6f 6b 46 6f  72 28 6e 2c 20 74 29 3b  |= LookFor(n, t);|
000038d0  0a 09 20 49 46 20 72 7e  3d 4e 75 6c 6c 20 54 48  |.. IF r~=Null TH|
000038e0  45 4e 20 7b 0a 09 20 20  20 20 4c 45 54 20 70 20  |EN {..    LET p |
000038f0  3d 20 40 70 65 6e 64 69  6e 67 53 74 6f 72 65 73  |= @pendingStores|
00003900  3b 0a 09 20 20 20 20 4c  45 54 20 6f 66 66 73 65  |;..    LET offse|
00003910  74 20 3d 20 68 34 21 6e  3b 0a 09 20 20 20 20 7b  |t = h4!n;..    {|
00003920  20 20 70 20 3a 3d 20 53  6c 6f 63 49 6e 4c 69 73  |  p := SlocInLis|
00003930  74 28 21 70 2c 20 6b 2e  69 72 65 67 2c 20 72 29  |t(!p, k.ireg, r)|
00003940  3b 0a 09 20 20 20 20 20  20 20 54 45 53 54 20 70  |;..       TEST p|
00003950  3d 4e 75 6c 6c 20 54 48  45 4e 20 7b 0a 09 09 20  |=Null THEN {... |
00003960  20 72 20 3a 3d 20 4e 75  6c 6c 3b 20 42 52 45 41  | r := Null; BREA|
00003970  4b 20 7d 0a 09 20 20 20  20 20 20 20 45 4c 53 45  |K }..       ELSE|
00003980  20 49 46 20 70 6c 2e 6f  66 66 73 65 74 21 70 3d  | IF pl.offset!p=|
00003990  6f 66 66 73 65 74 2d 31  20 54 48 45 4e 20 7b 0a  |offset-1 THEN {.|
000039a0  09 09 20 20 72 20 3a 3d  20 70 73 2e 72 65 67 21  |..  r := ps.reg!|
000039b0  70 3b 20 42 52 45 41 4b  20 7d 0a 09 20 20 20 20  |p; BREAK }..    |
000039c0  7d 20 52 45 50 45 41 54  20 7d 20 7d 3b 0a 0a 20  |} REPEAT } };.. |
000039d0  20 20 20 20 20 49 46 20  72 7e 3d 4e 75 6c 6c 20  |     IF r~=Null |
000039e0  54 48 45 4e 20 7b 0a 09  20 4c 45 54 20 73 20 3d  |THEN {.. LET s =|
000039f0  20 4e 75 6c 6c 3b 0a 09  20 49 46 20 28 43 47 44  | Null;.. IF (CGD|
00003a00  65 62 75 67 4d 6f 64 65  26 64 62 2e 72 65 67 73  |ebugMode&db.regs|
00003a10  29 7e 3d 30 0a 09 20 20  20 20 54 48 45 4e 20 57  |)~=0..    THEN W|
00003a20  72 69 74 65 46 28 22 72  25 6e 20 61 64 6a 61 63  |riteF("r%n adjac|
00003a30  65 6e 74 22 2c 20 72 29  3b 0a 09 20 73 20 3a 3d  |ent", r);.. s :=|
00003a40  20 4c 6f 6f 6b 46 6f 72  28 78 2c 20 4e 6f 74 41  | LookFor(x, NotA|
00003a50  64 64 72 29 3b 0a 09 20  49 46 20 73 3e 72 20 54  |ddr);.. IF s>r T|
00003a60  48 45 4e 20 52 45 53 55  4c 54 49 53 20 73 3b 0a  |HEN RESULTIS s;.|
00003a70  09 20 72 20 3a 3d 20 46  69 6e 64 52 65 67 69 73  |. r := FindRegis|
00003a80  74 65 72 42 65 74 77 65  65 6e 28 72 2b 31 2c 20  |terBetween(r+1, |
00003a90  72 2e 31 34 2c 20 46 41  4c 53 45 29 3b 0a 09 20  |r.14, FALSE);.. |
00003aa0  49 46 20 72 7e 3d 4e 75  6c 6c 20 54 48 45 4e 20  |IF r~=Null THEN |
00003ab0  7b 0a 09 20 20 20 20 4d  6f 76 65 54 6f 52 53 6f  |{..    MoveToRSo|
00003ac0  6d 65 54 69 6d 65 28 72  2c 20 78 29 3b 0a 09 20  |meTime(r, x);.. |
00003ad0  20 20 20 52 45 53 55 4c  54 49 53 20 72 20 7d 20  |   RESULTIS r } |
00003ae0  7d 20 7d 3b 0a 0a 20 20  20 52 45 53 55 4c 54 49  |} };..   RESULTI|
00003af0  53 20 4d 6f 76 65 54 6f  41 6e 79 43 52 53 6f 6d  |S MoveToAnyCRSom|
00003b00  65 54 69 6d 65 28 78 29  20 7d 0a 0a 41 4e 44 20  |eTime(x) }..AND |
00003b10  4d 6f 76 65 54 6f 41 6e  79 43 52 28 78 29 20 3d  |MoveToAnyCR(x) =|
00003b20  20 56 41 4c 4f 46 20 7b  0a 20 20 20 4c 45 54 20  | VALOF {.   LET |
00003b30  72 20 3d 20 4d 6f 76 65  54 6f 41 6e 79 43 52 53  |r = MoveToAnyCRS|
00003b40  6f 6d 65 54 69 6d 65 28  78 29 3b 0a 20 20 20 46  |omeTime(x);.   F|
00003b50  6c 75 73 68 50 65 6e 64  69 6e 67 4c 6f 61 64 73  |lushPendingLoads|
00003b60  46 6f 72 52 65 67 28 72  29 3b 0a 20 20 20 52 45  |ForReg(r);.   RE|
00003b70  53 55 4c 54 49 53 20 72  20 7d 0a 0a 41 4e 44 20  |SULTIS r }..AND |
00003b80  4d 6f 76 65 54 6f 41 6e  79 43 52 53 6f 6d 65 54  |MoveToAnyCRSomeT|
00003b90  69 6d 65 28 78 29 20 3d  0a 20 20 20 2f 2f 20 45  |ime(x) =.   // E|
00003ba0  6e 73 75 72 65 20 74 68  61 74 20 74 68 65 20 73  |nsure that the s|
00003bb0  69 6d 75 6c 61 74 65 64  20 73 74 61 63 6b 20 69  |imulated stack i|
00003bc0  74 65 6d 20 78 20 69 73  20 69 6e 20 61 20 72 65  |tem x is in a re|
00003bd0  67 69 73 74 65 72 2e 0a  20 20 20 2f 2f 20 54 68  |gister..   // Th|
00003be0  65 20 75 73 65 72 20 6f  66 20 74 68 69 73 20 72  |e user of this r|
00003bf0  6f 75 74 69 6e 65 20 67  75 61 72 61 6e 74 65 65  |outine guarantee|
00003c00  73 20 74 68 61 74 20 74  68 65 20 63 6f 6e 74 65  |s that the conte|
00003c10  6e 74 73 20 6f 66 0a 20  20 20 2f 2f 20 74 68 65  |nts of.   // the|
00003c20  20 72 65 67 69 73 74 65  72 20 77 69 6c 6c 20 6e  | register will n|
00003c30  6f 74 20 62 65 20 75 70  64 61 74 65 64 20 28 73  |ot be updated (s|
00003c40  6f 20 69 66 20 74 68 65  20 76 61 6c 75 65 20 69  |o if the value i|
00003c50  73 20 61 6c 72 65 61 64  79 0a 20 20 20 2f 2f 20  |s already.   // |
00003c60  69 6e 20 61 20 6c 6f 63  6b 65 64 20 72 65 67 69  |in a locked regi|
00003c70  73 74 65 72 2c 20 74 68  61 74 20 77 69 6c 6c 20  |ster, that will |
00003c80  64 6f 2e 0a 20 20 20 20  20 20 4d 6f 76 65 41 75  |do..      MoveAu|
00003c90  78 28 78 2c 20 28 7e 49  73 43 6f 6e 73 74 28 78  |x(x, (~IsConst(x|
00003ca0  29 20 26 20 68 34 21 78  7e 3d 30 29 20 7c 20 68  |) & h4!x~=0) | h|
00003cb0  32 21 78 3e 3d 30 29 0a  0a 41 4e 44 20 4d 6f 76  |2!x>=0)..AND Mov|
00003cc0  65 54 6f 41 6e 79 52 28  78 29 20 3d 20 56 41 4c  |eToAnyR(x) = VAL|
00003cd0  4f 46 20 7b 0a 20 20 20  4c 45 54 20 72 20 3d 20  |OF {.   LET r = |
00003ce0  4d 6f 76 65 54 6f 41 6e  79 52 53 6f 6d 65 54 69  |MoveToAnyRSomeTi|
00003cf0  6d 65 28 78 29 3b 0a 20  20 20 46 6c 75 73 68 50  |me(x);.   FlushP|
00003d00  65 6e 64 69 6e 67 4c 6f  61 64 73 46 6f 72 52 65  |endingLoadsForRe|
00003d10  67 28 72 29 3b 0a 20 20  20 52 45 53 55 4c 54 49  |g(r);.   RESULTI|
00003d20  53 20 72 20 7d 0a 0a 41  4e 44 20 4d 6f 76 65 54  |S r }..AND MoveT|
00003d30  6f 41 6e 79 52 53 6f 6d  65 54 69 6d 65 28 78 29  |oAnyRSomeTime(x)|
00003d40  20 3d 20 4d 6f 76 65 41  75 78 28 78 2c 20 54 52  | = MoveAux(x, TR|
00003d50  55 45 29 0a 0a 41 4e 44  20 4d 6f 76 65 41 75 78  |UE)..AND MoveAux|
00003d60  28 78 2c 20 63 6f 70 79  4c 6f 63 6b 65 64 29 20  |(x, copyLocked) |
00003d70  3d 20 56 41 4c 4f 46 20  7b 0a 20 20 20 4c 45 54  |= VALOF {.   LET|
00003d80  20 74 2c 20 6e 2c 20 6c  6f 63 20 3d 20 3f 2c 20  | t, n, loc = ?, |
00003d90  3f 2c 20 3f 3b 0a 20 20  20 52 65 6d 6f 76 65 46  |?, ?;.   RemoveF|
00003da0  61 6c 73 65 49 6e 64 69  72 65 63 74 69 6f 6e 28  |alseIndirection(|
00003db0  78 29 3b 0a 20 20 20 74  2c 20 6e 2c 20 6c 6f 63  |x);.   t, n, loc|
00003dc0  20 3a 3d 20 68 31 21 78  2c 20 2d 31 2c 20 68 33  | := h1!x, -1, h3|
00003dd0  21 78 3b 0a 20 20 20 54  45 53 54 20 31 3c 3d 41  |!x;.   TEST 1<=A|
00003de0  72 67 75 6d 65 6e 74 4e  75 6d 62 65 72 3c 3d 34  |rgumentNumber<=4|
00003df0  20 54 48 45 4e 20 7b 0a  20 20 20 20 20 20 6e 20  | THEN {.      n |
00003e00  3a 3d 20 41 72 67 75 6d  65 6e 74 52 65 67 69 73  |:= ArgumentRegis|
00003e10  74 65 72 28 41 72 67 75  6d 65 6e 74 4e 75 6d 62  |ter(ArgumentNumb|
00003e20  65 72 29 3b 0a 20 20 20  20 20 20 41 72 67 75 6d  |er);.      Argum|
00003e30  65 6e 74 4e 75 6d 62 65  72 20 3a 3d 20 4e 75 6c  |entNumber := Nul|
00003e40  6c 20 7d 0a 0a 20 20 20  45 4c 53 45 20 54 45 53  |l }..   ELSE TES|
00003e50  54 20 74 3d 6b 2e 72 65  67 20 7c 20 74 3d 6b 2e  |T t=k.reg | t=k.|
00003e60  73 68 72 65 67 20 54 48  45 4e 0a 20 20 20 20 20  |shreg THEN.     |
00003e70  20 54 45 53 54 20 63 6f  70 79 4c 6f 63 6b 65 64  | TEST copyLocked|
00003e80  20 26 0a 09 20 20 20 5b  4c 6f 63 6b 65 64 28 6c  | &..   [Locked(l|
00003e90  6f 63 2c 20 6b 2e 72 65  67 29 20 7c 0a 09 20 20  |oc, k.reg) |..  |
00003ea0  20 20 52 65 67 49 6e 50  65 6e 64 69 6e 67 4c 69  |  RegInPendingLi|
00003eb0  73 74 28 50 65 6e 64 69  6e 67 53 74 6f 72 65 73  |st(PendingStores|
00003ec0  2c 20 6c 6f 63 29 7e 3d  4e 75 6c 6c 5d 20 54 48  |, loc)~=Null] TH|
00003ed0  45 4e 0a 09 20 6e 20 3a  3d 20 4e 65 78 74 52 28  |EN.. n := NextR(|
00003ee0  29 0a 20 20 20 20 20 20  45 4c 53 45 0a 09 20 6e  |).      ELSE.. n|
00003ef0  20 3a 3d 20 6c 6f 63 0a  0a 20 20 20 45 4c 53 45  | := loc..   ELSE|
00003f00  20 49 46 20 68 32 21 78  3c 30 20 54 48 45 4e 20  | IF h2!x<0 THEN |
00003f10  7b 0a 20 20 20 20 20 20  6e 20 3a 3d 20 4c 6f 6f  |{.      n := Loo|
00003f20  6b 46 6f 72 28 78 2c 20  4e 6f 74 41 64 64 72 29  |kFor(x, NotAddr)|
00003f30  3b 0a 20 20 20 20 20 20  54 45 53 54 20 6e 3e 3d  |;.      TEST n>=|
00003f40  30 20 54 48 45 4e 0a 09  20 54 45 53 54 20 5b 63  |0 THEN.. TEST [c|
00003f50  6f 70 79 4c 6f 63 6b 65  64 20 7c 20 68 34 21 78  |opyLocked | h4!x|
00003f60  7e 3d 30 5d 20 26 0a 09  20 20 20 20 20 20 5b 4c  |~=0] &..      [L|
00003f70  6f 63 6b 65 64 28 6e 2c  20 6b 2e 72 65 67 29 20  |ocked(n, k.reg) |
00003f80  7c 0a 09 20 20 20 20 20  20 20 52 65 67 49 6e 50  ||..       RegInP|
00003f90  65 6e 64 69 6e 67 4c 69  73 74 28 50 65 6e 64 69  |endingList(Pendi|
00003fa0  6e 67 53 74 6f 72 65 73  2c 20 6e 29 7e 3d 4e 75  |ngStores, n)~=Nu|
00003fb0  6c 6c 5d 20 54 48 45 4e  0a 09 20 20 20 20 6e 20  |ll] THEN..    n |
00003fc0  3a 3d 20 4e 65 78 74 52  28 29 0a 09 20 45 4c 53  |:= NextR().. ELS|
00003fd0  45 0a 09 20 20 20 20 68  31 21 78 2c 20 68 33 21  |E..    h1!x, h3!|
00003fe0  78 20 3a 3d 20 6b 2e 72  65 67 2c 20 6e 0a 20 20  |x := k.reg, n.  |
00003ff0  20 20 20 20 45 4c 53 45  20 7b 0a 09 20 4c 45 54  |    ELSE {.. LET|
00004000  20 70 70 20 3d 20 53 6c  6f 63 49 6e 4c 69 73 74  | pp = SlocInList|
00004010  28 70 65 6e 64 69 6e 67  4c 6f 61 64 73 2c 20 74  |(pendingLoads, t|
00004020  2c 20 6c 6f 63 2d 31 29  0a 09 20 54 45 53 54 20  |, loc-1).. TEST |
00004030  70 70 7e 3d 4e 75 6c 6c  20 54 48 45 4e 20 7b 0a  |pp~=Null THEN {.|
00004040  09 20 20 20 20 4c 45 54  20 6f 74 68 65 72 52 20  |.    LET otherR |
00004050  3d 20 70 73 2e 72 65 67  21 70 70 3b 0a 09 20 20  |= ps.reg!pp;..  |
00004060  20 20 6e 20 3a 3d 20 46  69 6e 64 52 65 67 69 73  |  n := FindRegis|
00004070  74 65 72 42 65 74 77 65  65 6e 28 72 2e 30 2c 20  |terBetween(r.0, |
00004080  72 2e 31 34 2c 20 46 41  4c 53 45 29 3b 0a 09 20  |r.14, FALSE);.. |
00004090  20 20 20 54 45 53 54 20  6e 3d 4e 75 6c 6c 20 54  |   TEST n=Null T|
000040a0  48 45 4e 20 7b 0a 09 20  20 20 20 20 20 20 6e 20  |HEN {..       n |
000040b0  3a 3d 20 46 69 6e 64 52  65 67 69 73 74 65 72 42  |:= FindRegisterB|
000040c0  65 74 77 65 65 6e 28 6f  74 68 65 72 52 2b 31 2c  |etween(otherR+1,|
000040d0  20 72 2e 31 34 2c 20 54  52 55 45 29 3b 0a 09 20  | r.14, TRUE);.. |
000040e0  20 20 20 20 20 20 49 46  20 6e 3d 4e 75 6c 6c 20  |      IF n=Null |
000040f0  54 48 45 4e 20 6e 20 3a  3d 20 46 69 6e 64 52 28  |THEN n := FindR(|
00004100  29 20 7d 0a 09 20 20 20  20 45 4c 53 45 20 49 46  |) }..    ELSE IF|
00004110  20 6e 3c 3d 6f 74 68 65  72 52 20 54 48 45 4e 20  | n<=otherR THEN |
00004120  7b 0a 09 20 20 20 20 20  20 20 4c 45 54 20 72 20  |{..       LET r |
00004130  3d 20 46 69 6e 64 52 65  67 69 73 74 65 72 42 65  |= FindRegisterBe|
00004140  74 77 65 65 6e 28 6f 74  68 65 72 52 2b 31 2c 20  |tween(otherR+1, |
00004150  72 2e 31 34 2c 20 46 41  4c 53 45 29 3b 0a 09 20  |r.14, FALSE);.. |
00004160  20 20 20 20 20 20 49 46  20 72 7e 3d 4e 75 6c 6c  |      IF r~=Null|
00004170  20 54 48 45 4e 20 6e 20  3a 3d 20 72 20 7d 20 7d  | THEN n := r } }|
00004180  0a 0a 09 20 45 4c 53 45  20 54 45 53 54 20 28 56  |... ELSE TEST (V|
00004190  41 4c 4f 46 20 7b 0a 09  20 20 20 20 20 20 20 70  |ALOF {..       p|
000041a0  70 20 3a 3d 20 53 6c 6f  63 49 6e 4c 69 73 74 28  |p := SlocInList(|
000041b0  70 65 6e 64 69 6e 67 4c  6f 61 64 73 2c 20 74 2c  |pendingLoads, t,|
000041c0  20 6c 6f 63 2b 31 29 3b  0a 09 20 20 20 20 20 20  | loc+1);..      |
000041d0  20 52 45 53 55 4c 54 49  53 20 70 70 20 7d 29 7e  | RESULTIS pp })~|
000041e0  3d 4e 75 6c 6c 20 54 48  45 4e 20 7b 0a 09 20 20  |=Null THEN {..  |
000041f0  20 20 4c 45 54 20 6f 74  68 65 72 52 20 3d 20 70  |  LET otherR = p|
00004200  73 2e 72 65 67 21 70 70  3b 0a 09 20 20 20 20 6e  |s.reg!pp;..    n|
00004210  20 3a 3d 20 46 69 6e 64  52 65 67 69 73 74 65 72  | := FindRegister|
00004220  42 65 74 77 65 65 6e 28  72 2e 30 2c 20 72 2e 31  |Between(r.0, r.1|
00004230  34 2c 20 46 41 4c 53 45  29 3b 0a 09 20 20 20 20  |4, FALSE);..    |
00004240  54 45 53 54 20 6e 3d 4e  75 6c 6c 20 54 48 45 4e  |TEST n=Null THEN|
00004250  20 7b 0a 09 20 20 20 20  20 20 20 6e 20 3a 3d 20  | {..       n := |
00004260  46 69 6e 64 52 65 67 69  73 74 65 72 42 65 74 77  |FindRegisterBetw|
00004270  65 65 6e 28 72 2e 30 2c  20 6f 74 68 65 72 52 2d  |een(r.0, otherR-|
00004280  31 2c 20 54 52 55 45 29  3b 0a 09 20 20 20 20 20  |1, TRUE);..     |
00004290  20 20 49 46 20 6e 3d 4e  75 6c 6c 20 54 48 45 4e  |  IF n=Null THEN|
000042a0  20 6e 20 3a 3d 20 46 69  6e 64 52 28 29 20 7d 0a  | n := FindR() }.|
000042b0  09 20 20 20 20 45 4c 53  45 20 49 46 20 6e 3e 3d  |.    ELSE IF n>=|
000042c0  6f 74 68 65 72 52 20 54  48 45 4e 20 7b 0a 09 20  |otherR THEN {.. |
000042d0  20 20 20 20 20 20 4c 45  54 20 72 20 3d 20 46 69  |      LET r = Fi|
000042e0  6e 64 52 65 67 69 73 74  65 72 42 65 74 77 65 65  |ndRegisterBetwee|
000042f0  6e 28 72 2e 30 2c 20 6f  74 68 65 72 52 2d 31 2c  |n(r.0, otherR-1,|
00004300  20 46 41 4c 53 45 29 3b  0a 09 20 20 20 20 20 20  | FALSE);..      |
00004310  20 49 46 20 72 7e 3d 4e  75 6c 6c 20 54 48 45 4e  | IF r~=Null THEN|
00004320  20 6e 20 3a 3d 20 72 20  7d 20 7d 0a 09 20 45 4c  | n := r } }.. EL|
00004330  53 45 0a 09 20 20 20 20  6e 20 3a 3d 20 46 69 6e  |SE..    n := Fin|
00004340  64 52 28 29 3b 0a 09 20  46 6c 75 73 68 50 65 6e  |dR();.. FlushPen|
00004350  64 69 6e 67 55 73 65 73  4f 66 52 65 67 28 6e 29  |dingUsesOfReg(n)|
00004360  20 7d 20 7d 3b 0a 20 20  20 4d 6f 76 65 54 6f 52  | } };.   MoveToR|
00004370  53 6f 6d 65 54 69 6d 65  28 6e 2c 20 78 29 3b 0a  |SomeTime(n, x);.|
00004380  20 20 20 52 45 53 55 4c  54 49 53 20 68 33 21 78  |   RESULTIS h3!x|
00004390  20 7d 0a 0a 41 4e 44 20  55 73 69 6e 67 28 72 29  | }..AND Using(r)|
000043a0  20 3d 20 56 41 4c 4f 46  20 7b 0a 20 20 20 46 4f  | = VALOF {.   FO|
000043b0  52 20 74 20 3d 20 74 65  6d 70 76 20 54 4f 20 61  |R t = tempv TO a|
000043c0  72 67 31 20 42 59 20 53  53 53 69 7a 65 20 44 4f  |rg1 BY SSSize DO|
000043d0  0a 20 20 20 20 20 20 49  46 20 28 68 31 21 74 3d  |.      IF (h1!t=|
000043e0  6b 2e 72 65 67 20 7c 20  68 31 21 74 3d 6b 2e 73  |k.reg | h1!t=k.s|
000043f0  68 72 65 67 29 20 26 20  68 33 21 74 3d 72 0a 09  |hreg) & h3!t=r..|
00004400  20 54 48 45 4e 20 52 45  53 55 4c 54 49 53 20 72  | THEN RESULTIS r|
00004410  3b 0a 0a 20 20 20 52 45  53 55 4c 54 49 53 20 30  |;..   RESULTIS 0|
00004420  20 7d 0a 0a 41 4e 44 20  4e 65 78 74 52 28 29 20  | }..AND NextR() |
00004430  3d 20 56 41 4c 4f 46 20  7b 0a 20 20 20 4c 45 54  |= VALOF {.   LET|
00004440  20 72 20 3d 20 46 69 6e  64 52 28 29 3b 0a 20 20  | r = FindR();.  |
00004450  20 46 6c 75 73 68 50 65  6e 64 69 6e 67 55 73 65  | FlushPendingUse|
00004460  73 4f 66 52 65 67 28 72  29 3b 0a 20 20 20 52 45  |sOfReg(r);.   RE|
00004470  53 55 4c 54 49 53 20 72  20 7d 0a 0a 41 4e 44 20  |SULTIS r }..AND |
00004480  46 69 6e 64 52 65 67 69  73 74 65 72 42 65 74 77  |FindRegisterBetw|
00004490  65 65 6e 28 6c 6f 77 2c  20 68 69 67 68 2c 20 64  |een(low, high, d|
000044a0  69 73 63 61 72 64 29 20  3d 20 56 41 4c 4f 46 20  |iscard) = VALOF |
000044b0  7b 0a 20 20 20 53 54 41  54 49 43 20 7b 20 70 6f  |{.   STATIC { po|
000044c0  73 73 69 62 6c 65 52 20  3d 20 30 3b 20 70 6f 73  |ssibleR = 0; pos|
000044d0  73 69 62 6c 65 52 32 20  3d 20 30 20 7d 3b 0a 20  |sibleR2 = 0 };. |
000044e0  20 20 4c 45 54 20 49 73  49 74 46 72 65 65 28 72  |  LET IsItFree(r|
000044f0  2c 20 6c 6f 77 2c 20 68  69 67 68 29 20 3d 20 56  |, low, high) = V|
00004500  41 4c 4f 46 20 7b 0a 20  20 20 20 20 20 4c 45 54  |ALOF {.      LET|
00004510  20 78 20 3d 20 52 65 67  45 6e 74 72 79 28 6b 2e  | x = RegEntry(k.|
00004520  72 65 67 2c 20 72 29 3b  0a 20 20 20 20 20 20 49  |reg, r);.      I|
00004530  46 20 7e 28 6c 6f 77 3c  3d 72 3c 3d 68 69 67 68  |F ~(low<=r<=high|
00004540  29 20 54 48 45 4e 20 52  45 53 55 4c 54 49 53 20  |) THEN RESULTIS |
00004550  46 41 4c 53 45 3b 0a 20  20 20 20 20 20 49 46 20  |FALSE;.      IF |
00004560  55 73 69 6e 67 28 72 29  3d 30 20 54 48 45 4e 20  |Using(r)=0 THEN |
00004570  7b 0a 09 20 49 46 20 4c  6f 63 6b 65 64 28 72 2c  |{.. IF Locked(r,|
00004580  20 6b 2e 72 65 67 29 20  54 48 45 4e 20 52 45 53  | k.reg) THEN RES|
00004590  55 4c 54 49 53 20 46 41  4c 53 45 3b 0a 09 20 49  |ULTIS FALSE;.. I|
000045a0  46 20 70 6f 73 73 69 62  6c 65 52 3c 30 20 54 48  |F possibleR<0 TH|
000045b0  45 4e 0a 09 20 20 20 20  54 45 53 54 20 72 73 64  |EN..    TEST rsd|
000045c0  2e 73 68 69 66 74 73 74  61 74 65 21 78 7e 3d 30  |.shiftstate!x~=0|
000045d0  0a 09 20 20 20 20 20 20  20 54 48 45 4e 20 70 6f  |..       THEN po|
000045e0  73 73 69 62 6c 65 52 32  20 3a 3d 20 72 0a 09 20  |ssibleR2 := r.. |
000045f0  20 20 20 20 20 20 45 4c  53 45 20 70 6f 73 73 69  |      ELSE possi|
00004600  62 6c 65 52 20 3a 3d 20  72 3b 0a 09 20 49 46 20  |bleR := r;.. IF |
00004610  28 72 3d 72 2e 62 20 7c  20 72 3d 72 2e 31 34 29  |(r=r.b | r=r.14)|
00004620  20 26 20 6c 69 6e 6b 61  67 65 4e 6f 74 53 74 6f  | & linkageNotSto|
00004630  72 65 64 0a 09 20 20 20  20 54 48 45 4e 20 52 45  |red..    THEN RE|
00004640  53 55 4c 54 49 53 20 46  41 4c 53 45 3b 0a 09 20  |SULTIS FALSE;.. |
00004650  49 46 20 52 65 67 49 6e  50 65 6e 64 69 6e 67 4c  |IF RegInPendingL|
00004660  69 73 74 28 50 65 6e 64  69 6e 67 53 74 6f 72 65  |ist(PendingStore|
00004670  73 2c 20 72 29 3d 4e 75  6c 6c 20 26 0a 09 20 20  |s, r)=Null &..  |
00004680  20 20 52 65 67 49 6e 50  65 6e 64 69 6e 67 4c 69  |  RegInPendingLi|
00004690  73 74 28 50 65 6e 64 69  6e 67 4c 6f 61 64 73 2c  |st(PendingLoads,|
000046a0  20 72 29 3d 4e 75 6c 6c  20 26 0a 09 20 20 20 20  | r)=Null &..    |
000046b0  72 73 64 2e 74 79 70 65  21 78 3d 30 20 26 20 72  |rsd.type!x=0 & r|
000046c0  73 64 2e 73 6c 21 78 3d  30 20 54 48 45 4e 20 52  |sd.sl!x=0 THEN R|
000046d0  45 53 55 4c 54 49 53 20  54 52 55 45 20 7d 3b 0a  |ESULTIS TRUE };.|
000046e0  20 20 20 20 20 20 52 45  53 55 4c 54 49 53 20 46  |      RESULTIS F|
000046f0  41 4c 53 45 20 7d 3b 0a  0a 20 20 20 70 6f 73 73  |ALSE };..   poss|
00004700  69 62 6c 65 52 2c 20 70  6f 73 73 69 62 6c 65 52  |ibleR, possibleR|
00004710  32 20 3a 3d 20 2d 31 2c  20 2d 31 3b 0a 20 20 20  |2 := -1, -1;.   |
00004720  49 46 20 49 73 49 74 46  72 65 65 28 41 72 67 75  |IF IsItFree(Argu|
00004730  6d 65 6e 74 52 65 67 69  73 74 65 72 28 31 29 2c  |mentRegister(1),|
00004740  20 6c 6f 77 2c 20 68 69  67 68 29 0a 20 20 20 20  | low, high).    |
00004750  20 20 54 48 45 4e 20 52  45 53 55 4c 54 49 53 20  |  THEN RESULTIS |
00004760  41 72 67 75 6d 65 6e 74  52 65 67 69 73 74 65 72  |ArgumentRegister|
00004770  28 31 29 3b 0a 20 20 20  49 46 20 49 73 49 74 46  |(1);.   IF IsItF|
00004780  72 65 65 28 41 72 67 75  6d 65 6e 74 52 65 67 69  |ree(ArgumentRegi|
00004790  73 74 65 72 28 32 29 2c  20 6c 6f 77 2c 20 68 69  |ster(2), low, hi|
000047a0  67 68 29 0a 20 20 20 20  20 20 54 48 45 4e 20 52  |gh).      THEN R|
000047b0  45 53 55 4c 54 49 53 20  41 72 67 75 6d 65 6e 74  |ESULTIS Argument|
000047c0  52 65 67 69 73 74 65 72  28 32 29 3b 0a 20 20 20  |Register(2);.   |
000047d0  49 46 20 49 73 49 74 46  72 65 65 28 41 72 67 75  |IF IsItFree(Argu|
000047e0  6d 65 6e 74 52 65 67 69  73 74 65 72 28 33 29 2c  |mentRegister(3),|
000047f0  20 6c 6f 77 2c 20 68 69  67 68 29 0a 20 20 20 20  | low, high).    |
00004800  20 20 54 48 45 4e 20 52  45 53 55 4c 54 49 53 20  |  THEN RESULTIS |
00004810  41 72 67 75 6d 65 6e 74  52 65 67 69 73 74 65 72  |ArgumentRegister|
00004820  28 33 29 3b 0a 20 20 20  49 46 20 49 73 49 74 46  |(3);.   IF IsItF|
00004830  72 65 65 28 41 72 67 75  6d 65 6e 74 52 65 67 69  |ree(ArgumentRegi|
00004840  73 74 65 72 28 34 29 2c  20 6c 6f 77 2c 20 68 69  |ster(4), low, hi|
00004850  67 68 29 0a 20 20 20 20  20 20 54 48 45 4e 20 52  |gh).      THEN R|
00004860  45 53 55 4c 54 49 53 20  41 72 67 75 6d 65 6e 74  |ESULTIS Argument|
00004870  52 65 67 69 73 74 65 72  28 34 29 3b 0a 20 20 20  |Register(4);.   |
00004880  54 45 53 54 20 7e 72 65  76 65 72 73 65 64 53 74  |TEST ~reversedSt|
00004890  61 63 6b 20 7c 20 6c 69  6e 6b 61 67 65 4e 6f 74  |ack | linkageNot|
000048a0  53 74 6f 72 65 64 20 54  48 45 4e 20 7b 0a 20 20  |Stored THEN {.  |
000048b0  20 20 20 20 49 46 20 49  73 49 74 46 72 65 65 28  |    IF IsItFree(|
000048c0  72 2e 77 31 2c 20 6c 6f  77 2c 20 68 69 67 68 29  |r.w1, low, high)|
000048d0  20 54 48 45 4e 20 52 45  53 55 4c 54 49 53 20 72  | THEN RESULTIS r|
000048e0  2e 77 31 3b 0a 20 20 20  20 20 20 49 46 20 49 73  |.w1;.      IF Is|
000048f0  49 74 46 72 65 65 28 72  2e 62 2c 20 6c 6f 77 2c  |ItFree(r.b, low,|
00004900  20 68 69 67 68 29 20 20  54 48 45 4e 20 52 45 53  | high)  THEN RES|
00004910  55 4c 54 49 53 20 72 2e  62 3b 0a 20 20 20 20 20  |ULTIS r.b;.     |
00004920  20 49 46 20 55 73 65 73  46 72 61 6d 65 20 26 20  | IF UsesFrame & |
00004930  49 73 49 74 46 72 65 65  28 72 2e 31 34 2c 20 6c  |IsItFree(r.14, l|
00004940  6f 77 2c 20 68 69 67 68  29 20 54 48 45 4e 20 52  |ow, high) THEN R|
00004950  45 53 55 4c 54 49 53 20  72 2e 31 34 20 7d 0a 20  |ESULTIS r.14 }. |
00004960  20 20 45 4c 53 45 20 7b  0a 20 20 20 20 20 20 49  |  ELSE {.      I|
00004970  46 20 55 73 65 73 46 72  61 6d 65 20 26 20 49 73  |F UsesFrame & Is|
00004980  49 74 46 72 65 65 28 72  2e 31 34 2c 20 6c 6f 77  |ItFree(r.14, low|
00004990  2c 20 68 69 67 68 29 20  54 48 45 4e 20 52 45 53  |, high) THEN RES|
000049a0  55 4c 54 49 53 20 72 2e  31 34 3b 0a 20 20 20 20  |ULTIS r.14;.    |
000049b0  20 20 49 46 20 49 73 49  74 46 72 65 65 28 72 2e  |  IF IsItFree(r.|
000049c0  62 2c 20 6c 6f 77 2c 20  68 69 67 68 29 20 20 54  |b, low, high)  T|
000049d0  48 45 4e 20 52 45 53 55  4c 54 49 53 20 72 2e 62  |HEN RESULTIS r.b|
000049e0  3b 0a 20 20 20 20 20 20  49 46 20 49 73 49 74 46  |;.      IF IsItF|
000049f0  72 65 65 28 72 2e 77 31  2c 20 6c 6f 77 2c 20 68  |ree(r.w1, low, h|
00004a00  69 67 68 29 20 54 48 45  4e 20 52 45 53 55 4c 54  |igh) THEN RESULT|
00004a10  49 53 20 72 2e 77 31 20  7d 3b 0a 0a 20 20 20 49  |IS r.w1 };..   I|
00004a20  46 20 64 69 73 63 61 72  64 20 54 48 45 4e 0a 20  |F discard THEN. |
00004a30  20 20 20 20 20 54 45 53  54 20 70 6f 73 73 69 62  |     TEST possib|
00004a40  6c 65 52 3e 3d 30 20 54  48 45 4e 20 7b 0a 09 20  |leR>=0 THEN {.. |
00004a50  44 69 73 63 61 72 64 52  65 67 28 70 6f 73 73 69  |DiscardReg(possi|
00004a60  62 6c 65 52 2c 20 6b 2e  72 65 67 29 3b 20 52 45  |bleR, k.reg); RE|
00004a70  53 55 4c 54 49 53 20 70  6f 73 73 69 62 6c 65 52  |SULTIS possibleR|
00004a80  20 7d 0a 20 20 20 20 20  20 45 4c 53 45 20 49 46  | }.      ELSE IF|
00004a90  20 70 6f 73 73 69 62 6c  65 52 32 3e 3d 30 20 54  | possibleR2>=0 T|
00004aa0  48 45 4e 20 7b 0a 09 20  44 69 73 63 61 72 64 52  |HEN {.. DiscardR|
00004ab0  65 67 28 70 6f 73 73 69  62 6c 65 52 32 2c 20 6b  |eg(possibleR2, k|
00004ac0  2e 72 65 67 29 3b 20 52  45 53 55 4c 54 49 53 20  |.reg); RESULTIS |
00004ad0  70 6f 73 73 69 62 6c 65  52 32 20 7d 3b 0a 0a 20  |possibleR2 };.. |
00004ae0  20 20 52 45 53 55 4c 54  49 53 20 4e 75 6c 6c 20  |  RESULTIS Null |
00004af0  7d 0a 0a 41 4e 44 20 46  69 6e 64 52 28 29 20 3d  |}..AND FindR() =|
00004b00  20 56 41 4c 4f 46 20 7b  0a 20 20 20 4c 45 54 20  | VALOF {.   LET |
00004b10  72 20 3d 20 46 69 6e 64  52 65 67 69 73 74 65 72  |r = FindRegister|
00004b20  42 65 74 77 65 65 6e 28  72 2e 30 2c 20 72 2e 31  |Between(r.0, r.1|
00004b30  34 2c 20 54 52 55 45 29  3b 0a 20 20 20 49 46 20  |4, TRUE);.   IF |
00004b40  72 7e 3d 4e 75 6c 6c 20  54 48 45 4e 20 52 45 53  |r~=Null THEN RES|
00004b50  55 4c 54 49 53 20 72 3b  0a 0a 20 20 20 46 4f 52  |ULTIS r;..   FOR|
00004b60  20 74 20 3d 20 74 65 6d  70 76 20 54 4f 20 61 72  | t = tempv TO ar|
00004b70  67 31 20 42 59 20 53 53  53 69 7a 65 20 44 4f 0a  |g1 BY SSSize DO.|
00004b80  20 20 20 20 20 20 49 46  20 68 31 21 74 3d 6b 2e  |      IF h1!t=k.|
00004b90  72 65 67 20 26 20 7e 4c  6f 63 6b 65 64 28 68 33  |reg & ~Locked(h3|
00004ba0  21 74 2c 20 6b 2e 72 65  67 29 20 54 48 45 4e 20  |!t, k.reg) THEN |
00004bb0  7b 0a 09 20 72 20 3a 3d  20 68 33 21 74 3b 20 53  |{.. r := h3!t; S|
00004bc0  74 6f 72 65 54 28 74 29  3b 20 44 69 73 63 61 72  |toreT(t); Discar|
00004bd0  64 52 65 67 28 72 2c 20  6b 2e 72 65 67 29 3b 20  |dReg(r, k.reg); |
00004be0  52 45 53 55 4c 54 49 53  20 72 20 7d 3b 0a 0a 20  |RESULTIS r };.. |
00004bf0  20 20 42 61 63 6b 54 72  61 63 65 28 29 3b 0a 20  |  BackTrace();. |
00004c00  20 20 50 72 69 6e 74 53  69 6d 75 6c 61 74 65 64  |  PrintSimulated|
00004c10  53 74 61 63 6b 28 29 3b  0a 20 20 20 50 72 69 6e  |Stack();.   Prin|
00004c20  74 52 65 67 4c 69 73 74  28 29 3b 0a 20 20 20 43  |tRegList();.   C|
00004c30  47 45 72 72 6f 72 28 46  41 4c 53 45 2c 20 22 4e  |GError(FALSE, "N|
00004c40  6f 20 66 72 65 65 20 72  65 67 69 73 74 65 72 20  |o free register |
00004c50  66 6f 75 6e 64 20 69 6e  20 4e 65 78 74 52 22 29  |found in NextR")|
00004c60  3b 0a 20 20 20 52 45 53  55 4c 54 49 53 20 30 20  |;.   RESULTIS 0 |
00004c70  7d 0a 0a 41 4e 44 20 4c  6f 73 65 28 72 2c 20 74  |}..AND Lose(r, t|
00004c80  79 70 65 29 20 42 45 20  7b 0a 20 20 20 73 73 70  |ype) BE {.   ssp|
00004c90  20 3a 3d 20 73 73 70 2d  31 3b 0a 20 20 20 54 45  | := ssp-1;.   TE|
00004ca0  53 54 20 61 72 67 32 3d  74 65 6d 70 76 20 54 48  |ST arg2=tempv TH|
00004cb0  45 4e 20 7b 0a 20 20 20  20 20 20 68 31 21 61 72  |EN {.      h1!ar|
00004cc0  67 32 2c 20 68 32 21 61  72 67 32 2c 20 68 34 21  |g2, h2!arg2, h4!|
00004cd0  61 72 67 32 20 3a 3d 20  6b 2e 6c 6f 63 2c 20 2d  |arg2 := k.loc, -|
00004ce0  31 2c 20 30 3b 0a 20 20  20 20 20 20 68 33 21 61  |1, 0;.      h3!a|
00004cf0  72 67 32 2c 20 68 35 21  61 72 67 32 20 3a 3d 20  |rg2, h5!arg2 := |
00004d00  73 73 70 2d 32 2c 20 73  73 70 2d 32 20 7d 0a 20  |ssp-2, ssp-2 }. |
00004d10  20 20 45 4c 53 45 0a 20  20 20 20 20 20 61 72 67  |  ELSE.      arg|
00004d20  31 2c 20 61 72 67 32 20  3a 3d 20 61 72 67 32 2c  |1, arg2 := arg2,|
00004d30  20 61 72 67 32 2d 53 53  53 69 7a 65 3b 0a 0a 20  | arg2-SSSize;.. |
00004d40  20 20 68 31 21 61 72 67  31 2c 20 68 32 21 61 72  |  h1!arg1, h2!ar|
00004d50  67 31 2c 20 68 33 21 61  72 67 31 2c 20 68 34 21  |g1, h3!arg1, h4!|
00004d60  61 72 67 31 20 3a 3d 20  74 79 70 65 2c 20 2d 31  |arg1 := type, -1|
00004d70  2c 20 72 2c 20 30 3b 0a  20 20 20 68 35 21 61 72  |, r, 0;.   h5!ar|
00004d80  67 31 20 3a 3d 20 73 73  70 2d 31 3b 0a 20 20 20  |g1 := ssp-1;.   |
00004d90  44 69 73 63 61 72 64 52  65 67 28 72 2c 20 74 79  |DiscardReg(r, ty|
00004da0  70 65 29 20 7d 0a 0a 41  4e 44 20 4c 6f 73 65 52  |pe) }..AND LoseR|
00004db0  28 72 2c 20 64 29 20 42  45 20 7b 0a 20 20 20 4c  |(r, d) BE {.   L|
00004dc0  6f 73 65 28 72 2c 20 6b  2e 72 65 67 29 3b 0a 20  |ose(r, k.reg);. |
00004dd0  20 20 49 46 20 64 7e 3d  4e 75 6c 6c 20 54 48 45  |  IF d~=Null THE|
00004de0  4e 20 68 31 21 61 72 67  31 2c 20 68 34 21 61 72  |N h1!arg1, h4!ar|
00004df0  67 31 20 3a 3d 20 6b 2e  73 68 72 65 67 2c 20 64  |g1 := k.shreg, d|
00004e00  20 7d 0a 0a 41 4e 44 20  50 72 69 6e 74 53 69 6d  | }..AND PrintSim|
00004e10  75 6c 61 74 65 64 53 74  61 63 6b 28 29 20 42 45  |ulatedStack() BE|
00004e20  0a 20 20 20 46 4f 52 20  70 20 3d 20 74 65 6d 70  |.   FOR p = temp|
00004e30  76 20 54 4f 20 61 72 67  31 20 42 59 20 53 53 53  |v TO arg1 BY SSS|
00004e40  69 7a 65 20 44 4f 20 7b  0a 20 20 20 20 20 20 57  |ize DO {.      W|
00004e50  72 69 74 65 46 28 22 25  6e 3a 20 22 2c 20 70 29  |riteF("%n: ", p)|
00004e60  3b 0a 20 20 20 20 20 20  46 4f 52 20 69 20 3d 20  |;.      FOR i = |
00004e70  30 20 54 4f 20 53 53 53  69 7a 65 2d 31 20 44 4f  |0 TO SSSize-1 DO|
00004e80  20 57 72 69 74 65 46 28  22 20 25 6e 22 2c 20 70  | WriteF(" %n", p|
00004e90  21 69 29 3b 0a 20 20 20  20 20 20 4e 65 77 4c 69  |!i);.      NewLi|
00004ea0  6e 65 28 29 20 7d 0a 0a  41 4e 44 20 53 53 45 6e  |ne() }..AND SSEn|
00004eb0  74 72 79 28 6e 29 20 3d  20 56 41 4c 4f 46 20 7b  |try(n) = VALOF {|
00004ec0  0a 20 20 20 4c 45 54 20  62 61 73 65 20 3d 20 68  |.   LET base = h|
00004ed0  35 21 74 65 6d 70 76 3b  0a 20 20 20 4c 45 54 20  |5!tempv;.   LET |
00004ee0  74 6f 70 20 3d 20 68 35  21 61 72 67 31 3b 0a 20  |top = h5!arg1;. |
00004ef0  20 20 52 45 53 55 4c 54  49 53 20 62 61 73 65 3c  |  RESULTIS base<|
00004f00  3d 6e 3c 3d 74 6f 70 20  2d 3e 20 74 65 6d 70 76  |=n<=top -> tempv|
00004f10  2b 5b 53 53 53 69 7a 65  2a 28 6e 2d 62 61 73 65  |+[SSSize*(n-base|
00004f20  29 5d 2c 0a 09 09 09 20  20 20 20 4e 75 6c 6c 20  |)],....    Null |
00004f30  7d 0a 0a 41 4e 44 20 49  6e 69 74 53 74 61 63 6b  |}..AND InitStack|
00004f40  28 73 29 20 42 45 20 7b  0a 20 20 20 61 72 67 32  |(s) BE {.   arg2|
00004f50  2c 20 61 72 67 31 20 3a  3d 20 74 65 6d 70 76 2c  |, arg1 := tempv,|
00004f60  20 74 65 6d 70 76 2b 53  53 53 69 7a 65 3b 0a 20  | tempv+SSSize;. |
00004f70  20 20 73 73 70 20 3a 3d  20 73 0a 20 20 20 68 31  |  ssp := s.   h1|
00004f80  21 61 72 67 32 2c 20 68  32 21 61 72 67 32 2c 20  |!arg2, h2!arg2, |
00004f90  68 34 21 61 72 67 32 20  3a 3d 20 6b 2e 6c 6f 63  |h4!arg2 := k.loc|
00004fa0  2c 20 2d 31 2c 20 30 3b  0a 20 20 20 68 33 21 61  |, -1, 0;.   h3!a|
00004fb0  72 67 32 2c 20 68 35 21  61 72 67 32 20 3a 3d 20  |rg2, h5!arg2 := |
00004fc0  73 73 70 2d 32 2c 20 73  73 70 2d 32 3b 0a 20 20  |ssp-2, ssp-2;.  |
00004fd0  20 68 31 21 61 72 67 31  2c 20 68 32 21 61 72 67  | h1!arg1, h2!arg|
00004fe0  31 2c 20 68 34 21 61 72  67 31 20 3a 3d 20 6b 2e  |1, h4!arg1 := k.|
00004ff0  6c 6f 63 2c 20 2d 31 2c  20 30 3b 0a 20 20 20 68  |loc, -1, 0;.   h|
00005000  33 21 61 72 67 31 2c 20  68 35 21 61 72 67 31 20  |3!arg1, h5!arg1 |
00005010  3a 3d 20 73 73 70 2d 31  2c 20 73 73 70 2d 31 20  |:= ssp-1, ssp-1 |
00005020  7d 0a 0a 41 4e 44 20 4c  6f 61 64 28 61 2c 20 62  |}..AND Load(a, b|
00005030  29 20 42 45 20 7b 0a 20  20 20 61 72 67 32 20 3a  |) BE {.   arg2 :|
00005040  3d 20 61 72 67 31 3b 0a  20 20 20 61 72 67 31 20  |= arg1;.   arg1 |
00005050  3a 3d 20 61 72 67 31 2b  53 53 53 69 7a 65 3b 0a  |:= arg1+SSSize;.|
00005060  20 20 20 68 31 21 61 72  67 31 2c 20 68 32 21 61  |   h1!arg1, h2!a|
00005070  72 67 31 2c 20 68 33 21  61 72 67 31 20 3a 3d 20  |rg1, h3!arg1 := |
00005080  61 2c 20 2d 31 2c 20 62  3b 0a 20 20 20 68 34 21  |a, -1, b;.   h4!|
00005090  61 72 67 31 2c 20 68 35  21 61 72 67 31 20 3a 3d  |arg1, h5!arg1 :=|
000050a0  20 30 2c 20 73 73 70 3b  0a 20 20 20 73 73 70 20  | 0, ssp;.   ssp |
000050b0  3a 3d 20 73 73 70 2b 31  20 7d 0a 0a 41 4e 44 20  |:= ssp+1 }..AND |
000050c0  53 77 61 70 53 53 28 78  2c 20 79 29 20 42 45 20  |SwapSS(x, y) BE |
000050d0  7b 0a 20 20 20 4c 45 54  20 61 2c 20 62 2c 20 63  |{.   LET a, b, c|
000050e0  2c 20 64 20 3d 20 68 31  21 79 2c 20 68 32 21 79  |, d = h1!y, h2!y|
000050f0  2c 20 68 33 21 79 2c 20  68 34 21 79 3b 0a 20 20  |, h3!y, h4!y;.  |
00005100  20 68 31 21 79 2c 20 68  32 21 79 2c 20 68 33 21  | h1!y, h2!y, h3!|
00005110  79 2c 20 68 34 21 79 20  3a 3d 20 68 31 21 78 2c  |y, h4!y := h1!x,|
00005120  20 68 32 21 78 2c 20 68  33 21 78 2c 20 68 34 21  | h2!x, h3!x, h4!|
00005130  78 3b 0a 20 20 20 68 31  21 78 2c 20 68 32 21 78  |x;.   h1!x, h2!x|
00005140  2c 20 68 33 21 78 2c 20  68 34 21 78 20 3a 3d 20  |, h3!x, h4!x := |
00005150  61 2c 20 62 2c 20 63 2c  20 64 20 7d 0a 0a 41 4e  |a, b, c, d }..AN|
00005160  44 20 53 74 61 63 6b 28  6e 29 20 42 45 20 7b 0a  |D Stack(n) BE {.|
00005170  20 20 20 44 65 6c 4c 6f  63 73 41 62 6f 76 65 28  |   DelLocsAbove(|
00005180  6e 2b 31 2c 20 54 52 55  45 29 3b 0a 0a 20 20 20  |n+1, TRUE);..   |
00005190  49 46 20 6e 3e 3d 73 73  70 2b 34 20 54 48 45 4e  |IF n>=ssp+4 THEN|
000051a0  20 7b 0a 20 20 20 20 20  20 53 74 6f 72 65 28 30  | {.      Store(0|
000051b0  2c 20 73 73 70 29 3b 0a  20 20 20 20 20 20 49 6e  |, ssp);.      In|
000051c0  69 74 53 74 61 63 6b 28  6e 29 3b 0a 20 20 20 20  |itStack(n);.    |
000051d0  20 20 52 45 54 55 52 4e  20 7d 3b 0a 0a 20 20 20  |  RETURN };..   |
000051e0  57 48 49 4c 45 20 6e 3e  73 73 70 20 44 4f 20 4c  |WHILE n>ssp DO L|
000051f0  6f 61 64 28 6b 2e 6c 6f  63 2c 20 73 73 70 29 3b  |oad(k.loc, ssp);|
00005200  0a 0a 6c 3a 20 49 46 20  6e 3d 73 73 70 20 54 48  |..l: IF n=ssp TH|
00005210  45 4e 20 52 45 54 55 52  4e 3b 0a 20 20 20 49 46  |EN RETURN;.   IF|
00005220  20 61 72 67 32 7e 3d 74  65 6d 70 76 20 54 48 45  | arg2~=tempv THE|
00005230  4e 20 7b 0a 20 20 20 20  20 20 61 72 67 31 20 3a  |N {.      arg1 :|
00005240  3d 20 61 72 67 32 3b 0a  20 20 20 20 20 20 61 72  |= arg2;.      ar|
00005250  67 32 20 3a 3d 20 61 72  67 32 2d 53 53 53 69 7a  |g2 := arg2-SSSiz|
00005260  65 3b 0a 20 20 20 20 20  20 73 73 70 20 3a 3d 20  |e;.      ssp := |
00005270  73 73 70 2d 31 3b 0a 20  20 20 20 20 20 47 4f 54  |ssp-1;.      GOT|
00005280  4f 20 6c 20 7d 3b 0a 0a  20 20 20 49 46 20 6e 3d  |O l };..   IF n=|
00005290  73 73 70 2d 31 20 54 48  45 4e 20 7b 0a 20 20 20  |ssp-1 THEN {.   |
000052a0  20 20 20 46 4f 52 20 68  20 3d 20 68 31 20 54 4f  |   FOR h = h1 TO|
000052b0  20 68 35 20 44 4f 20 68  21 61 72 67 31 20 3a 3d  | h5 DO h!arg1 :=|
000052c0  20 68 21 61 72 67 32 3b  0a 20 20 20 20 20 20 73  | h!arg2;.      s|
000052d0  73 70 20 3a 3d 20 6e 3b  0a 20 20 20 20 20 20 68  |sp := n;.      h|
000052e0  31 21 61 72 67 32 2c 20  68 32 21 61 72 67 32 2c  |1!arg2, h2!arg2,|
000052f0  20 68 34 21 61 72 67 32  20 3a 3d 20 6b 2e 6c 6f  | h4!arg2 := k.lo|
00005300  63 2c 20 2d 31 2c 20 30  3b 0a 20 20 20 20 20 20  |c, -1, 0;.      |
00005310  68 33 21 61 72 67 32 2c  20 68 35 21 61 72 67 32  |h3!arg2, h5!arg2|
00005320  20 3a 3d 20 73 73 70 2d  32 2c 20 73 73 70 2d 32  | := ssp-2, ssp-2|
00005330  3b 0a 20 20 20 20 20 20  52 45 54 55 52 4e 20 7d  |;.      RETURN }|
00005340  3b 0a 0a 20 20 20 49 6e  69 74 53 74 61 63 6b 28  |;..   InitStack(|
00005350  6e 29 20 7d 0a 0a 41 4e  44 20 53 74 6f 72 65 28  |n) }..AND Store(|
00005360  70 2c 20 72 29 20 42 45  0a 20 20 20 46 4f 52 20  |p, r) BE.   FOR |
00005370  74 20 3d 20 74 65 6d 70  76 20 54 4f 20 61 72 67  |t = tempv TO arg|
00005380  31 20 42 59 20 53 53 53  69 7a 65 20 44 4f 20 7b  |1 BY SSSize DO {|
00005390  0a 20 20 20 20 20 20 4c  45 54 20 73 20 3d 20 68  |.      LET s = h|
000053a0  35 21 74 3b 0a 20 20 20  20 20 20 49 46 20 73 3e  |5!t;.      IF s>|
000053b0  72 20 54 48 45 4e 20 52  45 54 55 52 4e 3b 0a 20  |r THEN RETURN;. |
000053c0  20 20 20 20 20 49 46 20  73 3e 3d 70 20 54 48 45  |     IF s>=p THE|
000053d0  4e 20 53 74 6f 72 65 54  28 74 29 20 7d 0a 0a 41  |N StoreT(t) }..A|
000053e0  4e 44 20 53 74 6f 72 65  54 28 78 29 20 42 45 20  |ND StoreT(x) BE |
000053f0  7b 0a 20 20 20 4c 45 54  20 68 35 78 20 3d 20 68  |{.   LET h5x = h|
00005400  35 21 78 3b 0a 20 20 20  4c 45 54 20 74 2c 20 69  |5!x;.   LET t, i|
00005410  2c 20 6c 6f 63 2c 20 6f  20 3d 20 68 31 21 78 2c  |, loc, o = h1!x,|
00005420  20 68 32 21 78 2c 20 68  33 21 78 2c 20 68 34 21  | h2!x, h3!x, h4!|
00005430  78 0a 20 20 20 55 4e 4c  45 53 53 20 74 3d 6b 2e  |x.   UNLESS t=k.|
00005440  6c 6f 63 20 26 20 69 3c  30 20 26 20 6f 3d 30 20  |loc & i<0 & o=0 |
00005450  26 20 6c 6f 63 3d 68 35  78 20 54 48 45 4e 20 7b  |& loc=h5x THEN {|
00005460  0a 20 20 20 20 20 20 4c  45 54 20 6e 20 3d 20 52  |.      LET n = R|
00005470  65 67 69 73 74 65 72 44  65 64 69 63 61 74 65 64  |egisterDedicated|
00005480  54 6f 4c 6f 63 28 68 35  78 29 3b 0a 20 20 20 20  |ToLoc(h5x);.    |
00005490  20 20 4c 45 54 20 73 74  6f 72 65 4e 65 65 64 65  |  LET storeNeede|
000054a0  64 2c 20 69 6e 46 52 20  3d 20 54 52 55 45 2c 20  |d, inFR = TRUE, |
000054b0  46 41 4c 53 45 3b 0a 20  20 20 20 20 20 4c 45 54  |FALSE;.      LET|
000054c0  20 77 61 73 74 6f 73 20  3d 20 3f 3b 0a 20 20 20  | wastos = ?;.   |
000054d0  20 20 20 4c 45 54 20 64  20 3d 20 6e 3b 0a 0a 20  |   LET d = n;.. |
000054e0  20 20 20 20 20 54 45 53  54 20 74 3d 6b 2e 66 72  |     TEST t=k.fr|
000054f0  65 67 20 26 20 69 3c 30  20 26 20 6f 3d 30 20 54  |eg & i<0 & o=0 T|
00005500  48 45 4e 0a 09 20 69 6e  46 52 20 3a 3d 20 54 52  |HEN.. inFR := TR|
00005510  55 45 0a 20 20 20 20 20  20 45 4c 53 45 20 54 45  |UE.      ELSE TE|
00005520  53 54 20 6e 3d 4e 75 6c  6c 20 54 48 45 4e 0a 09  |ST n=Null THEN..|
00005530  20 6e 20 3a 3d 20 4d 6f  76 65 54 6f 41 6e 79 43  | n := MoveToAnyC|
00005540  52 53 6f 6d 65 54 69 6d  65 46 6f 72 53 74 6f 72  |RSomeTimeForStor|
00005550  65 54 6f 28 78 2c 20 6b  2e 6c 6f 63 2c 20 68 35  |eTo(x, k.loc, h5|
00005560  78 29 0a 20 20 20 20 20  20 45 4c 53 45 20 7b 0a  |x).      ELSE {.|
00005570  09 20 4d 6f 76 65 54 6f  52 53 6f 6d 65 54 69 6d  |. MoveToRSomeTim|
00005580  65 28 6e 2c 20 78 29 3b  0a 09 20 73 74 6f 72 65  |e(n, x);.. store|
00005590  4e 65 65 64 65 64 20 3a  3d 20 46 41 4c 53 45 20  |Needed := FALSE |
000055a0  7d 3b 0a 0a 20 20 20 20  20 20 54 45 53 54 20 69  |};..      TEST i|
000055b0  6e 46 52 20 54 48 45 4e  0a 09 20 54 45 53 54 20  |nFR THEN.. TEST |
000055c0  64 7e 3d 4e 75 6c 6c 20  54 48 45 4e 0a 09 20 20  |d~=Null THEN..  |
000055d0  20 20 4d 6f 76 65 46 52  54 6f 52 28 6c 6f 63 2c  |  MoveFRToR(loc,|
000055e0  20 64 2c 20 78 29 0a 09  20 45 4c 53 45 20 7b 0a  | d, x).. ELSE {.|
000055f0  09 20 20 20 20 4c 45 54  20 62 2c 20 6e 20 3d 20  |.    LET b, n = |
00005600  72 2e 70 2c 20 68 35 78  3b 0a 09 20 20 20 20 54  |r.p, h5x;..    T|
00005610  45 53 54 20 75 73 65 73  46 72 61 6d 65 20 54 48  |EST usesFrame TH|
00005620  45 4e 0a 09 20 20 20 20  20 20 20 49 46 20 6c 69  |EN..       IF li|
00005630  6e 6b 61 67 65 4e 6f 74  53 74 6f 72 65 64 20 54  |nkageNotStored T|
00005640  48 45 4e 20 62 20 3a 3d  20 72 2e 74 73 0a 09 20  |HEN b := r.ts.. |
00005650  20 20 20 45 4c 53 45 0a  09 20 20 20 20 20 20 20  |   ELSE..       |
00005660  62 2c 20 6e 20 3a 3d 20  72 2e 74 73 2c 20 6e 2d  |b, n := r.ts, n-|
00005670  73 61 76 65 53 70 61 63  65 53 69 7a 65 3b 0a 09  |saveSpaceSize;..|
00005680  20 20 20 20 6e 20 3a 3d  20 28 6e 65 78 74 53 74  |    n := (nextSt|
00005690  61 63 6b 57 6f 72 64 2f  42 79 74 65 73 50 65 72  |ackWord/BytesPer|
000056a0  57 6f 72 64 29 2a 6e 3b  0a 09 20 20 20 20 77 61  |Word)*n;..    wa|
000056b0  73 74 6f 73 20 3a 3d 20  44 69 73 63 61 72 64 41  |stos := DiscardA|
000056c0  64 64 72 65 73 73 28 6b  2e 6c 6f 63 2c 20 68 35  |ddress(k.loc, h5|
000056d0  78 29 3b 0a 09 20 20 20  20 54 45 53 54 20 77 61  |x);..    TEST wa|
000056e0  73 74 6f 73 20 7c 20 68  35 78 3d 54 4f 53 4f 66  |stos | h5x=TOSOf|
000056f0  66 73 65 74 20 54 48 45  4e 20 7b 0a 09 20 20 20  |fset THEN {..   |
00005700  20 20 20 20 46 4f 52 20  6e 20 3d 20 68 35 78 2d  |    FOR n = h5x-|
00005710  31 20 54 4f 20 34 20 42  59 20 2d 31 20 44 4f 20  |1 TO 4 BY -1 DO |
00005720  7b 0a 09 09 20 20 4c 45  54 20 70 20 3d 20 53 6c  |{...  LET p = Sl|
00005730  6f 63 49 6e 4c 69 73 74  28 50 65 6e 64 69 6e 67  |ocInList(Pending|
00005740  53 74 6f 72 65 73 2c 20  6b 2e 6c 6f 63 2c 20 6e  |Stores, k.loc, n|
00005750  29 3b 0a 09 09 20 20 49  46 20 70 7e 3d 4e 75 6c  |);...  IF p~=Nul|
00005760  6c 20 54 48 45 4e 20 7b  0a 09 09 20 20 20 20 20  |l THEN {...     |
00005770  46 6c 75 73 68 50 65 6e  64 69 6e 67 53 74 6f 72  |FlushPendingStor|
00005780  65 73 55 70 54 6f 28 70  29 3b 0a 09 09 20 20 20  |esUpTo(p);...   |
00005790  20 20 42 52 45 41 4b 20  7d 20 7d 3b 0a 09 20 20  |  BREAK } };..  |
000057a0  20 20 20 20 20 49 46 20  68 35 78 3d 54 4f 53 4f  |     IF h5x=TOSO|
000057b0  66 66 73 65 74 20 54 48  45 4e 20 54 4f 53 4f 66  |ffset THEN TOSOf|
000057c0  66 73 65 74 20 3a 3d 20  54 4f 53 4f 66 66 73 65  |fset := TOSOffse|
000057d0  74 2b 31 0a 09 20 20 20  20 20 20 20 53 74 6f 72  |t+1..       Stor|
000057e0  65 46 52 28 6c 6f 63 2c  20 72 2e 74 73 2c 20 66  |eFR(loc, r.ts, f|
000057f0  2e 70 6f 73 74 2f 2a 66  2e 77 62 20 69 6d 70 6c  |.post/*f.wb impl|
00005800  69 65 64 2a 2f 2c 20 31  29 20 7d 0a 09 20 20 20  |ied*/, 1) }..   |
00005810  20 45 4c 53 45 0a 09 20  20 20 20 20 20 20 53 74  | ELSE..       St|
00005820  6f 72 65 46 52 28 6c 6f  63 2c 20 62 2c 20 66 2e  |oreFR(loc, b, f.|
00005830  70 72 65 2c 20 6e 29 3b  0a 09 20 77 61 73 74 6f  |pre, n);.. wasto|
00005840  73 20 3a 3d 20 53 74 6f  72 65 52 28 6b 2e 66 72  |s := StoreR(k.fr|
00005850  65 67 2c 20 6c 6f 63 2c  20 6b 2e 6c 6f 63 2c 20  |eg, loc, k.loc, |
00005860  68 35 78 29 20 7d 0a 20  20 20 20 20 20 45 4c 53  |h5x) }.      ELS|
00005870  45 20 7b 0a 09 20 77 61  73 74 6f 73 20 3a 3d 20  |E {.. wastos := |
00005880  53 74 6f 72 65 52 28 6b  2e 72 65 67 2c 20 6e 2c  |StoreR(k.reg, n,|
00005890  20 6b 2e 6c 6f 63 2c 20  68 35 78 29 3b 0a 09 20  | k.loc, h5x);.. |
000058a0  49 46 20 53 74 6f 72 65  4e 65 65 64 65 64 20 54  |IF StoreNeeded T|
000058b0  48 45 4e 0a 09 20 20 20  20 54 45 53 54 20 68 35  |HEN..    TEST h5|
000058c0  78 3d 54 4f 53 4f 66 66  73 65 74 20 54 48 45 4e  |x=TOSOffset THEN|
000058d0  20 7b 0a 09 20 20 20 20  20 20 20 41 64 64 54 6f  | {..       AddTo|
000058e0  50 65 6e 64 69 6e 67 53  74 6f 72 65 73 28 6e 2c  |PendingStores(n,|
000058f0  20 6b 2e 6c 6f 63 2c 20  68 35 78 2c 20 54 52 55  | k.loc, h5x, TRU|
00005900  45 2c 20 30 29 3b 0a 09  20 20 20 20 20 20 20 54  |E, 0);..       T|
00005910  4f 53 4f 66 66 73 65 74  20 3a 3d 20 54 4f 53 4f  |OSOffset := TOSO|
00005920  66 66 73 65 74 2b 31 20  7d 0a 09 20 20 20 20 45  |ffset+1 }..    E|
00005930  4c 53 45 0a 09 20 20 20  20 20 20 20 41 64 64 54  |LSE..       AddT|
00005940  6f 50 65 6e 64 69 6e 67  53 74 6f 72 65 73 28 6e  |oPendingStores(n|
00005950  2c 20 6b 2e 6c 6f 63 2c  20 68 35 78 2c 20 77 61  |, k.loc, h5x, wa|
00005960  73 74 6f 73 2c 20 30 29  20 7d 3b 0a 20 20 20 20  |stos, 0) };.    |
00005970  20 20 68 31 21 78 2c 20  68 32 21 78 2c 20 68 33  |  h1!x, h2!x, h3|
00005980  21 78 2c 20 68 34 21 78  20 3a 3d 20 6b 2e 6c 6f  |!x, h4!x := k.lo|
00005990  63 2c 20 2d 31 2c 20 68  35 78 2c 20 30 20 7d 20  |c, -1, h5x, 0 } |
000059a0  7d 0a 0a 41 4e 44 20 49  73 53 69 6d 70 6c 65 53  |}..AND IsSimpleS|
000059b0  74 6f 72 65 4c 6f 63 28  78 29 20 3d 20 56 41 4c  |toreLoc(x) = VAL|
000059c0  4f 46 20 7b 0a 20 20 20  4c 45 54 20 74 79 70 65  |OF {.   LET type|
000059d0  20 3d 20 68 31 21 78 3b  0a 20 20 20 52 45 53 55  | = h1!x;.   RESU|
000059e0  4c 54 49 53 20 68 32 21  78 3c 30 20 26 0a 09 20  |LTIS h2!x<0 &.. |
000059f0  20 20 20 28 74 79 70 65  3d 6b 2e 6c 6f 63 20 7c  |   (type=k.loc ||
00005a00  20 74 79 70 65 3d 6b 2e  6c 61 62 20 7c 20 74 79  | type=k.lab | ty|
00005a10  70 65 3d 6b 2e 73 74 61  74 69 63 20 7c 20 74 79  |pe=k.static | ty|
00005a20  70 65 3d 6b 2e 67 6c 6f  62 29 20 7d 0a 0a 41 4e  |pe=k.glob) }..AN|
00005a30  44 20 49 73 49 6e 54 68  65 53 74 61 63 6b 28 78  |D IsInTheStack(x|
00005a40  29 20 3d 20 68 31 21 78  3d 6b 2e 6c 6f 63 20 26  |) = h1!x=k.loc &|
00005a50  20 68 32 21 78 3c 30 20  26 20 68 34 21 78 3d 30  | h2!x<0 & h4!x=0|
00005a60  0a 0a 41 4e 44 20 43 6c  61 73 73 28 78 2c 20 46  |..AND Class(x, F|
00005a70  69 6e 64 43 6f 70 79 29  20 3d 20 56 41 4c 4f 46  |indCopy) = VALOF|
00005a80  0a 20 20 20 54 45 53 54  20 68 32 21 78 3e 3d 30  |.   TEST h2!x>=0|
00005a90  20 54 48 45 4e 0a 20 20  20 20 20 20 52 45 53 55  | THEN.      RESU|
00005aa0  4c 54 49 53 20 61 74 79  70 65 0a 20 20 20 45 4c  |LTIS atype.   EL|
00005ab0  53 45 20 53 57 49 54 43  48 4f 4e 20 68 31 21 78  |SE SWITCHON h1!x|
00005ac0  20 49 4e 54 4f 0a 20 20  20 7b 20 20 43 41 53 45  | INTO.   {  CASE|
00005ad0  20 6b 2e 6e 75 6d 62 65  72 3a 20 52 45 53 55 4c  | k.number: RESUL|
00005ae0  54 49 53 20 6b 74 79 70  65 0a 20 20 20 20 20 20  |TIS ktype.      |
00005af0  43 41 53 45 20 6b 2e 6c  6f 63 3a 0a 20 20 20 20  |CASE k.loc:.    |
00005b00  20 20 43 41 53 45 20 6b  2e 67 6c 6f 62 3a 0a 20  |  CASE k.glob:. |
00005b10  20 20 20 20 20 43 41 53  45 20 6b 2e 73 74 61 74  |     CASE k.stat|
00005b20  69 63 3a 0a 20 20 20 20  20 20 43 41 53 45 20 6b  |ic:.      CASE k|
00005b30  2e 6c 61 62 3a 20 20 20  20 49 46 20 68 34 21 78  |.lab:    IF h4!x|
00005b40  3d 30 20 54 48 45 4e 0a  09 09 09 49 46 20 7e 46  |=0 THEN....IF ~F|
00005b50  69 6e 64 43 6f 70 79 20  7c 20 4c 6f 6f 6b 46 6f  |indCopy | LookFo|
00005b60  72 28 78 2c 20 4e 6f 74  41 64 64 72 29 3c 30 20  |r(x, NotAddr)<0 |
00005b70  54 48 45 4e 0a 09 09 09  20 20 20 52 45 53 55 4c  |THEN....   RESUL|
00005b80  54 49 53 20 61 74 79 70  65 0a 20 20 20 20 20 20  |TIS atype.      |
00005b90  44 45 46 41 55 4c 54 3a  09 20 20 20 20 20 52 45  |DEFAULT:.     RE|
00005ba0  53 55 4c 54 49 53 20 72  74 79 70 65 0a 20 20 20  |SULTIS rtype.   |
00005bb0  20 20 20 43 41 53 45 20  6b 2e 73 68 72 65 67 3a  |   CASE k.shreg:|
00005bc0  20 20 52 45 53 55 4c 54  49 53 20 73 68 69 66 74  |  RESULTIS shift|
00005bd0  65 64 72 74 79 70 65 0a  20 20 20 20 20 20 43 41  |edrtype.      CA|
00005be0  53 45 20 6b 2e 72 65 67  3a 20 20 20 20 52 45 53  |SE k.reg:    RES|
00005bf0  55 4c 54 49 53 20 6c 6f  63 6b 65 64 28 68 33 21  |ULTIS locked(h3!|
00005c00  78 2c 20 6b 2e 72 65 67  29 20 2d 3e 20 6c 6f 63  |x, k.reg) -> loc|
00005c10  6b 65 64 72 74 79 70 65  2c 0a 09 09 09 09 09 20  |kedrtype,...... |
00005c20  20 20 20 20 20 72 74 79  70 65 20 7d 0a 0a 41 4e  |     rtype }..AN|
00005c30  44 20 49 73 43 6f 6e 73  74 28 78 29 20 3d 20 56  |D IsConst(x) = V|
00005c40  41 4c 4f 46 0a 20 20 20  54 45 53 54 20 68 31 21  |ALOF.   TEST h1!|
00005c50  78 3d 6b 2e 6e 75 6d 62  65 72 20 26 20 68 32 21  |x=k.number & h2!|
00005c60  78 3c 30 20 54 48 45 4e  20 7b 0a 20 20 20 20 20  |x<0 THEN {.     |
00005c70  20 68 33 21 78 20 3a 3d  20 68 33 21 78 2b 68 34  | h3!x := h3!x+h4|
00005c80  21 78 3b 20 68 34 21 78  20 3a 3d 20 30 3b 0a 20  |!x; h4!x := 0;. |
00005c90  20 20 20 20 20 52 45 53  55 4c 54 49 53 20 54 52  |     RESULTIS TR|
00005ca0  55 45 20 7d 0a 20 20 20  45 4c 53 45 0a 20 20 20  |UE }.   ELSE.   |
00005cb0  20 20 20 52 45 53 55 4c  54 49 53 20 46 41 4c 53  |   RESULTIS FALS|
00005cc0  45 0a                                             |E.|
00005cc2