Subversion Repositories Kolibri OS

Rev

Rev 9715 | Details | Compare with Previous | Last modification | View Log | RSS feed

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