----- Ursprüngliche Nachricht -----
Von: Hardy Griech
Gesendet am: 30 Apr 2009 22:49:02

> You can follow the thread on the Contiki mailing list: 
> http://sourceforge.net/mailarchive/forum.php?forum_name=contiki-developers

thanks.

>> p.s.: in theory, the whole calculation could be done at compile time, in 
>> both cases, since all values are known and no variable is declared volatile.

>Perhaps this will be done, if you switch optimization on?

When testing it, I used optimization. I didn't test without (I just added the 
code to an existing project main file for testing)


----- Ursprüngliche Nachricht -----
Von: Conrado_Porto_Lopes_Gouv
Gesendet am: 30 Apr 2009 23:38:10
Betreff: Re: [Mspgcc-users] Fwd: DEFINEd value messes up 8-bit multiplication. 
Why?]

>> As we can see, the compiler directly calculates the result of 255*3 to -3 
>> (0xfffd). And here is the problem. Somehow the 255 gets interpreted as -1 
>> signed 8-bit instead of 255 unsigned 16 bit.

>Wild guess: what happens if you change the define to:
>#define PRR_SCALE ((uint8_t) 255)
>or add a cast in the expression?

Hey, 'Wild Guess' is MY trademark :)
It should work with casts, but the main question is: why is 255 interpreted as 
-1 at all? The compiler should notice that 255 constant is beyond signed char 
range and cast it to signed/unsigned INT as 255. No reson 
(other than the compiler misbehaving) to explicitely cast anything.


----- Ursprüngliche Nachricht -----
Von: Hardy Griech
Gesendet am: 01 Mai 2009 09:20:25

>Forwarded from Ward:

>The same compiler version as reported by Frederik Hermans:

>w...@virtualubuntu8:/$ msp430-gcc -v
>Configured with: ../src/configure --target=msp430 --host=i486-linux-gnu
>--build=i486-linux-gnu --prefix=/usr --mandir=${prefix}/share/man
>--infodir=${prefix}/share/info
>Thread model: single
>gcc version 3.2.3

Okay, it's mspgcc (and I already confirmed, that the bug is there).
Unfortunately, the message does not state the mspgcc build but only the gcc 
version it is based on. And this hasn't changed for quite a few mspgcc 
versions. (feature suggestion!)
Anyways, my older version has the bug and I guess the newer ones too.
So someone with cvs access should take a deeper look into the constant value 
parsing algorithm and constant expression evaluation.

JMGross

Reply via email to