您现在的位置: 范文先生网 >> 理工论文 >> 计算机论文 >> 正文

CRC校验实用程序库

时间:2007-1-30栏目:计算机论文

turn 1; */
/* 函数crcupdate用以用查表法计算CRC值并更新CRC累加器值 */
void crcupdate(data,accum,crctab)
unsigned short data;/* 输入的数据 */
unsigned short *accum;/* 指向CRC累加器的指针 */
unsigned short *crctab;/* 指向内存中CRC表的指针 */
{
static short comb-val;
comb-val=(*accum>>8)^data;
*accum=(*accum<<8)^crctab[comb-val];
}
/* 函数crcrevhware是传统的CRC算法的反序算法,其返回值即CRC值 */
unsigned short crcrevhware(data,genpoly,accum)
unsigned short data;
unsigned short genpoly;
unsigned short accum;
{
static int i;
data<<=1;
for(i=8;i>0;i--)
{
data>>=1;
if((data^accum)&0x0001)

accum=(accum>>1)^genpoly;
else
accum>>=1;
}
return accum;
}
/* 函数crcrevupdate用以用反序查表法计算CRC值并更新CRC累加器值 */
void crcrevupdate(data,accum,crcrevtab)
unsigned short data;
unsigned short *accum;

 


上一页  [1] [2] 

下页更精彩:1 2 3 4 下一页