4 * Copyright (c) 2006-2007 CodeSourcery
5 * Written by Paul Brook
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 #include "qemu/osdep.h"
23 #include "exec/helper-proto.h"
24 #include "exec/exec-all.h"
26 int32_t HELPER(reds32)(CPUM68KState *env, FPReg *val)
28 return floatx80_to_int32(val->d, &env->fp_status);
31 float32 HELPER(redf32)(CPUM68KState *env, FPReg *val)
33 return floatx80_to_float32(val->d, &env->fp_status);
36 void HELPER(exts32)(CPUM68KState *env, FPReg *res, int32_t val)
38 res->d = int32_to_floatx80(val, &env->fp_status);
41 void HELPER(extf32)(CPUM68KState *env, FPReg *res, float32 val)
43 res->d = float32_to_floatx80(val, &env->fp_status);
46 void HELPER(extf64)(CPUM68KState *env, FPReg *res, float64 val)
48 res->d = float64_to_floatx80(val, &env->fp_status);
51 float64 HELPER(redf64)(CPUM68KState *env, FPReg *val)
53 return floatx80_to_float64(val->d, &env->fp_status);
56 void HELPER(firound)(CPUM68KState *env, FPReg *res, FPReg *val)
58 res->d = floatx80_round_to_int(val->d, &env->fp_status);
61 void HELPER(fitrunc)(CPUM68KState *env, FPReg *res, FPReg *val)
63 res->d = floatx80_round_to_int(val->d, &env->fp_status);
66 void HELPER(fsqrt)(CPUM68KState *env, FPReg *res, FPReg *val)
68 res->d = floatx80_sqrt(val->d, &env->fp_status);
71 void HELPER(fabs)(CPUM68KState *env, FPReg *res, FPReg *val)
73 res->d = floatx80_abs(val->d);
76 void HELPER(fchs)(CPUM68KState *env, FPReg *res, FPReg *val)
78 res->d = floatx80_chs(val->d);
81 void HELPER(fadd)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
83 res->d = floatx80_add(val0->d, val1->d, &env->fp_status);
86 void HELPER(fsub)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
88 res->d = floatx80_sub(val1->d, val0->d, &env->fp_status);
91 void HELPER(fmul)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
93 res->d = floatx80_mul(val0->d, val1->d, &env->fp_status);
96 void HELPER(fdiv)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
98 res->d = floatx80_div(val1->d, val0->d, &env->fp_status);
101 void HELPER(fsub_cmp)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
103 /* ??? This may incorrectly raise exceptions. */
104 /* ??? Should flush denormals to zero. */
105 res->d = floatx80_sub(val0->d, val1->d, &env->fp_status);
106 if (floatx80_is_quiet_nan(res->d, &env->fp_status)) {
107 /* +/-inf compares equal against itself, but sub returns nan. */
108 if (!floatx80_is_quiet_nan(val0->d, &env->fp_status)
109 && !floatx80_is_quiet_nan(val1->d, &env->fp_status)) {
110 res->d = floatx80_zero;
111 if (floatx80_lt_quiet(val0->d, res->d, &env->fp_status)) {
112 res->d = floatx80_chs(res->d);
118 uint32_t HELPER(fcompare)(CPUM68KState *env, FPReg *val)
120 return floatx80_compare_quiet(val->d, floatx80_zero, &env->fp_status);