CRC-16-CCITT: Difference between revisions
From Bitchin100 DocGarden
Jump to navigationJump to search
(→Author) |
(→Code) |
||
(One intermediate revision by the same user not shown) | |||
Line 14: | Line 14: | ||
<pre> | <pre> | ||
; XMODEM/CRC, YMODEM, ZMODEM CRC-16 | ; XMODEM/CRC, YMODEM, ZMODEM CRC-16 | ||
; Will CRC up to | ; Will CRC up to 255 bytes at a time. | ||
; Call multiple times to CRC more than | ; Call multiple times to CRC more than 255 bytes. | ||
; Entry: | ; Entry: | ||
; HL contains initial CRC value. Supply zero for initial block | ; HL contains initial CRC value. Supply zero for initial block | ||
Line 52: | Line 52: | ||
RET | RET | ||
</pre> | </pre> | ||
[[Category:Model T Developer Reference]] [[Category:8085 Subroutine]] |
Latest revision as of 13:35, 12 August 2011
Overview
The CRC-16-CCITT CRC is used in XMODEM/CRC, YMODEM, and ZMODEM.
This article includes 8085 code to compute this CRC on blocks as large as 256 characters. It can be called multiple times with the prior checksum to extend the CRC over larger blocks.
Author
John R. Hogerhuis <jhoger@pobox.com>
Speaker To Machines, Inc.
Code
; XMODEM/CRC, YMODEM, ZMODEM CRC-16 ; Will CRC up to 255 bytes at a time. ; Call multiple times to CRC more than 255 bytes. ; Entry: ; HL contains initial CRC value. Supply zero for initial block ; DE contains a pointer to the value to CRC ; B contains the number of bytes to CRC. ; nb: B must be non-zero. No checking is performed here. ; Exit: ; HL contains the CRC ; DE points just past the last CRC'ed character ; B is zero ; C is zero ; A, flags are undefined CALC_CRC16: LDAX D XRA H MOV H,A MVI C,8 FOR_CRC_BIT: DAD H JNC NEXT_CRC_BIT MVI A,$10 XRA H MOV H,A MVI A,$21 XRA L MOV L,A NEXT_CRC_BIT: DCR C JNZ FOR_CRC_BIT INX D DCR B JNZ CALC_CRC16 RET