[FAST486][NTVDM]
[reactos.git] / lib / fast486 / opcodes.c
index 39ec666..81848a9 100644 (file)
 
 /* INCLUDES *******************************************************************/
 
-// #define WIN32_NO_STATUS
-// #define _INC_WINDOWS
 #include <windef.h>
-#include <limits.h>
 
 // #define NDEBUG
 #include <debug.h>
@@ -876,7 +873,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeHalt)
     }
 
     /* Halt */
-    while (!State->HardwareInt) State->IdleCallback(State);
+    while (State->IntStatus != FAST486_INT_SIGNAL) State->IdleCallback(State);
 
     /* Return success */
     return TRUE;
@@ -2743,9 +2740,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeSbbByteModrm)
     if (!(Opcode & FAST486_OPCODE_WRITE_REG))
     {
         /* Swap the order */
-        FirstValue ^= SecondValue;
-        SecondValue ^= FirstValue;
-        FirstValue ^= SecondValue;
+        SWAP(FirstValue, SecondValue);
     }
 
     /* Calculate the result */
@@ -2806,9 +2801,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeSbbModrm)
         if (!(Opcode & FAST486_OPCODE_WRITE_REG))
         {
             /* Swap the order */
-            FirstValue ^= SecondValue;
-            SecondValue ^= FirstValue;
-            FirstValue ^= SecondValue;
+            SWAP(FirstValue, SecondValue);
         }
     
         /* Calculate the result */
@@ -2846,9 +2839,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeSbbModrm)
         if (!(Opcode & FAST486_OPCODE_WRITE_REG))
         {
             /* Swap the order */
-            FirstValue ^= SecondValue;
-            SecondValue ^= FirstValue;
-            FirstValue ^= SecondValue;
+            SWAP(FirstValue, SecondValue);
         }
     
         /* Calculate the result */
@@ -3067,9 +3058,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeCmpSubByteModrm)
     if (!(Opcode & FAST486_OPCODE_WRITE_REG))
     {
         /* Swap the order */
-        FirstValue ^= SecondValue;
-        SecondValue ^= FirstValue;
-        FirstValue ^= SecondValue;
+        SWAP(FirstValue, SecondValue);
     }
 
     /* Calculate the result */
@@ -3138,9 +3127,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeCmpSubModrm)
         if (!(Opcode & FAST486_OPCODE_WRITE_REG))
         {
             /* Swap the order */
-            FirstValue ^= SecondValue;
-            SecondValue ^= FirstValue;
-            FirstValue ^= SecondValue;
+            SWAP(FirstValue, SecondValue);
         }
     
         /* Calculate the result */
@@ -3187,9 +3174,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeCmpSubModrm)
         if (!(Opcode & FAST486_OPCODE_WRITE_REG))
         {
             /* Swap the order */
-            FirstValue ^= SecondValue;
-            SecondValue ^= FirstValue;
-            FirstValue ^= SecondValue;
+            SWAP(FirstValue, SecondValue);
         }
     
         /* Calculate the result */
@@ -3706,11 +3691,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeImulModrmImm)
     }
 
     /* Check for carry/overflow */
-    if ((Product < LONG_MIN) || (Product > LONG_MAX))
-    {
-        State->Flags.Cf = State->Flags.Of = TRUE;
-    }
-    else State->Flags.Cf = State->Flags.Of = FALSE;
+    State->Flags.Cf = State->Flags.Of = ((Product < MINLONG) || (Product > MAXLONG));
 
     /* Write-back the result */
     return Fast486WriteModrmDwordOperands(State,
@@ -4350,10 +4331,10 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeLdsLes)
             && (ModRegRm.SecondRegister == FAST486_REG_ESP)
             && (State->BopCallback != NULL))
         {
-            USHORT BopCode;
+            UCHAR BopCode;
 
             /* Fetch the BOP code */
-            if (!Fast486FetchWord(State, &BopCode))
+            if (!Fast486FetchByte(State, &BopCode))
             {
                 /* Exception occurred */
                 return FALSE;