(48g/50g) CRC32

07102014, 05:02 PM
(This post was last modified: 07112014 11:22 PM by sirhecubus42.)
Post: #1




(48g/50g) CRC32
This UserRPL program computes the CRC32 of a hexadecimal string (e.g. "078F245BA1204C"). I use it at work to generate CRC's that match those generated by the DSU on the Atmel SAMD20 series of CortexM0+ microcontrollers. It is based on the implementation found here (since I didn't want a lookup table):
http://www.hackersdelight.org/hdcodetxt/crc.c.txt My program differs in that the CRC at the end is in one's complement format because that's what the SAMD DSU produces. Adding NOT as the last program statement will give the correct format. I used "#0h NOT" as the value to initialize the CRC because it takes up fewer bytes than #FFFFFFFFh. Hex strings with an odd number of characters are assumed to have a leading "0". Edit: Replaced DUPDUP with two DUPs so it would work on the 48G...not sure about the 48S/SX...don't have one to test. « 32 STWS # 0h NOT SWAP DUP SIZE DUP 2 MOD IF 0 = THEN 2 / ELSE 2 / 1  END 0 SWAP FOR i DUP DUP SIZE i 2 *  DUP 1  SWAP SUB "#" SWAP + "h" + STR> ROT XOR 0 7 FOR j DUP # 1h AND NEG # EDB88320h AND SWAP SR XOR NEXT SWAP NEXT SWAP » 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)