On Wed, 13 Oct 2004 at 15:24 +0200, Daniel Schürmann <schuerm...@svea.de> wrote:

> From: Daniel Schürmann <schuerm...@svea.de>
>
> i might have found a problem with code generation and optimization.
>
> I use the command:
> msp430-gcc -mmcu=msp430x1132 -g -O2 -Wall   -c -o Merten_Argus.o 
> Merten_Argus.c
>
> This shows insight im mixed View:
>  <<MA_get_brigtness.mix>>
> Here are the *.i and *.s files:
>  <<Merten_Argus.i>>  <<Merten_Argus.s>>
> In Funktion MA_get_brightness, the statement:
>
> buff *= im_SegA.im.MA_gain_multipier;
>
> is not compiled correctly. But when I delete the irrelevant line
>
> buff  = (U32)(MA_brightness & 0x07ff );
>
> or switch off the optimization, everything works as desired.

Are you asking why mspgcc seems to be assuming that
im_SegA.im.MA_gain_multipier is a constant 32?
    (The compiler sees that buff was initialized to 500,
    and 16000/500 is 32)

The assignment of 500 to buff is after the line you deleted,
so it is surprising that that would have affected the results,
although I can see how turning off optimizaton would probably
force the multiply to be fully performed.

        355             buff = 500;
        356
        357             if( im_SegA.im.MA_gain_multipier ){
-       0xefb4  <MA_get_brightness+18>:         cmp.b   #0,     &0x1011 ;subst 
r3 with As==00
-       0xefb8  <MA_get_brightness+22>:         jz      $+64            ;abs 
dst addr 0xeff8
        358                     // Berechnung <FC>ber Gain
        359                     buff *= im_SegA.im.MA_gain_multipier;
-       0xefba  <MA_get_brightness+24>:         mov     #16000, r12     ;#0x3e80
-       0xefbe  <MA_get_brightness+28>:         clr     r13             ;


ps.
 was  Merten_Argus.i really the whole preprocessed output?

Reply via email to