Article View: comp.sys.ibm.pc.programmer
Article #981CCITT CRC-16, code w/o tables
From: Joe Doupnik
Date: Sun, 15 Jul 1990 23:17
Date: Sun, 15 Jul 1990 23:17
31 lines
1608 bytes
1608 bytes
CRC calculation, the fast way. From MS-DOS Kermit, file MSSCOM.ASM. Copyright
but free to use non-commercially.
Joe D.
----------------------
; Calculate the CRC of the null-terminated string whose address is in BX.
; Returns the CRC in CX. Destroys BX and AX.
; The CRC is based on the SDLC polynomial: x**16 + x**12 + x**5 + 1.
; By Edgar Butt 28 Oct 1987 [ebb].
; Enter with initial CRC in DX (normally 0).
crcclc: push dx
mov cl,4 ; load shift count
crc0: mov ah,[bx] ; get the next char of the string
or ah,ah ; if null, then we're done
jz crc1 ; z = null, stop
inc bx
xor dl,ah ; XOR input with lo order byte of CRC
mov ah,dl ; copy it
shl ah,cl ; shift copy
xor ah,dl ; XOR to get quotient byte in ah
mov dl,dh ; high byte of CRC becomes low byte
mov dh,ah ; initialize high byte with quotient
xor al,al
shr ax,cl ; shift quotient byte
xor dl,ah ; XOR (part of) it with CRC
shr ax,1 ; shift it again
xor dx,ax ; XOR it again to finish up
jmp short crc0
crc1: mov cx,dx ; return CRC in CX
pop dx
ret
-------------------------------
Technical Details
Message-ID:
<28223@cc.usu.edu>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!emory!hubcap!mephisto!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!samsung!cs.utexas.edu!hellgate.utah.edu!cc.utah.edu!cc.usu.edu!jrdShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!emory!hubcap!mephisto!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!samsung!cs.utexas.edu!hellgate.utah.edu!cc.utah.edu!cc.usu.edu!jrd From: JRD@cc.usu.edu (Joe Doupnik) Newsgroups: comp.sys.ibm.pc.programmer Subject: CCITT CRC-16, code w/o tables Message-ID: <28223@cc.usu.edu> Date: 15 Jul 90 23:17:10 GMT Lines: 31