; run length de-coder test system

.text

rldt::	movem.l	d0-d3/a0-a2,-(a7)
	move.l	#21,d3		; d3 is the decremental counter used to run down through the list of encoded data
	move.l	#$60000,a6	; a6 is where the final counts will be placed

tlop:	move.l	d3,d0

	asl.l	#2,d0		; multiply up
	add.l	rlepoint.w,d0
	movea.l	d0,a2
	movea.l	(a2)+,a1
	movea.l	(a2)+,a2

	moveq.l	#0,d0
	moveq.l	#0,d1

.din:	move.w	(a1)+,d0
	btst	#15,d0
	bne.b	.singles

	addq.l	#2,a1
	bra.b	.din

.singles:
	sub.l	#$8000,d0
	beq.b	.ended

	asl.l	#1,d0
	adda.l	d0,a1
	bra.b	.din

.ended:	move.l	a2,(a6)+
	move.l	a1,(a6)+

	dbra	d3,tlop

	movem.l	(a7)+,d0-d3/a0-a2
	rts


