 |
|
 |
MESC TOOL NEWS:
MESCT-NC308WA-991016D
NC308WA V.1.00 Release 1 Precaution
|
Please take note of the following problems in using C compiler NC308WA (with assembler and integrated development environment) for the M16C/80 series of microcomputers.
- On Arithmetic Operations of Integer Constants Cast to Pointers
- 1.1 Problem
- When an integer constant cast to a pointer is involved in an arithmetic operation, an error will occur because the size of the type referenced by the pointer cannot be taken into consideration.
- 1.2 Conditions
- This problem occurs if the following two conditions are satisfied:
- (1)A pointer to which an integer constant is cast is of type other than char, unsigned char, signed char, and void.
- (2)A subtraction is performed between pointers of the type described in (1) above (see Example 1), or an addition or subtraction is performed between a pointer of the type described in (1) above and an integer constant (see Example 2).
-
----------------------------------------------------------------------
| [Example 1]
| /* The expression below will give 0x0400 as n, not 0x0100,
| the correct value. */
| int n = ((long *)0x0800) - ((long *)0x0400);
|
| [Example 2]
| /* The expression below will give 0x0402 as p, not 0x0408,
| the correct value. */
| long *p = ((long *)0x0400) + 2;
----------------------------------------------------------------------
- 1.3 Workaround
- Declare temporary variables placed at the addresses specified by the integer constant by using the #pragma ADDRESS directive, not by casting integer constants to pointers; then perform arithmetic operations of these addresses of the variables directly.
-
[Modifications of Examples 1 and 2]
----------------------------------------------------------------------
| #pragma ADDRESS data_top 0400H
| #pragma ADDRESS data_end 0800H
| extern long data_top;
| extern long data_end;
|
| int n = &data_end - &data_top;
| long *p = &datatop + 2;
----------------------------------------------------------------------
- If code efficiency is an important issue in the subtraction between pointers of the type described in (1) above, perform the subtraction operation after casting integer constants to type unsigned int or unsigned long int, not to pointers, and then divide the result of the subtraction by sizeof (the type pointed to by pointers described in (1) above).
-
[Example]
----------------------------------------------------------------------
| int n = ((unsigned int)0x0800 - (unsigned int)0x0400) / sizeof(long);
|
----------------------------------------------------------------------
- 1.4 Schedule of Fixing Problem
- We plan to fix this problem in our next release.
NC308WA V.1.00 Release 1 Precaution MESCT-NC308WA-991016D
- On Calculation of Stack Usage Including Standard Function Library
- 2.1 Problem
- When the stack size including the standard function library is calculated by the stack size calculation utility stk308 that specifies the stack size information file (nc308lib.stk) in the above library included with the compiler, the result obtained may be different from the actual value.
- 2.2 Workaround
- Modify the nc308lib.stk file as follows (by an editor, for example):
-
[Modified]
----------------------------------------------------------------------
| FUNCTION ldiv
| context 0 bytes
| auto 26 bytes <-- Modified portion
| f8regSize 0 bytes
| 0 bytes PUSH (MAX)
----------------------------------------------------------------------
[Original]
----------------------------------------------------------------------
| FUNCTION ldiv
| context 0 bytes
| auto 24 bytes
| f8regSize 0 bytes
| 0 bytes PUSH (MAX)
----------------------------------------------------------------------
|
 |