Jens Kilian wrote:
/* model internal state of address register */
int N;
Most of your problem can be dealt with by making N volatile and making
RD be or call a function (it could be inline so there is no extra overhead).
if (RD(42) == RD(23))
But that still wouldn't control which of RD(42) or RD(23) happens
first. Did you expect to control that?
The compiler can't resequence volatile accesses across "sequence points".
With RD as a macro, you have:
if ( (writeit(42), readit()) == (writeit(23), readit()) )
I'm think the comma is a sequence point between each writeit and the
corresponding readit, but I don't think you have any sequence point
between either readit an the non corresponding writeit. If RD were or
called an inline function, there would be plenty of sequence points
between either readit an the non corresponding writeit.