Author: aandrejevic Date: Fri Nov 22 01:22:00 2013 New Revision: 61068
URL: http://svn.reactos.org/svn/reactos?rev=61068&view=rev Log: [FAST486] Fix the calculation of AF in ADC and the calculation of AF and CF in SBB.
Modified: branches/ntvdm/lib/fast486/opcodes.c branches/ntvdm/lib/fast486/opgroups.c
Modified: branches/ntvdm/lib/fast486/opcodes.c URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/opcodes.c?rev=... ============================================================================== --- branches/ntvdm/lib/fast486/opcodes.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/opcodes.c [iso-8859-1] Fri Nov 22 01:22:00 2013 @@ -2483,7 +2483,7 @@ State->Flags.Cf = State->Flags.Cf || ((Result < FirstValue) && (Result < SecondValue)); State->Flags.Of = ((FirstValue & SIGN_FLAG_BYTE) == (SecondValue & SIGN_FLAG_BYTE)) && ((FirstValue & SIGN_FLAG_BYTE) != (Result & SIGN_FLAG_BYTE)); - State->Flags.Af = ((((FirstValue & 0x0F) + (SecondValue & 0x0F)) & 0x10) != 0); + State->Flags.Af = ((FirstValue ^ SecondValue ^ Result) & 0x10) != 0; State->Flags.Zf = (Result == 0); State->Flags.Sf = ((Result & SIGN_FLAG_BYTE) != 0); State->Flags.Pf = Fast486CalculateParity(Result); @@ -2540,7 +2540,7 @@ State->Flags.Cf = State->Flags.Cf || ((Result < FirstValue) && (Result < SecondValue)); State->Flags.Of = ((FirstValue & SIGN_FLAG_LONG) == (SecondValue & SIGN_FLAG_LONG)) && ((FirstValue & SIGN_FLAG_LONG) != (Result & SIGN_FLAG_LONG)); - State->Flags.Af = ((((FirstValue & 0x0F) + (SecondValue & 0x0F)) & 0x10) != 0); + State->Flags.Af = ((FirstValue ^ SecondValue ^ Result) & 0x10) != 0; State->Flags.Zf = (Result == 0); State->Flags.Sf = ((Result & SIGN_FLAG_LONG) != 0); State->Flags.Pf = Fast486CalculateParity(Result); @@ -2575,7 +2575,7 @@ State->Flags.Cf = State->Flags.Cf || ((Result < FirstValue) && (Result < SecondValue)); State->Flags.Of = ((FirstValue & SIGN_FLAG_WORD) == (SecondValue & SIGN_FLAG_WORD)) && ((FirstValue & SIGN_FLAG_WORD) != (Result & SIGN_FLAG_WORD)); - State->Flags.Af = ((((FirstValue & 0x0F) + (SecondValue & 0x0F)) & 0x10) != 0); + State->Flags.Af = ((FirstValue ^ SecondValue ^ Result) & 0x10) != 0; State->Flags.Zf = (Result == 0); State->Flags.Sf = ((Result & SIGN_FLAG_WORD) != 0); State->Flags.Pf = Fast486CalculateParity(Result); @@ -2621,7 +2621,7 @@ State->Flags.Cf = State->Flags.Cf || ((Result < FirstValue) && (Result < SecondValue)); State->Flags.Of = ((FirstValue & SIGN_FLAG_BYTE) == (SecondValue & SIGN_FLAG_BYTE)) && ((FirstValue & SIGN_FLAG_BYTE) != (Result & SIGN_FLAG_BYTE)); - State->Flags.Af = ((((FirstValue & 0x0F) + (SecondValue & 0x0F)) & 0x10) != 0); + State->Flags.Af = ((FirstValue ^ SecondValue ^ Result) & 0x10) != 0; State->Flags.Zf = (Result == 0); State->Flags.Sf = ((Result & SIGN_FLAG_BYTE) != 0); State->Flags.Pf = Fast486CalculateParity(Result); @@ -2664,7 +2664,7 @@ State->Flags.Cf = State->Flags.Cf || ((Result < FirstValue) && (Result < SecondValue)); State->Flags.Of = ((FirstValue & SIGN_FLAG_LONG) == (SecondValue & SIGN_FLAG_LONG)) && ((FirstValue & SIGN_FLAG_LONG) != (Result & SIGN_FLAG_LONG)); - State->Flags.Af = ((((FirstValue & 0x0F) + (SecondValue & 0x0F)) & 0x10) != 0); + State->Flags.Af = ((FirstValue ^ SecondValue ^ Result) & 0x10) != 0; State->Flags.Zf = (Result == 0); State->Flags.Sf = ((Result & SIGN_FLAG_LONG) != 0); State->Flags.Pf = Fast486CalculateParity(Result); @@ -2694,7 +2694,7 @@ State->Flags.Cf = State->Flags.Cf || ((Result < FirstValue) && (Result < SecondValue)); State->Flags.Of = ((FirstValue & SIGN_FLAG_WORD) == (SecondValue & SIGN_FLAG_WORD)) && ((FirstValue & SIGN_FLAG_WORD) != (Result & SIGN_FLAG_WORD)); - State->Flags.Af = ((((FirstValue & 0x0F) + (SecondValue & 0x0F)) & 0x10) != 0); + State->Flags.Af = ((FirstValue ^ SecondValue ^ Result) & 0x10) != 0; State->Flags.Zf = (Result == 0); State->Flags.Sf = ((Result & SIGN_FLAG_WORD) != 0); State->Flags.Pf = Fast486CalculateParity(Result); @@ -2765,10 +2765,10 @@ Result = FirstValue - SecondValue - Carry;
/* Update the flags */ - State->Flags.Cf = FirstValue < (SecondValue + 1); + State->Flags.Cf = Carry ? (FirstValue <= SecondValue) : (FirstValue < SecondValue); State->Flags.Of = ((FirstValue & SIGN_FLAG_BYTE) != (SecondValue & SIGN_FLAG_BYTE)) && ((FirstValue & SIGN_FLAG_BYTE) != (Result & SIGN_FLAG_BYTE)); - State->Flags.Af = (FirstValue & 0x0F) < ((SecondValue + 1) & 0x0F); + State->Flags.Af = ((FirstValue ^ SecondValue ^ Result) & 0x10) != 0; State->Flags.Zf = (Result == 0); State->Flags.Sf = ((Result & SIGN_FLAG_BYTE) != 0); State->Flags.Pf = Fast486CalculateParity(Result); @@ -2826,10 +2826,10 @@ Result = FirstValue - SecondValue - Carry;
/* Update the flags */ - State->Flags.Cf = FirstValue < (SecondValue + Carry); + State->Flags.Cf = Carry ? (FirstValue <= SecondValue) : (FirstValue < SecondValue); State->Flags.Of = ((FirstValue & SIGN_FLAG_LONG) != (SecondValue & SIGN_FLAG_LONG)) && ((FirstValue & SIGN_FLAG_LONG) != (Result & SIGN_FLAG_LONG)); - State->Flags.Af = (FirstValue & 0x0F) < ((SecondValue + 1) & 0x0F); + State->Flags.Af = ((FirstValue ^ SecondValue ^ Result) & 0x10) != 0; State->Flags.Zf = (Result == 0); State->Flags.Sf = ((Result & SIGN_FLAG_LONG) != 0); State->Flags.Pf = Fast486CalculateParity(Result); @@ -2864,10 +2864,10 @@ Result = FirstValue - SecondValue - Carry;
/* Update the flags */ - State->Flags.Cf = FirstValue < (SecondValue + Carry); + State->Flags.Cf = Carry ? (FirstValue <= SecondValue) : (FirstValue < SecondValue); State->Flags.Of = ((FirstValue & SIGN_FLAG_WORD) != (SecondValue & SIGN_FLAG_WORD)) && ((FirstValue & SIGN_FLAG_WORD) != (Result & SIGN_FLAG_WORD)); - State->Flags.Af = (FirstValue & 0x0F) < ((SecondValue + 1) & 0x0F); + State->Flags.Af = ((FirstValue ^ SecondValue ^ Result) & 0x10) != 0; State->Flags.Zf = (Result == 0); State->Flags.Sf = ((Result & SIGN_FLAG_WORD) != 0); State->Flags.Pf = Fast486CalculateParity(Result); @@ -2906,10 +2906,10 @@ Result = FirstValue - SecondValue - Carry;
/* Update the flags */ - State->Flags.Cf = FirstValue < (SecondValue + Carry); + State->Flags.Cf = Carry ? (FirstValue <= SecondValue) : (FirstValue < SecondValue); State->Flags.Of = ((FirstValue & SIGN_FLAG_BYTE) != (SecondValue & SIGN_FLAG_BYTE)) && ((FirstValue & SIGN_FLAG_BYTE) != (Result & SIGN_FLAG_BYTE)); - State->Flags.Af = (FirstValue & 0x0F) < ((SecondValue + 1) & 0x0F); + State->Flags.Af = ((FirstValue ^ SecondValue ^ Result) & 0x10) != 0; State->Flags.Zf = (Result == 0); State->Flags.Sf = ((Result & SIGN_FLAG_BYTE) != 0); State->Flags.Pf = Fast486CalculateParity(Result); @@ -2947,10 +2947,10 @@ Result = FirstValue - SecondValue - Carry;
/* Update the flags */ - State->Flags.Cf = FirstValue < (SecondValue + Carry); + State->Flags.Cf = Carry ? (FirstValue <= SecondValue) : (FirstValue < SecondValue); State->Flags.Of = ((FirstValue & SIGN_FLAG_LONG) != (SecondValue & SIGN_FLAG_LONG)) && ((FirstValue & SIGN_FLAG_LONG) != (Result & SIGN_FLAG_LONG)); - State->Flags.Af = (FirstValue & 0x0F) < ((SecondValue + Carry) & 0x0F); + State->Flags.Af = ((FirstValue ^ SecondValue ^ Result) & 0x10) != 0; State->Flags.Zf = (Result == 0); State->Flags.Sf = ((Result & SIGN_FLAG_LONG) != 0); State->Flags.Pf = Fast486CalculateParity(Result); @@ -2973,10 +2973,10 @@ Result = FirstValue - SecondValue - Carry;
/* Update the flags */ - State->Flags.Cf = FirstValue < (SecondValue + Carry); + State->Flags.Cf = Carry ? (FirstValue <= SecondValue) : (FirstValue < SecondValue); State->Flags.Of = ((FirstValue & SIGN_FLAG_WORD) != (SecondValue & SIGN_FLAG_WORD)) && ((FirstValue & SIGN_FLAG_WORD) != (Result & SIGN_FLAG_WORD)); - State->Flags.Af = (FirstValue & 0x0F) < ((SecondValue + Carry) & 0x0F); + State->Flags.Af = ((FirstValue ^ SecondValue ^ Result) & 0x10) != 0; State->Flags.Zf = (Result == 0); State->Flags.Sf = ((Result & SIGN_FLAG_WORD) != 0); State->Flags.Pf = Fast486CalculateParity(Result);
Modified: branches/ntvdm/lib/fast486/opgroups.c URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/opgroups.c?rev... ============================================================================== --- branches/ntvdm/lib/fast486/opgroups.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/opgroups.c [iso-8859-1] Fri Nov 22 01:22:00 2013 @@ -85,7 +85,7 @@ || ((Result < FirstValue) && (Result < (SecondValue + Carry))); State->Flags.Of = ((FirstValue & SignFlag) == (SecondValue & SignFlag)) && ((FirstValue & SignFlag) != (Result & SignFlag)); - State->Flags.Af = ((((FirstValue & 0x0F) + ((SecondValue + Carry) & 0x0F)) & 0x10) != 0); + State->Flags.Af = ((FirstValue ^ SecondValue ^ Result) & 0x10) != 0;
break; } @@ -98,10 +98,12 @@ Result = (FirstValue - SecondValue - Carry) & MaxValue;
/* Update CF, OF and AF */ - State->Flags.Cf = FirstValue < (SecondValue + Carry); + State->Flags.Cf = Carry + ? (FirstValue <= SecondValue) + : (FirstValue < SecondValue); State->Flags.Of = ((FirstValue & SignFlag) != (SecondValue & SignFlag)) && ((FirstValue & SignFlag) != (Result & SignFlag)); - State->Flags.Af = (FirstValue & 0x0F) < ((SecondValue + Carry) & 0x0F); + State->Flags.Af = ((FirstValue ^ SecondValue ^ Result) & 0x10) != 0;
break; }