div.s
2.54 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
* 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