Author: aandrejevic Date: Sun Oct 20 00:55:31 2013 New Revision: 60717
URL: http://svn.reactos.org/svn/reactos?rev=60717&view=rev Log: [FAST486] Create a macro SWAP (swaps two variables) to shorten the code. Implement the BSWAP instruction.
Modified: branches/ntvdm/lib/fast486/common.h branches/ntvdm/lib/fast486/extraops.c branches/ntvdm/lib/fast486/extraops.h branches/ntvdm/lib/fast486/opcodes.c
Modified: branches/ntvdm/lib/fast486/common.h URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/common.h?rev=6... ============================================================================== --- branches/ntvdm/lib/fast486/common.h [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/common.h [iso-8859-1] Sun Oct 20 00:55:31 2013 @@ -54,6 +54,7 @@ {\ x = !x;\ } +#define SWAP(x, y) { (x) ^= (y); (y) ^= (x); (x) ^= (y); }
#define PAGE_ALIGN(x) ((x) & 0xFFFFF000) #define PAGE_OFFSET(x) ((x) & 0x00000FFF)
Modified: branches/ntvdm/lib/fast486/extraops.c URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/extraops.c?rev... ============================================================================== --- branches/ntvdm/lib/fast486/extraops.c [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/extraops.c [iso-8859-1] Sun Oct 20 00:55:31 2013 @@ -238,14 +238,14 @@ NULL, // Invalid NULL, // Invalid NULL, // Invalid - NULL, // TODO: OPCODE 0xC8 NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xC9 NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xCA NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xCB NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xCC NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xCD NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xCE NOT IMPLEMENTED - NULL, // TODO: OPCODE 0xCF NOT IMPLEMENTED + Fast486ExtOpcodeBswap, + Fast486ExtOpcodeBswap, + Fast486ExtOpcodeBswap, + Fast486ExtOpcodeBswap, + Fast486ExtOpcodeBswap, + Fast486ExtOpcodeBswap, + Fast486ExtOpcodeBswap, + Fast486ExtOpcodeBswap, NULL, // Invalid NULL, // Invalid NULL, // Invalid @@ -1021,6 +1021,23 @@ return Fast486WriteModrmByteOperands(State, &ModRegRm, FALSE, Value); }
+FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBswap) +{ + PUCHAR Pointer; + + NO_LOCK_PREFIX(); + + /* Get a pointer to the value */ + Pointer = (PUCHAR)&State->GeneralRegs[Opcode & 0x07].Long; + + /* Swap the byte order */ + SWAP(Pointer[0], Pointer[3]); + SWAP(Pointer[1], Pointer[2]); + + /* Return success */ + return TRUE; +} + FAST486_OPCODE_HANDLER(Fast486OpcodeExtended) { UCHAR SecondOpcode;
Modified: branches/ntvdm/lib/fast486/extraops.h URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/extraops.h?rev... ============================================================================== --- branches/ntvdm/lib/fast486/extraops.h [iso-8859-1] (original) +++ branches/ntvdm/lib/fast486/extraops.h [iso-8859-1] Sun Oct 20 00:55:31 2013 @@ -35,6 +35,7 @@ FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBtc); FAST486_OPCODE_HANDLER(Fast486ExtOpcodeConditionalJmp); FAST486_OPCODE_HANDLER(Fast486ExtOpcodeConditionalSet); +FAST486_OPCODE_HANDLER(Fast486ExtOpcodeBswap); FAST486_OPCODE_HANDLER(Fast486OpcodeExtended);
#endif // _EXTRAOPS_H_
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] Sun Oct 20 00:55:31 2013 @@ -2743,9 +2743,7 @@ if (!(Opcode & FAST486_OPCODE_WRITE_REG)) { /* Swap the order */ - FirstValue ^= SecondValue; - SecondValue ^= FirstValue; - FirstValue ^= SecondValue; + SWAP(FirstValue, SecondValue); }
/* Calculate the result */ @@ -2806,9 +2804,7 @@ if (!(Opcode & FAST486_OPCODE_WRITE_REG)) { /* Swap the order */ - FirstValue ^= SecondValue; - SecondValue ^= FirstValue; - FirstValue ^= SecondValue; + SWAP(FirstValue, SecondValue); }
/* Calculate the result */ @@ -2846,9 +2842,7 @@ if (!(Opcode & FAST486_OPCODE_WRITE_REG)) { /* Swap the order */ - FirstValue ^= SecondValue; - SecondValue ^= FirstValue; - FirstValue ^= SecondValue; + SWAP(FirstValue, SecondValue); }
/* Calculate the result */ @@ -3067,9 +3061,7 @@ if (!(Opcode & FAST486_OPCODE_WRITE_REG)) { /* Swap the order */ - FirstValue ^= SecondValue; - SecondValue ^= FirstValue; - FirstValue ^= SecondValue; + SWAP(FirstValue, SecondValue); }
/* Calculate the result */ @@ -3138,9 +3130,7 @@ if (!(Opcode & FAST486_OPCODE_WRITE_REG)) { /* Swap the order */ - FirstValue ^= SecondValue; - SecondValue ^= FirstValue; - FirstValue ^= SecondValue; + SWAP(FirstValue, SecondValue); }
/* Calculate the result */ @@ -3187,9 +3177,7 @@ if (!(Opcode & FAST486_OPCODE_WRITE_REG)) { /* Swap the order */ - FirstValue ^= SecondValue; - SecondValue ^= FirstValue; - FirstValue ^= SecondValue; + SWAP(FirstValue, SecondValue); }
/* Calculate the result */