blob: aeab24e083c40a5f4aa231b2346f5af3377b660f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*---------------------------------------------------------------------------+
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070018void fadd__(void)
19{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010020 /* fadd st,st(i) */
21 int i = FPU_rm;
22 clear_C1();
23 FPU_add(&st(i), FPU_gettagi(i), 0, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070024}
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026void fmul__(void)
27{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010028 /* fmul st,st(i) */
29 int i = FPU_rm;
30 clear_C1();
31 FPU_mul(&st(i), FPU_gettagi(i), 0, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070032}
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034void fsub__(void)
35{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010036 /* fsub st,st(i) */
37 clear_C1();
38 FPU_sub(0, FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070039}
40
Linus Torvalds1da177e2005-04-16 15:20:36 -070041void fsubr_(void)
42{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010043 /* fsubr st,st(i) */
44 clear_C1();
45 FPU_sub(REV, FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070046}
47
Linus Torvalds1da177e2005-04-16 15:20:36 -070048void fdiv__(void)
49{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010050 /* fdiv st,st(i) */
51 clear_C1();
52 FPU_div(0, FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053}
54
Linus Torvalds1da177e2005-04-16 15:20:36 -070055void fdivr_(void)
56{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010057 /* fdivr st,st(i) */
58 clear_C1();
59 FPU_div(REV, FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060}
61
Linus Torvalds1da177e2005-04-16 15:20:36 -070062void fadd_i(void)
63{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010064 /* fadd st(i),st */
65 int i = FPU_rm;
66 clear_C1();
67 FPU_add(&st(i), FPU_gettagi(i), i, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070068}
69
Linus Torvalds1da177e2005-04-16 15:20:36 -070070void fmul_i(void)
71{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010072 /* fmul st(i),st */
73 clear_C1();
74 FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075}
76
Linus Torvalds1da177e2005-04-16 15:20:36 -070077void fsubri(void)
78{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010079 /* fsubr st(i),st */
80 clear_C1();
81 FPU_sub(DEST_RM, FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082}
83
Linus Torvalds1da177e2005-04-16 15:20:36 -070084void fsub_i(void)
85{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010086 /* fsub st(i),st */
87 clear_C1();
88 FPU_sub(REV | DEST_RM, FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089}
90
Linus Torvalds1da177e2005-04-16 15:20:36 -070091void fdivri(void)
92{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +010093 /* fdivr st(i),st */
94 clear_C1();
95 FPU_div(DEST_RM, FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096}
97
Linus Torvalds1da177e2005-04-16 15:20:36 -070098void fdiv_i(void)
99{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +0100100 /* fdiv st(i),st */
101 clear_C1();
102 FPU_div(REV | DEST_RM, FPU_rm, control_word);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103}
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105void faddp_(void)
106{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +0100107 /* 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();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112}
113
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114void fmulp_(void)
115{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +0100116 /* fmulp st(i),st */
117 clear_C1();
118 if (FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word) >= 0)
119 FPU_pop();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120}
121
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122void fsubrp(void)
123{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +0100124 /* fsubrp st(i),st */
125 clear_C1();
126 if (FPU_sub(DEST_RM, FPU_rm, control_word) >= 0)
127 FPU_pop();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128}
129
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130void fsubp_(void)
131{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +0100132 /* fsubp st(i),st */
133 clear_C1();
134 if (FPU_sub(REV | DEST_RM, FPU_rm, control_word) >= 0)
135 FPU_pop();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136}
137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138void fdivrp(void)
139{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +0100140 /* fdivrp st(i),st */
141 clear_C1();
142 if (FPU_div(DEST_RM, FPU_rm, control_word) >= 0)
143 FPU_pop();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144}
145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146void fdivp_(void)
147{
Ingo Molnar3d0d14f2008-01-30 13:30:11 +0100148 /* fdivp st(i),st */
149 clear_C1();
150 if (FPU_div(REV | DEST_RM, FPU_rm, control_word) >= 0)
151 FPU_pop();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152}