1 .file "wm_sqrt.S"
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 #include "exception.h"
28 #include "fpu_asm.h"
29
30
31 .data
32
33
34
35 .align 4,0
36 accum_2:
37 .long 0
38 accum_1:
39 .long 0
40 accum_0:
41 .long 0
42
43 sq_2:
44 .long 0
45 sq_1:
46 .long 0
47 sq_0:
48 .long 0
49
50 .text
51 .align 2,144
52
53 .globl _wm_sqrt
54
55 _wm_sqrt:
56 pushl %ebp
57 movl %esp,%ebp
58 pushl %esi
59 pushl %edi
60
61
62 movl PARAM1,%esi
63
64 movl SIGH(%esi),%eax
65 movl SIGL(%esi),%ecx
66 xorl %edx,%edx
67
68
69
70 cmpl EXP_BIAS,EXP(%esi)
71 jnz L10
72
73 shrl $1,%eax
74 rcrl $1,%ecx
75 rcrl $1,%edx
76
77 L10:
78
79
80
81 movl %eax,sq_2
82 movl %ecx,sq_1
83 movl %edx,sq_0
84
85 shrl $1,%eax
86 addl $0x40000000,%eax
87 movl $0xaaaaaaaa,%ecx
88 mull %ecx
89 shll %edx
90 testl $0x80000000,%edx
91 jnz no_adjust
92
93 movl $0x80000000,%edx
94
95 no_adjust:
96 movl %edx,%esi
97
98
99
100
101 movl sq_2,%ecx
102
103
104
105
106
107
108 shrl %ecx
109
110
111 movl %ecx,%edx
112 divl %esi
113 shrl %esi
114 addl %eax,%esi
115
116 movl %ecx,%edx
117 divl %esi
118 shrl %esi
119 addl %eax,%esi
120
121 movl %ecx,%edx
122 divl %esi
123 shrl %esi
124 addl %eax,%esi
125
126
127
128
129
130
131
132
133 movl %esi,%eax
134 mull %esi
135
136
137 movl sq_1,%ecx
138 subl %ecx,%eax
139 movl sq_2,%ecx
140 sbbl %ecx,%edx
141 jnc l40
142
143
144
145 notl %edx
146 notl %eax
147 addl $1,%eax
148 adcl $0,%edx
149
150 divl %esi
151 movl %eax,%ecx
152
153 movl %edx,%eax
154 divl %esi
155 jmp l45
156
157 l40:
158 divl %esi
159 movl %eax,%ecx
160
161 movl %edx,%eax
162 divl %esi
163
164 notl %ecx
165 notl %eax
166 addl $1,%eax
167 adcl $0,%ecx
168
169 l45:
170 sarl $1,%ecx
171 rcrl $1,%eax
172
173 movl %eax,%edi
174 addl %ecx,%esi
175
176
177
178
179 movl %edi,%eax
180 mull %edi
181 movl %edx,accum_0
182
183 movl %esi,%eax
184 mull %esi
185 movl %edx,accum_2
186 movl %eax,accum_1
187
188 movl %edi,%eax
189 mull %esi
190 addl %eax,accum_0
191 adcl %edx,accum_1
192 adcl $0,accum_2
193
194 movl %esi,%eax
195 mull %edi
196 addl %eax,accum_0
197 adcl %edx,accum_1
198 adcl $0,accum_2
199
200
201
202 movl sq_1,%eax
203 subl %eax,accum_1
204 movl sq_2,%eax
205 sbbl %eax,accum_2
206 jnc l60
207
208
209
210 notl accum_0
211 notl accum_1
212 notl accum_2
213 addl $1,accum_0
214 adcl $0,accum_1
215
216 #ifdef PARANOID
217 adcl $0,accum_2
218 jz l51
219
220 pushl EX_INTERNAL|0x207
221 call EXCEPTION
222
223 l51:
224 #endif PARANOID
225
226 movl accum_1,%edx
227 movl accum_0,%eax
228 divl %esi
229 movl %eax,%ecx
230
231 movl %edx,%eax
232 divl %esi
233
234 sarl $1,%ecx
235 rcrl $1,%eax
236
237
238 addl $0x80000000,%eax
239 adcl $0,%ecx
240
241 addl %ecx,%edi
242 adcl $0,%esi
243
244 jmp l65
245
246 l60:
247 movl accum_1,%edx
248 movl accum_0,%eax
249 divl %esi
250 movl %eax,%ecx
251
252 movl %edx,%eax
253 divl %esi
254
255 sarl $1,%ecx
256 rcrl $1,%eax
257
258
259 addl $0x80000000,%eax
260 adcl $0,%ecx
261
262 subl %ecx,%edi
263 sbbl $0,%esi
264
265 l65:
266 movl PARAM1,%ecx
267
268 movl %edi,SIGL(%ecx)
269 movl %esi,SIGH(%ecx)
270
271 movl EXP_BIAS,EXP(%ecx)
272
273
274 popl %edi
275 popl %esi
276 leave
277 ret