- 打卡等级:以坛为家II
- 打卡总天数:469
- 最近打卡:2025-05-02 11:38:17
金牌会员
- 积分
- 2845
|
发表于 2024-9-5 10:57:37
|
显示全部楼层
应该有吧, 看啥sdcc的用户手册3.7
3.7 Overlaying
For non-reentrant functions SDCC will try to reduce internal ram space usage by overlaying parameters and local
variables of a function (if possible). Parameters and local variables of a function will be allocated to an overlayable
segment if the function has no other function calls and the function is non-reentrant and the memory model is small.
If an explicit intrinsic named address space is specified for a local variable, it will NOT be overlaid.
Note that the compiler (not the linkage editor) makes the decision for overlaying the data items. Functions that
are called from an interrupt service routine should be preceded by a #pragma nooverlay if they are not reentrant. !
Also note that the compiler does not do any processing of inline assembler code, so the compiler might incorrectly
assign local variables and parameters of a function into the overlay segment if the inline assembler code calls
other c-functions that might use the overlay. In that case the #pragma nooverlay should be used.
Parameters and local variables of functions that contain 16 or 32 bit multiplication or division will NOT be
overlaid since these are implemented using external functions, e.g.:
#pragma save
#pragma nooverlay
void set_error(unsigned char errcd)
{
P3 = errcd;
}
#pragma restore
void some_isr () __interrupt (2)
{
...
set_error(10);
...
}
In the above example the parameter errcd for the function set_error would be assigned to the overlayable segment
if the #pragma nooverlay was not present, this could cause unpredictable runtime behaviour when called from an
interrupt service routine. The #pragma nooverlay ensures that the parameters and local variables for the function
are NOT overlaid. |
|