include	clib.inc
include	iost.inc

	public	oupdcrc

_TEXT	SEGMENT

oupdcrc	proc
	push ax
	push di
	les bx,[si]
	add bx,dx		; update from read offset
      ifdef __386__
	mov cx,ax		; size to update
	mov edx,[si.ios_bb]	; current CRC value
	.while cx
	    movzx ax,dl
	    xor	al,es:[bx]
	    shl ax,2
	    mov di,ax
	    shr edx,8
	    xor edx,[di+crctab]
	    inc bx
	    dec cx
	.endw
	mov [si.ios_bb],edx
      else
	push si
	mov dx,word ptr [si.ios_bb]
	mov cx,word ptr [si.ios_bb+2]
	mov si,ax
	.while si
	    mov ah,0
	    mov al,dl
	    xor al,es:[bx]
	    shl ax,2
	    mov di,ax
	    mov dl,dh
	    mov dh,cl
	    mov cl,ch
	    mov ch,0
	    xor dx,word ptr [di+crctab]
	    xor cx,word ptr [di+crctab+2]
	    inc bx
	    dec si
	.endw
	pop si
	mov word ptr [si.ios_bb],dx
	mov word ptr [si.ios_bb+2],cx
      endif
	pop di
	pop ax
	ret
oupdcrc	endp

_TEXT	ENDS

	END
