找回密码
 立即注册
楼主: 大锤子

寻找SDCC技术交流组织

[复制链接]
  • 打卡等级:初来乍到
  • 打卡总天数:9
  • 最近打卡:2025-03-03 10:30:04

0

主题

13

回帖

156

积分

注册会员

积分
156
发表于 2024-9-4 19:26:24 | 显示全部楼层
本帖最后由 magic8421 于 2024-9-4 19:32 编辑

sdcc 是没有overlay功能的 翻遍了官网也没找到这功能
所以项目大一点就得用 --mode-large --stack-auto 这样
不然内部内存总是不够得
说起来你可能不信 他就是一个变量占一个内存 占完就编译不过 不存在keil那种local变量只要没有调用关系就可以共享的
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家II
  • 打卡总天数:469
  • 最近打卡:2025-05-02 11:38:17

44

主题

230

回帖

2845

积分

金牌会员

积分
2845
发表于 2024-9-5 10:57:37 | 显示全部楼层
magic*** 发表于 2024-9-4 19:26
sdcc 是没有overlay功能的 翻遍了官网也没找到这功能
所以项目大一点就得用 --mode-large --stack-auto 这 ...

应该有吧, 看啥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.
不争是争
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:初来乍到
  • 打卡总天数:9
  • 最近打卡:2025-03-03 10:30:04

0

主题

13

回帖

156

积分

注册会员

积分
156
发表于 2024-9-5 18:20:54 | 显示全部楼层
大*** 发表于 2024-9-5 10:57
应该有吧, 看啥sdcc的用户手册3.7
3.7 Overlaying
For non-reentrant functions SDCC will try to redu ...

这段我看了啊 只有leaf function会overlay
“if the function has no other function calls ”
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家II
  • 打卡总天数:469
  • 最近打卡:2025-05-02 11:38:17

44

主题

230

回帖

2845

积分

金牌会员

积分
2845
发表于 2024-9-5 22:39:35 | 显示全部楼层
magic*** 发表于 2024-9-5 18:20
这段我看了啊 只有leaf function会overlay
“if the function has no other function calls ”
...

哦, 也没啥问题吧。 现在的单片机速度和存储都够用了。 我目前也没有接触过大到不够用的情况。 而且一般直接设置成large模式。 在使用rtos的时候也需要使用auto-stack
不争是争
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:初来乍到
  • 打卡总天数:9
  • 最近打卡:2025-03-03 10:30:04

0

主题

13

回帖

156

积分

注册会员

积分
156
发表于 2024-9-6 10:26:26 | 显示全部楼层
本帖最后由 magic8421 于 2024-9-6 10:31 编辑
大*** 发表于 2024-9-5 22:39
哦, 也没啥问题吧。 现在的单片机速度和存储都够用了。 我目前也没有接触过大到不够用的情况。 而且一般 ...

large有个问题就是:当函数太复杂时会生成sloc临时变量,然而sloc是必须分配在在内部内存的,所以工程大了large也会导致无法编译
不需要太大工程rom用到20k的时候就会出现这问题  sdcc太拉跨了 忍不住吐槽一下
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家II
  • 打卡总天数:469
  • 最近打卡:2025-05-02 11:38:17

44

主题

230

回帖

2845

积分

金牌会员

积分
2845
发表于 2024-9-6 10:43:26 | 显示全部楼层
magic*** 发表于 2024-9-6 10:26
large有个问题就是:当函数太复杂时会生成sloc临时变量,然而sloc是必须分配在在内部内存的,所以工程大了 ...

大佬研究这么深入,
不争是争
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家II
  • 打卡总天数:423
  • 最近打卡:2025-05-02 07:55:56
已绑定手机

19

主题

3191

回帖

4872

积分

论坛元老

积分
4872
发表于 2024-9-6 21:57:33 | 显示全部楼层
magic*** 发表于 2024-9-6 10:26
large有个问题就是:当函数太复杂时会生成sloc临时变量,然而sloc是必须分配在在内部内存的,所以工程大了 ...

看来sdcc只能玩玩啊,大项目还用不了
回复 支持 反对

使用道具 举报 送花

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|深圳国芯人工智能有限公司 ( 粤ICP备2022108929号-2 )

GMT+8, 2025-5-2 22:07 , Processed in 0.151671 second(s), 92 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表