; Copyright (c) 2002
; Pavel "EvilOne" Minayev
;
; Permission to use, copy, modify, distribute and sell this software
; and its documentation for any purpose is hereby granted without fee,
; provided that the above copyright notice appear in all copies and
; that both that copyright notice and this permission notice appear
; in supporting documentation.  Author makes no representations about
; the suitability of this software for any purpose. It is provided
; "as is" without express or implied warranty.

bits 32

segment .text
start:
	enter 0, 0
	; load arguments into registers
    mov ebx, [ebp+16]	; CRC-table
    mov ecx, [ebp+12]	; string length
	mov esi, [ebp+08]	; string
	; initialize
	mov eax, 0xFFFFFFFF
	xor edx, edx
calcbyte:
	; process a single byte:
	; crc = table[(unsigned char)crc ^ byte] ^ (crc >> 8)
	mov dl, al
	xor dl, [esi]
	shr eax, 8
	xor eax, [ebx+edx*4]
	inc esi
	loop calcbyte
	; clean up and return
	leave
	ret 16
