Difference between revisions of "Z80 Routines:Security:CRC16"
From WikiTI
m (just a CRC16 routine I edited) |
(Previous edit by Saibot84 is not minor (creating a new page is not minor! :))) |
||
Line 2: | Line 2: | ||
[[Category:Z80 Routines|CRC16]] | [[Category:Z80 Routines|CRC16]] | ||
{{Untested-Code}} | {{Untested-Code}} | ||
+ | |||
<nowiki>CRC16: | <nowiki>CRC16: | ||
;Borrowed from http://zilog.sh.cvut.cz/~base/misc/z80bits.html | ;Borrowed from http://zilog.sh.cvut.cz/~base/misc/z80bits.html |
Latest revision as of 14:51, 27 May 2006
This code is untested and may not work as advertised or at all.
CRC16: ;Borrowed from http://zilog.sh.cvut.cz/~base/misc/z80bits.html ; and moddified to be a loop ;The arrow comments show what lines I added or commented out from the original. ;Inputs: de->data bc=number of bytes ;Outputs: hl=CRC16 push bc ;<---<<< push de ;<---<<< push af ;<---<<< ld hl,$FFFF push bc ;<---<<< CRC16_Read: ld a,(de) inc de xor h ld h,a ld b,8 CRC16_CrcByte: add hl,hl jr nc,CRC16_Next ld a,h xor $10 ld h,a ld a,l xor $21 ld l,a CRC16_Next: djnz CRC16_CrcByte ; dec c ;>>>---> pop bc ;<---<<< dec bc ;<---<<< push bc ;<---<<< ld a,b ;<---<<< or c ;<---<<< jr nz,CRC16_Read pop bc ;<---<<< pop af ;<---<<< pop de ;<---<<< pop bc ;<---<<< ret