JMGross wrote:
:
The second approach does an 8x8 bit multiplication, resulting in a 16 bit
intermediate result. This delivers the correct value to the following division.
But in the first approach, the compiler could optimize the whole thing to a
((A<<8)-A)
>
> which is faster and smaller than a multiplication with 255.
> Unfortunately this might be done on 8 bit range, dropping the upper 8
> bit,
:
Also this seems to be elegant, it is wrong, because uint8_t has to be
promoted to int, which is 16bit and will yield the correct result in
both cases.
It seems, that mspgcc is doing something wrong with int promotion!?
Also it seems to be an mspgcc bug, because a native gcc3.2.3 compiler on
Debian/386 showed the correct results.
Hardy