IAR for STM8 编译选项 Target 里 code small 什么意思

2020-01-03 19:08发布

如题,IAR for STM8 编译选项 Target 里
code 有Small, Medium, Large
Data 也有Small, Medium, Large
这几个选项,不同选择会影响编译出来代码的大小,但是一直不明白这几个选项的意义,百度没搜出来,有没有人知道的?
23条回答
hd12
1楼 · 2020-01-06 19:27.采纳回答
本帖最后由 hd12 于 2015-3-6 10:46 编辑
walker 发表于 2015-3-5 21:53
搜索--code_model (compiler option)   --data_model (compiler option) 有详细参数


在 IARC/C++ Development Guide 里找到了描述
DATA MODEL
One of the characteristics of the STM8 microcontroller is a trade-off in how memory is
accessed, ranging from cheap access to small memory areas, up to more expensive
access methods that can access any location.
In the compiler, you can set a default memory access method by selecting a data model.
These data models are supported:
?In the small data model, variables are placed in the 8-bit address range
?In the medium data model, all data is placed in the 16-bit address range
?In the large data model, constants are placed in the 24-bit address range.
The chapter Data storage covers data models in greater detail and how to override the
default access method for individual variables.
For guidelines about the choice of data model and efficient use of memory types, see
Efficient use of memory types, page 213.


CODE MODEL
The compiler supports code models that control which function calls are generated by
default, which determines the size of the linked application. These code models are
available:
?In the small code model, all functions are placed in the 16-bit address range
?In the medium code model, all functions are placed in the 24-bit address range.
Functions are not allowed to cross 64-Kbyte section boundaries.
?In the large code model, all functions are placed in the 24-bit address range.
Functions are allowed to cross 64-Kbyte section boundaries.
For detailed information about the code models, see the chapter Functions.
For guidelines about the choice of data model and efficient use of memory types, see
Efficient use of memory types, page 213.

总结下:
Code的small是64K byte寻址范围,medium是16M byte范围,但函数不允许跨越64K byte边界, large模式下是16M byte寻址范围,函数不存在跨界限制,随便放
Date的small是256 byte寻址范围,medium是64K byte范围,large是16M范围。
shuailong0411
2楼-- · 2020-01-03 22:23
一直也没修改过这一块,也想知道是什么意思,帮顶一下!
haibaogk
3楼-- · 2020-01-04 03:17
寻址代码空间大小问题,相当于51的短跳转和长跳转
试过把small改为large,占用代码空间会增多。
hd12
4楼-- · 2020-01-04 07:37
 精彩回答 2  元偷偷看……
haibaogk
5楼-- · 2020-01-04 13:08
大了建议选medium或者large,有20k选medium好像就够的
hd12
6楼-- · 2020-01-04 18:42
haibaogk 发表于 2015-3-4 11:46
大了建议选medium或者large,有20k选medium好像就够的

谢谢你的回复,我是想明确,这个选项是不是在代码大到一个数值时“必须选“ , 你的回复不明确。

虽然现在做的测试,将代码减小一些工作正常了,但没有可靠的证据显示是code选项没选正确导致的
ecat
7楼-- · 2020-01-04 20:26
这和程序的大小没啥关系吧!看你硬件有没有扩展ram和rom,编译器根据这个来做优化方案。

一周热门 更多>