div.s 2.54 KB

/*	
 * div.s			Mon May  2 15:43:58 PDT 1994
 *	
 * this is a simple RSP program that tests the permutations of
 * divides that you might want to do...
 *
 */

.base	0x04001000

 #
 # define some symbolic registers to make this clearer: (I hope)
 #
.name	s_int,		$v0
.name	s_frac,		$v2
.name	t_int,		$v1
.name	t_frac,		$v3
.name	sres_int,	$v4
.name	sres_frac,	$v6
.name	dres_int,	$v5
.name	dres_frac,	$v7
.name	res_int,	$v9
.name	res_frac,	$v11
.name	r2_int,		$v13
.name	r2_frac,	$v15
.name	tmp_i,		$v12
.name	tmp_f,		$v14
	
.name	vconst,		$v31

.name	in_base,	$20	

#define	TASKDATABASE	0x0000		

	.data	0x04000000

	.half	0x0000
	.half	0x0001
	.half	0x0002
	.half	0x0200
	.half	0x0000
	.half	0x0000
	.half	0x0000
	.half	0x0000


	.word	0x00080000
	.word	0x00000000

	.text
	
	addi	in_base, $0, TASKDATABASE
	
  # get vconst
	lqv	vconst[0], 0(in_base)
	
  # get s and t:	
	lsv	s_int[0],  16(in_base)
	lsv	s_frac[0], 18(in_base)
	lsv	t_int[0],  20(in_base)
	lsv	t_frac[0], 22(in_base)
	nop
	nop
	nop
	nop
	nop

  # single precision:
	vrcp	sres_frac[0], s_int[0]
	vrcph	sres_int[0], vconst[0]
#if 0
  # single precision:
	vrsq	sres_frac[0], s_int[0]
	vrsqh	sres_int[0], vconst[0]
#endif

#if 0
  # double precision:
	vrcph	dres_int[0], t_int[0]
	vrcpl	dres_frac[0], t_frac[0]
	vrcph	dres_int[0], vconst[0]
#endif
	
  # double precision:
	vrsqh	dres_int[0], t_int[0]
	vrsql	dres_frac[0], t_frac[0]
	vrsqh	dres_int[0], vconst[0]

  # shift right by 8 bits.
	vmudl	dres_frac, dres_frac, vconst[3]
	vmadm	dres_int, dres_int, vconst[3]
 	vmadn	dres_frac, vconst, vconst[0]

	
#if 0
  # make a S15.16 
	vmudn	dres_frac, dres_frac, vconst[2]
	vmadh	dres_int, dres_int, vconst[2]
 	vmadn	dres_frac, vconst, vconst[0]

#endif
	nop
	nop
	nop
	nop
	nop

#if 0
  # Newton-Raphson:	R2 = R*(2 - R*X)
	vmov	tmp_i[0], vconst[2]
	vmov	tmp_f[0], vconst[0]
	vmudl	r2_frac, dres_frac, t_frac	# R*X
	vmadm	r2_frac, dres_int, t_frac
	vmadn	r2_frac, dres_frac, t_int
	vmadh	r2_int, dres_int, t_int
	vmadn	r2_frac, vconst, vconst[0]
	
	vsubc	r2_frac, tmp_f, r2_frac		# 2 - (R*X)
	vsub	r2_int, tmp_i, r2_int
	
	vmudl	r2_frac, dres_frac, r2_frac	# R * (2-R*X)
	vmadm	r2_frac, dres_int, r2_frac
	vmadn	r2_frac, dres_frac, r2_int
	vmadh	r2_int, dres_int, r2_int
	vmadn	r2_frac, vconst, vconst[0]

#endif

#if 0
	vmov	r2_frac[0], dres_frac[0]
	vmov	r2_int[0], dres_int[0]
#endif
	
	nop
	nop
	nop
	nop
	
#if 0
	vmudl	dres_frac, r2_frac, s_frac	# s / t
	vmadm	dres_frac, r2_int,  s_frac
	vmadn	dres_frac, r2_frac, s_int
	vmadh	dres_int,  r2_int,  s_int
	vmadn	dres_frac, vconst, vconst[0]
#endif
	
	nop
	nop
	nop
	nop
	break
	nop