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