piclist 1999\04\16\022427a >
Thread: CRC16
face BY : Dr. Imre Bartfai email (remove spam text)

On Thu, 15 Apr 1999, Gerhard Fiedler wrote:

{Quote hidden}

Hi, if I talk about CRC16 I mean *always* all CRC's with 16 bits because
of the algorythm is always the same. There are only 2 differences: which
mask you use (in the example it was A005 if I recall; I use always 1021h
according to the CCITT recommendation), and whether there is a start value
of 0x00 or 0xFF . For the sake of convenience, I include my own CRC
routine for x86 (no fear, it's no longish).


P.S. The IF NZ construct is self-explanatory. It is coming from the A86
assembler (thank you, Eric Isaacson!).

;This subroutine calculates a 16-bit CRC
;Synopsis:  MOV AX,CRC16    ; i/o parameter
;           MOV BL,C        ; char using the update
;           MOV DX,MASK     ; polynomial (e. g. 1021h for CCITT)
;           CALL CRC16
;           MOV CRC16,AX    ; store returned value
;                           ; BX destroyed
CRC16:  PUSH    CX,SI       ; save register
       XOR     BH,BH       ; clear upper
       XCHG    BL,BH       ; into upper
       MOV     CX,8        ; set up loop
L1:     MOV     SI,AX       ; temporary save
       SAL     AX,1        ; rotate
       XOR     SI,BX       ; temporary result
       TEST    SI,8000h    ; highest bit
       IF NZ   XOR AX,DX   ; if set
       SAL     BX,1        ; use operand
       LOOP    L1          ; end of loop
       POP     SI,CX       ; restore register
       RET                 ; return to caller


In reply to: <4.1.19990415092036.0099c810@mail.elcjn1.sdca.home.com>
See also: www.piclist.com/techref/method/errors.htm?key=crc
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) CRC16

month overview.

new search...