hello all,
I've written a function in c that converts a byte (unsigned char) BCD string into ASCII. Please have look at the code and advice some improvements.
Is there any other efficient way that can convert BYTE BCD to ASCII.
BYTE_BCD_to_ASC(BYTE *SrcString, char *DesString)
{
switch (((BCD *)SrcString)->l)
{
case 10:/*A*/
case 11:/*B*/
case 12:/*C*/
case 13:/*D*/
case 14:/*E*/
case 15:/*F*/
*DesString = (char)(((BCD *)SrcString)->l + '0' + 7);
break;
default:
*DesString = (char)(((BCD *)SrcString)->l + '0');
break;
}
switch (((BCD *)SrcString)->h)
{
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
*(DesString + 1) = (char)(((BCD *)SrcString)->h + '0' + 7);
break;
default:
*(DesString + 1) = (char)(((BCD *)SrcString)->h + '0');
break;
}
*(DesString + 2) = '\0';
}
thanks
Fakhar