1 * $NetBSD: MONADIC.GEN,v 1.3 1994/10/26 07:48:42 cgd Exp $
3 * MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
4 * M68000 Hi-Performance Microprocessor Division
5 * M68040 Software Package
7 * M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
10 * THE SOFTWARE is provided on an "AS IS" basis and without warranty.
11 * To the maximum extent permitted by applicable law,
12 * MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
13 * INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
14 * PARTICULAR PURPOSE and any warranty against infringement with
15 * regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
16 * and any accompanying written materials.
18 * To the maximum extent permitted by applicable law,
19 * IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
20 * (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
21 * PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
22 * OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
23 * SOFTWARE. Motorola assumes no responsibility for the maintenance
24 * and support of the SOFTWARE.
26 * You are hereby granted a copyright license to use, modify, and
27 * distribute the SOFTWARE so long as this entire notice is retained
28 * without alteration in any modified and/or redistributed versions,
29 * and that such modified versions are clearly identified as such.
30 * No licenses are granted by implication, estoppel or otherwise
31 * under any patents or trademarks of Motorola, Inc.
34 * MONADIC.GEN 1.5 5/18/92
36 * MONADIC.GEN 1.4 1/16/92
38 * MONADIC.GEN 1.3 4/30/91
40 * MONADIC.GEN --- generic MONADIC template
42 * This version saves all registers that will be used by the emulation
43 * routines and restores all but FP0 on exit. The FPSR is
44 * updated to reflect the result of the operation. Return value
45 * is placed in FP0 for single, double and extended results.
47 * The package subroutines expect the incoming FPCR to be zeroed
48 * since they need extended precision to work properly. The
49 * 'final' FPCR is expected in d1 so that the calculated result
50 * can be properly sized and rounded. Also, if the incoming FPCR
51 * has enabled any exceptions, the exception will be taken on the
52 * final fmovem in this template.
55 * 1. Remove the movem.l at the entry and exit of
56 * each routine if your compiler treats those
57 * registers as scratch.
58 * 2. Likewise, don't save FP0/FP1 if they are scratch
60 * 3. Delete handling of the fpsr if you only care about
62 * 4. Some (most?) C compilers convert all float arguments
63 * to double, and provide no support at all for extended
64 * precision so remove the _OPs_ and _OPx_ entry points.
65 * 5. Move the result to d0/d1 if the compiler is that old.
78 movem.l d0-d1/a0-a1,USER_DA(a6)
79 fmovem.x fp0-fp3,USER_FP0(a6)
80 fmove.l fpsr,USER_FPSR(a6)
81 fmove.l fpcr,USER_FPCR(a6)
82 fmove.l fpcr,d1 ; user's rounding mode/precision
83 fmove.l #0,fpcr ; force rounding mode/prec to extended,rn
85 * copy, convert and tag input argument
94 bsr _OPr_ ; normalized (regular) number
102 cmp.b #$40,d0 ; infinity?
112 bsr _OPm_ ; assuming a denorm...
115 fmove.l fpsr,d0 ; update status register
116 or.b FPSR_AEXCEPT(a6),d0 ;add previously accrued exceptions
119 * Result is now in FP0
121 movem.l USER_DA(a6),d0-d1/a0-a1
122 fmovem.x USER_FP1(a6),fp1-fp3 ; note: FP0 not restored
123 fmove.l USER_FPCR(a6),fpcr ; fpcr restored
130 movem.l d0-d1/a0-a1,USER_DA(a6)
131 fmovem.x fp0-fp3,USER_FP0(a6)
132 fmove.l fpsr,USER_FPSR(a6)
133 fmove.l fpcr,USER_FPCR(a6)
134 fmove.l fpcr,d1 ; user's rounding mode/precision
135 fmove.l #0,fpcr ; force rounding mode/prec to extended,rn
137 * copy, convert and tag input argument
140 fmove.x fp0,ETEMP(a6)
146 bsr _OPr_ ; normalized (regular) number
149 cmp.b #$20,d0 ; zero?
154 cmp.b #$40,d0 ; infinity?
164 bsr _OPm_ ; assuming a denorm...
167 fmove.l fpsr,d0 ; update status register
168 or.b FPSR_AEXCEPT(a6),d0 ;add previously accrued exceptions
171 * Result is now in FP0
173 movem.l USER_DA(a6),d0-d1/a0-a1
174 fmovem.x USER_FP1(a6),fp1-fp3 ; note: FP0 not restored
175 fmove.l USER_FPCR(a6),fpcr ; fpcr restored
182 movem.l d0-d1/a0-a1,USER_DA(a6)
183 fmovem.x fp0-fp3,USER_FP0(a6)
184 fmove.l fpsr,USER_FPSR(a6)
185 fmove.l fpcr,USER_FPCR(a6)
186 fmove.l fpcr,d1 ; user's rounding mode/precision
187 fmove.l #0,fpcr ; force rounding mode/prec to extended,rn
189 * copy, convert and tag input argument
192 fmove.x fp0,ETEMP(a6)
198 bsr _OPr_ ; normalized (regular) number
201 cmp.b #$20,d0 ; zero?
206 cmp.b #$40,d0 ; infinity?
216 bsr _OPm_ ; assuming a denorm...
219 fmove.l fpsr,d0 ; update status register
220 or.b FPSR_AEXCEPT(a6),d0 ;add previously accrued exceptions
223 * Result is now in FP0
225 movem.l USER_DA(a6),d0-d1/a0-a1
226 fmovem.x USER_FP1(a6),fp1-fp3 ; note: FP0 not restored
227 fmove.l USER_FPCR(a6),fpcr ; fpcr restored