aboutsummaryrefslogtreecommitdiff
path: root/target
diff options
context:
space:
mode:
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2023-01-14 23:29:57 +0000
committerLaurent Vivier <laurent@vivier.eu>2023-01-16 09:47:31 +0100
commit60b598df6e3e3d76dae6967e03d4418f6aac6064 (patch)
treed4a468635fd12196c79f6fa2e002488abae17aaf /target
parent3ec21437b1470cff373c002c1ebb4f70f666f0c3 (diff)
target/m68k: pass sign directly into make_quotient()
This enables the quotient parameter to be changed from int32_t to uint32_t and also allows the extra sign logic in make_quotient() to be removed. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20230114232959.118224-3-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'target')
-rw-r--r--target/m68k/fpu_helper.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c
index 0932c464fd..76b34b8988 100644
--- a/target/m68k/fpu_helper.c
+++ b/target/m68k/fpu_helper.c
@@ -515,39 +515,42 @@ uint32_t HELPER(fmovemd_ld_postinc)(CPUM68KState *env, uint32_t addr,
return fmovem_postinc(env, addr, mask, cpu_ld_float64_ra);
}
-static void make_quotient(CPUM68KState *env, int32_t quotient)
+static void make_quotient(CPUM68KState *env, int sign, uint32_t quotient)
{
- int sign;
-
- sign = quotient < 0;
- if (sign) {
- quotient = -quotient;
- }
-
quotient = (sign << 7) | (quotient & 0x7f);
env->fpsr = (env->fpsr & ~FPSR_QT_MASK) | (quotient << FPSR_QT_SHIFT);
}
void HELPER(fmod)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
{
+ uint32_t quotient;
+ int sign;
+
res->d = floatx80_mod(val1->d, val0->d, &env->fp_status);
if (floatx80_is_any_nan(res->d)) {
return;
}
- make_quotient(env, floatx80_to_int32(res->d, &env->fp_status));
+ sign = extractFloatx80Sign(res->d);
+ quotient = floatx80_to_int32(floatx80_abs(res->d), &env->fp_status);
+ make_quotient(env, sign, quotient);
}
void HELPER(frem)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
{
+ uint32_t quotient;
+ int sign;
+
res->d = floatx80_rem(val1->d, val0->d, &env->fp_status);
if (floatx80_is_any_nan(res->d)) {
return;
}
- make_quotient(env, floatx80_to_int32(res->d, &env->fp_status));
+ sign = extractFloatx80Sign(res->d);
+ quotient = floatx80_to_int32(floatx80_abs(res->d), &env->fp_status);
+ make_quotient(env, sign, quotient);
}
void HELPER(fgetexp)(CPUM68KState *env, FPReg *res, FPReg *val)