home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.cbm
- Path: sparky!uunet!elroy.jpl.nasa.gov!usc!sol.ctr.columbia.edu!destroyer!ubc-cs!unixg.ubc.ca!kakwa.ucs.ualberta.ca!access.usask.ca!ccu.umanitoba.ca!shad04
- From: shad04@ccu.umanitoba.ca (Dan Fandrich)
- Subject: Re: 16 bit CRC source?
- Message-ID: <1992Sep9.094328.16978@ccu.umanitoba.ca>
- Summary: Actual code!
- Organization: University of Manitoba, Winnipeg, Manitoba, Canada
- References: <ioVNqB1w164w@jwt.UUCP>
- Date: Wed, 9 Sep 1992 09:43:28 GMT
- Lines: 64
-
- In article <ioVNqB1w164w@jwt.UUCP> bbs-artmoore@jwt.UUCP writes:
- >Am looking for either 16-bit CRC source code (64/128) or the
- >equation/tables.
-
- Here's a 6502 code fragment to calculate a 16-bit CRC from my nearly finished
- C64 ZMODEM implementation (which has fallen by the wayside -- anyone
- interested in finishing it?).
-
- -------- cut here
- ;
- ;Calculate 16-bit CRC on a data block
- ;by Daniel Fandrich <shad04@ccu.umanitoba.ca>
- ;
- ;This algorithm is the same as used in ZMODEM's CRC-16 fallback mode.
- ;
- ;To use:
- ; 1) store 0 in crc and crc+1
- ; 2) call updcrc once for each byte in the data block
- ; 3) call updcrc twice with the block's two CRC-16 bytes
- ; 4) if the result in crc and crc+1 are both 0, the data block is correct
- ;
- crc = $fb
- temp = $fd
-
- updcrc sta temp
- pha
- txa
- pha
- ldx #$07
- crc1 bit crc+1
- bpl crc2
- jsr crccal
- lda crc+1
- eor #$10
- sta crc+1
- lda crc
- eor #$21
- sta crc
- clc
- bcc crc3
- crc2 jsr crccal
- crc3 dex
- bpl crc1
- pla
- tax
- pla
- rts ;exit routine
- ;
- crccal asl crc
- rol crc+1
- asl temp
- lda crc
- adc #0
- sta crc
- lda crc+1
- adc #0
- sta crc+1
- rts
- ;end of source fragment
- -------- cut here
-
- >>> Dan
- --
- Internet: shad04@ccu.umanitoba.ca Compu$erve: 72365,306
-