CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Optimisation levels

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
EdWaugh



Joined: 07 Dec 2004
Posts: 127
Location: Southampton, UK

View user's profile Send private message

Optimisation levels
PostPosted: Tue Jan 20, 2009 4:30 am     Reply with quote

Hi all,

I've managed to get myself the latest version of the compiler and was having a play with the optimisation settings. I normally use 9 so I was trying 10 and 11.

At level 10 the following code gets broken and calculates incorrect results:
Code:

uint16_t generate_16bit_crc(uint8_t* data, uint16_t length, uint16_t pattern)
{
   uint8_t* current_data;
   uint16_t crc_Dbyte;
   uint16_t byte_counter;
   uint8_t bit_counter;

   current_data = (uint8_t*)(data + 2);
   crc_Dbyte =  make16(data[0], data[1]);

   for(byte_counter=0; byte_counter < (length-2); byte_counter++)
   {
      for(bit_counter=0; bit_counter < 8; bit_counter++)
      {
         if(!bit_test(crc_Dbyte,15))
         {
            crc_Dbyte <<= 1;
            bit_test(*current_data, 7 - bit_counter) ?
               bit_set(crc_Dbyte,0) : bit_clear(crc_Dbyte,0);
            continue;
         }
         crc_Dbyte <<= 1;
         bit_test(*current_data, 7 - bit_counter) ?
            bit_set(crc_Dbyte,0) : bit_clear(crc_Dbyte,0);
         crc_Dbyte ^= pattern;
      }
      current_data++;
   }

   for(bit_counter=0; bit_counter < 16; bit_counter++)
   {
      if(!bit_test(crc_Dbyte,15))
      {
         crc_Dbyte <<= 1;
         continue;
      }
      crc_Dbyte <<= 1;
      crc_Dbyte ^= pattern;
   }

   return crc_Dbyte;
}


This is actually just the CCS CRC generator from v3. Setting opt to 9 makes this work correctly, at level 10 it calculates incorrect CRCs and at 11 I get the compiler error:

Internal Error - Contact CCS LABEL SCR=18907

I have also emailed CCS, any thoughts about this and what is the best opt level to stick to would be appreciated.

thanks

ed[/code]
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jan 20, 2009 2:38 pm     Reply with quote

I never change the default #opt level. I just consider the other levels
to be experimental. If you want to find the problem, print out the .LST
files for both #opt levels and compare the ASM code.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group