byte bval;
word wval,wj;
word code *sumvalue;// define the ROM checksum value
byte *bbpt;
word str2whex(byte *pt)
{
byte i;
for(i=0;i<=3;i++)
{
wj=0x0000;
if((pt[i]>='0')&&(pt[i]<='9'))wj=pt[i]-'0';
if((pt[i]>='A')&&(pt[i]<='F'))wj=0x0a+(pt[i]-'A');
if((pt[i]>='a')&&(pt[i]<='f'))wj=0x0a+(pt[i]-'a');
if(i==0)wval=wj;
if(i==1)wval=wval+(wj<<4 nbsp="" span="">4>
if(i==2)wval=wval+(wj<<8 nbsp="" span="">8>
if(i==3)wval=wval+(wj<<12 nbsp="" span="">12>
}
return wval;
}
byte str2bhex(byte *pt)
{
byte i,j;
for(i=0;i<=1;i++)
{
j=0x00;
if((pt[i]>='0')&&(pt[i]<='9'))j=pt[i]-'0';
if((pt[i]>='A')&&(pt[i]<='F'))j=0x0a+(pt[i]-'A');
if((pt[i]>='a')&&(pt[i]<='f'))j=0x0a+(pt[i]-'a');
if(i==0)bval=j;
if(i==1)bval=bval+(j<<4 nbsp="" span="">4>
}
return bval;
}
void fillauxram()
{
//byte xdata ss;
CHPCON = 0x10;
xdatapt = 0x0000;
for(mi=0;mi<0xfe mi="" span="">0xfe>
*xdatapt=0x55;
xdatapt++;
}
xdatapt = 0x0100;
for(mi=0;mi<0xfe mi="" span="">0xfe>
*xdatapt=0xa5;
xdatapt++;
}
//CHPCON = 0x00;
}
byte w2byte(word xx,byte yy){
if(yy==0){
return (byte )xx&0x00ff;
}
if(yy==1){
return (byte )xx>>8;
}
}
word setchecksum(word spt1,word spt2){
word idata chkvalue;
byte code *ipt;
chkvalue = 0x0000;
for(ipt = spt1 ; ipt <= spt2 ; ipt++ )chkvalue += *ipt;
return chkvalue;
}
byte iramcheck(){//check 0x40..0xfe idata ram
byte IDATA *ipt;
byte i,tmp;
EA=0;
ipt = 0x40;
for(i=0x40;i<0xfe i="" span="">0xfe>
tmp =*ipt;
*ipt=0x55;
if(*ipt != 0x55)break;
*ipt=0xaa;
if(*ipt != 0xaa)break;
*ipt=tmp;
ipt++;
}
EA=1;
if( i != 0xfe)
return 0x55; //err ram
else
return 0x00;//ok !
}
byte xramcheck(){ // chcek 0x00.. 0xfe aux xdata ram
byte IDATA *xpt;
byte i,tmp;
CHPCON = 0x10;
EA=0;
xpt = 0x0000;
for(i=0x00;i<0xfe i="" span="">0xfe>
tmp =*xpt;
*xpt=0x55;
if(*xpt != 0x55)break;
*xpt=0xaa;
if(*xpt != 0xaa)break;
*xpt=tmp;
xpt++;
}
EA=1;
if(i != 0xfe)
return 0x55; //err ram
else
return 0x00;//ok !
}
word wval,wj;
word code *sumvalue;// define the ROM checksum value
byte *bbpt;
word str2whex(byte *pt)
{
byte i;
for(i=0;i<=3;i++)
{
wj=0x0000;
if((pt[i]>='0')&&(pt[i]<='9'))wj=pt[i]-'0';
if((pt[i]>='A')&&(pt[i]<='F'))wj=0x0a+(pt[i]-'A');
if((pt[i]>='a')&&(pt[i]<='f'))wj=0x0a+(pt[i]-'a');
if(i==0)wval=wj;
if(i==1)wval=wval+(wj<<4 nbsp="" span="">4>
if(i==2)wval=wval+(wj<<8 nbsp="" span="">8>
if(i==3)wval=wval+(wj<<12 nbsp="" span="">12>
}
return wval;
}
byte str2bhex(byte *pt)
{
byte i,j;
for(i=0;i<=1;i++)
{
j=0x00;
if((pt[i]>='0')&&(pt[i]<='9'))j=pt[i]-'0';
if((pt[i]>='A')&&(pt[i]<='F'))j=0x0a+(pt[i]-'A');
if((pt[i]>='a')&&(pt[i]<='f'))j=0x0a+(pt[i]-'a');
if(i==0)bval=j;
if(i==1)bval=bval+(j<<4 nbsp="" span="">4>
}
return bval;
}
void fillauxram()
{
//byte xdata ss;
CHPCON = 0x10;
xdatapt = 0x0000;
for(mi=0;mi<0xfe mi="" span="">0xfe>
*xdatapt=0x55;
xdatapt++;
}
xdatapt = 0x0100;
for(mi=0;mi<0xfe mi="" span="">0xfe>
*xdatapt=0xa5;
xdatapt++;
}
//CHPCON = 0x00;
}
byte w2byte(word xx,byte yy){
if(yy==0){
return (byte )xx&0x00ff;
}
if(yy==1){
return (byte )xx>>8;
}
}
word setchecksum(word spt1,word spt2){
word idata chkvalue;
byte code *ipt;
chkvalue = 0x0000;
for(ipt = spt1 ; ipt <= spt2 ; ipt++ )chkvalue += *ipt;
return chkvalue;
}
byte iramcheck(){//check 0x40..0xfe idata ram
byte IDATA *ipt;
byte i,tmp;
EA=0;
ipt = 0x40;
for(i=0x40;i<0xfe i="" span="">0xfe>
tmp =*ipt;
*ipt=0x55;
if(*ipt != 0x55)break;
*ipt=0xaa;
if(*ipt != 0xaa)break;
*ipt=tmp;
ipt++;
}
EA=1;
if( i != 0xfe)
return 0x55; //err ram
else
return 0x00;//ok !
}
byte xramcheck(){ // chcek 0x00.. 0xfe aux xdata ram
byte IDATA *xpt;
byte i,tmp;
CHPCON = 0x10;
EA=0;
xpt = 0x0000;
for(i=0x00;i<0xfe i="" span="">0xfe>
tmp =*xpt;
*xpt=0x55;
if(*xpt != 0x55)break;
*xpt=0xaa;
if(*xpt != 0xaa)break;
*xpt=tmp;
xpt++;
}
EA=1;
if(i != 0xfe)
return 0x55; //err ram
else
return 0x00;//ok !
}
沒有留言:
張貼留言