1 /*---------------------------------------------------------------------------+
2 | fpu_arith.c |
3 | |
4 | Code to implement the FPU register/register arithmetic instructions |
5 | |
6 | Copyright (C) 1992,1993,1997 |
7 | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia |
8 | E-mail billm@suburbia.net |
9 | |
10 | |
11 +---------------------------------------------------------------------------*/
12
13 #include "fpu_system.h"
14 #include "fpu_emu.h"
15 #include "control_w.h"
16 #include "status_w.h"
17
fadd__(void)18 void fadd__(void)
19 {
20 /* fadd st,st(i) */
21 int i = FPU_rm;
22 clear_C1();
23 FPU_add(&st(i), FPU_gettagi(i), 0, control_word);
24 }
25
fmul__(void)26 void fmul__(void)
27 {
28 /* fmul st,st(i) */
29 int i = FPU_rm;
30 clear_C1();
31 FPU_mul(&st(i), FPU_gettagi(i), 0, control_word);
32 }
33
fsub__(void)34 void fsub__(void)
35 {
36 /* fsub st,st(i) */
37 clear_C1();
38 FPU_sub(0, FPU_rm, control_word);
39 }
40
fsubr_(void)41 void fsubr_(void)
42 {
43 /* fsubr st,st(i) */
44 clear_C1();
45 FPU_sub(REV, FPU_rm, control_word);
46 }
47
fdiv__(void)48 void fdiv__(void)
49 {
50 /* fdiv st,st(i) */
51 clear_C1();
52 FPU_div(0, FPU_rm, control_word);
53 }
54
fdivr_(void)55 void fdivr_(void)
56 {
57 /* fdivr st,st(i) */
58 clear_C1();
59 FPU_div(REV, FPU_rm, control_word);
60 }
61
fadd_i(void)62 void fadd_i(void)
63 {
64 /* fadd st(i),st */
65 int i = FPU_rm;
66 clear_C1();
67 FPU_add(&st(i), FPU_gettagi(i), i, control_word);
68 }
69
fmul_i(void)70 void fmul_i(void)
71 {
72 /* fmul st(i),st */
73 clear_C1();
74 FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word);
75 }
76
fsubri(void)77 void fsubri(void)
78 {
79 /* fsubr st(i),st */
80 clear_C1();
81 FPU_sub(DEST_RM, FPU_rm, control_word);
82 }
83
fsub_i(void)84 void fsub_i(void)
85 {
86 /* fsub st(i),st */
87 clear_C1();
88 FPU_sub(REV | DEST_RM, FPU_rm, control_word);
89 }
90
fdivri(void)91 void fdivri(void)
92 {
93 /* fdivr st(i),st */
94 clear_C1();
95 FPU_div(DEST_RM, FPU_rm, control_word);
96 }
97
fdiv_i(void)98 void fdiv_i(void)
99 {
100 /* fdiv st(i),st */
101 clear_C1();
102 FPU_div(REV | DEST_RM, FPU_rm, control_word);
103 }
104
faddp_(void)105 void faddp_(void)
106 {
107 /* faddp st(i),st */
108 int i = FPU_rm;
109 clear_C1();
110 if (FPU_add(&st(i), FPU_gettagi(i), i, control_word) >= 0)
111 FPU_pop();
112 }
113
fmulp_(void)114 void fmulp_(void)
115 {
116 /* fmulp st(i),st */
117 clear_C1();
118 if (FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word) >= 0)
119 FPU_pop();
120 }
121
fsubrp(void)122 void fsubrp(void)
123 {
124 /* fsubrp st(i),st */
125 clear_C1();
126 if (FPU_sub(DEST_RM, FPU_rm, control_word) >= 0)
127 FPU_pop();
128 }
129
fsubp_(void)130 void fsubp_(void)
131 {
132 /* fsubp st(i),st */
133 clear_C1();
134 if (FPU_sub(REV | DEST_RM, FPU_rm, control_word) >= 0)
135 FPU_pop();
136 }
137
fdivrp(void)138 void fdivrp(void)
139 {
140 /* fdivrp st(i),st */
141 clear_C1();
142 if (FPU_div(DEST_RM, FPU_rm, control_word) >= 0)
143 FPU_pop();
144 }
145
fdivp_(void)146 void fdivp_(void)
147 {
148 /* fdivp st(i),st */
149 clear_C1();
150 if (FPU_div(REV | DEST_RM, FPU_rm, control_word) >= 0)
151 FPU_pop();
152 }
153