Subversion Repositories Kolibri OS

Rev

Rev 6827 | Rev 9715 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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