Re: [cc65] CRC-32

Date view Thread view Subject view

From: MagerValp (MagerValp_at_cling.gu.se)
Date: 2003-09-22 16:04:36


>>>>> "ST" == Spiro Trikaliotis <trik-news_at_gmx.de> writes:

UvB> Well, I had the same problems as Magervalp (crc 32 functions that
UvB> do not work together). And, checking the polynomial mentioned in
UvB> the source code available from 6502.org doesn't match the one
UvB> I've used for years in my own code.

ST> I don't know your exact code. Normally, CRC32 are calculated with
ST> MSB first. Anyway, to optimize the code, depending on
ST> big-/low-endianness, some algorithms in fact need a reversed
ST> polynomial. Have you checked if this is the case in the polynomial
ST> you used?

Yes, there does indeed seem to be a fair bit of confusion about
CRC-32, both wrt the polynomial and the starting seed. However, it
turned out that I just wasn't reading the docs on 6502.org correctly.
The polynomial used is (binary) reversed for performance reasons, and
the result needs to be inverted (result =^ 0xffffffff). After doing
this, it gives me the same result as zip does. However, perl is still
fux0red. The source code for String::CRC lists the following as the
(64-bit) polynomial and the init:

#define HINIT1  0xFAC432B1UL
#define HINIT2  0x0CD5E44AUL

#define POLY1   0x00600340UL
#define POLY2   0x00F0D50BUL

The polynomial is simply shifted one bit for every size down to
CRC-16. I have no idea where they got them from.

-- 
                       Wildstar delenda est
    ___          .     .  .         .       . +  .         .      o   
  _|___|_   +   .  +     .     +         .  Per Olofsson, arkadspelare
    o-o    .      .     .   o         +          MagerValp_at_cling.gu.se
     -       +            +    .     http://www.cling.gu.se/~cl3polof/
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-09-22 16:09:38 CEST