Hi all,

There seems to be a bug in the optimiser. When multplying unsigned longs by 
65536
it fails to zero the lower half. If instead you shift 16 places left, it works.

Here is a test case:

unsigned long x, y;

void main(void) {
        x = (x * 65536UL) + 1UL;
        y = (y << 16) + 1UL;
}

compiled with gcc 3.2.3 + mspgcc CVS as of 3/27/2004:
msp430-gcc -mmcu=msp430x449 -S  -O1 test.c

results in this code:
/***********************
 * Function `main'
 ***********************/
main:
/* prologue: frame size = 0 */
.L__FrameSize_main=0x0
.L__FrameOffset_main=0x0
        mov     #(__stack-0), r1
/* prologue end (size=2) */
        mov     &x, r15
        add     #llo(1), r14        <<<<<<< r14 uninitialized
        addc    #lhi(1), r15
        mov     r14, &x
        mov     r15, &x+2
        mov     &y, r15
        mov     #llo(0), r14        <<<<<<< here OK
        add     #llo(1), r14
        addc    #lhi(1), r15
        mov     r14, &y
        mov     r15, &y+2
/* epilogue: frame size=0 */
        br      #__stop_progExec__
/* epilogue end (size=4) */
/* function main size 25 (19) */
.Lfe1:
        .size   main,.Lfe1-main
/********* End of function ******/

regards,
Francisco


Reply via email to