[Simh] O2 optimization on Linux

Bob Supnik bob at supnik.org
Mon Jan 3 12:47:28 EST 2011


Well, the 780 microcode is complicated and patched to fare-thee-well, 
but it uses absolutely common code for the tests on P0BR and P1BR.  [The 
PDFs are on line at Bitsaver.]  Based on the comments, the actual tests are:

1) Offset P1BR by 0x800000 (2**23).
2) Test PxBR<1:0> = 0.
3) Test PxBR<31> = 1.
4) Test PxBR<30> = 0.  [this is missing in SimH]

For SBR, it's:

1) Test SBR<1:0> = 0.
2) Test SBR<31:30> = 0. [this is missing in SimH]

So while SimH may not be SRM conformant, it follows the 780 microcode 
more or less faithfully; in particular, by using a common macro for 
testing P0BR and P1BR.  Remember, SimH is a hardware simulator, not an 
architectural simulator.

So I would venture that the "right" formulation of these tests is:

#define ML_SBR_TEST(r)  if ((r) & 0xC000003) RSVD_OPND_FAULT
#define ML_PXBR_TEST(r) if ((((r) & 0x80000000) == 0) || \
                             ((r) & 0x40000003)) RSVD_OPND_FAULT

Of course, you can throw in whatever casts, etc, you want to add to make 
the code 64b proof; and also the != 0 that good C coding seems to imply 
these days:

#define ML_SBR_TEST(r) if (((uint32)(r)) & 0xC000003u) != 0) RSVD_OPND_FAULT
#define ML_PXBR_TEST(r) if (((((uint32)(r)) & 0x80000000u) == 0) || \
                             (((uint32)(r)) & 0x40000003u) != 0)) 
RSVD_OPND_FAULT

The ANSI C standard says that hex constants are unsigned by default, so 
I really don't think all the u's are needed.

Remember, the problem is unique to one version of the C compiler, with 
CentOS 5.5.  It works everywhere else.

/Bob



More information about the Simh mailing list