源程序正确运行,如下:
#include<reg51.h>
#include<stdio.h>
#define uchar unsigned char
#define uint unsigned int
uchar data a[32] _at_ 0x30;
uint i _at_ 0x55;
uint j _at_ 0x60;
uint t _at_ 0x65;
uchar data a[]={1,3,9,2,17,4,11,6,5,20,100,64,21,14,79,35,92,7,91,23,65,16,13,18,18,73,65,101,27,19,62,69};
void main()
{
for(i=0;i<31;i++)
{
for(j=0;j<31-i;j++)
{
if(a[j]>a[j+1])
t=a[j],a[j]=a[j+1],a[j+1]=t;
}
}
while(1);
}
为什么把数组定义放到程序里面后,数组的起始地址变为0x08 ???
修改后的程序:
#include<reg51.h>
#include<stdio.h>
#define uchar unsigned char
#define uint unsigned int
uchar data a[32] _at_ 0x30;
uint i _at_ 0x55;
uint j _at_ 0x60;
uint t _at_ 0x65;
void main()
{
uchar data a[]={1,3,9,2,17,4,11,6,5,20,100,64,21,14,79,35,92,7,91,23,65,16,13,18,18,73,65,101,27,19,62,69};
for(i=0;i<31;i++)
{
for(j=0;j<31-i;j++)
{
if(a[j]>a[j+1])
t=a[j],a[j]=a[j+1],a[j+1]=t;
}
}
while(1);
}
|