本帖最后由 zhbsniper 于 2012-1-6 15:57 编辑
#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
uchar a;
uint b;
uint sum(uint c)
{
uint d;
d = c;
return d;
}
void main()
{}
Program Size: data=12.0 xdata=0 code=17
#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
uchar a;
uint b;
uint sum(uint c)
{
uint d;
d = c;
return d;
}
void main()
{
b = sum(5);
}
Program Size: data=12.0 xdata=0 code=28
#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
uchar a;
uint b;
uint sum(uint c)
{
uint d;
}
void main()
{
}
Program Size: data=16.0 xdata=0 code=21
TYPE BASE LENGTH RELOCATION SEGMENT NAME
-----------------------------------------------------
* * * * * * *
D A T A M E M O R Y
* * * * * * *
REG 0000H 0008H ABSOLUTE "REG BANK 0"
DATA 0008H 0004H UNIT ?DT?_SUM?MAIN
DATA 000CH 0003H UNIT ?DT?MAIN
IDATA 000FH 0001H UNIT ?STACK
上面是3个简单的程序的内存分配,及其M51文件中的内容。M51中第三个程序比前2个多了蓝色部分。为什么程序1和2 RAM分配相同,而程序3的却那么大,请教高手 |