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范围。
小小菜
2楼-- · 2020-01-04 22:45
没用过IAR,感觉可能是堆栈模式的不同
kebaojun305
3楼-- · 2020-01-05 02:23
 精彩回答 2  元偷偷看……
monkhooder
4楼-- · 2020-01-05 04:28
看编译器自带的文档,里面应该有说明
walker
5楼-- · 2020-01-05 07:25
做过实验,把一个正常的工程,禁止优化再编译一边,代码数据量明显大许多,如果CODE不修改,超出32K就通不过,改大一级就通过。

我认为这是一个粗框架,与程序的代码和数据占得比重有关,假如有大量的常数定义在flash,Data小了可能不行。
hd12
6楼-- · 2020-01-05 10:10
monkhooder 发表于 2015-3-4 20:04
看编译器自带的文档,里面应该有说明

编译器文档里没找到相关介绍
hd12
7楼-- · 2020-01-05 14:49
walker 发表于 2015-3-5 17:10
做过实验,把一个正常的工程,禁止优化再编译一边,代码数据量明显大许多,如果CODE不修改,超出32K就通不 ...

Code 和Data都有这个选项,我也试过,就目前的程序Data如果不选Medium根本不能编译,难道Code的small是32K,Data里的是其它值,在IAR的编译器文档里没找到对2个参数的具体描述

一周热门 更多>