Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
MESC TOOL NEWS: MESCT-CC32R-991016D

CC32R Precaution

Please take note of the following problem in using cross-tool kit CC32R for the M32R family of microcomputers.


  1. Versions Concerned
    CC32R V.1.00 Release1 -- V.2.00 Release1

  2. Problem
    When compiling files written in the C language which include conditional statements expressions that compares constant 1 with the result of an operation, codes that incorrectly compare positions between bits may be generated. In such a case, conditional branches will not be performed correctly.

  3. Conditions
    This problem occurs if the following three conditions are satisfied:
    3.1 An optimizing option (-O1, -O3, -O5, or -O7) is used at compilation.
    3.2 Codes generated at compilation are maintained to function the register for making decision of branches at the end of the execution sequence.
    3.3 Any of the following conditional expressions is described in a C-language source file:
    (1)a conditional expression that compares (==,!=) constant 1 with the result of a division operation where
    • the dividend is a variable and
    • the divisor is a constant of 0x80000000
      [Example]
       -------------------------------------------------------------
      | int a
      | if ((a / 0x80000000) == 1) {
      |     ....
      | }
       -------------------------------------------------------------
      
    (2)a conditional expression that compares (==,!=) constant 1 with the result of a right shift operation where
    • the value to be shifted is a variable of type unsigned and
    • the shift count is a constant of 31
      [Example]    
       -------------------------------------------------------------
      | unsigned int a;
      | if ((a >> 31) == 1) {
      |     ....
      | }
       -------------------------------------------------------------
      
    (3)A conditional expression that compares (==,!=) constant 1 with such a member variable of a bit field that
    • the bit length is 1 and
    • the type is unsigned
      [Example]
       -------------------------------------------------------------
      | struct bitf {
      |         unsigned int    a : 1;
      |         ....
      | } BIT;
      | if (BIT.a == 1) {
      |         ....
      | }
       -------------------------------------------------------------
      
  4. Workaround
    This problem will be circumvented by either of the following ways:
    (1)Modifying the source program
    Temporarily assign the result of an operation or a variable in a conditional expression to an external variable declared as volatile;
    then use the external variable in the above conditional expression.
    [Example of modifying the conditional expression in 3.3-(2) above]
     ------------------------------------------------------------------
    | volatile unsigned int tmp;
    | void foo()
    | {
    |        unsigned int a;
    |
    |        tmp = a >> 31;
    |        if (tmp == 1) {
    |             ....
    |        }
    |        ...
    | }
     ------------------------------------------------------------------
    
    (2)Changing optimizing options
    Use an optimizing option -O2, -O4, or -O6 in place of -O1, -O3, -O5, or -O7.





© 2008. Renesas Technology Corp., All rights reserved. Privacy | Legal