Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
RENESAS TOOL NEWS on August 1, 2007: 070801/tn2

A Note on Using the C/C++ Compiler Package for the M32R Family of MCUs
--With Using a Control or Iteration Statement Containing a Substatement of 128 KB or More in Code Size--


Please take note of the following problem in using the C/C++ compiler package for the M32R of MCUs:
  • With using a control or iteration statement containing a substatement of 128 KB or more in code size


1. Product and Versions Concerned
   The C/C++ compiler package--M3T-CC32R--for the M32R family
     V.1.00 Release 1 through V.5.01 Release 00

2. Description
   If a control statement (an if statement, for example) or an iteration
   statement (a while statement, for example) contains a substatement
   to be executed that consumes a large amount of memory, compiling C source
   code including those statements may cause the following error to arise,
   and compilation be unsuccessfully terminated:

   a132R: "xxx": error: 16-bit displacement overflow in operand 2

   NOTICE:
   "xxx" is the file name given automatically at compilation
   by the compiler. It is not the name of the C/C++ source file to be
   compiled.

2.1 Conditions
    This problem may occur if the following conditions are all satisfied:

    (1) In a control or iteration statement exists a substatement of
        128 KB or more in code size.
    (2) The substatement in (1) is contained to be executed within any of
        the following statements:
        (a) an if statement; valid only when it executes the substatement
            in (1) if the result of evaluation of the controlling expression
            is TRUE
        (b) a switch statement; valid only when the total size of the
            substatements exceeds 128 KB
        (c) a while statement
        (d) a do statement
        (e) a for statement

2.2 Examples
    1. Source file sample1.c
    -----------------------------------------------------------------------
    int ans1;
    void
    func1(int a)
    {
        if (a) {                            /* Condition (2)-(a) */
     . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
          /* This part reaches 128 KB */    /* Condition (1) */
     . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
        } else {
           ans1 = 1;
        }
    }
    -------------------------------------------------------------------------
    2. Source file sample2.c
    ------------------------------------------------------------------------
    int ans2;
    void
    func2(int a)
    {
        switch (a) {                      /* Condition (2)-(b) */
          case 0:
     . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
          /* This part reaches 128 KB */    /* Condition (1) */
     . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
            break;
          case 1:
            ans2 = 2;
            break;
        }
    }
    ------------------------------------------------------------------------
    3. Source file sample3.c
    -------------------------------------------------------------------------
    void
    func3(int a)
    {
        while (--a) {                       /* Condition (2)-(c) */
     . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
          /* This part reaches 128 KB */    /* Condition (1) */
     . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
        }
    }
    ------------------------------------------------------------------------

3. Workarounds
   Avoid this problem in either of the following ways:
   (1) In the case of an if statement
       Because this problem does not occur if the substatement concerned
       is placed after else, invert the meaning of the controlling
       expression and change the places between the substatement
       concerned and the one after else. When the substatement executed
       if TRUE is empty after the change, this workaround has no effect.
       So be sure to fill it with any statement.

      Modification of Example 1 (source file sample1.c)
      ----------------------------------------------------------------------
      int ans1;
      void
      func1(int a)
      {
         if (!a) {          /* Meaning of controlling expression inverted */
             ans1 = 1;      /* Substatement changed */
         } else {
       . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
          /* This part reaches 128 KB */    /* Substatement changed */
       . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
         }
      }
      ----------------------------------------------------------------------

   (2) In the case of any control or iteration statement
       Convert the whole substatement or a part of the substatement into
       a newly created function and call it. Be sure not to declare the
       function to be inline.

      Modification of Example 1 (source file sample3.c)
      ----------------------------------------------------------------------
      void
      sub_func3(void)           /* Newly created function */
      {
      . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
          /* This part reaches 128 KB */
      . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
      }
      void
      func3(int a)
      {
          while (--a) {
            sub_func3();     /* Newly created function is called */
          }
      }
      ----------------------------------------------------------------------



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