Subversion Repositories Kolibri OS

Rev

Rev 6827 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6827 dunkaist 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2017. All rights reserved. ;;
4
;;  Distributed under terms of the GNU General Public License.  ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
8130 dunkaist 8
$Revision: 8130 $
9
 
6827 dunkaist 10
; This crc32 routine doesn't use precomputed table to allow different
11
; polynomials, which is the first param.
12
; Partial hash in assumed to be eax (both in and out).
13
; Usage:
14
; 1. mov eax, -1
15
; 2. stdcall crypto.crc32 zero or more times
16
; 3. xor eax, -1
17
proc crc_32 _poly, _buffer, _length
18
        push    ebx ecx edx esi
19
 
20
        mov     esi, [_buffer]
21
.next_byte:
22
        dec     [_length]
23
        js      .done
24
        movzx   ebx, byte[esi]
25
        inc     esi
26
        mov     ecx, 8
27
.next_bit:
28
        mov     edx, eax
29
        xor     edx, ebx
30
        shr     eax, 1
31
        test    edx, 1
32
        jz      @f
33
        xor     eax, [_poly]
34
@@:
35
        shr     ebx, 1
36
        dec     ecx
37
        jnz     .next_bit
38
        jmp     .next_byte
39
.done:
40
        pop     esi edx ecx ebx
41
        ret
42
endp