 |
|
 |
MESC TOOL NEWS:
MESCT-NC308WA-990616D
NC308WA and NC30WA
Precautions
|
Please take note of the following problems in using C compilers (with assembler and integrated development environment) NC308WA for the M16C/80 series and NC30WA for the M16C/60 and M16C/20 series of microcomputers.
On Multiplication of Variables of Type "int" and Type "pointer to int"
- Products Concerned
NC30WA V.3.00 Release 1 -- V.3.10 Release 1
- Problem
Multiplying a variable of type int by another variable of type pointer to int may result in incorrect code being generated.
- Conditions
This problem occurs if the following four conditions are satisfied:
(1)Multiplication of a variable of type int and another variable of type pointer to int is performed.
(2)The multiplicand (not of type pointer to int) is cast to type long at multiplication.
(3)The result of multiplication of two variables is assigned to a variable of type long.
(4)The variable storing the result of multiplication and the multiplicand are declared as register variables.
[Example: -fER or optimization option used]
---------------------------------------------------------
| extern unsigned long out;
| extern unsigned int in;
| extern unsigned int *p;
|
| void func(void)
| {
| register unsigned int a = in;
| (*(unsigned int *)a) = 0;
| out = (unsigned long)a * *p;
| }
|
---------------------------------------------------------
- Workaround
Temporarily assign the multiplier to a TMP variable of type long; then perform multiplication with this variable.
NC308WA and NC30WA Precautions MESCT-NC308WA-990616D
On Compilation of Switch -- Case Statements
- Products Concerned
NC308WA V.1.00 Release 1
NC30WA V.1.00 Release 1 -- V.3.10 Release 1
- Problem
Switch-case statements may cause compilation not to be terminated.
- Conditions
This problem occurs if the following two conditions are satisfied:
(1)The argument of a switch statement is of type signed long or unsigned long.
(2)When the case values in the switch statement are assumed to be signed numbers, the difference between their maximum and minimum falls within a range of 0x40000000--0x7fffffff or 0xc0000000--0xffffffff.
[Example]
---------------------------------------------------------
| void func( unsigned long call_type )
| {
| switch( call_type ) {
| case 0x40000001UL:
| break;
| case 0x80000004UL:
| break;
| }
| }
|
---------------------------------------------------------
- Workaround
(1)If case values greater than 0x7fffffff exist, divide a switch statement into two; the one with the case values greater than 0x7fffffff and the other with those equal to or less than 0x7fffffff.
(2)Substitute if statements for switch statements.
|
 |