From 4b005f11bfeec4bfef2f86796986a91bd4f4c287 Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Fri, 15 Nov 2013 20:49:48 +0000 Subject: [PATCH] [FAST486] - When accessing memory using ESP, make the SS segment default. - The INT instructions always pushes 16-bit values in real mode, regardless of the operand/address size attributes. svn path=/branches/ntvdm/; revision=61000 --- lib/fast486/common.c | 8 ++++++++ lib/fast486/common.inl | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/fast486/common.c b/lib/fast486/common.c index 42b7b962204..d41c7c8257b 100644 --- a/lib/fast486/common.c +++ b/lib/fast486/common.c @@ -240,6 +240,14 @@ Fast486InterruptInternal(PFAST486_STATE State, if (!Fast486StackPush(State, OldEsp)) return FALSE; } } + else + { + if (State->SegmentRegs[FAST486_REG_CS].Size) + { + /* Set OPSIZE, because INT always pushes 16-bit values in real mode */ + State->PrefixFlags |= FAST486_PREFIX_OPSIZE; + } + } /* Push EFLAGS */ if (!Fast486StackPush(State, State->Flags.Long)) return FALSE; diff --git a/lib/fast486/common.inl b/lib/fast486/common.inl index a6ad252c346..1297b246dd0 100644 --- a/lib/fast486/common.inl +++ b/lib/fast486/common.inl @@ -730,6 +730,17 @@ Fast486ParseModRegRm(PFAST486_STATE State, } } + if ((SibByte & 0x07) == FAST486_REG_ESP) + { + /* Check if there is no segment override */ + if (!(State->PrefixFlags & FAST486_PREFIX_SEG)) + { + /* Add a SS: prefix */ + State->PrefixFlags |= FAST486_PREFIX_SEG; + State->SegmentOverride = FAST486_REG_SS; + } + } + /* Calculate the address */ ModRegRm->MemoryAddress = Base + Index * Scale; } -- 2.17.1