Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
MAEC TOOL NEWS: MAECT-NC30WA-010816D

NC30WA
Precaution

Please take note of the following problem in using C compiler NC30WA (with an assembler and integrated development environment) for the M16C/60 and M16C/20 series MCUs.
  • On testing equality or inequality (== or !=) between a bit field greater than 2 bits and an immediate value of 0 (zero)


  1. Versions Concerned
    NC30WA V.2.00 Release 1 -- V.4.00 Release 2

  2. Description
    Testing equality or inequality of a bit field greater than 2 bits that is of type signed long or unsigned long with immediate value 0 (zero) may result in incorrect code being generated.

  3. Conditions
    This problem occurs if the following two conditions are satisfied:
    (1) There exists a bit field greater than 2 bits that is of type unsigned long or signed long, extending across a 16-bit word boundary.
    (2) Equality or inequality (== or !=) between a bit field satisfying condition (1) and immediate value 0 is tested in the conditional expression of a control statement (if, while, or for).

  4. Example
    ---------------------------------------------------------------
      struct _BitF {
              long    b1:10;         /* Condition (1) */
              long    b2:10;
              long    b2:12;
      } bf;
    
      void func(void)
      {
              if(bf.b2 != 0){        /* Condition (2) */
                     :
              }
      }
    ---------------------------------------------------------------
  5. Workaround
    Assign the bit field concerned to a temporary variable, and then perform equality or inequality test of the variable and immediate value 0.
    [Example of modification:]
    ---------------------------------------------------------------
      void func(void){
         unsigned long tmp;
         tmp = bf.b2;        // Assign a bit field to a temporary variable
         if(tmp != 0){       // Inequality of the temporary variable with 
                             // immediate value 0 tested
                     :
         }
     }
    ---------------------------------------------------------------
  6. Schedule of Fixing the Problem
    We plan to fix this problem in our next release.




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