Ultra-fast CRC-32 calculation library for Rapid-Q Copyright (c) 2002 Pavel "EvilOne" Minayev
This is a Rapid-Q library (include file) that provides functions to calculate CRC-32 of an arbitrary block of memory, and of string. The core of the library is written in assembler and thus is significantly faster than any algorithm that could be implemented in Rapid-Q. No external files are needed, the machine code is embedded into your executable using my ASM-in-RQ technique.
To use it in your program, first make sure that CRC32.BIN is the directory from where you call the compiler. Then, just use $INCLUDE to load the CRC32.INC file into your program.
The library contains two public functions:
FUNCTION CRC32(Pointer AS LONG, Size AS LONG) AS LONG FUNCTION STRCRC32(Str AS STRING) AS LONG
The first one calculates CRC-32 of a block of memory located at Pointer, of Size bytes and returns the result. The second calculates CRC-32 of the string passed as an argument, and is just a convenient wrapper around the first. Note that both functions return LONG (Windows version doesn't support DWORD), however, the bit-pattern is exactly the same, since the algorithm works with unsigned integers internally.
For a sample program, see CRCTEST.RQ. Source code is in CRC32.INC and CRC32.ASM. |