Included below is a small piece of code that attempts
to "shift down" some unsigned long's in an array. The
2nd assignment in "shiftArray()" fails:
// Code start --- mspgcc_bug.c ---------------------------------
//
unsigned long temp[3] = {
0x11112222L,
0x33334444L,
0x00000000L
};
void shiftArray(unsigned long *t)
{
t[2] = t[1]; // OK - Code generated was (r15 is pointer to temp):
// mov 4(r15), 8(r15)
// mov 6(r15), 10(r15)
t[1] = t[0]; // Fails - Generated code:
// mov @r15+, 4(r15)
// mov @r15+, 6(r15)
}
int main(void)
{
shiftArray(temp);
return 0;
}
//
// Code end ---------------------------------------------
The problem is that r15 is being autoincremented in the last
two fetches/sources. It's also being used as an index for the
destination, without compensating for the fact that the fetches
have altered r15.
Background info:
OS: Redhat 9.0
Tools: Built from sources, Oct 20, 2003
CPU: MSP430F149
Cmd Line: msp430-gcc -mmcu=msp430x149 -O2 -Wall -g -o mspgcc_bug
mspgcc_bug.c
Am I doing something stupid, or is this really a compiler bug?
Thanks,
Mike