! Program which just sits in a loop looking at its registers to see
! whether they're still what it expects them to be.

%option "-low"

%systemroutinespec phex(%integer i)

%begin
   %recordformat r fm(%integerarray d, a(0 : 7))
   %ownrecord(r fm) r, s
   %integer i
   %label L, error
the top:
      A0 = addr(r)
      *movem.l D0-D7/A0-A7, (A0)
   L: ! Compare all the registers with what we've stored
      *cmp.l   (A0), D0
      *bne error
      *cmp.l  4(A0), D1
      *bne error
      *cmp.l  8(A0), D2
      *bne error
      *cmp.l 12(A0), D3
      *bne error
      *cmp.l 16(A0), D4
      *bne error
      *cmp.l 20(A0), D5
      *bne error
      *cmp.l 24(A0), D6
      *bne error
      *cmp.l 28(A0), D7
      *bne error
      *cmp.l 32(A0), A0
      *bne error
      *cmp.l 36(A0), A1
      *bne error
      *cmp.l 40(A0), A2
      *bne error
      *cmp.l 44(A0), A3
      *bne error
      *cmp.l 48(A0), A4
      *bne error
      *cmp.l 52(A0), A5
      *bne error
      *cmp.l 56(A0), A6
      *bne error
      *cmp.l 60(A0), A7
      *bne error
      !! %stop
      -> L
error:
      A0 = addr(s)
      *movem.l D0-D7/A0-A7, (A0)
      printstring("Got registers:");  newline
      %for i = 0, 1, 7 %cycle
         space
         phex(s_d(i))
      %repeat
      newline
      %for i = 0, 1, 7 %cycle
         space
         phex(s_a(i))
      %repeat
      newline
      printstring("Expecting registers:");  newline
      %for i = 0, 1, 7 %cycle
         space
         phex(r_d(i))
      %repeat
      newline
      %for i = 0, 1, 7 %cycle
         space
         phex(r_a(i))
      %repeat
      newline
      -> the top
%end %of %program
