
/*
 *  Adds crc-16 to bytes p[len] and p[len+1]
 */
void inline addcrc(register unsigned char *p, register unsigned int len)
{
    register unsigned int i, bit, dat, bcc = 0x000000ff;
    while ( len-- ) {
        dat = *(p++); i = 8;
        while ( i-- ) {
            bit = (bcc^(dat&0x1))&0x1;
            bcc >>= 1;
            dat >>= 1;
            if ( bit ) bcc ^= 0x00008408;
        }
    }
    *(p++) = bcc&0xff;
    bcc >>= 8;
    *(p++) = bcc&0xff;
    return;
}
