Author: aandrejevic
Date: Fri Oct 18 21:45:10 2013
New Revision: 60694
URL:
http://svn.reactos.org/svn/reactos?rev=60694&view=rev
Log:
[SOFT386]
Fix typecasts to make sure the value is sign-extended.
Modified:
branches/ntvdm/lib/soft386/opgroups.c
Modified: branches/ntvdm/lib/soft386/opgroups.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/opgroups.c?re…
==============================================================================
--- branches/ntvdm/lib/soft386/opgroups.c [iso-8859-1] (original)
+++ branches/ntvdm/lib/soft386/opgroups.c [iso-8859-1] Fri Oct 18 21:45:10 2013
@@ -988,7 +988,7 @@
SOFT386_OPCODE_HANDLER(Soft386OpcodeGroupF6)
{
- UCHAR Dummy, Value;
+ UCHAR Dummy, Value = 0;
SOFT386_MOD_REG_RM ModRegRm;
BOOLEAN AddressSize = State->SegmentRegs[SOFT386_REG_CS].Size;
@@ -1081,7 +1081,7 @@
/* IMUL */
case 5:
{
- SHORT Result = (SHORT)Value *
(SHORT)State->GeneralRegs[SOFT386_REG_EAX].LowByte;
+ SHORT Result = (SHORT)((CHAR)Value) *
(SHORT)((CHAR)State->GeneralRegs[SOFT386_REG_EAX].LowByte);
/* Update the flags */
State->Flags.Cf = State->Flags.Of =
@@ -1125,7 +1125,7 @@
SOFT386_OPCODE_HANDLER(Soft386OpcodeGroupF7)
{
- ULONG Dummy, Value, SignFlag;
+ ULONG Dummy, Value = 0, SignFlag;
SOFT386_MOD_REG_RM ModRegRm;
BOOLEAN OperandSize, AddressSize;
@@ -1292,7 +1292,7 @@
{
if (OperandSize)
{
- LONGLONG Result = (LONGLONG)Value *
(LONGLONG)State->GeneralRegs[SOFT386_REG_EAX].Long;
+ LONGLONG Result = (LONGLONG)((LONG)Value) *
(LONGLONG)((LONG)State->GeneralRegs[SOFT386_REG_EAX].Long);
/* Update the flags */
State->Flags.Cf = State->Flags.Of =
@@ -1304,7 +1304,7 @@
}
else
{
- LONG Result = (LONG)Value *
(LONG)State->GeneralRegs[SOFT386_REG_EAX].LowWord;
+ LONG Result = (LONG)Value *
(LONG)((SHORT)State->GeneralRegs[SOFT386_REG_EAX].LowWord);
/* Update the flags */
State->Flags.Cf = State->Flags.Of =
@@ -1365,8 +1365,8 @@
{
LONG Dividend = (LONG)State->GeneralRegs[SOFT386_REG_EAX].LowWord
| ((LONG)State->GeneralRegs[SOFT386_REG_EDX].LowWord
<< 16);
- SHORT Quotient = Dividend / (SHORT)Value;
- SHORT Remainder = Dividend % (SHORT)Value;
+ SHORT Quotient = Dividend / (SHORT)LOWORD(Value);
+ SHORT Remainder = Dividend % (SHORT)LOWORD(Value);
/* Write back the results */
State->GeneralRegs[SOFT386_REG_EAX].LowWord = (USHORT)Quotient;