Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  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.  
  8. ; This crc32 routine doesn't use precomputed table to allow different
  9. ; polynomials, which is the first param.
  10. ; Partial hash in assumed to be eax (both in and out).
  11. ; Usage:
  12. ; 1. mov eax, -1
  13. ; 2. stdcall crypto.crc32 zero or more times
  14. ; 3. xor eax, -1
  15. proc crc_32 _poly, _buffer, _length
  16.         push    ebx ecx edx esi
  17.  
  18.         mov     esi, [_buffer]
  19. .next_byte:
  20.         dec     [_length]
  21.         js      .done
  22.         movzx   ebx, byte[esi]
  23.         inc     esi
  24.         mov     ecx, 8
  25. .next_bit:
  26.         mov     edx, eax
  27.         xor     edx, ebx
  28.         shr     eax, 1
  29.         test    edx, 1
  30.         jz      @f
  31.         xor     eax, [_poly]
  32. @@:
  33.         shr     ebx, 1
  34.         dec     ecx
  35.         jnz     .next_bit
  36.         jmp     .next_byte
  37. .done:
  38.         pop     esi edx ecx ebx
  39.         ret
  40. endp
  41.