Author: hbelusca
Date: Mon Nov 18 00:45:00 2013
New Revision: 61033
URL:
http://svn.reactos.org/svn/reactos?rev=61033&view=rev
Log:
[NTVDM]
- Implement and export getEFLAGS and setEFLAGS.
- Do some code reorganization (move all registers-related functions into
"registers.c").
Modified:
branches/ntvdm/subsystems/ntvdm/emulator.c
branches/ntvdm/subsystems/ntvdm/emulator.h
branches/ntvdm/subsystems/ntvdm/ntvdm.spec
branches/ntvdm/subsystems/ntvdm/registers.c
branches/ntvdm/subsystems/ntvdm/registers.h
Modified: branches/ntvdm/subsystems/ntvdm/emulator.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/emulator…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] Mon Nov 18 00:45:00 2013
@@ -14,6 +14,7 @@
#include "cmos.h"
#include "bios.h"
#include "bop.h"
+#include "registers.h"
#include "dos.h"
#include "speaker.h"
#include "vga.h"
@@ -311,11 +312,6 @@
if (BaseAddress != NULL) HeapFree(GetProcessHeap(), 0, BaseAddress);
}
-VOID EmulatorSetStack(WORD Segment, DWORD Offset)
-{
- Fast486SetStack(&EmulatorContext, Segment, Offset);
-}
-
// FIXME: This function assumes 16-bit mode!!!
VOID EmulatorExecute(WORD Segment, WORD Offset)
{
@@ -335,50 +331,6 @@
Fast486InterruptSignal(&EmulatorContext);
}
-ULONG EmulatorGetRegister(ULONG Register)
-{
- if (Register < EMULATOR_REG_ES)
- {
- return EmulatorContext.GeneralRegs[Register].Long;
- }
- else
- {
- return EmulatorContext.SegmentRegs[Register - EMULATOR_REG_ES].Selector;
- }
-}
-
-VOID EmulatorSetRegister(ULONG Register, ULONG Value)
-{
- if (Register < EMULATOR_REG_ES)
- {
- EmulatorContext.GeneralRegs[Register].Long = Value;
- }
- else
- {
- Fast486SetSegment(&EmulatorContext, Register - EMULATOR_REG_ES,
(USHORT)Value);
- }
-}
-
-ULONG EmulatorGetProgramCounter(VOID)
-{
- return EmulatorContext.InstPtr.Long;
-}
-
-BOOLEAN EmulatorGetFlag(ULONG Flag)
-{
- return (EmulatorContext.Flags.Long & Flag) ? TRUE : FALSE;
-}
-
-VOID EmulatorSetFlag(ULONG Flag)
-{
- EmulatorContext.Flags.Long |= Flag;
-}
-
-VOID EmulatorClearFlag(ULONG Flag)
-{
- EmulatorContext.Flags.Long &= ~Flag;
-}
-
VOID EmulatorStep(VOID)
{
/* Dump the state for debugging purposes */
Modified: branches/ntvdm/subsystems/ntvdm/emulator.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/emulator…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/emulator.h [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/emulator.h [iso-8859-1] Mon Nov 18 00:45:00 2013
@@ -59,24 +59,6 @@
EMULATOR_EXCEPTION_PAGE_FAULT
};
-enum
-{
- EMULATOR_REG_AX,
- EMULATOR_REG_CX,
- EMULATOR_REG_DX,
- EMULATOR_REG_BX,
- EMULATOR_REG_SP,
- EMULATOR_REG_BP,
- EMULATOR_REG_SI,
- EMULATOR_REG_DI,
- EMULATOR_REG_ES,
- EMULATOR_REG_CS,
- EMULATOR_REG_SS,
- EMULATOR_REG_DS,
- EMULATOR_REG_FS,
- EMULATOR_REG_GS
-};
-
extern FAST486_STATE EmulatorContext;
/* FUNCTIONS ******************************************************************/
@@ -121,16 +103,9 @@
);
BOOLEAN EmulatorInitialize(VOID);
-VOID EmulatorSetStack(WORD Segment, DWORD Offset);
VOID EmulatorExecute(WORD Segment, WORD Offset);
VOID EmulatorInterrupt(BYTE Number);
VOID EmulatorInterruptSignal(VOID);
-ULONG EmulatorGetRegister(ULONG Register);
-ULONG EmulatorGetProgramCounter(VOID);
-VOID EmulatorSetRegister(ULONG Register, ULONG Value);
-BOOLEAN EmulatorGetFlag(ULONG Flag);
-VOID EmulatorSetFlag(ULONG Flag);
-VOID EmulatorClearFlag(ULONG Flag);
VOID EmulatorStep(VOID);
VOID EmulatorCleanup(VOID);
VOID EmulatorSetA20(BOOLEAN Enabled);
Modified: branches/ntvdm/subsystems/ntvdm/ntvdm.spec
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/ntvdm.sp…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/ntvdm.spec [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/ntvdm.spec [iso-8859-1] Mon Nov 18 00:45:00 2013
@@ -23,7 +23,7 @@
@ cdecl getECX()
@ cdecl getEDI()
@ cdecl getEDX()
-; @ cdecl getEFLAGS()
+@ cdecl getEFLAGS()
@ cdecl getEIP()
@ cdecl getES()
@ cdecl getESI()
@@ -69,7 +69,7 @@
@ cdecl setECX(long)
@ cdecl setEDI(long)
@ cdecl setEDX(long)
-; @ cdecl setEFLAGS(long)
+@ cdecl setEFLAGS(long)
@ cdecl setEIP(long)
@ cdecl setES(long)
@ cdecl setESI(long)
Modified: branches/ntvdm/subsystems/ntvdm/registers.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/register…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/registers.c [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/registers.c [iso-8859-1] Mon Nov 18 00:45:00 2013
@@ -12,118 +12,184 @@
#include "emulator.h"
+// TODO: Should be moved to fast486.h
+enum
+{
+ EMULATOR_REG_EAX,
+ EMULATOR_REG_ECX,
+ EMULATOR_REG_EDX,
+ EMULATOR_REG_EBX,
+ EMULATOR_REG_ESP,
+ EMULATOR_REG_EBP,
+ EMULATOR_REG_ESI,
+ EMULATOR_REG_EDI,
+
+ EMULATOR_REG_ES,
+ EMULATOR_REG_CS,
+ EMULATOR_REG_SS,
+ EMULATOR_REG_DS,
+ EMULATOR_REG_FS,
+ EMULATOR_REG_GS
+};
+
/* PUBLIC FUNCTIONS ***********************************************************/
+ULONG EmulatorGetRegister(ULONG Register)
+{
+ if (Register < EMULATOR_REG_ES)
+ {
+ return EmulatorContext.GeneralRegs[Register].Long;
+ }
+ else
+ {
+ return EmulatorContext.SegmentRegs[Register - EMULATOR_REG_ES].Selector;
+ }
+}
+
+VOID EmulatorSetRegister(ULONG Register, ULONG Value)
+{
+ if (Register < EMULATOR_REG_ES)
+ {
+ EmulatorContext.GeneralRegs[Register].Long = Value;
+ }
+ else
+ {
+ Fast486SetSegment(&EmulatorContext, Register - EMULATOR_REG_ES,
(USHORT)Value);
+ }
+}
+
+BOOLEAN EmulatorGetFlag(ULONG Flag)
+{
+ return (EmulatorContext.Flags.Long & Flag) ? TRUE : FALSE;
+}
+
+VOID EmulatorSetFlag(ULONG Flag)
+{
+ EmulatorContext.Flags.Long |= Flag;
+}
+
+VOID EmulatorClearFlag(ULONG Flag)
+{
+ EmulatorContext.Flags.Long &= ~Flag;
+}
+
+VOID EmulatorSetStack(WORD Segment, DWORD Offset)
+{
+ Fast486SetStack(&EmulatorContext, Segment, Offset);
+}
+
+
+
ULONG
CDECL
getEAX(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_AX].Long;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_EAX].Long;
}
VOID
CDECL
setEAX(ULONG Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_AX].Long = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_EAX].Long = Value;
}
USHORT
CDECL
getAX(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_AX].LowWord;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_EAX].LowWord;
}
VOID
CDECL
setAX(USHORT Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_AX].LowWord = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_EAX].LowWord = Value;
}
UCHAR
CDECL
getAH(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_AX].HighByte;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_EAX].HighByte;
}
VOID
CDECL
setAH(UCHAR Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_AX].HighByte = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_EAX].HighByte = Value;
}
UCHAR
CDECL
getAL(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_AX].LowByte;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_EAX].LowByte;
}
VOID
CDECL
setAL(UCHAR Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_AX].LowByte = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_EAX].LowByte = Value;
}
ULONG
CDECL
getEBX(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_BX].Long;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_EBX].Long;
}
VOID
CDECL
setEBX(ULONG Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_BX].Long = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_EBX].Long = Value;
}
USHORT
CDECL
getBX(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_BX].LowWord;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_EBX].LowWord;
}
VOID
CDECL
setBX(USHORT Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_BX].LowWord = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_EBX].LowWord = Value;
}
UCHAR
CDECL
getBH(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_BX].HighByte;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_EBX].HighByte;
}
VOID
CDECL
setBH(UCHAR Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_BX].HighByte = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_EBX].HighByte = Value;
}
UCHAR
CDECL
getBL(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_BX].LowByte;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_EBX].LowByte;
}
VOID
CDECL
setBL(UCHAR Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_BX].LowByte = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_EBX].LowByte = Value;
}
@@ -132,56 +198,56 @@
CDECL
getECX(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_CX].Long;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_ECX].Long;
}
VOID
CDECL
setECX(ULONG Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_CX].Long = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_ECX].Long = Value;
}
USHORT
CDECL
getCX(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_CX].LowWord;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_ECX].LowWord;
}
VOID
CDECL
setCX(USHORT Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_CX].LowWord = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_ECX].LowWord = Value;
}
UCHAR
CDECL
getCH(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_CX].HighByte;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_ECX].HighByte;
}
VOID
CDECL
setCH(UCHAR Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_CX].HighByte = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_ECX].HighByte = Value;
}
UCHAR
CDECL
getCL(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_CX].LowByte;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_ECX].LowByte;
}
VOID
CDECL
setCL(UCHAR Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_CX].LowByte = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_ECX].LowByte = Value;
}
@@ -190,56 +256,56 @@
CDECL
getEDX(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_DX].Long;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_EDX].Long;
}
VOID
CDECL
setEDX(ULONG Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_DX].Long = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_EDX].Long = Value;
}
USHORT
CDECL
getDX(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_DX].LowWord;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_EDX].LowWord;
}
VOID
CDECL
setDX(USHORT Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_DX].LowWord = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_EDX].LowWord = Value;
}
UCHAR
CDECL
getDH(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_DX].HighByte;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_EDX].HighByte;
}
VOID
CDECL
setDH(UCHAR Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_DX].HighByte = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_EDX].HighByte = Value;
}
UCHAR
CDECL
getDL(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_DX].LowByte;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_EDX].LowByte;
}
VOID
CDECL
setDL(UCHAR Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_DX].LowByte = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_EDX].LowByte = Value;
}
@@ -248,7 +314,7 @@
CDECL
getESP(VOID)
{
- return EmulatorGetRegister(EMULATOR_REG_SP);
+ return EmulatorGetRegister(EMULATOR_REG_ESP);
}
VOID
@@ -262,7 +328,7 @@
CDECL
getSP(VOID)
{
- return LOWORD(EmulatorGetRegister(EMULATOR_REG_SP));
+ return LOWORD(EmulatorGetRegister(EMULATOR_REG_ESP));
}
VOID
@@ -278,28 +344,28 @@
CDECL
getEBP(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_BP].Long;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_EBP].Long;
}
VOID
CDECL
setEBP(ULONG Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_BP].Long = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_EBP].Long = Value;
}
USHORT
CDECL
getBP(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_BP].LowWord;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_EBP].LowWord;
}
VOID
CDECL
setBP(USHORT Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_BP].LowWord = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_EBP].LowWord = Value;
}
@@ -308,28 +374,28 @@
CDECL
getESI(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_SI].Long;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_ESI].Long;
}
VOID
CDECL
setESI(ULONG Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_SI].Long = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_ESI].Long = Value;
}
USHORT
CDECL
getSI(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_SI].LowWord;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_ESI].LowWord;
}
VOID
CDECL
setSI(USHORT Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_SI].LowWord = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_ESI].LowWord = Value;
}
@@ -338,28 +404,28 @@
CDECL
getEDI(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_DI].Long;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_EDI].Long;
}
VOID
CDECL
setEDI(ULONG Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_DI].Long = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_EDI].Long = Value;
}
USHORT
CDECL
getDI(VOID)
{
- return EmulatorContext.GeneralRegs[EMULATOR_REG_DI].LowWord;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_EDI].LowWord;
}
VOID
CDECL
setDI(USHORT Value)
{
- EmulatorContext.GeneralRegs[EMULATOR_REG_DI].LowWord = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_EDI].LowWord = Value;
}
@@ -368,7 +434,7 @@
CDECL
getEIP(VOID)
{
- return EmulatorGetProgramCounter();
+ return EmulatorContext.InstPtr.Long;
}
VOID
@@ -382,7 +448,7 @@
CDECL
getIP(VOID)
{
- return LOWORD(EmulatorGetProgramCounter());
+ return EmulatorContext.InstPtr.LowWord;
}
VOID
@@ -618,6 +684,22 @@
+ULONG
+CDECL
+getEFLAGS(VOID)
+{
+ return EmulatorContext.Flags.Long;
+}
+
+VOID
+CDECL
+setEFLAGS(ULONG Flags)
+{
+ EmulatorContext.Flags.Long = Flags;
+}
+
+
+
USHORT
CDECL
getMSW(VOID)
Modified: branches/ntvdm/subsystems/ntvdm/registers.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/register…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/registers.h [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/registers.h [iso-8859-1] Mon Nov 18 00:45:00 2013
@@ -10,6 +10,14 @@
#define _REGISTERS_H_
/* INCLUDES *******************************************************************/
+
+ULONG EmulatorGetRegister(ULONG Register);
+VOID EmulatorSetRegister(ULONG Register, ULONG Value);
+BOOLEAN EmulatorGetFlag(ULONG Flag);
+VOID EmulatorSetFlag(ULONG Flag);
+VOID EmulatorClearFlag(ULONG Flag);
+VOID EmulatorSetStack(WORD Segment, DWORD Offset);
+
ULONG getEAX(VOID);
VOID setEAX(ULONG);
@@ -104,6 +112,9 @@
ULONG getOF(VOID);
VOID setOF(ULONG);
+ULONG getEFLAGS(VOID);
+VOID setEFLAGS(ULONG);
+
USHORT getMSW(VOID);
VOID setMSW(USHORT);