資源簡介
通過在STVD的安裝路徑加入此插件,可以完成代碼量統計的功能,顯示ROM,RAM的使用情況。

代碼片段和文件信息
//?mapinfo.cpp?:?Defines?the?entry?point?for?the?console?application.
//
#include?
#include?
#include?
#define?STR_FLAG????“?segment?“
#define?STR_STACK “Stack?size:“
enum
{
????TYPE_UNKNOWN
????TYPE_RAM
????TYPE_FLASH
????TYPE_RAM_FLASH
????TYPE_EEPROM
TYPE_INFO
TYPE_BIT
TYPE_DEBUG
};
int?get_len(char?*pos);
int?get_type(char?*pos);
int?main(int?argc?char*?argv[])
{
????char?fn[2048]?=?“\0“;
????char?*buf?=?NULL;
????for(int?i=1;i ????{
????????strcat(fnargv[i]);
????}
????//
????//
????//
????FILE?*fp;
????fp?=?fopen(fn“r“);
????if(?NULL==fp?)
????{
????????printf(“mapinfo?error:?Can?not?read?\“%s\““fn);
????????return?-1;
????}
fseek(fp0SEEK_END);
long?flen?=?ftell(fp);
buf?=?(char*)malloc(flen);
if(?NULL==buf?)
{
printf(“mapinfo?error:?malloc?failed!“);
????????return?-1;
}
????fseek(fp0SEEK_SET);
????fread(buf1flenfp);
????fclose(fp);
????buf[flen-1]=‘\0‘;
????//
????//
????//
????char?*pos?=?buf;
char?*next?=?buf;
int?byte_unknown?=?0;
????int?byte_flash?=?0;
????int?byte_ram?=?0;
????int?byte_ram_flash?=?0;
????int?byte_eeprom?=?0;
int?byte_stack?=?0;
????for(;;)
????{
????????pos?=?strstr(pos?STR_FLAG);
????????if(?NULL==pos?)
????????{
????????????break;
????????}
????????int?len?=?get_len(pos);
????????pos?+=?sizeof(STR_FLAG);
next?=?pos;
????????int?type?=?get_type(pos);
????????//
????????//
????????//
????????switch(?type?)
????????{
case?TYPE_UNKNOWN:
byte_unknown?+=?len;
break;
????????case?TYPE_FLASH:
????????????byte_flash?+=?len;
????????????break;
????????case?TYPE_RAM:
????????????byte_ram?+=?len;
????????????break;
????????case?TYPE_RAM_FLASH:
????????????byte_ram?+=?len;
????????????byte_flash?+=?len;
????????????break;
????????case?TYPE_EEPROM:
????????????byte_eeprom?+=?len;
????????????break;
????????}
????}
pos?=?strstr(nextSTR_STACK);
if(?pos!=NULL?)
{
byte_stack?=?atoi(&pos[sizeof(STR_STACK)]);
}
????//
????//
????//
if(?byte_unknown!=0?)
{
printf(“\nram:%d???flash:%d???eeprom:%d???stack:%d???unknown:%d“?byte_rambyte_flashbyte_eeprombyte_stackbyte_unknown);
}
else
{
printf(“\nram:%d???flash:%d???eeprom:%d???stack:%d“?byte_rambyte_flashbyte_eeprombyte_stack);
}
????return?0;
}
int?get_len(char?*pos)
{
????*pos?=?‘\0‘;
????while(*--pos!=‘?‘)
????{
????}
????return?atoi(pos+1);
}
#define????STRCMP(str1str2)????strncmp(str1str2sizeof(str2)-1)
int?get_type(char?*pos)
{
????if(?0==STRCMP(pos“const“)?)
????{
????????return?TYPE_FLASH;
????}
????else
????if(?0==STRCMP(pos“text“)?)
????{
????????return?TYPE_FLASH;
????}
????else
????if(?0==STRCMP(pos“eeprom“)?)
????{
????????return?TYPE_EEPROM;
????}
else
????if(?0==STRCMP(pos“bsct?initialized“)?)
????{
????????return?TYPE_BIT;
????}
????else
????if(?0==STRCMP(pos“bsct?from“)?)
????{
????????return?T
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3892??2010-10-28?11:35??mapinfo.cpp
?????文件??????45056??2010-10-28?11:35??mapinfo.exe
?????文件????????866??2016-11-23?08:34??Readme.txt
-----------?---------??----------?-----??----
????????????????49814????????????????????3
- 上一篇:FPGA中電子鐘的設計與實現
- 下一篇:nsct變化工具箱
評論
共有 條評論