⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libchain.lst

📁 威望公司MP3 + USB MCU 的参考软件
💻 LST
📖 第 1 页 / 共 4 页
字号:
                              point += 3;                     // move the the MSB of next half word
                              *target = unicode;      // save the target
                              target ++;                      
                              length -= 2;
                      }
              
                      return target;                  // return the rear address of array
              }
              #endif
              #endif
 266          
 267          #if 0
              void UpperCase08(BYTE *string)
                      {
                      while(*string)
                              {
                              if(*string >= 0x61 && *string <=0x7a)   *string -= 0x20;
                              string ++;
                              }
                      }
              
              
              int ArrayCompare08(BYTE *a, BYTE *b, DWORD count)
                      {
                      while(count)
                              {
                              if(*a != *b)    return 0;
                              a ++;   b ++;
                              count --;
                              }
                              
                      return 1;
                      }
              
              
              
              int StringCompare08(BYTE *a, BYTE *b)
                      {
                      while(*a & *b)
                              {
                              if(*a != *b)    return 0;
                              a ++;   b ++;
                              }
                              
                      if(*a | *b)             return 0;
                      else                    return 1;
C51 COMPILER V8.01   LIBCHAIN                                                              04/17/2008 09:45:56 PAGE 6   

                      }
              
              
              
              void UpperCase16(WORD *string)
                      {
                      while(*string)
                              {
                              if(*string >= 0x0061 && *string <=0x007a)       *string -= 0x0020;
                              string ++;
                              }
                      }
              
              
              
              int ArrayCompare16(WORD *a, WORD *b, DWORD count)
                      {
                      while(count)
                              {
                              if(*a != *b)    return 0;
                              a ++;   b ++;
                              count --;
                              }
                              
                      return 1;
                      }
              
              
              
              int StringCompare16(WORD *a, WORD *b)
                      {
                      while(*a & *b)
                              {
                              if(*a != *b)    return 0;
                              a ++;   b ++;
                              }
                              
                      if(*a | *b)             return 0;
                      else                    return 1;
                      }
              
              
              
              // convert 'hex' to a hexdecimal string start at the position pointed
              // by 'string' and this string will have 'length' characters
              // return the BYTE position after the last character
              BYTE *HexString(BYTE *string, DWORD hex, BYTE length)
                      {
                      hex = hex << ( ( 8 - length ) * 4 );
                      
                      while(length)
                              {
                              *string = hex >> 28;
                              hex = hex << 4;
                              *string = *string + 0x30;
                              if(*string > 0x39)      *string = *string + 7;
                              string ++;
                              length --;
                              }
                      *string = 0;
              
                      return string;
C51 COMPILER V8.01   LIBCHAIN                                                              04/17/2008 09:45:56 PAGE 7   

                      }
              
              
              
              // convert the 'value' from binary to BCD
              DWORD Bin2Bcd(DWORD value)
                      {
                      register DWORD bcd;
                      register DWORD base;
                      
                      if(value > 99999999)    return 0x99999999;
                      
                      bcd = 0;        base = 10000000;
                      while(value >= base){value -= base;     bcd ++;}
                              
                      bcd <<= 4;      base = 1000000;
                      while(value >= base){value -= base;     bcd ++;}
                      
                      bcd <<= 4;      base = 100000;
                      while(value >= base){value -= base;     bcd ++;}
                      
                      bcd <<= 4;      base = 10000;
                      while(value >= base){value -= base;     bcd ++;}
                      
                      bcd <<= 4;      base = 1000;
                      while(value >= base){value -= base;     bcd ++;}
                      
                      bcd <<= 4;      base = 100;
                      while(value >= base){value -= base;     bcd ++;}
                      
                      bcd <<= 4;      base = 10;
                      while(value >= base){value -= base;     bcd ++;}
                      
                      bcd <<= 4;      bcd += value;
                      
                      return bcd;
                      }
              
              
              // convert 'dec' to a decimal string start at the position pointed
              // by 'string' and this string will have 'length' characters
              // return the BYTE position after the last character
              BYTE *DecString(BYTE *string, DWORD dec, BYTE length, BYTE decimal)
                      {
                      dec = Bin2Bcd(dec);
                      string = HexString(string, dec >> decimal, length);
                      
                      if(decimal)
                              {
                              *string = '.';
                              string ++;
                              string = HexString(string, dec, decimal);
                              }
                              
                      return string;
                      }
              
              BYTE *SkipLeadingZero(BYTE *string)
                      {
                      while(*string == '0')   string ++;
                      if(!*string)    string --;
                      
C51 COMPILER V8.01   LIBCHAIN                                                              04/17/2008 09:45:56 PAGE 8   

                      return string;
                      }
              
              
              
              BYTE *DigitStringSeparate(BYTE *string)
                      {
                      BYTE length;
                      BYTE commaNumber;
                      BYTE commaCounter;
                      BYTE *source, *target, *ret;
                      
                      length = StringLength08(string);
                      commaNumber = length / 3;
                      if(length == (commaNumber * 3)) commaNumber --;
                      
                      source = string + length - 1;
                      target = source + commaNumber + 1;
                      *target = 0;
                      ret = target;
                      target --;
                      
                      commaCounter = 0;
                      while(length)
                              {
                              *target = *source;
                              target --;
                              source --;
                              commaCounter ++;
                              if(commaCounter == 3 && commaNumber)
                                      {
                                      *target = ',';
                                      target --;
                                      commaCounter = 0;
                                      commaNumber --;
                                      }
                              length --;
                              }
                      
                      return ret;
                      }
              
              BYTE *StringCopy08(BYTE *target, BYTE *source)
                      {
                      while(*source)
                              {
                              *target = *source;
                              target ++;
                              source ++;
                              }
                      *target = '\0';
                      
                      return target;
                      }       
              
              BYTE *StringCopy1608(BYTE *target, WORD *source)
                      {
                      while(*source)
                              {
                              *target = (BYTE)*source;
                              target ++;
                              source ++;
C51 COMPILER V8.01   LIBCHAIN                                                              04/17/2008 09:45:56 PAGE 9   

                              }
                      *target = 0;
                      
                      return target;
                      }
              
              WORD StringLength08(BYTE *string)
                      {
                      register WORD length;
                      
                      length = 0;
                      while(*string)
                              {
                              length ++;
                              string ++;
                              }
                              
                      return length;
                      }
              
              
              
              WORD StringLength16(WORD *string)
                      {
                      register WORD length;
                      
                      length = 0;
                      while(*string)
                              {
                              length ++;
                              string ++;
                              }
                              
                      return length;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -