trig.s 686 Bytes

 #
 # trig.s
 #
 # Quick test of the trig ROM. Put an angle (0-2pi ==> 0-4095) in
 # register $1. 
 #	
 # It will report:	
 #
 #	$2 - the sin of the angle (signed fraction)
 #	$3 - the cos of the angle (signed fraction)
 # 	$4 - the table entry.
 #

	/* where is the trig ROM? */
#define rsp_TRIG_BASE	0x10010000
#define rsp_TRIG_BASEHI	0x1001
#define rsp_TRIG_BASELO	0x0000
	
.name	angle, 	$1
.name	sin_a,	$2
.name	cos_a,	$3
.name	tabent,	$4
.name	trigp,	$10

.base 0x0

	# As of now, the angle is in register $1.

		lui	angle, rsp_TRIG_BASEHI
		lw	tabent, 0(angle)	# sin in upper, cos in lower
		sra	sin_a, tabent, 16
		sll	cos_a, tabent, 16
		sra	cos_a, cos_a, 16
	
		nop
		break