Thread View: comp.sys.ibm.pc.programmer
1 messages
1 total messages
Started by Joe Doupnik
Sun, 15 Jul 1990 23:17
CCITT CRC-16, code w/o tables
Author: 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
-------------------------------
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads