aboutsummaryrefslogtreecommitdiff
path: root/target/m68k/fpu_helper.c
diff options
context:
space:
mode:
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2023-01-14 23:29:58 +0000
committerLaurent Vivier <laurent@vivier.eu>2023-01-16 09:47:31 +0100
commitad6dae3b3369433ab43a1b190bb3a8aacabb1bbf (patch)
treec8d1c2c400ba7d5d429109832519bc38a831acee /target/m68k/fpu_helper.c
parent60b598df6e3e3d76dae6967e03d4418f6aac6064 (diff)
target/m68k: fix FPSR quotient byte for fmod instruction
The FPSR quotient byte should be set to the value of the quotient and not the result. Switch from using floatx80_mod() to floatx80_modrem() which returns the quotient as a uint64_t which can be used for the quotient byte. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20230114232959.118224-4-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'target/m68k/fpu_helper.c')
-rw-r--r--target/m68k/fpu_helper.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c
index 76b34b8988..5fd094a33c 100644
--- a/target/m68k/fpu_helper.c
+++ b/target/m68k/fpu_helper.c
@@ -523,17 +523,16 @@ static void make_quotient(CPUM68KState *env, int sign, uint32_t quotient)
void HELPER(fmod)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
{
- uint32_t quotient;
- int sign;
+ uint64_t quotient;
+ int sign = extractFloatx80Sign(val1->d) ^ extractFloatx80Sign(val0->d);
- res->d = floatx80_mod(val1->d, val0->d, &env->fp_status);
+ res->d = floatx80_modrem(val1->d, val0->d, true, &quotient,
+ &env->fp_status);
if (floatx80_is_any_nan(res->d)) {
return;
}
- sign = extractFloatx80Sign(res->d);
- quotient = floatx80_to_int32(floatx80_abs(res->d), &env->fp_status);
make_quotient(env, sign, quotient);
}