DYADIC.GEN revision 1.2 1 * $NetBSD: DYADIC.GEN,v 1.2 1994/10/26 07:48:29 cgd Exp $
2
3 * MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
4 * M68000 Hi-Performance Microprocessor Division
5 * M68040 Software Package
6 *
7 * M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
8 * All rights reserved.
9 *
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.
17 *
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.
25 *
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.
32
33 *
34 * DYADIC.GEN 1.2 4/30/91
35 *
36 * DYADIC.GEN --- generic DYADIC template
37 *
38 * This version saves all registers that will be used by the emulation
39 * routines and restores all but FP0 on exit. The FPSR is
40 * updated to reflect the result of the operation. Return value
41 * is placed in FP0 for single, double and extended results.
42 *
43 * The package subroutines expect the incoming FPCR to be zeroed
44 * since they need extended precision to work properly. The
45 * 'final' FPCR is expected in USER_FPCR(a6) so that the calculated result
46 * can be properly sized and rounded. Also, if the incoming FPCR
47 * has enabled any exceptions, the exception will be taken on the
48 * final fmovem in this template.
49 *
50 * Customizations:
51 * 1. Remove the movem.l at the entry and exit of
52 * each routine if your compiler treats those
53 * registers as scratch.
54 * 2. Likewise, don't save FP0/FP1 if they are scratch
55 * registers.
56 * 3. Delete updating of the fpsr if you only care about
57 * the result.
58 * 4. Remove the _OPs_ and _OPx_ entry points if your compiler
59 * treats everything as doubles.
60 * 5. Move the result to d0/d1 if the compiler is that old.
61 *
62
63 xref _OPa_
64 xref tag
65
66 xdef _OPs_
67 _OPs_:
68 link a6,#-LOCAL_SIZE
69 movem.l d0-d1/a0-a1,USER_DA(a6)
70 fmovem.x fp0-fp3,USER_FP0(a6)
71 fmovem.l fpsr/fpcr,USER_FPSR(a6) ; user's rounding mode/precision
72 fmove.l #0,fpcr ; force rounding mode/prec to extended,rn
73 *
74 * copy, convert and tag input arguments
75 *
76 fmove.s 8(a6),fp0
77 fmove.x fp0,FPTEMP(a6)
78 lea FPTEMP(a6),a0
79 bsr tag
80 move.b d0,DTAG(a6)
81
82 fmove.s 12(a6),fp0
83 fmove.x fp0,ETEMP(a6)
84 lea ETEMP(a6),a0
85 bsr tag
86 move.b d0,STAG(a6)
87
88 bsr _OPa_
89
90 fmove.l fpsr,d0 ; update status register
91 or.b FPSR_AEXCEPT(a6),d0 ;add previously accrued exceptions
92 swap.w d0
93 or.b FPSR_QBYTE(a6),d0 ; pickup sign of quotient byte
94 swap.w d0
95 fmove.l d0,fpsr
96 *
97 * Result is now in FP0
98 *
99 movem.l USER_DA(a6),d0-d1/a0-a1
100 fmovem.x USER_FP1(a6),fp1-fp3 ; note: FP0 not restored
101 unlk a6
102 rts
103
104 xdef _OPd_
105 _OPd_:
106 link a6,#-LOCAL_SIZE
107 movem.l d0-d1/a0-a1,USER_DA(a6)
108 fmovem.x fp0-fp3,USER_FP0(a6)
109 fmovem.l fpsr/fpcr,USER_FPSR(a6) ; user's rounding mode/precision
110 fmove.l #0,fpcr ; force rounding mode/prec to extended,rn
111 *
112 * copy, convert and tag input arguments
113 *
114 fmove.d 8(a6),fp0
115 fmove.x fp0,FPTEMP(a6)
116 lea FPTEMP(a6),a0
117 bsr tag
118 move.b d0,DTAG(a6)
119
120 fmove.d 16(a6),fp0
121 fmove.x fp0,ETEMP(a6)
122 lea ETEMP(a6),a0
123 bsr tag
124 move.b d0,STAG(a6)
125
126 bsr _OPa_
127
128 fmove.l fpsr,d0 ; update status register
129 or.b FPSR_AEXCEPT(a6),d0 ;add previously accrued exceptions
130 swap.w d0
131 or.b FPSR_QBYTE(a6),d0 ; pickup sign of quotient byte
132 swap.w d0
133 fmove.l d0,fpsr
134 *
135 * Result is now in FP0
136 *
137 movem.l USER_DA(a6),d0-d1/a0-a1
138 fmovem.x USER_FP1(a6),fp1-fp3 ; note: FP0 not restored
139 unlk a6
140 rts
141
142 xdef _OPx_
143 _OPx_:
144 link a6,#-LOCAL_SIZE
145 movem.l d0-d1/a0-a1,USER_DA(a6)
146 fmovem.x fp0-fp3,USER_FP0(a6)
147 fmovem.l fpsr/fpcr,USER_FPSR(a6) ; user's rounding mode/precision
148 fmove.l #0,fpcr ; force rounding mode/prec to extended,rn
149 *
150 * copy, convert and tag input arguments
151 *
152 fmove.x 8(a6),fp0
153 fmove.x fp0,FPTEMP(a6)
154 lea FPTEMP(a6),a0
155 bsr tag
156 move.b d0,DTAG(a6)
157
158 fmove.x 20(a6),fp0
159 fmove.x fp0,ETEMP(a6)
160 lea ETEMP(a6),a0
161 bsr tag
162 move.b d0,STAG(a6)
163
164 bsr _OPa_
165
166 fmove.l fpsr,d0 ; update status register
167 or.b FPSR_AEXCEPT(a6),d0 ;add previously accrued exceptions
168 swap.w d0
169 or.b FPSR_QBYTE(a6),d0 ; pickup sign of quotient byte
170 swap.w d0
171 fmove.l d0,fpsr
172 *
173 * Result is now in FP0
174 *
175 movem.l USER_DA(a6),d0-d1/a0-a1
176 fmovem.x USER_FP1(a6),fp1-fp3 ; note: FP0 not restored
177 unlk a6
178 rts
179
180