 |
|
 |
RENESAS TOOL NEWS [August 16, 2003: RSO-M3T-NC308WA_1-030816D]
A Note on Using C Compiler M3T-NC308WA
|
Please take note of the following problem in using the M3T-NC308WA C compiler (with an assembler and integrated development environment) for the M32C/80 and M16C/80 series MCUs:
- On calling a function indirectly
- Versions Concerned
- M3T-NC308WA V.5.00 Release 1 and V.5.10 Release 1
- for the M32C/80 and M16C/80 series MCUs
- Description
When a function is called indirectly, the data saved at the beginning of the calling function on the stack may not be recovered at its end.
- 2.1 Conditions
- This problem occurs if the following four conditions are satisfied:
| (1) | Either of the -OR and -OS optimizing options is used. |
| (2) | A function is indirectly called immediately before the return statement in or the end of the calling function. |
| (3) | The function to be called has no arguments passed to the stack. |
| (4) | The calling function has no AUTO variables on the stack. (If all the AUTO variables declared in the program are deleted by optimizing functions, this condition is met.) |
- 2.2 Example
---------------------------------------------------
void (*func)(void);
long sub1(void);
void sub2(void);
int i;
void sample(void)
{
long l; /* Condition (4): variable l is deleted by
optimization because it is not referenced
after a write to it. */
func = &sub2;
l = sub1();
(*func)(); /* Conditions (2) and (3) */
}
void sub2(void) /* Condition (3) */
{
i = 100;
}
---------------------------------------------------
- Workaround
- Place a dummy asm function immediately after an indirect call to a function within a calling function.
-
---------------------------------------------------
void (*func)(void);
long sub1(void);
void sub2(void);
int i;
void sample(void)
{
long l;
func = &sub2;
l = sub1();
(*func)();
asm(); /* Dummy asm function */
}
void sub2(void)
{
i = 100;
}
---------------------------------------------------
- Schedule of Fixing the Problem
We plan to fix this problem in our next release of the product.
|
 |