Hi,

this is a message from the Contiki mailing list describing a potential bug in mspgcc.

Hardy

-------- Original Message --------
Subject:        [Contiki-developers] Fwd: DEFINEd value messes up 8-bit
multiplication. Why?
Date:   Mon, 27 Apr 2009 15:18:29 +0200
From:   Ward Van Heddeghem (VUB) <[email protected]>
Reply-To:       Contiki developer mailing list
<[email protected]>
To:     Contiki developers list <[email protected]>



I've posted this question on stackoverflow as well
(http://stackoverflow.com/questions/791638/).
And it's analysed as a bug in the msp430 compiler.

Can anybody confirm this?
Doesn't this potentially affect a lot of the existing contiki code when
compiling for sky nodes?

regards,
Ward

----- Original message -----
From: "Ward Van Heddeghem (VUB)" <[email protected]>
To: "Contiki developers list" <[email protected]>
Date: Mon, 27 Apr 2009 00:20:27 +0200
Subject: [Contiki-developers] DEFINEd value messes up 8-bit
multiplication. Why?


Hi,

I have a problem with multiplication when I compile for the sky platform.

I have the following C code:

|#define PRR_SCALE 255
...
uint8_t a = 3;
uint8_t b = 4;
uint8_t prr;
prr = (PRR_SCALE * a) / b;
printf("prr: %u\n", prr);
|

If I compile this the result is 0 while I expected 191.

If I change it to:

|uint8_t a = 3;
uint8_t b = 4;
uint8_t c = 255;
uint8_t prr;
prr = (c * a) / b;
printf("prr: %u\n", prr);
|

it works out correctly and prints 191.

Compiling a simple version of this 'normally' using gcc on an Ubuntu box
prints the correct value in both cases.

I am not exactly sure why this is. I could circumvent it by assigning
the DEFINEd value to a variable beforehand, but I'd rather not do that.

Anybody any idea why this is happening? And what the best way is to
handle this?

regards,
Ward
------------------------------------------------------------------------------
Crystal Reports &#45; New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty&#45;free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Contiki-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/contiki-developers
------------------------------------------------------------------------------
Crystal Reports &#45; New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty&#45;free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Contiki-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/contiki-developers

Reply via email to