Author: aandrejevic
Date: Sun Dec  1 03:16:49 2013
New Revision: 61163

URL: http://svn.reactos.org/svn/reactos?rev=61163&view=rev
Log:
[FAST486]
Fix MOVS and STOS when DF = 1. The starting position in the block was off by 1.


Modified:
    branches/ntvdm/lib/fast486/opcodes.c

Modified: branches/ntvdm/lib/fast486/opcodes.c
URL: 
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/opcodes.c?rev=61163&r1=61162&r2=61163&view=diff
==============================================================================
--- branches/ntvdm/lib/fast486/opcodes.c        [iso-8859-1] (original)
+++ branches/ntvdm/lib/fast486/opcodes.c        [iso-8859-1] Sun Dec  1 
03:16:49 2013
@@ -5398,16 +5398,16 @@
 
             if (State->Flags.Df)
             {
-                /* Reduce ESI and EDI by the number of bytes to transfer */
+                /* Move ESI and EDI to the start of the block */
                 if (AddressSize)
                 {
-                    State->GeneralRegs[FAST486_REG_ESI].Long -= Processed * 
DataSize;
-                    State->GeneralRegs[FAST486_REG_EDI].Long -= Processed * 
DataSize;
+                    State->GeneralRegs[FAST486_REG_ESI].Long -= (Processed - 
1) * DataSize;
+                    State->GeneralRegs[FAST486_REG_EDI].Long -= (Processed - 
1) * DataSize;
                 }
                 else
                 {
-                    State->GeneralRegs[FAST486_REG_ESI].LowWord -= Processed * 
DataSize;
-                    State->GeneralRegs[FAST486_REG_EDI].LowWord -= Processed * 
DataSize;
+                    State->GeneralRegs[FAST486_REG_ESI].LowWord -= (Processed 
- 1) * DataSize;
+                    State->GeneralRegs[FAST486_REG_EDI].LowWord -= (Processed 
- 1) * DataSize;
                 }
             }
 
@@ -5458,6 +5458,20 @@
                     State->GeneralRegs[FAST486_REG_EDI].LowWord += Processed * 
DataSize;
                 }
             }
+            else
+            {
+                /* Reduce ESI and EDI */
+                if (AddressSize)
+                {
+                    State->GeneralRegs[FAST486_REG_ESI].Long -= DataSize;
+                    State->GeneralRegs[FAST486_REG_EDI].Long -= DataSize;
+                }
+                else
+                {
+                    State->GeneralRegs[FAST486_REG_ESI].LowWord -= DataSize;
+                    State->GeneralRegs[FAST486_REG_EDI].LowWord -= DataSize;
+                }
+            }
 
             /* Reduce the total count by the number processed in this run */
             Count -= Processed;
@@ -5728,9 +5742,9 @@
 
             if (State->Flags.Df)
             {
-                /* Reduce EDI by the number of bytes to transfer */
-                if (AddressSize) State->GeneralRegs[FAST486_REG_EDI].Long -= 
Processed * DataSize;
-                else State->GeneralRegs[FAST486_REG_EDI].LowWord -= Processed 
* DataSize;
+                /* Set EDI to the starting location */
+                if (AddressSize) State->GeneralRegs[FAST486_REG_EDI].Long -= 
(Processed - 1) * DataSize;
+                else State->GeneralRegs[FAST486_REG_EDI].LowWord -= (Processed 
- 1) * DataSize;
             }
 
             /* Write to memory */
@@ -5754,6 +5768,12 @@
                 /* Increase EDI by the number of bytes transfered */
                 if (AddressSize) State->GeneralRegs[FAST486_REG_EDI].Long += 
Processed * DataSize;
                 else State->GeneralRegs[FAST486_REG_EDI].LowWord += Processed 
* DataSize;
+            }
+            else
+            {
+                /* Reduce EDI */
+                if (AddressSize) State->GeneralRegs[FAST486_REG_EDI].Long -= 
DataSize;
+                else State->GeneralRegs[FAST486_REG_EDI].LowWord -= DataSize;
             }
 
             /* Reduce the total count by the number processed in this run */


Reply via email to