'---------------------------------------------------------------------------------------- ' Name: CRC_DEMO_001.TIG ' Type: TIGER-BASIC(tm) Source Code ' ' Purpose: Short demo of new CRC function for subsequent use for easy calculation of ' CRCs in large objects as sequential data streams of indefinite length, ' files from SmartMedia FLASH cards, or any other kind of large data sources. ' ' (C) - Copyright Wilke Technology, P.O.Box 1727, D-52018 Aachen, Germany '---------------------------------------------------------------------------------------- ' ' Thank you for using BASIC Tigers in your products. If you have questions, ideas ' or special needs, please contact your next distributor or the Tiger support team ' and visit our web site: ' ' Wilke Technology GmbH ' The Tiger Support Team ' P.O.Box 1727, D-52018 Aachen, Germany ' Krefelder Str. 147, D-52070 Aachen, Germany ' ' email: support@wilke-technology.com (english) ' email: support@wilke.de (german) ' Phone: +49 (241) 918 900 Mo to Fr, 7:00 to 16:00 (GMT) ' Fax: +49 (241) 918 9068 ' ' New information, new drivers and free downloads see: ' ' www.wilke-technology.com (english) ' www.wilke.de (german) ' ' Sincerely, ' ' Your Tiger Support Team ' '---------------------------------------------------------------------------------------- ' ' Calculate CRC: CRC (A$, POS, LEN, START, STEP, CRC) ' ' ' Comparison: In contrast to "CALC_CRC" there is NO function value ! ' This new function lends itself to calculate the CRC in large objects ' as files (e.g. from SmartMedia FLASH cards) over many megabytes. ' ' ' CRC (A$, POS, LEN, START, STEP, CRC) ' ===== === <-- "====" Input + Output !!! ' ' ' The function calculates a CRC in a SOURCE string. The parameters "POS" and "LEN" ' determine, from which position and how many bytes should be taken. ' ' START = Starting value of FACTOR --> also starting value: --> gives NEXT START value for ' the following function call ' STEP = Stepping width of FACTOR ' ' LEN = Length in bytes: 1...64K-1 (for now: limited) ' ' CRC = Entry value for CRC --> also starting value: Resulting CRC ' Start CRC is summed up ' ' ' Note: Value range of FACTOR = 0...FFFF (unsigned) ' FACTOR jumps at the end of the range back to the next, small value ' ' ' Build 32-bit CRC: 1. Byte * (FAKTOR) --> sum up ' (byte-by-byte) 2. Byte * (FACTOR+1*STEP) --> sum up ' 3. Byte * (FACTOR+2*STEP) --> sum up ' 4. Byte * (FACTOR+3*STEP) --> sum up ' . . ' . . ' 100. Byte * (FACTOR+199*STEP) --> sum up ' . . ' . . ' Sum = 32 bit = 8 HEX digits ' (on overrun: don't care !!) ' ' ' Note: To get a useful protection by the CRC: ' Starting value = odd ' Stepping width = even ' ' To possibly get the maximum number of factors = 32k ' choose the stepping width wisely. ' E.g. Step = 6 (32K factors) is good, Step = 8 (8K factors) ' is not so good. ' ' Example: Start = 7, Step = 6 ' ' 7,13,19,25, ... 65533,3,9,15, .... 65535,5,11,17, .... ' ' ' Also good: STEP = 2 (logical) ---> gives 32K factors '---------------------------------------------------------------------------------------- TASK MAIN STRING A$ (1K) LONG POS, XLEN, START, XSTEP, XCRC A$ = FILL$ ("the quick ", 1K) POS = 0 XLEN = 2 START = 7 XSTEP = 4 XCRC = 0 '----------------------------------------------------------------------------------------- ' Repeated use of the CRC function is easily possible '----------------------------------------------------------------------------------------- ' CRC (A$, POS, LEN, START, STEP, CRC) ' ===== === <-- "====" Input + Output !!! CRC (A$, POS, XLEN, START, XSTEP, XCRC) CRC (A$, POS, XLEN, START, XSTEP, XCRC) CRC (A$, POS, XLEN, START, XSTEP, XCRC) CRC (A$, POS, XLEN, START, XSTEP, XCRC) CRC (A$, POS, XLEN, START, XSTEP, XCRC) END