Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
RENESAS TOOL NEWS on March 1, 2004: RSO-M3T-NC30WA_1-040301D

A Note on Using C Compiler
M3T-NC30WA
--On an OR Operation Between a Variable and a Constant--

Please take note of the following problem in using C compiler (with an assembler and integrated development environment) M3T-NC30WA for the M16C/60, M16C/30, M16C/Tiny, M16C/20, M16C/10, and R8C/Tiny series MCUs:
  • On an OR operation between a variable and a constant


  1. Versions Concerned
    M3T-NC30WA V.2.00 Release 1 through V.5.20 Release 1


  2. Description
    Performing an OR operation between a variable of type unsigned or signed long and a constant of powers of 2 may generate incorrect code.


  3. Conditions
    This problem occurs if the following four conditions are satisfied:
    (1) An OR operation between variable A and a constant of powers of 2 is performed.
    (2) The type of variable A is unsigned or signed long.
    (3) Variable A is declared with the volatile qualifier.
    (4) The result of the operation (1) is assigned to variable B, which satisfies the following conditions:
    a.  It is an auto variable.
    b.  It is declared without the volatile qualifier.
    c.  Its address is either of the following:
          * the address of register FB - 17 or earlier
          * the address of register FB + 16 or later


  4. Example
    --------------------------------------------------------
    volatile long gl;                /* Conditions (2) and (3) */
    void func(void)
    {
            long bl[6];              /* Condition (4) */
    
            bl[0] = gl | 0x000001L;  /* Conditions (1) and (4) */
                ...
    }
    --------------------------------------------------------


  5. Workaround
    This problem can be circumvented by going through the following steps:
    (1) Define temporary variable C of type signed or unsigned long.
    (2) Assign to the variable in (1) the constant of powers of 2 between which and variable A an OR operation would be done.
    (3) Perform the OR operation between variables A and C.
    --------------------------------------------------------
    volatile long gl;
    void func(void)
    {
            long bl[6];
            long tmp;                /* Constant C */
    
        tmp = 0x000001L;
            bl[0] = gl | tmp;
                ...
    }
    --------------------------------------------------------


  6. Schedule of Fixing the Problem
    We plan to fix this problem in our next release of the product.





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