comp = qproc (b: _bytevec)
	move	(rr)+,n1
	asr	3,n1
	subq	1,n1
	qloop
		not	(rr)+
		dbra	n1,this
	end
	movea	n0,rr
	end comp

getb = qproc (b: _bytevec, bit: int) returns (bool)
	movea	b,r1
	move	rr,n1
	asr	1,n1
	moveq	0,n2
	moveb	n1,n2
	andib	7,n2
	asr	3,n1
	btst	n2,4(r1,n1)
	sne	n2
	return(n2)
	end getb

getn = qproc (b: _bytevec, bit, len: int) returns (int)
	move	rr,n6
	ifeq	asr	1,n6
	then	return(n0)
	end
	movea	b,r1
	move	bit,n1
	asr	1,n1
	moveq	0,n2
	moveb	n1,n2
	andib	31,n2
	asr	3,n1
	andib	-4,n1
	moveq	1,n3
	asl	n6,n3
	subq	1,n3
	rol	n2,n3
	moveq	32,n7
	sub	n2,n7
	sub	n6,n7
	ifgt	neg	n7
	then	moveq	1,n5
		asl	n7,n5
		subq	1,n5
		move	n3,n4
		ifne	and	n5,n4
		then	move	8(r1,n1),n7
			rolw	8,n7
			swap	n7
			rolw	8,n7
			and	n7,n4
		end
		not	n5
		and	n5,n3
		move	4(r1,n1),n7
		rolw	8,n7
		swap	n7
		rolw	8,n7
		and	n7,n3
		or	n4,n3
	else	move	4(r1,n1),n7
		rolw	8,n7
		swap	n7
		rolw	8,n7
		and	n7,n3
	end
	ror	n2,n3
	add	n3,n3
	addq	1,n3
	return(n3)
	end getn

setb = qproc (b: _bytevec, bit: int)
	movea	b,r1
	move	rr,n1
	asr	1,n1
	moveb	n1,n2
	andib	7,n2
	asr	3,n1
	bset	n2,4(r1,n1)
	end setb

setn = qproc (b: _bytevec, bit, len: int)
	move	rr,n6
	ifeq	asr	1,n6
	then	return
	end
	movea	b,r1
	move	bit,n1
	asr	1,n1
	moveq	0,n2
	moveb	n1,n2
	andib	31,n2
	asr	3,n1
	andib	-4,n1
	moveq	1,n3
	asl	n6,n3
	subq	1,n3
	rol	n2,n3
	moveq	32,n7
	sub	n2,n7
	sub	n6,n7
	ifgt	neg	n7
	then	moveq	1,n5
		asl	n7,n5
		subq	1,n5
		move	n3,n4
		ifne	and	n5,n4
		then	;rolw	8,n4
			swap	n4
			;rolw	8,n4
			or	n4,8(r1,n1)
		end
		not	n5
		and	n5,n3
	end
	;rolw	8,n3
	swap	n3
	;rolw	8,n3
	or	n3,4(r1,n1)
	end setn
