 |
|
 |
MAEC TOOL NEWS:
MAECT-NC77WA-010701D
Please take note of the problem shown below in using C compiler (with an assembler and integrated development environment) NC77WA for the 77xx series MCUs.
- On division and modulus operations
- Versions Concerned
NC77WA V.4.00 Release 1 -- V.5.20 Release 4
- Description
When performing division or modulus operations involving variables of type unsigned long, the run-time library for these operations is called out without clearing the X flag.
- 2.1 Conditions
- This problem may occur if the following four conditions are satisfied:
- (1) A dividend is a variable.
- (2) A divisor is a constant.
- (3) Either or both of the dividend and divisor are of type unsigned long.
- (4) A subscript of an array that takes an argument of type char is used in the conditional expression in an iteration statement immediately before a division or modulus operation.
- Note: If the above conditions are all met, no problem may occur depending on the constructions of C source programs. If so, use your C compiler as it is.
- 2.2 Example
-------------------------------------------------------------
void func(unsigned char ch, unsigned long *array)
{
unsigned long tmp;
while( ch-- != 0 ){ /* Condition (4) */
array[ch] = tmp / 10;
/* Conditions (1), (2), and (3) */
}
}
-------------------------------------------------------------
- Workaround
If this problem arises, change the type of the subscript of the array from char to signed char or unsigned char.
Example:
-------------------------------------------------------------
void func(unsigned int ch, unsigned long *array)
{
unsigned long tmp;
while( ch-- != 0 ){
array[ch] = tmp / 10;
}
}
-------------------------------------------------------------
- Schedule of Fixing the Program
We plan to fix this problem in our next release.
|
 |