woodelf wrote:
9000 VAX wrote:
> I met a problem in Watcom C 11.0. I uses wcl which makes 8086 code.
> The code is running on a 386. I got wired result with
> printf("%x %x %x ",inportb(H_ADDR2), inportb(H_ADDR1), inportb(H_ADDR0));
>
> but the following code worked as expected,
> printf("%x ", inportb(H_ADDR2));
> printf("%x ",inportb(H_ADDR1));
> printf("%x ", inportb(H_ADDR0));
The order of evaluation of arguments to functions is
undefined in C. A compiler may evaluate left-to-right,
or right-to-left or in some other sequence, you just
can't control it. The second example forces the
compiled code to evaluate the 'inportb' expressions
in sequence. Could the order of the reads from the
port make a difference?
Would 'volatile' help in this case?
No, I don't think so.
--
John Honniball
coredump at gifford.co.uk