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范围。
hd12
2楼-- · 2020-01-06 18:44
walker 发表于 2015-3-5 21:53
搜索--code_model (compiler option)   --data_model (compiler option) 有详细参数

Code model
The code model controls how code is generated for an application. Typically, the code model controls behavior such as how functions are called and in which code segment/section functions will be located. All object files of an application must be compiled using the same code model。

Data model
The data model specifies the default memory type. This means that the data model typically controls one or more of the following: The method used and the code generated to access static and global variables, dynamically allocated data, and the runtime stack. It also controls the default pointer type and in which data segments/sections static and global variables will be located. A project can only use one data model at a time, and the same model must be used by all user modules and all library modules in the project.

你说的是这2段么?这个不是解释Code和Data选Small, Medium, Large的作用吧。
llww30402048
3楼-- · 2020-01-06 20:24
hd12 发表于 2015-3-6 09:50
430的Data会那么大?STM8我试过Data基本都要选Medium,除了测试一小段功能的程序可以选small外。目前还没 ...

flash 有256K的,5系列,因为430是16位,4系列及以前的MCU 最大只能寻址到64K;
然后 后面 TI 出了大flash的 所以寻址就不一样了,IAR需要选着 large 才行
hiya3621
4楼-- · 2020-01-07 00:46
正好stm8s003F3代码空间不够了,medium改成small后又有2K可用了,感谢分享!
lzchuo
5楼-- · 2020-01-07 03:00
 精彩回答 2  元偷偷看……

一周热门 更多>