trig.s
686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#
# 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