Hi Robert,

I'm having trouble with mspgcc version 3.2.3 accessing a variable
that's been declared as volatile twice, when my code refers to it
only once.  This is a problem because that variable happens to be
I2CIV, the value of which changes upon access.
... Snip
Is this a known problem?  Is there a fix in a later version of gcc?

I have not seen this issue before, although I had noticed some thing like it with switching in the timer interrupt vectors and had not tracked it down.

I did some testing and gcc-3.2 on i386 generates the same code sequence, and gcc-4.1.0 (i386) is ok.

mspgcc-3.2.3 is really the only working option, Ill have a look at gcc-3.3.4 (really the only other option for a working version of gcc, gcc 4.xx is not working due to problems in the machine description file).

Interestingly this generates the correct code:

volatile int test;
int main( void )
{
  int i;

  switch( test )
    {
    case 0: i = 1; break;
    case 1: i = 2; break;
    case 2: i = 3; break;
    case 3: i = 4; break;
    case 4: i = 5; break;
    case 5: i = 6; break;
    case 6: i = 7; break;
    case 700: i = 8; break;
    }
}

as does

volatile int test;
int main( void )
{
  int i;

  switch( test )
    {
    case 0: i = 1; break;
    case 1: i = 2; break;
    case 2: i = 3; break;
    case 3: i = 4; break;
    case 4: i = 5; break;
    case 5: i = 6; break;
    case 6: i = 7; break;
    case 7: i = 8; break;
    default: i = 0; break;
    }
}

as does

volatile int test;
int main( void )
{
  int i;
  int j;

  j = test;

  switch( j )
    {
    case 0: i = 1; break;
    case 1: i = 2; break;
    case 2: i = 3; break;
    case 3: i = 4; break;
    case 4: i = 5; break;
    case 5: i = 6; break;
    case 6: i = 7; break;
    case 7: i = 8; break;
    }
}

So yes gcc-3.2.3 generates broken code in some case, there are many options to make it generate the correct code, I suspect the problem is somewhere in the gcc-3.2 language processing part, not in the msp430 backend.

Regards,

--
Peter Jansen
STS
Antarctic Division
203 Channel Highway
Kingston
TAS  7050
AUSTRALIA
Phone +61 3 6232 3533

___________________________________________________________________________

   Australian Government Antarctic Division - Commonwealth of Australia
IMPORTANT: This transmission is intended for the addressee only. If you are not 
the
intended recipient, you are notified that use or dissemination of this 
communication is
strictly prohibited by Commonwealth law. If you have received this transmission 
in error,
please notify the sender immediately by e-mail or by telephoning +61 3 6232 
3209 and
DELETE the message.
       Visit our web site at http://www.aad.gov.au/
___________________________________________________________________________

Reply via email to