 |
|
 |
MAEC TOOL NEWS:
MAECT-NC308WA_2-010416D
NC308WA and NC30WA Precautions
|
Please take note of the following problem in using C compiler (with an assembler and integrated development environment) NC308WA and NC30WA:
- On describing assignment expressions within iteration statements
- Versions Concerned
- M16C/80 series MCUs
| NC308WA V.1.00 Release 1 -- V.3.10 Release 1 |
- M16C/60 and M16C/20 series MCUs
| NC30WA V.1.00 Release 1 -- V.4.00 Release 2 |
- Description
When expressions assigning constants are described in an iteration statement (while, do-while, or for), the assignment expressions may erroneously be moved in front of the iteration statement after compilation.
- 2.1 Conditions
- This problem occurs if the following five conditions are satisfied:
- (1) More than one expression assigning a constant to a variable exists in an iteration statement.
- (2) Only one of the assignment expressions in (1) is unconditionally executed every time of iteration.
- (3) Whether each of the other assignment expressions than the one in (2) is executed or not depends on the results of evaluating the conditional expression in an "if" or "switch" statement.
- (4) Compile option "-OS" is used.
- (5) As a result of compilation created is the code that executes each of the assignment expressions in (3) with any of the following instructions:
- (a) In NC30WA: STZ, STNZ, and STZX
- (b) In NC308WA: MAX, MIN, CLIP, SCZ, and SCNZ, SCC, SCNC as well as STZ, STNZ, and STZX.
- 2.2 Example
-----------------------------------------------------------------------
int x;
void func(void)
{
int i;
char a;
for (i = 0; i < 3; i++) {
a = 0; /* Conditions (1) and (3); this assignment
expression moves in error to the next of the
initializer expression "i=0" of
the "for" statement */
if (x) x = 0;
if (x == 0) a = 3; /* Conditions (2), (3) and (5);
an STZ instruction is generated as
a result of compilation */
}
x = a;
}
-----------------------------------------------------------------------
- Workaround
Add a dummy asm function immediately before or after the assignment expression that is moved erroneously.
If the assignment expression is included in the controlling expression of a "for" statement, as shown in "for (i = 0; a=0, i < 3; i++)", place it outside the controlling expression and add a dummy function the same way as described above.
---------------------------------------------------------------------
int x;
void func(void)
{
int i;
char a;
for (i = 0; i < 3; i++) {
asm(); /* Add this line */
a = 0;
if (x) x = 0;
if (x == 0) a = 3;
}
x = a;
}
---------------------------------------------------------------------
- Schedule of Fixing the Problem
- This problem has been fixed in NC308WA V.3.10 Release 2.
- For details, refer to MAEC TOOL NEWS "NC308WA V.3.10 Release 2 Upgraded Version Announcement" issued on April 16, 2001.
- NC30WA is due to be modified in its next release.
|
 |