/*当前米数储存子程序*/
void dqmscc()
{
uchar w,q,b,g,s;
w=(unsigned char)dqms/10000%10;
q=(unsigned char)dqms/1000%10;
b=(unsigned char)dqms/100%10;
s=(unsigned char)dqms/10%10;
g=(unsigned char)dqms%10;
SectorErase(0x2000);
byte_write(0x2000,w);
byte_write(0x2008,q);
byte_write(0x200f,b);
byte_write(0x2017,s);
byte_write(0x201e,g);
}
/*当前米数读出子程序*/
void dqmsdc()
{
uchar w,q,b,g,s;
w=byte_read(0x2000);
q=byte_read(0x2008);
b=byte_read(0x200f);
s=byte_read(0x2017);
g=byte_read(0x201e);
dqms=w*10000+q*1000+b*100+s*10+g;
}
最好写成
/*当前米数储存子程序*/
void dqmscc()
{
uchar w,q,b,g,s;
q=(qms>>24)&0xff;
b=(dqms>>16)&0xff;
s=(dqms>>8)&0xff;
g=dqms&0xff;
SectorErase(0x2000);
byte_write(0x2000,w);
byte_write(0x2008,q);
byte_write(0x200f,b);
byte_write(0x2017,s);
byte_write(0x201e,g);
}
/*当前米数读出子程序*/
void dqmsdc()
{
uchar w,q,b,g,s;
q=byte_read(0x2008);
b=byte_read(0x200f);
s=byte_read(0x2017);
g=byte_read(0x201e);
dqms=(q<<24)|(b<<16)|(s<<8)|g;
}
|