{
ULONG Processed = min(Count, STRING_BLOCK_SIZE / DataSize);
+ /* Simulate the 16-bit wrap-around of DI in 16-bit address mode */
+ if (!AddressSize)
+ {
+ ULONG MaxBytes = 0x10000 - (ULONG)State->GeneralRegs[SOFT386_REG_EDI].LowWord;
+
+ Processed = min(Processed, MaxBytes / DataSize);
+ if (Processed == 0) Processed = 1;
+ }
+
if (State->Flags.Df)
{
/* Reduce EDI by the number of bytes to transfer */
{
ULONG Processed = min(Count, STRING_BLOCK_SIZE / DataSize);
+ /* Simulate the 16-bit wrap-around of DI in 16-bit address mode */
+ if (!AddressSize)
+ {
+ ULONG MaxBytes = 0x10000 - (ULONG)State->GeneralRegs[SOFT386_REG_EDI].LowWord;
+
+ Processed = min(Processed, MaxBytes / DataSize);
+ if (Processed == 0) Processed = 1;
+ }
+
/* Read from the I/O port */
State->IoReadCallback(State,
State->GeneralRegs[SOFT386_REG_EDX].LowWord,
{
ULONG Processed = min(Count, STRING_BLOCK_SIZE / DataSize);
+ /* Simulate the 16-bit wrap-around of DI in 16-bit address mode */
+ if (!AddressSize)
+ {
+ ULONG MaxBytes = 0x10000 - (ULONG)State->GeneralRegs[SOFT386_REG_EDI].LowWord;
+
+ Processed = min(Processed, MaxBytes / DataSize);
+ if (Processed == 0) Processed = 1;
+ }
+
/* Read from memory */
if (!Soft386ReadMemory(State,
SOFT386_REG_ES,
if (ModRegRm.Register == 0)
{
- /* Increment and update OF */
+ /* Increment and update OF and AF */
Value++;
State->Flags.Of = (Value == SIGN_FLAG_BYTE) ? TRUE : FALSE;
+ State->Flags.Af = ((Value & 0x0F) == 0);
}
else
{
- /* Decrement and update OF */
+ /* Decrement and update OF and AF */
State->Flags.Of = (Value == SIGN_FLAG_BYTE) ? TRUE : FALSE;
Value--;
+ State->Flags.Af = ((Value & 0x0F) == 0x0F);
}
/* Update flags */
State->Flags.Sf = (Value & SIGN_FLAG_BYTE) ? TRUE : FALSE;
State->Flags.Zf = (Value == 0) ? TRUE : FALSE;
- State->Flags.Af = ((Value & 0x0F) == 0) ? TRUE : FALSE;
State->Flags.Pf = Soft386CalculateParity(Value);
/* Write back the result */
if (ModRegRm.Register == 0)
{
- /* Increment and update OF */
+ /* Increment and update OF and AF */
Value++;
State->Flags.Of = (Value == SIGN_FLAG_LONG) ? TRUE : FALSE;
+ State->Flags.Af = ((Value & 0x0F) == 0);
}
else if (ModRegRm.Register == 1)
{
- /* Decrement and update OF */
+ /* Decrement and update OF and AF */
State->Flags.Of = (Value == SIGN_FLAG_LONG) ? TRUE : FALSE;
Value--;
+ State->Flags.Af = ((Value & 0x0F) == 0x0F);
}
if (ModRegRm.Register <= 1)
/* Update flags */
State->Flags.Sf = (Value & SIGN_FLAG_LONG) ? TRUE : FALSE;
State->Flags.Zf = (Value == 0) ? TRUE : FALSE;
- State->Flags.Af = ((Value & 0x0F) == 0) ? TRUE : FALSE;
State->Flags.Pf = Soft386CalculateParity(Value);
/* Write back the result */
/* Increment and update OF */
Value++;
State->Flags.Of = (Value == SIGN_FLAG_WORD) ? TRUE : FALSE;
+ State->Flags.Af = ((Value & 0x0F) == 0);
}
else if (ModRegRm.Register == 1)
{
/* Decrement and update OF */
State->Flags.Of = (Value == SIGN_FLAG_WORD) ? TRUE : FALSE;
Value--;
+ State->Flags.Af = ((Value & 0x0F) == 0x0F);
}
if (ModRegRm.Register <= 1)
/* Update flags */
State->Flags.Sf = (Value & SIGN_FLAG_WORD) ? TRUE : FALSE;
State->Flags.Zf = (Value == 0) ? TRUE : FALSE;
- State->Flags.Af = ((Value & 0x0F) == 0) ? TRUE : FALSE;
State->Flags.Pf = Soft386CalculateParity(Value);
/* Write back the result */