DYADIC.GEN revision 1.1 1 * MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
2 * M68000 Hi-Performance Microprocessor Division
3 * M68040 Software Package
4 *
5 * M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
6 * All rights reserved.
7 *
8 * THE SOFTWARE is provided on an "AS IS" basis and without warranty.
9 * To the maximum extent permitted by applicable law,
10 * MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
11 * INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
12 * PARTICULAR PURPOSE and any warranty against infringement with
13 * regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
14 * and any accompanying written materials.
15 *
16 * To the maximum extent permitted by applicable law,
17 * IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
18 * (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
19 * PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
20 * OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
21 * SOFTWARE. Motorola assumes no responsibility for the maintenance
22 * and support of the SOFTWARE.
23 *
24 * You are hereby granted a copyright license to use, modify, and
25 * distribute the SOFTWARE so long as this entire notice is retained
26 * without alteration in any modified and/or redistributed versions,
27 * and that such modified versions are clearly identified as such.
28 * No licenses are granted by implication, estoppel or otherwise
29 * under any patents or trademarks of Motorola, Inc.
30
31 *
32 * DYADIC.GEN 1.2 4/30/91
33 *
34 * DYADIC.GEN --- generic DYADIC template
35 *
36 * This version saves all registers that will be used by the emulation
37 * routines and restores all but FP0 on exit. The FPSR is
38 * updated to reflect the result of the operation. Return value
39 * is placed in FP0 for single, double and extended results.
40 *
41 * The package subroutines expect the incoming FPCR to be zeroed
42 * since they need extended precision to work properly. The
43 * 'final' FPCR is expected in USER_FPCR(a6) so that the calculated result
44 * can be properly sized and rounded. Also, if the incoming FPCR
45 * has enabled any exceptions, the exception will be taken on the
46 * final fmovem in this template.
47 *
48 * Customizations:
49 * 1. Remove the movem.l at the entry and exit of
50 * each routine if your compiler treats those
51 * registers as scratch.
52 * 2. Likewise, don't save FP0/FP1 if they are scratch
53 * registers.
54 * 3. Delete updating of the fpsr if you only care about
55 * the result.
56 * 4. Remove the _OPs_ and _OPx_ entry points if your compiler
57 * treats everything as doubles.
58 * 5. Move the result to d0/d1 if the compiler is that old.
59 *
60
61 xref _OPa_
62 xref tag
63
64 xdef _OPs_
65 _OPs_:
66 link a6,#-LOCAL_SIZE
67 movem.l d0-d1/a0-a1,USER_DA(a6)
68 fmovem.x fp0-fp3,USER_FP0(a6)
69 fmovem.l fpsr/fpcr,USER_FPSR(a6) ; user's rounding mode/precision
70 fmove.l #0,fpcr ; force rounding mode/prec to extended,rn
71 *
72 * copy, convert and tag input arguments
73 *
74 fmove.s 8(a6),fp0
75 fmove.x fp0,FPTEMP(a6)
76 lea FPTEMP(a6),a0
77 bsr tag
78 move.b d0,DTAG(a6)
79
80 fmove.s 12(a6),fp0
81 fmove.x fp0,ETEMP(a6)
82 lea ETEMP(a6),a0
83 bsr tag
84 move.b d0,STAG(a6)
85
86 bsr _OPa_
87
88 fmove.l fpsr,d0 ; update status register
89 or.b FPSR_AEXCEPT(a6),d0 ;add previously accrued exceptions
90 swap.w d0
91 or.b FPSR_QBYTE(a6),d0 ; pickup sign of quotient byte
92 swap.w d0
93 fmove.l d0,fpsr
94 *
95 * Result is now in FP0
96 *
97 movem.l USER_DA(a6),d0-d1/a0-a1
98 fmovem.x USER_FP1(a6),fp1-fp3 ; note: FP0 not restored
99 unlk a6
100 rts
101
102 xdef _OPd_
103 _OPd_:
104 link a6,#-LOCAL_SIZE
105 movem.l d0-d1/a0-a1,USER_DA(a6)
106 fmovem.x fp0-fp3,USER_FP0(a6)
107 fmovem.l fpsr/fpcr,USER_FPSR(a6) ; user's rounding mode/precision
108 fmove.l #0,fpcr ; force rounding mode/prec to extended,rn
109 *
110 * copy, convert and tag input arguments
111 *
112 fmove.d 8(a6),fp0
113 fmove.x fp0,FPTEMP(a6)
114 lea FPTEMP(a6),a0
115 bsr tag
116 move.b d0,DTAG(a6)
117
118 fmove.d 16(a6),fp0
119 fmove.x fp0,ETEMP(a6)
120 lea ETEMP(a6),a0
121 bsr tag
122 move.b d0,STAG(a6)
123
124 bsr _OPa_
125
126 fmove.l fpsr,d0 ; update status register
127 or.b FPSR_AEXCEPT(a6),d0 ;add previously accrued exceptions
128 swap.w d0
129 or.b FPSR_QBYTE(a6),d0 ; pickup sign of quotient byte
130 swap.w d0
131 fmove.l d0,fpsr
132 *
133 * Result is now in FP0
134 *
135 movem.l USER_DA(a6),d0-d1/a0-a1
136 fmovem.x USER_FP1(a6),fp1-fp3 ; note: FP0 not restored
137 unlk a6
138 rts
139
140 xdef _OPx_
141 _OPx_:
142 link a6,#-LOCAL_SIZE
143 movem.l d0-d1/a0-a1,USER_DA(a6)
144 fmovem.x fp0-fp3,USER_FP0(a6)
145 fmovem.l fpsr/fpcr,USER_FPSR(a6) ; user's rounding mode/precision
146 fmove.l #0,fpcr ; force rounding mode/prec to extended,rn
147 *
148 * copy, convert and tag input arguments
149 *
150 fmove.x 8(a6),fp0
151 fmove.x fp0,FPTEMP(a6)
152 lea FPTEMP(a6),a0
153 bsr tag
154 move.b d0,DTAG(a6)
155
156 fmove.x 20(a6),fp0
157 fmove.x fp0,ETEMP(a6)
158 lea ETEMP(a6),a0
159 bsr tag
160 move.b d0,STAG(a6)
161
162 bsr _OPa_
163
164 fmove.l fpsr,d0 ; update status register
165 or.b FPSR_AEXCEPT(a6),d0 ;add previously accrued exceptions
166 swap.w d0
167 or.b FPSR_QBYTE(a6),d0 ; pickup sign of quotient byte
168 swap.w d0
169 fmove.l d0,fpsr
170 *
171 * Result is now in FP0
172 *
173 movem.l USER_DA(a6),d0-d1/a0-a1
174 fmovem.x USER_FP1(a6),fp1-fp3 ; note: FP0 not restored
175 unlk a6
176 rts
177
178