 |
|
 |
MAEC TOOL NEWS:
MAECT-NC308WA-010401D
NC308WA and NC30WA Precaution
|
Please take note of the following problem in using C compilers (with an assembler and integrated development environment) NC308WA and NC30WA:
- On assigning variables or immediate values to members of a structure
- The Versions Concerned
| Compiler for the M16C/80 series MCUs |
: NC308WA V.1.00 Release 1 -- V.3.10 Release 1 |
| Compiler for the M16C/60 and M16C/20 series MCUs |
: NC30WA V.3.10 Release 1 -- V.4.00 Release 2 |
- Problem
Variables or immediate values cannot correctly be assigned to members of structures in iteration statement (while, do-while, or for).
- Conditions
- This problem may occur if the following nine conditions are satisfied:
- (1) The member of a structure to which variables or immediate values are assigned is an array and not the first member of the structure.
- (2) The member described in (1) is 8 or 16 bits in length of integer type.
- (3) The iteration statement is any of the for, while and do statements that is equivalent to "for (n = 0; n < c; n++)", where n is a variable called "counter" and c is a constant.
- (4) The counter is a 16-bit variable of integer type, and the initial value of it is 0.
- (5) The constant n in (3) is 1 or 2; that is, the number of iteration is 1 or 2.
- (6) The program statement that constitutes the body of the loop is either of the following:
- (a) In the for statement, it is only an assignment to an element of the array that is a member of the structure in (1).
- (b) In the while or do statement, it consists of the assignment described in (a) above and such an expression as n++ as in (3).
- (7) In the assignment expression in the body of the loop in (6), the subscript representing each element of the array is used as the counter, and neither the structure nor its array-typed member is indirectly referenced by pointers.
- (8) Any of the "-OR", "-OS", and "-O[3-5]" compile options is used.
- (9) In the case of the for statement, compile option "-Oloop_unroll(-OLU)" is not used.
Example:
--------------------------------------------------------------------
struct SS {
char a[3];
int b[2]; /* Conditions (1) and (2) */
} s;
void func(void)
{
int i; /* Condition (4) */
for(i = 0; i < 2; i++){ /* Conditions (3), (4), and (5) */
s.b[i] = -1; /* Conditions (6) and (7) */
}
}
--------------------------------------------------------------------
- Workaround
Add a dummy asm function before or after the expression assigning a variable or immediate value to an array-typed member of a structure.
Example:
--------------------------------------------------------------------
void func(void)
{
int i;
for(i = 0; i < 2; i++){
asm(); /* A dummy asm function */
s.b[i] = -1;
}
}
--------------------------------------------------------------------
- The Schedule of Fixing the Problem
We plan to fix this problem in our next release.
|
 |