Program Size: Code=5988 RO-data=6416 RW-data=52 ZI-data=2860
Code是代码指令占用的字节数,main函数中指令增多则code字节数增多;
RO-data(Read Only)是只读数据占用的字节数,只读数据如const+变量类型,例如const unsigned char ascii[10]={…},main中只要引用了ascii[0]~ascii[9],则RO-data则会多占用10个字节,即(10=6426-6416)如果是声明了const unsigned int ascii[10]={…}并在main中引用了ascii[0]~ascii[9],则RO-data则会多占用40个字节(32位机中int是4个字节),引用了几个就多nX4个字节;
RW-data是(Read Write) 是已被初始化的可读/写数据占用的字节数,例如在main函数之前初始化t1如unsigned char t1=2,而main函数里面并没有读写变量t1,则keil则会在编译时优化掉t1,所以RW-data字节数并没有增加。如果在main函数之前初始化ttunsigned char t1=2或者声明unsigned char t1,并且在main函数里面读写变量t1,如写t1=10,则RW-data字节数增加4个字节,如果顺序声明或者定义了4个变量t1 t2 t3 t4,并假设在main中都进行了写操作,例如unsigned char t1=2 unsigned short int t2=2 unsigned short int t3=2 unsigned int t4=2,前面t1 +t2一起占用3个字节,则keil只分配了1个地址(4个字节)给这两个变量,t3+t4占6个字节>4个字节,所以t3(2字节short int)被分配一个地址(4个字节),t4用4字节,刚好分配到了一个地址(4个字节),所以4个变量总共使RW-data增加了3x4个字节数。
ZI-data是(Zero Initialized Data)是 未进行初始化的可读/写数据占用的字节数
(Flash的被占用的空间大小)ROM Size = Code + RO Data + RW Data
运行程序时,Flash的RW Data被调到RAM中,所以
RAM Size = RW Data + ZI Data
Code是代码指令占用的字节数,main函数中指令增多则code字节数增多;
RO-data(Read Only)是只读数据占用的字节数,只读数据如const+变量类型,例如const unsigned char ascii[10]={…},main中只要引用了ascii[0]~ascii[9],则RO-data则会多占用10个字节,即(10=6426-6416)如果是声明了const unsigned int ascii[10]={…}并在main中引用了ascii[0]~ascii[9],则RO-data则会多占用40个字节(32位机中int是4个字节),引用了几个就多nX4个字节;
RW-data是(Read Write) 是已被初始化的可读/写数据占用的字节数,例如在main函数之前初始化t1如unsigned char t1=2,而main函数里面并没有读写变量t1,则keil则会在编译时优化掉t1,所以RW-data字节数并没有增加。如果在main函数之前初始化ttunsigned char t1=2或者声明unsigned char t1,并且在main函数里面读写变量t1,如写t1=10,则RW-data字节数增加4个字节,如果顺序声明或者定义了4个变量t1 t2 t3 t4,并假设在main中都进行了写操作,例如unsigned char t1=2 unsigned short int t2=2 unsigned short int t3=2 unsigned int t4=2,前面t1 +t2一起占用3个字节,则keil只分配了1个地址(4个字节)给这两个变量,t3+t4占6个字节>4个字节,所以t3(2字节short int)被分配一个地址(4个字节),t4用4字节,刚好分配到了一个地址(4个字节),所以4个变量总共使RW-data增加了3x4个字节数。
ZI-data是(Zero Initialized Data)是 未进行初始化的可读/写数据占用的字节数
(Flash的被占用的空间大小)ROM Size = Code + RO Data + RW Data
运行程序时,Flash的RW Data被调到RAM中,所以
RAM Size = RW Data + ZI Data