 |
|
 |
MESC TOOL NEWS:
MESCT-NC30WA-991016D
Please take note of the following problems in using C compiler NC30WA (with assembler and integrated development environment) for the M16C/60 and 20 series of microcomputers.
- Versions Concerned
NC30WA V.1.00 Release 1 -- V.3.10 Release 1
- On Arithmetic Operations of Integer Constants Cast to Pointers
- 2.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.
- 2.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;
----------------------------------------------------------------------
- 2.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);
|
----------------------------------------------------------------------
NC30WA Precaution MESCT-NC30WA-991016D
- On Calculation of Stack Usage Including Standard Function Library
- 3.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.
- 3.2 Workaround
- Modify the nc30lib.stk file as follows (by an editor, for example):
note: No series three modified portions on the file.
-----------------------------------------------------------------------
| FUNCTION _i4div
| context 0 bytes
| auto 27 bytes <-- Change to 33 bytes
| f8regSize 0 bytes
| 0 bytes PUSH (MAX)
| ----------------------------------------------------------------------
| FUNCTION _i4mod
| context 0 bytes
| auto 29 bytes <-- Change to 31 bytes
| f8regSize 0 bytes
| 0 bytes PUSH (MAX)
| ----------------------------------------------------------------------
| FUNCTION ldiv
| context 0 bytes
| auto 6 bytes <-- Change to 8 bytes
| f8regSize 0 bytes
| 0 bytes PUSH (MAX)
-----------------------------------------------------------------------
|
 |