*******************************************************************************
*									      *
*  SHIFT RIGHT								      *
*  03/07/09 (dkc)							      *
*									      *
*  This C64 subroutine shifts right by a specified amount.  The calling       *
*  sequence of the subroutine is;					      *
*									      *
*     d[0] => a4							      *
*     d[1] => b4							      *
*     shift amount => a6						      *
*     address of output => b6						      *
*									      *
*******************************************************************************
	.global _shift
	.text
_shift: b.s2 b3
||	mvk.s1 32, a0		   ; load 32

	mv.l2x a6, b0		   ; load shift
||	shru.s1 a4, a6, a1	   ; d[0]>>shift
||	sub.l1 a0, a6, a0	   ; 32-shift

	shru.s2 b4, b0, b4	   ; d[1]>>shift
||	shl.s1 a4, a0, a4	   ; d[0]<<(32-shift)

	stw.d2 a1, *b6		   ; store d[0]

	or.l2x a4, b4, b4	   ; d[0]<<(32-shift))|(d[1]>>shift)

	stw.d2 b4, *+b6[1]	   ; store d[1]
	.end