 |
|
 |
RENESAS TOOL NEWS on November 16, 2005: RSO-M3T-NC308WA_2-051116D
A Note on Using the C Compiler Package
M3T-NC308WA |
Please take note of the following problem in using the C compiler package M3T-NC308WA, which is used for the M32C/90, M32C/80, and M16C/80 series of MCUs:
- On performing a subtraction containing a constant as a subtrahend
- Versions Concerned
M3T-NC308WA V.5.00 Release 1 through V.5.20 Release 02
- Description
Performing a subtraction containing a constant as a subtrahend results in incorrect code being generated.
| 2.1 |
|
Conditions
This problem may occur if the following conditions are all satisfied:
| (1) |
|
In a subtraction expression, a minuend is not a constant and its type is any of the following:
- signed short
- unsigned short
- signed int
- unsigned int
|
| (2) |
|
A subtrahend is a constant whose value falls within a range of 0xFF01 to 0xFFFF. |
|
| 2.2 |
|
Example
------------------------------------------------------------------------
int array[];
int func(int i)
{
int j
j = array[ i - 0xFFE0 ]; /* Conditions (1) and (2) */
return j;
}
------------------------------------------------------------------------ |
- Workaround
Assign the result of a subtraction to a temporary variable, and place a dummy asm function immediately after the assignment expression. Then, replace the subtraction expression with the temporary variable.
Example:
------------------------------------------------------------------------
int array[];
int func(void)
{
int j;
int tmp; /* Declare a tmp variable */
tmp = i - 0xFFE0; /* Assign result of subtraction
to tmp variable */
asm(); /* Place a dummy asm() function */
j = array[ tmp ]; /* Use tmp variable */
return j;
}
------------------------------------------------------------------------
- Schedule of Fixing the Problem
We plan to fix this problem in the next release of the product.
|
 |