l_support.sa revision 1.3 1 1.3 cgd * $NetBSD: l_support.sa,v 1.3 1994/10/26 07:49:16 cgd Exp $
2 1.3 cgd
3 1.1 mycroft * MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
4 1.1 mycroft * M68000 Hi-Performance Microprocessor Division
5 1.1 mycroft * M68040 Software Package
6 1.1 mycroft *
7 1.1 mycroft * M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
8 1.1 mycroft * All rights reserved.
9 1.1 mycroft *
10 1.1 mycroft * THE SOFTWARE is provided on an "AS IS" basis and without warranty.
11 1.1 mycroft * To the maximum extent permitted by applicable law,
12 1.1 mycroft * MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
13 1.1 mycroft * INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
14 1.1 mycroft * PARTICULAR PURPOSE and any warranty against infringement with
15 1.1 mycroft * regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
16 1.1 mycroft * and any accompanying written materials.
17 1.1 mycroft *
18 1.1 mycroft * To the maximum extent permitted by applicable law,
19 1.1 mycroft * IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
20 1.1 mycroft * (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
21 1.1 mycroft * PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
22 1.1 mycroft * OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
23 1.1 mycroft * SOFTWARE. Motorola assumes no responsibility for the maintenance
24 1.1 mycroft * and support of the SOFTWARE.
25 1.1 mycroft *
26 1.1 mycroft * You are hereby granted a copyright license to use, modify, and
27 1.1 mycroft * distribute the SOFTWARE so long as this entire notice is retained
28 1.1 mycroft * without alteration in any modified and/or redistributed versions,
29 1.1 mycroft * and that such modified versions are clearly identified as such.
30 1.1 mycroft * No licenses are granted by implication, estoppel or otherwise
31 1.1 mycroft * under any patents or trademarks of Motorola, Inc.
32 1.1 mycroft
33 1.1 mycroft *
34 1.1 mycroft * l_support.sa 1.2 5/1/91
35 1.1 mycroft *
36 1.1 mycroft
37 1.1 mycroft L_SUPPORT IDNT 2,1 Motorola 040 Floating Point Software Package
38 1.1 mycroft
39 1.1 mycroft section 8
40 1.1 mycroft
41 1.1 mycroft mns_one dc.l $bfff0000,$80000000,$00000000
42 1.1 mycroft pls_one dc.l $3fff0000,$80000000,$00000000
43 1.1 mycroft pls_inf dc.l $7fff0000,$00000000,$00000000
44 1.1 mycroft pls_huge dc.l $7ffe0000,$ffffffff,$ffffffff
45 1.1 mycroft mns_huge dc.l $fffe0000,$ffffffff,$ffffffff
46 1.1 mycroft pls_tiny dc.l $00000000,$80000000,$00000000
47 1.1 mycroft mns_tiny dc.l $80000000,$80000000,$00000000
48 1.1 mycroft small dc.l $20000000,$80000000,$00000000
49 1.1 mycroft pls_zero dc.l $00000000,$00000000,$00000000
50 1.1 mycroft
51 1.1 mycroft include l_fpsp.h
52 1.1 mycroft
53 1.1 mycroft *
54 1.1 mycroft * tag --- determine the type of an extended precision operand
55 1.1 mycroft *
56 1.1 mycroft * The tag values returned match the way the 68040 would have
57 1.1 mycroft * tagged them.
58 1.1 mycroft *
59 1.1 mycroft * Input: a0 points to operand
60 1.1 mycroft *
61 1.1 mycroft * Output d0.b = $00 norm
62 1.1 mycroft * $20 zero
63 1.1 mycroft * $40 inf
64 1.1 mycroft * $60 nan
65 1.1 mycroft * $80 denorm
66 1.1 mycroft * All other registers are unchanged
67 1.1 mycroft *
68 1.1 mycroft xdef tag
69 1.1 mycroft tag:
70 1.1 mycroft move.w LOCAL_EX(a0),d0
71 1.1 mycroft andi.w #$7fff,d0
72 1.1 mycroft beq.b chk_zro
73 1.1 mycroft cmpi.w #$7fff,d0
74 1.1 mycroft beq.b chk_inf
75 1.1 mycroft tag_nrm:
76 1.1 mycroft clr.b d0
77 1.1 mycroft rts
78 1.1 mycroft tag_nan:
79 1.1 mycroft move.b #$60,d0
80 1.1 mycroft rts
81 1.1 mycroft tag_dnrm:
82 1.1 mycroft move.b #$80,d0
83 1.1 mycroft rts
84 1.1 mycroft chk_zro:
85 1.1 mycroft btst.b #7,LOCAL_HI(a0) # check if J-bit is set
86 1.1 mycroft bne.b tag_nrm
87 1.1 mycroft tst.l LOCAL_HI(a0)
88 1.1 mycroft bne.b tag_dnrm
89 1.1 mycroft tst.l LOCAL_LO(a0)
90 1.1 mycroft bne.b tag_dnrm
91 1.1 mycroft tag_zero:
92 1.1 mycroft move.b #$20,d0
93 1.1 mycroft rts
94 1.1 mycroft chk_inf:
95 1.1 mycroft tst.l LOCAL_HI(a0)
96 1.1 mycroft bne.b tag_nan
97 1.1 mycroft tst.l LOCAL_LO(a0)
98 1.1 mycroft bne.b tag_nan
99 1.1 mycroft tag_inf:
100 1.1 mycroft move.b #$40,d0
101 1.1 mycroft rts
102 1.1 mycroft
103 1.1 mycroft *
104 1.1 mycroft * t_dz, t_dz2 --- divide by zero exception
105 1.1 mycroft *
106 1.1 mycroft * t_dz2 is used by monadic functions such as flogn (from do_func).
107 1.1 mycroft * t_dz is used by monadic functions such as satanh (from the
108 1.1 mycroft * transcendental function).
109 1.1 mycroft *
110 1.1 mycroft xdef t_dz2
111 1.1 mycroft t_dz2:
112 1.1 mycroft fmovem.x mns_one,fp0
113 1.1 mycroft fmove.l d1,fpcr
114 1.1 mycroft fdiv.x pls_zero,fp0
115 1.1 mycroft rts
116 1.1 mycroft
117 1.1 mycroft xdef t_dz
118 1.1 mycroft t_dz:
119 1.1 mycroft btst.b #sign_bit,ETEMP_EX(a6) ;check sign for neg or pos
120 1.1 mycroft beq.b p_inf ;branch if pos sign
121 1.1 mycroft m_inf:
122 1.1 mycroft fmovem.x mns_one,fp0
123 1.1 mycroft fmove.l d1,fpcr
124 1.1 mycroft fdiv.x pls_zero,fp0
125 1.1 mycroft rts
126 1.1 mycroft p_inf:
127 1.1 mycroft fmovem.x pls_one,fp0
128 1.1 mycroft fmove.l d1,fpcr
129 1.1 mycroft fdiv.x pls_zero,fp0
130 1.1 mycroft rts
131 1.1 mycroft *
132 1.1 mycroft * t_operr --- Operand Error exception
133 1.1 mycroft *
134 1.1 mycroft xdef t_operr
135 1.1 mycroft t_operr:
136 1.1 mycroft fmovem.x pls_inf,fp0
137 1.1 mycroft fmove.l d1,fpcr
138 1.1 mycroft fmul.x pls_zero,fp0
139 1.1 mycroft rts
140 1.1 mycroft
141 1.1 mycroft *
142 1.1 mycroft * t_unfl --- UNFL exception
143 1.1 mycroft *
144 1.1 mycroft xdef t_unfl
145 1.1 mycroft t_unfl:
146 1.1 mycroft btst.b #sign_bit,ETEMP(a6)
147 1.1 mycroft beq.b unf_pos
148 1.1 mycroft unf_neg:
149 1.1 mycroft fmovem.x mns_tiny,fp0
150 1.1 mycroft fmove.l d1,fpcr
151 1.1 mycroft fmul.x pls_tiny,fp0
152 1.1 mycroft rts
153 1.1 mycroft
154 1.1 mycroft unf_pos:
155 1.1 mycroft fmovem.x pls_tiny,fp0
156 1.1 mycroft fmove.l d1,fpcr
157 1.1 mycroft fmul.x fp0,fp0
158 1.1 mycroft rts
159 1.1 mycroft *
160 1.1 mycroft * t_ovfl --- OVFL exception
161 1.1 mycroft *
162 1.1 mycroft * t_ovfl is called as an exit for monadic functions. t_ovfl2
163 1.1 mycroft * is for dyadic exits.
164 1.1 mycroft *
165 1.1 mycroft xdef t_ovfl
166 1.1 mycroft t_ovfl:
167 1.1 mycroft xdef t_ovfl2
168 1.1 mycroft move.l d1,USER_FPCR(a6) user's control register
169 1.1 mycroft move.l #ovfinx_mask,d0
170 1.1 mycroft bra.b t_work
171 1.1 mycroft t_ovfl2:
172 1.1 mycroft move.l #ovfl_inx_mask,d0
173 1.1 mycroft t_work:
174 1.1 mycroft btst.b #sign_bit,ETEMP(a6)
175 1.1 mycroft beq.b ovf_pos
176 1.1 mycroft ovf_neg:
177 1.1 mycroft fmovem.x mns_huge,fp0
178 1.1 mycroft fmove.l USER_FPCR(a6),fpcr
179 1.1 mycroft fmul.x pls_huge,fp0
180 1.1 mycroft fmove.l fpsr,d1
181 1.1 mycroft or.l d1,d0
182 1.1 mycroft fmove.l d0,fpsr
183 1.1 mycroft rts
184 1.1 mycroft ovf_pos:
185 1.1 mycroft fmovem.x pls_huge,fp0
186 1.1 mycroft fmove.l USER_FPCR(a6),fpcr
187 1.1 mycroft fmul.x pls_huge,fp0
188 1.1 mycroft fmove.l fpsr,d1
189 1.1 mycroft or.l d1,d0
190 1.1 mycroft fmove.l d0,fpsr
191 1.1 mycroft rts
192 1.1 mycroft *
193 1.1 mycroft * t_inx2 --- INEX2 exception (correct fpcr is in USER_FPCR(a6))
194 1.1 mycroft *
195 1.1 mycroft xdef t_inx2
196 1.1 mycroft t_inx2:
197 1.1 mycroft fmove.l fpsr,USER_FPSR(a6) capture incoming fpsr
198 1.1 mycroft fmove.l USER_FPCR(a6),fpcr
199 1.1 mycroft *
200 1.1 mycroft * create an inex2 exception by adding two numbers with very different exponents
201 1.1 mycroft * do the add in fp1 so as to not disturb the result sitting in fp0
202 1.1 mycroft *
203 1.1 mycroft fmove.x pls_one,fp1
204 1.1 mycroft fadd.x small,fp1
205 1.1 mycroft *
206 1.1 mycroft or.l #inx2a_mask,USER_FPSR(a6) ;set INEX2, AINEX
207 1.1 mycroft fmove.l USER_FPSR(a6),fpsr
208 1.1 mycroft rts
209 1.1 mycroft *
210 1.1 mycroft * t_frcinx --- Force Inex2 (for monadic functions)
211 1.1 mycroft *
212 1.1 mycroft xdef t_frcinx
213 1.1 mycroft t_frcinx:
214 1.1 mycroft fmove.l fpsr,USER_FPSR(a6) capture incoming fpsr
215 1.1 mycroft fmove.l d1,fpcr
216 1.1 mycroft *
217 1.1 mycroft * create an inex2 exception by adding two numbers with very different exponents
218 1.1 mycroft * do the add in fp1 so as to not disturb the result sitting in fp0
219 1.1 mycroft *
220 1.1 mycroft fmove.x pls_one,fp1
221 1.1 mycroft fadd.x small,fp1
222 1.1 mycroft *
223 1.1 mycroft or.l #inx2a_mask,USER_FPSR(a6) ;set INEX2, AINEX
224 1.1 mycroft btst.b #unfl_bit,FPSR_EXCEPT(a6) ;test for unfl bit set
225 1.1 mycroft beq.b no_uacc1 ;if clear, do not set aunfl
226 1.1 mycroft bset.b #aunfl_bit,FPSR_AEXCEPT(a6)
227 1.1 mycroft no_uacc1:
228 1.1 mycroft fmove.l USER_FPSR(a6),fpsr
229 1.1 mycroft rts
230 1.1 mycroft *
231 1.1 mycroft * dst_nan --- force result when destination is a NaN
232 1.1 mycroft *
233 1.1 mycroft xdef dst_nan
234 1.1 mycroft dst_nan:
235 1.1 mycroft fmove.l USER_FPCR(a6),fpcr
236 1.1 mycroft fmove.x FPTEMP(a6),fp0
237 1.1 mycroft rts
238 1.1 mycroft
239 1.1 mycroft *
240 1.1 mycroft * src_nan --- force result when source is a NaN
241 1.1 mycroft *
242 1.1 mycroft xdef src_nan
243 1.1 mycroft src_nan:
244 1.1 mycroft fmove.l USER_FPCR(a6),fpcr
245 1.1 mycroft fmove.x ETEMP(a6),fp0
246 1.1 mycroft rts
247 1.1 mycroft *
248 1.1 mycroft * mon_nan --- force result when source is a NaN (monadic version)
249 1.1 mycroft *
250 1.1 mycroft * This is the same as src_nan except that the user's fpcr comes
251 1.1 mycroft * in via d1, not USER_FPCR(a6).
252 1.1 mycroft *
253 1.1 mycroft xdef mon_nan
254 1.1 mycroft mon_nan:
255 1.1 mycroft fmove.l d1,fpcr
256 1.1 mycroft fmove.x ETEMP(a6),fp0
257 1.1 mycroft rts
258 1.1 mycroft *
259 1.1 mycroft * t_extdnrm, t_resdnrm --- generate results for denorm inputs
260 1.1 mycroft *
261 1.1 mycroft * For all functions that have a denormalized input and that f(x)=x,
262 1.1 mycroft * this is the entry point.
263 1.1 mycroft *
264 1.1 mycroft xdef t_extdnrm
265 1.1 mycroft t_extdnrm:
266 1.1 mycroft fmove.l d1,fpcr
267 1.1 mycroft fmove.x LOCAL_EX(a0),fp0
268 1.1 mycroft fmove.l fpsr,d0
269 1.1 mycroft or.l #unfinx_mask,d0
270 1.1 mycroft fmove.l d0,fpsr
271 1.1 mycroft rts
272 1.1 mycroft
273 1.1 mycroft xdef t_resdnrm
274 1.1 mycroft t_resdnrm:
275 1.1 mycroft fmove.l USER_FPCR(a6),fpcr
276 1.1 mycroft fmove.x LOCAL_EX(a0),fp0
277 1.1 mycroft fmove.l fpsr,d0
278 1.1 mycroft or.l #unfl_mask,d0
279 1.1 mycroft fmove.l d0,fpsr
280 1.1 mycroft rts
281 1.1 mycroft *
282 1.1 mycroft *
283 1.1 mycroft *
284 1.1 mycroft xdef t_avoid_unsupp
285 1.1 mycroft t_avoid_unsupp:
286 1.1 mycroft fmove.x fp0,fp0
287 1.1 mycroft rts
288 1.1 mycroft
289 1.1 mycroft xdef sto_cos
290 1.1 mycroft sto_cos:
291 1.1 mycroft fmovem.x LOCAL_EX(a0),fp1
292 1.1 mycroft rts
293 1.1 mycroft *
294 1.1 mycroft * Native instruction support
295 1.1 mycroft *
296 1.1 mycroft * Some systems may need entry points even for 68040 native
297 1.1 mycroft * instructions. These routines are provided for
298 1.1 mycroft * convenience.
299 1.1 mycroft *
300 1.1 mycroft xdef sadd
301 1.1 mycroft sadd:
302 1.1 mycroft fmovem.x FPTEMP(a6),fp0
303 1.1 mycroft fmove.l USER_FPCR(a6),fpcr
304 1.1 mycroft fadd.x ETEMP(a6),fp0
305 1.1 mycroft rts
306 1.1 mycroft
307 1.1 mycroft xdef ssub
308 1.1 mycroft ssub:
309 1.1 mycroft fmovem.x FPTEMP(a6),fp0
310 1.1 mycroft fmove.l USER_FPCR(a6),fpcr
311 1.1 mycroft fsub.x ETEMP(a6),fp0
312 1.1 mycroft rts
313 1.1 mycroft
314 1.1 mycroft xdef smul
315 1.1 mycroft smul:
316 1.1 mycroft fmovem.x FPTEMP(a6),fp0
317 1.1 mycroft fmove.l USER_FPCR(a6),fpcr
318 1.1 mycroft fmul.x ETEMP(a6),fp0
319 1.1 mycroft rts
320 1.1 mycroft
321 1.1 mycroft xdef sdiv
322 1.1 mycroft sdiv:
323 1.1 mycroft fmovem.x FPTEMP(a6),fp0
324 1.1 mycroft fmove.l USER_FPCR(a6),fpcr
325 1.1 mycroft fdiv.x ETEMP(a6),fp0
326 1.1 mycroft rts
327 1.1 mycroft
328 1.1 mycroft xdef sabs
329 1.1 mycroft sabs:
330 1.1 mycroft fmovem.x ETEMP(a6),fp0
331 1.1 mycroft fmove.l d1,fpcr
332 1.2 mycroft fabs.x fp0
333 1.1 mycroft rts
334 1.1 mycroft
335 1.1 mycroft xdef sneg
336 1.1 mycroft sneg:
337 1.1 mycroft fmovem.x ETEMP(a6),fp0
338 1.1 mycroft fmove.l d1,fpcr
339 1.2 mycroft fneg.x fp0
340 1.1 mycroft rts
341 1.1 mycroft
342 1.1 mycroft xdef ssqrt
343 1.1 mycroft ssqrt:
344 1.1 mycroft fmovem.x ETEMP(a6),fp0
345 1.1 mycroft fmove.l d1,fpcr
346 1.2 mycroft fsqrt.x fp0
347 1.1 mycroft rts
348 1.1 mycroft
349 1.1 mycroft *
350 1.1 mycroft * l_sint,l_sintrz,l_sintd --- special wrapper for fint and fintrz
351 1.1 mycroft *
352 1.1 mycroft * On entry, move the user's FPCR to USER_FPCR.
353 1.1 mycroft *
354 1.1 mycroft * On return from, we need to pickup the INEX2/AINEX bits
355 1.1 mycroft * that are in USER_FPSR.
356 1.1 mycroft *
357 1.1 mycroft xref sint
358 1.1 mycroft xref sintrz
359 1.1 mycroft xref sintd
360 1.1 mycroft
361 1.1 mycroft xdef l_sint
362 1.1 mycroft l_sint:
363 1.1 mycroft move.l d1,USER_FPCR(a6)
364 1.1 mycroft jsr sint
365 1.1 mycroft fmove.l fpsr,d0
366 1.1 mycroft or.l USER_FPSR(a6),d0
367 1.1 mycroft fmove.l d0,fpsr
368 1.1 mycroft rts
369 1.1 mycroft
370 1.1 mycroft xdef l_sintrz
371 1.1 mycroft l_sintrz:
372 1.1 mycroft move.l d1,USER_FPCR(a6)
373 1.1 mycroft jsr sintrz
374 1.1 mycroft fmove.l fpsr,d0
375 1.1 mycroft or.l USER_FPSR(a6),d0
376 1.1 mycroft fmove.l d0,fpsr
377 1.1 mycroft rts
378 1.1 mycroft
379 1.1 mycroft xdef l_sintd
380 1.1 mycroft l_sintd:
381 1.1 mycroft move.l d1,USER_FPCR(a6)
382 1.1 mycroft jsr sintd
383 1.1 mycroft fmove.l fpsr,d0
384 1.1 mycroft or.l USER_FPSR(a6),d0
385 1.1 mycroft fmove.l d0,fpsr
386 1.1 mycroft rts
387 1.1 mycroft
388 1.1 mycroft end
389