当前位置:网站首页>Keil compile size and storage instructions
Keil compile size and storage instructions
2022-07-30 08:06:00 【Electronic Dragon】
Keil、IAR编译(Build)The window prints out the information:
Program Size: Code=2596 RO-data=268 RW-data=44 ZI-data=1028
72765 bytes of readonly code memory
3508 bytes of readonly data memory
20202 bytes of readwrite data memory
5676 bytes of CODE memory
926 bytes of CONST memory
1148 bytes of DATA memory
I believe everyone has seen the above information,You should all know what they mean,But how many friends have deeply understood the detailed knowledge of storage?
to know the code、常量、全局、Where are local variables stored,就需要了解FLASH和RAM的一些特性,In the project, the size and corresponding storage address should be analyzed in detail,可以从mapfile analysis.
to take care of most people,Briefly explain the meaning of the above printed information.这里提醒一下大家,There is also a lot of relevant information on the Internet,But a lot of information on the Internet says there is ambiguity,可能会误导大家,如:RW-datais an initialized global variable.加了static修饰的变量叫静态变量,There are still differences with global variables,But initialized static variables are also classifiedRW-data中.
1.KeilCompile window information
Program Size: Code=2596 RO-data=268 RW-data=44 ZI-data=1028
Code:指代码的大小;
Ro-data:指除了内联数据(inline data)之外的常量数据;
RW-data:指可读写(RW)、已初始化的变量数据;
ZI-data:指未初始化(ZI)的变量数据;
Code、Ro-data:位于FLASH中;
RW-data、ZI-data:位于RAM中;
提醒:RW-data已初始化的数据会存储在Flash中,上电会从FLASH搬移至RAM中.
关系如下:
RO Size = Code + RO Data
RW Size = RW Data + ZI Data
ROM Size = Code + RO Data + RW Data
2.IARCompile window information
IAR存在两种情况,But the meaning is the same,只是显示不一样:
编译工程(点击Make),会出现如下信息:
72 765 bytes of readonly code memory
3 508 bytes of readonly data memory
20 202 bytes of readwrite data memory
编译单个文件(点击Compile),会出现下面信息(若没有DATAThere is no such line):
5 676 bytes of CODE memory
926 bytes of CONST memory
1 148 bytes of DATA memory
readonly code:代码大小(类似于CODE);
readonly data:常量数据(类似于CONST);
readwrite data:Can read and write variable data(类似于DATA);
说明:
IAR中的Data相当于Keil中RW Data + ZI Data
内存(RAM)分配
Expand this sectionRAM的一些知识,Helps everyone to run the programRAM的情况.
内存分为5类:
1、栈区(stack): 由编译器自动分配和释放 ,存放函数的参数值,局部变量的值等.
2、堆区(heap) : 一般由程序员(使用malloc)分配和(使用free)释放, 若程序员不释放,is always occupied.一般来说,Programs of the microcontroller class generally do not use the heap.
3、全局区(静态区)(static):全局变量和静态变量的存储是放在一块的,初始化的全局变量和静态变量在一块区域, 未初始化的全局变量和未初始化的静态变量在相邻的另一块区域.
4、文字常量区(const) :常量字符串就是放在这里的.
5、程序代码区 (code): 存放函数体的二进制代码.
经典例子:
int a = 0; 全局初始化区
char *p1; 全局未初始化区
main(void)
{
int b;// 栈
char s[] = "abc"; //栈
char *p2; //栈
char *p3 = "123456"; 123456\0";//在常量区,p3在栈上.
static int c =0; //全局(静态)初始化区
p1 = (char *)malloc(10);
p2 = (char *)malloc(20);
//分配得来得10和20字节的区域就在堆区.
strcpy(p1, "123456"); //123456\0放在常量区,编译器可能会将它与p3所指向的"123456"优化成一个地方.
}
边栏推荐
猜你喜欢

C# 使用RestSharp 实现Get,Post 请求(2)

The Geometric Meaning of Vector Cross Product and the Calculation of Modulus

uniapp中canvas与v-if更“配”

阿里二面:列出 Api 接口优化的几个技巧

五号黯区靶场 mysql 注入之limit注入记录

UDP和TCP使用同一个端口,可行吗?

Ali two sides: Sentinel vs Hystrix comparison, how to choose?

AI可通过X光片识别种族,但没人知道为什么
![[GO语言基础] 一.为什么我要学习Golang以及GO语言入门普及](/img/ac/80ab67505f7df52d92a206bc3dd50e.png)
[GO语言基础] 一.为什么我要学习Golang以及GO语言入门普及

Required request body is missing problem solving
随机推荐
node.js中实现对数据库的链式操作
go : 使用gorm创建数据库记录
[硬核干货]由0到1,突破信息系统项目管理师(呕心沥血经验之谈)!!!
Vue2进阶篇-编程式路由导航、缓存路由组件、路由的激活与失活
《心智社会》—马文·明斯基
Derivative Operations on Vectors and Derivative Operations on Vector Cross and Dot Products
How to use Swagger, say goodbye to postman
分布式锁开发
The terminal connection tools, rolling Xshell
bin文件夹下的roslyn文件夹
2020年度总结——品曾经,明得失,展未来
Go uses freecache for caching
五号黯区靶场 mysql 注入之limit注入记录
Headline 2: there are several kinds of common SQL errors in MySQL usage?
export , export default, import complete usage
New material under the plastic restriction order - polylactic acid (PLA)
Go语学习笔记 - gorm使用 - 数据库配置、表新增 Web框架Gin(七)
这个终端连接工具,碾压Xshell
Let the "label" content in Baidu map generator expand--solution
The newcomer deleted data by mistake, and the team leader skillfully used MySQL master-slave replication to delay the recovery of losses