From 60b598df6e3e3d76dae6967e03d4418f6aac6064 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Sat, 14 Jan 2023 23:29:57 +0000 Subject: 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 Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20230114232959.118224-3-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- target/m68k/fpu_helper.c | 23 +++++++++++++---------- 1 file 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) -- cgit v1.2.3