再回到IAR编译器里来:
我将一段程序编译,其中用到printf函数的编译结果如下:
6 116 bytes of CODE memory
82 bytes of DATA memory (+ 18 absolute )
585 bytes of CONST memory
用到sin函数的编译结果如下:
2 946 bytes of CODE memory
84 bytes of DATA memory (+ 18 absolute )
552 bytes of CONST memory
什么都没用的:
498 bytes of CODE memory
82 bytes of DATA memory (+ 18 absolute )
552 bytes of CONST memory
可见IAR使用这些标准库里的函数跟CCS消耗的ram和rom量是不一样的
在之前的使用中,2553在IAR中是可以使用sin函数的,而在CCS中则不可以,下面这段测试程序
#include "msp430g2553.h"
#include "math.h"
void main(void) {
volatile int a;//必须用volatile,不然看不到效果的,会被优化掉
a=sin(1.2);
}
报错如下:
"../lnk_msp430g2553.cmd", line 56: error #10099-D: program will not fit into
available memory. run placement with alignment fails for section ".bss"
size 0x304 . Available memory ranges:
RAM size: 0x200 unused: 0x90 max hole: 0x90
error #10010: errors encountered during linking; "justlookwhathappen.out" not
built
.bss段是用来放置未初始化变量的,查看lnk_msp430g2553.cmd", line 56: 其分配在ram区域。