*******************************************************************************
*									      *
*  PACK BITS								      *
*  08/01/11 (dkc)							      *
*									      *
*  This C64 subroutine packs bits.  The calling sequence of the subroutine    *
*  is;									      *
*									      *
*     input data-> a4							      *
*     size-> b4 							      *
*     shift -> a6							      *
*									      *
*******************************************************************************
	.global _pack
	.text
_pack:	sub.l1x b4, a6, a0		; size - shift
||	shru.s1 a4, a6, a5		; shift off bits
||	mvk.d2 1, b0
||	b.s2 b3 			;  return

	shl.s1 a4, a0, a4
||	shl.s2 b0, b4, b0		; 2<<size

	or.l1 a5, a4, a4
||	sub.l2 b0, 1, b0		; 2<<size-1

	nop

	and.l1x a4, b0, a4

	nop
	.end