include	clib.inc
include	tobj.inc

PPROC	tosetbitflag, tobj:dword, count:word, flag:word, bitflag:dword
	push	si
	push	di
	mov	dx,word ptr bitflag
	mov	si,flag
	mov	cx,count
	les	bx,tobj
	mov	ax,si
	not	ax
	mov	di,16
	test	cx,cx
	jz	tosetbitflag_end
    tosetbitflag_loop:
	and	es:[bx],ax
	shr	dx,1
	jnc	@F
	or	es:[bx],si
    @@:	add	bx,16
	dec	di
	jnz	@F
	mov	dx,word ptr bitflag+2
    @@:	dec	cx
	jnz	tosetbitflag_loop
    tosetbitflag_end:
	pop	di
	pop	si
	ret
PEND	tosetbitflag

	END
