Re: A89: What's wrong with _rowread???
[Prev][Next][Index][Thread]
Re: A89: What's wrong with _rowread???
Hi!
Just to know: the current implemenentation of _rowread is a bit buggy.
The problem is that in some cases the compiler (more precise, the
optimizer) can move _rowread out of loop, and this can be fatal. This
is because the compiler concludes that _rowread constantly read the
same memory location, and it think that this need not to be into the
loop. The fool compiler does not know that 0x60001B is not a memory
location, but an I/O port. This is a common problem in C compilers
whenever you access to memory-mapped I/O ports. One usage of keyword
"volatile" is dedicated just to preventing unwanted optimizations
when they must not be performed. So, the problem with _rowread is
solved in TIGCCLIB 2.3 (by making this address volatile), which will
appear, together with TIGCC 0.9, in next 3-4 days. In addition, the
new compiler will have the native floating point support!!!
By the way, problem of reading I/O ports may be problematic in
general. See the following code:
while (*(unsigned char *)0x600017 != 255);
The compiler will make this (virtually correct) code into an
endless loop. The code which works correctly should be:
while (*(volatile unsigned char *)0x600017 != 255);
To make the life easier, I introduced peekIO function (macro) in
TIGCCLIB 2.3, so you can write easily:
while (peekIO (0x600017) != 255);
In general, you should use peekIO always for reading I/O ports.
Cheers,
Zeljko Juric