Page 97 of 346 Start Back Next End ZBasic System Library 85 ZBasic Microcontrollers CRC32 Type Function returning UnsignedLong Invocation CRC32(data, count, crcPoly, crcInit, crcFlags) Parameter Method Type Description data ByRef anyType The data bytes to add to the CRC value. count ByVal integral The number of bytes to process. crcPoly ByVal UnsignedLong The CRC polynomial to use. crcInit ByVal UnsignedLong The initial value of the CRC. crcFlags ByVal integral Flag bits that control the CRC computation. Discussion This function computes the CRC value over a number of data bytes using a specified polynomial and initial value. The values to use for the polynomial and the initial value depend on the style of CRC that you need to generate. The flags parameter contains bits that control aspects of the CRC computation as described in the table below. Flag Values for the CRC Compuation Constant Hex Binary Description zxCRCRefIn &H01 xxxx xxx1 The input data bytes will be “reflected”. zxCRCRefOut &H02 xxxx xx1x The final CRC will be “reflected”. The remaining bits are reserved for future use and should always be zero. Although this function will typically be used to compute the CRC value for an entire block of data at once, it may also be used in a byte-by-byte or data burst mode. To do so, you would pass the computed CRC value from the previous iteration as the initial value. Note, however, that you shouldn’t use the zxRefOut flag bit in this case. Rather, if you need reflected output you would perform the bit reversal on the final CRC value when you reach the end of the data stream. See the discussion of the CRC16() function for additional information. Example Dim data(1 to 20) as Byte Dim crc as UnsignedLong crc = Not CRC32(data, 10, &H04c11db7, &Hffffffff, zxCRCRefIn Or zxCRCRefOut) Compatibility This function is not available in BasicX compatibility mode. Also, on ZX models that are based on the ATmega32 processor (e.g. the ZX-24) this function is implemented in “user code” (as opposed to being part of the VM) and is consequently slower than on other ZX models and ZBasic devices generally. See Also CRC16