Jan,<br><br>The solution I have adopted is to define ML_PXBR_TEST as<br><br>#define ML_PXBR_TEST(r) { int32 r2 = (r);                                 \<br>                        if (((r2 & 0x80000000) == 0) ||                          \<br>
                             (r2 & 0x00000003)) RSVD_OPND_FAULT; \<br>                        }<br><br>This works on CentOS 5.5. <br><br>There are 3 differences between my version and yours:<br><br>1) I left in an extra set of bracked around r2 & ......., just because of my paranoia<br>
2) I believe your version has a typo of one bracket missing just after the "if"<br>3) I have defined the internal block variable (r2, in my case) to be int32. I have done this because the variable t in op_ldpctx and val in op_mtpr are defined as int32. I am not claiming that I am right and you are wrong, just that that is my reason. uint32 does feel like it should be correct, but then surely t and val should be defined as uint32 as well.<br>
<br>I think this level of complication in the macro is as far as it is sensible to go because the original, simpler version should work. It is only (I believe) a bug in the compiler that we are trying to work around and you can never second guess what any future bug might throw up.<br>
<br>Anyway, I now have a working VAX-11/780 emulator that I am happy with.<br><br>Thanks for everyone's help with this.<br><br>Peter Allan<br><br><br><div class="gmail_quote">On 6 January 2011 12:22, Jan-Benedict Glaw <span dir="ltr"><<a href="mailto:jbglaw@lug-owl.de">jbglaw@lug-owl.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">On Thu, 2011-01-06 02:48:30 -0700, Tim Riker <Tim@Rikers.org> wrote:<br>

> On 01/03/2011 12:57 PM, Jason Stevens wrote:<br>
> > wait, it should have been more like this<br>
> ><br>
> ><br>
> > > #define ML_SBR_TEST(r) if (((uint32)(r)) & 0xC000003u) != 0) RSVD_OPND_FAULT<br>
> > > #define ML_PXBR_TEST(r) if (((((uint32)(r)) & 0x80000000u) == 0) || \<br>
> > >                            (((uint32)(r)) & 0x40000003u) != 0))<br>
> > > RSVD_OPND_FAULT<br>
> ><br>
> > into this:<br>
> ><br>
> > #define ML_SBR_TEST(r)  if (((uint32)(r) & 0xC0000003u)!=0) RSVD_OPND_FAULT<br>
> ><br>
> > #define ML_PXBR_TEST(r) if (((((uint32)r) & 0x80000000u) == 0) || \<br>
> >                             (((uint32)r) & 0x40000003u)!=0) RSVD_OPND_FAULT<br>
> You want the typecast to apply after any math that might be happening in<br>
> the expression r.<br>
><br>
> You should include r in parentheses in the expansion. ie: not (uint32)r<br>
> ever, but instead (uint32)(r) so that r is evaluated first before<br>
> typecast is applied.<br>
<br>
</div>In terms of correctness, there are several things that could be made<br>
better:<br>
<br>
First of all, `r' is used twice here. The current uses seem sane, but<br>
what, if `r' contained side effects (pre/post inc/dec etc.)? That<br>
could probably be written as:<br>
<br>
#define ML_PXBR_TEST(r) {                                               \<br>
                                uint32 ____t = (r);                     \<br>
                                if ((____t & 0x80000000u) == 0) ||      \<br>
                                    ____t & 0x40000003u)                \<br>
                                        RSVD_OPND_FAULT;                \<br>
                        }<br>
<br>
That would ensure `r' being evaluated only once. And it would<br>
introduce a block around the if () ...;  construct. Think of:<br>
<br>
        if (foo)<br>
                ML_PXBR_TEST (x);<br>
        else<br>
                do_something ();<br>
<br>
Looks sane, but would work totally irrational with the original macro.<br>
To accept a `;' after the closing brace of the block, maybe a do/while<br>
should be added (as eg. the Linux kernel code does it):<br>
<br>
#define ML_PXBR_TEST(r) do {                                            \<br>
                                uint32 ____t = (r);                     \<br>
                                if ((____t & 0x80000000u) == 0) ||      \<br>
                                    ____t & 0x40000003u)                \<br>
                                        RSVD_OPND_FAULT;                \<br>
                        } while (0)<br>
<br>
Comments?<br>
<br>
MfG, JBG<br>
<font color="#888888"><br>
--<br>
      Jan-Benedict Glaw      <a href="mailto:jbglaw@lug-owl.de">jbglaw@lug-owl.de</a>              +49-172-7608481<br>
  Signature of:                          Zensur im Internet? Nein danke!<br>
  the second  :<br>
</font><br>-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG v1.4.9 (GNU/Linux)<br>
<br>
iEYEARECAAYFAk0ltA4ACgkQHb1edYOZ4bsjSACgkLWEJqvZh1JPurUcvL9WgJnp<br>
wGMAniIIQYEMEQCgIkvh3jk1OGgijDj5<br>
=DG6c<br>
-----END PGP SIGNATURE-----<br>
<br>_______________________________________________<br>
Simh mailing list<br>
<a href="mailto:Simh@trailing-edge.com">Simh@trailing-edge.com</a><br>
<a href="http://mailman.trailing-edge.com/mailman/listinfo/simh" target="_blank">http://mailman.trailing-edge.com/mailman/listinfo/simh</a><br></blockquote></div><br>