Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
MESC TOOL NEWS: MESCT-NC308WA-010116D

NC308WA
Precaution

Please take note of the following problems in using C compiler with an assembler and integrated development environment NC308WA for the M16C/80 series of MCUs:
  • On bitwise exclusive OR operations
  • On "if" statements with expressions testing bit fields
  • On multiplications of long or unsigned long type expressions
  • On generating the MAX instruction


  1. Problem on Bitwise Exclusive OR operations
    1.1 Version Concerned
    NC308WA V.3.10 Release 1

    1.2 Description
    Compiling the C source file described a bitwise exclusive OR operation may result incorrect code being generated.

    1.3 Conditions
    This problem occurs if the following three conditions are satisfied:
    (1) A bitwise exclusive OR operation is performed between a variable and a constant.
    (2) The constant in (1) is the nth power of 2 (n: an integer).
    (3) The result of the bitwise exclusive OR operation is stored in another variable.

    1.4 Example
         ------------------------------------------------------------------
         unsigned int    a, b;
         void func(void)
         {
             a = b ^ 0x0080;        /* Conditions (1), (2), and (3): 
                                    0x0080 is the seventh power of 2 */
         }
         ------------------------------------------------------------------
    
    1.5 Workaround
    Use the same variable as the operand and the destination of a bitwise exclusive OR operation.
         ------------------------------------------------------------------
         unsigned int    a, b;
         void func(void)
         {
             unsigned int    t;      /* Declares a temporary variable */
             t = b;
             t = t ^ 0x0080;         /* The destination and the operand 
                                     of an operation are the same */
             a = t;
         }
         ------------------------------------------------------------------
    
    1.6 Workaround
    We plan to fix this problem in our next release.



    NC308WA Precaution
    MESCT-NC308WA-010116D

  2. Problem on "if" Statements with Expressions Testing Bit Fields
    2.1 Versions Concerned
    NC308WA V.3.00 Release 1 and V.3.10 Release 1

    2.2 Description
    When an expression performing logical AND operations of bit fields are described in an if statement, incorrect code may be generated.

    2.3 Conditions
    This problem occurs if the following ten conditions are satisfied simultaneously:
    (1) A single if statement or nested if statements are described.
    (2) A controlling expression in an if construct tests four bit fields.
    (3) All the bit fields in (2) are 1 bit wide each.
    (4) All the bit fields in (2) are contained in the same structure.
    (5) In the bit fields in (2), the low-order bit position has an offset of 0.
    (6) The bit fields in (2) are not assigned to continuous bit positions 0 through 3.
    (7) The following are used as expressions testing bit fields in (2), where "b" and "s" represent a bit field and the structure containing b respectively:
    • s.b
    • !s.b
    • s.b == 1
    • s.b != 1
    • s.b == 0
    • s.b != 0
    (8) When two or more expressions testing bit fields exist in one controlling expression, they are all joined by the logical AND operator (&&).
    (9) The program is compiled using both the -O4 and the -OR options or the -O5 and the -OR options.
    (10) Option -ONLOC (-Ono_logical_or_combine) is not used.

    2.4 Example
         -----------------------------------------------------------------
         struct bits {
             char    b0:1;        /* Conditions (3), (4), (5), and (6) */
             char    b1:1;
             char    dummy:1;     /* This field not used */
             char    b3:1;
             char    b4:1;
         } s;
         
         int     i, j;
    
         /* Condition (1): a single if statement */
         void func1(void)
         {
             if (s.b0 && !s.b1 && (s.b3 == 1) && (s.b4 != 1)) {  
                                         /* Conditions (2), (7), and (8) */
                 i++;
             }
             j++;
         }
    
         /* Condition (1): nested if statements */
         void func2(void)
         {
             if (s.b0 && !s.b1) {        /* Conditions (2), (7), and (8) */
                 if (!s.b3 && s.b4) {    /* Conditions (2), (7), and (8) */
                     i++;
                 }
             }
             j++;
         }
         -----------------------------------------------------------------
    
    2.5 Workaround
    Use option -ONLOC (-Ono_logical_or_combine) at compilation.

    2.6 Schedule of Fixing Problem
    We plan to fix this problem in our next release.



    NC308WA Precaution
    MESCT-NC308WA-010116D

  3. Problem on Multiplications of Long or Unsigned Long Type Expressions
    3.1 Version Concerned
    NC308WA V.3.10 Release 1

    3.2 Description
    When multiply operations of long or unsigned long type variables are described, System Error may arise at compilation.

    3.3 Conditions
    This problem occurs if the following three conditions are satisfied:
    (1) Either or both of the operands in a multiplication are expressions of type long.
    (2) Either or both of the operands in a multiplication are not plain variables but expressions with operations (including implicit type conversion).
    (3) Option -OS is used.

    3.4 Examples
         ------------------------------------------------------------------
         long    l, m;
         char    c;
         
         void func(void)
         {
             l = c * l;          /* Example 1: Conditions (1) and (2) 
                                               (implicit type conversion) */
             m = m * (l + 1);    /* Example 2: Conditions (1) and (2) */
         }
         ------------------------------------------------------------------
    
    3.5 Workaround
    Temporarily assign the expression used as an operand in a multiplication to a variable of type long; then, perform the multiply operation using this variable.
         ------------------------------------------------------------------
         long    l, m;
         char    c;
         
         void func(void)
         {
             long    t;
             
             t = (long)c;    /* Circumvents Example 1 */
             l = t * l;
             
             t = l + 1;      /* Circumvents Example 2 */
             m = m * t;
         }
         ------------------------------------------------------------------
    
    3.6 Schedule of Fixing Problem
    We plan to fix this problem in our next release.



    NC308WA Precaution
    MESCT-NC308WA-010116D

  4. Problem on Generating the MAX instruction
    4.1 Version Concerned
    NC308WA V.3.10 Release 1

    4.2 Description
    When a MAX instruction is generated, unnecessary comma is output, which may cause an assemble error.

    4.3 Conditions
    This problem occurs if the following five conditions are satisfied:
    (1) The controlling expression in the if construct is the one that compares two variables by using relational operator "<" or ">".
    (2) The type of two variables in (1) is signed char or short (int).
    (3) The program statement executed if the controlling expression of the if statement in (1) is TRUE is only an assignment of the larger variable to the smaller one.
    (4) The result of the assignment in (3) is stored in a register.
    (5) Any one or more of the optimizing options -O, -O[1-5], -OR, and -OS are used for compilation.

    4.4 Example
         ------------------------------------------------------------------
         int     j;                 /* Condition (2) */
         
         int func(int i)            /* Condition (2) */
         {
             if (i < j)             /* Condition (1) */
                 i = j;             /* Condition (3) */
             return i;
         }
         ------------------------------------------------------------------
    
    4.5 Workaround
    Place asm(); immediately before the expression that is executed if the controlling expression is TRUE.
             ----------------------------------------------------------
             if (i < j) {
                 asm();
                 i = j;
             }
             ----------------------------------------------------------
    
    4.6 Schedule of Fixing Problem
    We plan to fix this problem in our next release.





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