Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
MAEC TOOL NEWS: MAECT-M3T-NC79WA-020301D

A Note on C Compilers
M3T-NC79WA and M3T-NC77WA

Please take note of the following problem in using C compilers (with an assembler and integrated development environment) M3T-NC79WA and M3T-NC77WA.
  • On switch-case statements


  1. Products and Versions Concerned
    For the 7900 series MCUs: M3T-NC79WA V.2.00 Release 1 -- V.4.10 Release 1
    For the 77xx series MCUs: M3T-NC77WA V.3.10 Release 2 -- V.5.20 Release 4

  2. Description
    When compiling switch-case statements, code that makes a jump only to the default or a specific case label may be generated no matter what case value meets the conditional expression.

  3. Conditions
    This problem occurs if condition (1) or (2) below is satisfied with compile option -fswitch_table[-fST] selected.
    (1) In the conditional expression of a switch statement, a variable of type unsigned char is used, and the sequence of the case values is any of the following three types:
    a. The case values are 255 consecutive numbers from 1 to 255.
    b. The case values are 255 consecutive numbers from 0 to 254.
    c. The total number of cases (excluding the default) is 143 or more with the minimum case value 0 and the maximum 255.

    (2) In the conditional expression of a switch statement, a variable of type signed char is used, and the sequence of the case values is any of the following three types:
    a. The case values are 255 consecutive numbers from -127 to +127.
    b. The case values are 255 consecutive numbers from -128 to +126.
    c. The total number of cases (excluding the default) is 143 or more with the minimum case value -128 and the maximum 127.

  4. Example
    [In condition (1)-a]
    --------------------------------------------------------------------
       char c;
       switch(c){
       case    1:
       case    2:
               func(3);
               break;
               :
               :
       case    255:
               func(255);
               break;
       default:
               break;
       }
    --------------------------------------------------------------------
  5. Workaround
    In the conditional expression of the switch statement, when the variable is of type unsigned char, cast it to an unisigned int value; when it is of type signed char, cast it to a signed int value.
    [Example]
    --------------------------------------------------------------------
       char c;
       switch((unsigned int)c){      /* Variable c of type unsigned char 
       case    1:                       is cast to of type unsigned int */
           :
           :
       case    255:
           :
       }
    --------------------------------------------------------------------
  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