From e6553975dab405ab5e6385c9cf7dc3db9766a982 Mon Sep 17 00:00:00 2001 From: OBattler Date: Tue, 9 Aug 2016 03:42:32 +0200 Subject: [PATCH] FILD with MOD 3 now correctly behaves like FFREEP (undocumented behavior). --- src/x87_ops_loadstore.h | 8 ++++++++ src/x87_ops_misc.h | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/src/x87_ops_loadstore.h b/src/x87_ops_loadstore.h index bede280b9..00b52b505 100644 --- a/src/x87_ops_loadstore.h +++ b/src/x87_ops_loadstore.h @@ -3,6 +3,10 @@ static int opFILDiw_a16(uint32_t fetchdat) int16_t temp; FP_ENTER(); fetch_ea_16(fetchdat); + if (mod == 3) + { + return opFFREEP(fetchdat) + } if (fplog) pclog("FILDw %08X:%08X\n", easeg, eaaddr); temp = geteaw(); if (abrt) return 1; if (fplog) pclog(" %f\n", (double)temp); @@ -15,6 +19,10 @@ static int opFILDiw_a32(uint32_t fetchdat) int16_t temp; FP_ENTER(); fetch_ea_32(fetchdat); + if (mod == 3) + { + return opFFREEP(fetchdat) + } if (fplog) pclog("FILDw %08X:%08X\n", easeg, eaaddr); temp = geteaw(); if (abrt) return 1; if (fplog) pclog(" %f\n", (double)temp); diff --git a/src/x87_ops_misc.h b/src/x87_ops_misc.h index 401e84cc6..82c7cd976 100644 --- a/src/x87_ops_misc.h +++ b/src/x87_ops_misc.h @@ -50,6 +50,15 @@ static int opFFREE(uint32_t fetchdat) return 0; } +static int opFFREEP(uint32_t fetchdat) +{ + if (fplog) pclog("FFREEP\n"); + tag[(TOP + fetchdat) & 7] = 3; if (abrt) return 1; + x87_pop(); + CLOCK_CYCLES(3); + return 0; +} + static int opFST(uint32_t fetchdat) { FP_ENTER();