Merge from vendor branch NTPD:
[dragonfly.git] / sys / i386 / gnu / fpemul / fpu_arith.c
1 /*
2  *  fpu_arith.c
3  *
4  * Code to implement the FPU register/register arithmetic instructions
5  *
6  *
7  * Copyright (C) 1992,1993,1994
8  *                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163,
9  *                       Australia.  E-mail   billm@vaxc.cc.monash.edu.au
10  * All rights reserved.
11  *
12  * This copyright notice covers the redistribution and use of the
13  * FPU emulator developed by W. Metzenthen. It covers only its use
14  * in the 386BSD, FreeBSD and NetBSD operating systems. Any other
15  * use is not permitted under this copyright.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions
19  * are met:
20  * 1. Redistributions of source code must retain the above copyright
21  *    notice, this list of conditions and the following disclaimer.
22  * 2. Redistributions in binary form must include information specifying
23  *    that source code for the emulator is freely available and include
24  *    either:
25  *      a) an offer to provide the source code for a nominal distribution
26  *         fee, or
27  *      b) list at least two alternative methods whereby the source
28  *         can be obtained, e.g. a publically accessible bulletin board
29  *         and an anonymous ftp site from which the software can be
30  *         downloaded.
31  * 3. All advertising materials specifically mentioning features or use of
32  *    this emulator must acknowledge that it was developed by W. Metzenthen.
33  * 4. The name of W. Metzenthen may not be used to endorse or promote
34  *    products derived from this software without specific prior written
35  *    permission.
36  *
37  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
38  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
39  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
40  * W. METZENTHEN BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
41  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
42  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
43  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
44  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
45  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
46  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47  *
48  *
49  * The purpose of this copyright, based upon the Berkeley copyright, is to
50  * ensure that the covered software remains freely available to everyone.
51  *
52  * The software (with necessary differences) is also available, but under
53  * the terms of the GNU copyleft, for the Linux operating system and for
54  * the djgpp ms-dos extender.
55  *
56  * W. Metzenthen   June 1994.
57  *
58  *
59  * $FreeBSD: src/sys/gnu/i386/fpemul/fpu_arith.c,v 1.9 1999/08/28 00:42:49 peter Exp $
60  * $DragonFly: src/sys/i386/gnu/fpemul/Attic/fpu_arith.c,v 1.3 2003/08/07 21:17:20 dillon Exp $
61  *
62  */
63
64
65
66
67 #include <sys/param.h>
68 #include <sys/proc.h>
69 #include <machine/pcb.h>
70
71 #include "fpu_emu.h"
72 #include "fpu_system.h"
73
74
75 void
76 fadd__()
77 {
78         /* fadd st,st(i) */
79         reg_add(FPU_st0_ptr, &st(FPU_rm), FPU_st0_ptr, control_word);
80 }
81
82
83 void
84 fmul__()
85 {
86         /* fmul st,st(i) */
87         reg_mul(FPU_st0_ptr, &st(FPU_rm), FPU_st0_ptr, control_word);
88 }
89
90
91
92 void
93 fsub__()
94 {
95         /* fsub st,st(i) */
96         reg_sub(FPU_st0_ptr, &st(FPU_rm), FPU_st0_ptr, control_word);
97 }
98
99
100 void
101 fsubr_()
102 {
103         /* fsubr st,st(i) */
104         reg_sub(&st(FPU_rm), FPU_st0_ptr, FPU_st0_ptr, control_word);
105 }
106
107
108 void
109 fdiv__()
110 {
111         /* fdiv st,st(i) */
112         reg_div(FPU_st0_ptr, &st(FPU_rm), FPU_st0_ptr, control_word);
113 }
114
115
116 void
117 fdivr_()
118 {
119         /* fdivr st,st(i) */
120         reg_div(&st(FPU_rm), FPU_st0_ptr, FPU_st0_ptr, control_word);
121 }
122
123
124
125 void
126 fadd_i()
127 {
128         /* fadd st(i),st */
129         reg_add(FPU_st0_ptr, &st(FPU_rm), &st(FPU_rm), control_word);
130 }
131
132
133 void
134 fmul_i()
135 {
136         /* fmul st(i),st */
137         reg_mul(&st(FPU_rm), FPU_st0_ptr, &st(FPU_rm), control_word);
138 }
139
140
141 void
142 fsubri()
143 {
144         /* fsubr st(i),st */
145         /* This is the sense of the 80486 manual reg_sub(&st(FPU_rm),
146          * FPU_st0_ptr, &st(FPU_rm), control_word); */
147         reg_sub(FPU_st0_ptr, &st(FPU_rm), &st(FPU_rm), control_word);
148 }
149
150
151 void
152 fsub_i()
153 {
154         /* fsub st(i),st */
155         /* This is the sense of the 80486 manual reg_sub(FPU_st0_ptr,
156          * &st(FPU_rm), &st(FPU_rm), control_word); */
157         reg_sub(&st(FPU_rm), FPU_st0_ptr, &st(FPU_rm), control_word);
158 }
159
160
161 void
162 fdivri()
163 {
164         /* fdivr st(i),st */
165         reg_div(FPU_st0_ptr, &st(FPU_rm), &st(FPU_rm), control_word);
166 }
167
168
169 void
170 fdiv_i()
171 {
172         /* fdiv st(i),st */
173         reg_div(&st(FPU_rm), FPU_st0_ptr, &st(FPU_rm), control_word);
174 }
175
176
177
178 void
179 faddp_()
180 {
181         /* faddp st(i),st */
182         reg_add(FPU_st0_ptr, &st(FPU_rm), &st(FPU_rm), control_word);
183         pop();
184 }
185
186
187 void
188 fmulp_()
189 {
190         /* fmulp st(i),st */
191         reg_mul(&st(FPU_rm), FPU_st0_ptr, &st(FPU_rm), control_word);
192         pop();
193 }
194
195
196
197 void
198 fsubrp()
199 {
200         /* fsubrp st(i),st */
201         /* This is the sense of the 80486 manual reg_sub(&st(FPU_rm),
202          * FPU_st0_ptr, &st(FPU_rm), control_word); */
203         reg_sub(FPU_st0_ptr, &st(FPU_rm), &st(FPU_rm), control_word);
204         pop();
205 }
206
207
208 void
209 fsubp_()
210 {
211         /* fsubp st(i),st */
212         /* This is the sense of the 80486 manual reg_sub(FPU_st0_ptr,
213          * &st(FPU_rm), &st(FPU_rm), control_word); */
214         reg_sub(&st(FPU_rm), FPU_st0_ptr, &st(FPU_rm), control_word);
215         pop();
216 }
217
218
219 void
220 fdivrp()
221 {
222         /* fdivrp st(i),st */
223         reg_div(FPU_st0_ptr, &st(FPU_rm), &st(FPU_rm), control_word);
224         pop();
225 }
226
227
228 void
229 fdivp_()
230 {
231         /* fdivp st(i),st */
232         reg_div(&st(FPU_rm), FPU_st0_ptr, &st(FPU_rm), control_word);
233         pop();
234 }