[FAST486]

Whether stack operations use ESP or SP depends on the size of the stack segment.


svn path=/trunk/; revision=67320
This commit is contained in:
Aleksandar Andrejevic 2015-04-20 00:36:46 +00:00
parent 43ee605045
commit 08077d0820

View file

@ -301,6 +301,7 @@ Fast486StackPush(PFAST486_STATE State,
ULONG Value) ULONG Value)
{ {
BOOLEAN Size = State->SegmentRegs[FAST486_REG_CS].Size; BOOLEAN Size = State->SegmentRegs[FAST486_REG_CS].Size;
ULONG StackPointer = State->GeneralRegs[FAST486_REG_ESP].Long;
/* The OPSIZE prefix toggles the size */ /* The OPSIZE prefix toggles the size */
TOGGLE_OPSIZE(Size); TOGGLE_OPSIZE(Size);
@ -320,7 +321,9 @@ Fast486StackPush(PFAST486_STATE State,
/* Store the value in SS:[ESP - 4] */ /* Store the value in SS:[ESP - 4] */
if (!Fast486WriteMemory(State, if (!Fast486WriteMemory(State,
FAST486_REG_SS, FAST486_REG_SS,
State->GeneralRegs[FAST486_REG_ESP].Long - sizeof(ULONG), State->SegmentRegs[FAST486_REG_SS].Size
? StackPointer - sizeof(ULONG)
: LOWORD(StackPointer - sizeof(ULONG)),
&Value, &Value,
sizeof(ULONG))) sizeof(ULONG)))
{ {
@ -328,10 +331,18 @@ Fast486StackPush(PFAST486_STATE State,
return FALSE; return FALSE;
} }
if (State->SegmentRegs[FAST486_REG_SS].Size)
{
/* Subtract ESP by 4 */ /* Subtract ESP by 4 */
State->GeneralRegs[FAST486_REG_ESP].Long -= sizeof(ULONG); State->GeneralRegs[FAST486_REG_ESP].Long -= sizeof(ULONG);
} }
else else
{
/* Subtract SP by 4 */
State->GeneralRegs[FAST486_REG_ESP].LowWord -= sizeof(ULONG);
}
}
else
{ {
/* 16-bit size */ /* 16-bit size */
USHORT ShortValue = LOWORD(Value); USHORT ShortValue = LOWORD(Value);
@ -346,7 +357,9 @@ Fast486StackPush(PFAST486_STATE State,
/* Store the value in SS:[SP - 2] */ /* Store the value in SS:[SP - 2] */
if (!Fast486WriteMemory(State, if (!Fast486WriteMemory(State,
FAST486_REG_SS, FAST486_REG_SS,
LOWORD(State->GeneralRegs[FAST486_REG_ESP].LowWord - sizeof(USHORT)), State->SegmentRegs[FAST486_REG_SS].Size
? StackPointer - sizeof(USHORT)
: LOWORD(StackPointer - sizeof(USHORT)),
&ShortValue, &ShortValue,
sizeof(USHORT))) sizeof(USHORT)))
{ {
@ -354,9 +367,17 @@ Fast486StackPush(PFAST486_STATE State,
return FALSE; return FALSE;
} }
if (State->SegmentRegs[FAST486_REG_SS].Size)
{
/* Subtract ESP by 2 */
State->GeneralRegs[FAST486_REG_ESP].Long -= sizeof(USHORT);
}
else
{
/* Subtract SP by 2 */ /* Subtract SP by 2 */
State->GeneralRegs[FAST486_REG_ESP].LowWord -= sizeof(USHORT); State->GeneralRegs[FAST486_REG_ESP].LowWord -= sizeof(USHORT);
} }
}
return TRUE; return TRUE;
} }