mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
[SOFT386]
Fix the "persistant prefix" bug. Fix the conditional jump bug. Implement Soft386ExecuteAt. [NTVDM] Add Soft386 support to ntvdm. svn path=/branches/ntvdm/; revision=59929
This commit is contained in:
parent
e8aa2372b7
commit
758bdf41d9
5 changed files with 47 additions and 6 deletions
|
@ -332,6 +332,10 @@ VOID
|
|||
NTAPI
|
||||
Soft386Interrupt(PSOFT386_STATE State, UCHAR Number);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
Soft386ExecuteAt(PSOFT386_STATE State, USHORT Segment, ULONG Offset);
|
||||
|
||||
#endif // _SOFT386_H_
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -726,7 +726,7 @@ Soft386OpcodeShortConditionalJmp(PSOFT386_STATE State, UCHAR Opcode)
|
|||
}
|
||||
}
|
||||
|
||||
if ((Opcode & 0xF0) & 1)
|
||||
if (Opcode & 1)
|
||||
{
|
||||
/* Invert the result */
|
||||
Jump = !Jump;
|
||||
|
|
|
@ -58,6 +58,12 @@ Soft386ExecutionControl(PSOFT386_STATE State, INT Command)
|
|||
/* This is not a valid opcode */
|
||||
Soft386Exception(State, SOFT386_EXCEPTION_UD);
|
||||
}
|
||||
|
||||
if (Soft386OpcodeHandlers[Opcode] != Soft386OpcodePrefix)
|
||||
{
|
||||
/* A non-prefix opcode has been executed, reset the prefix flags */
|
||||
State->PrefixFlags = 0;
|
||||
}
|
||||
}
|
||||
while ((Command == SOFT386_CONTINUE)
|
||||
|| (Command == SOFT386_STEP_OVER && ProcedureCallCount > 0)
|
||||
|
@ -246,4 +252,19 @@ Soft386Interrupt(PSOFT386_STATE State, UCHAR Number)
|
|||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
Soft386ExecuteAt(PSOFT386_STATE State, USHORT Segment, ULONG Offset)
|
||||
{
|
||||
/* Load the new CS */
|
||||
if (!Soft386LoadSegment(State, SOFT386_REG_CS, Segment))
|
||||
{
|
||||
/* An exception occurred, let the handler execute instead */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set the new IP */
|
||||
State->InstPtr.Long = Offset;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -31,8 +31,6 @@ static BOOLEAN A20Line = FALSE;
|
|||
|
||||
/* PRIVATE FUNCTIONS **********************************************************/
|
||||
|
||||
#ifndef NEW_EMULATOR
|
||||
|
||||
static VOID EmulatorReadMemory(PVOID Context, UINT Address, LPBYTE Buffer, INT Size)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(Context);
|
||||
|
@ -230,6 +228,8 @@ static VOID EmulatorWriteIo(PVOID Context, UINT Address, LPBYTE Buffer, INT Size
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef NEW_EMULATOR
|
||||
|
||||
static VOID EmulatorBop(WORD Code)
|
||||
{
|
||||
WORD StackSegment, StackPointer, CodeSegment, InstructionPointer;
|
||||
|
@ -407,7 +407,14 @@ BOOLEAN EmulatorInitialize()
|
|||
/* Connect the emulated FPU to the emulated CPU */
|
||||
softx87_connect_to_CPU(&EmulatorContext, &FpuEmulatorContext);
|
||||
#else
|
||||
// TODO: NOT IMPLEMENTED
|
||||
/* Set the callbacks */
|
||||
EmulatorContext.MemReadCallback = (SOFT386_MEM_READ_PROC)EmulatorReadMemory;
|
||||
EmulatorContext.MemWriteCallback = (SOFT386_MEM_WRITE_PROC)EmulatorWriteMemory;
|
||||
EmulatorContext.IoReadCallback = (SOFT386_IO_READ_PROC)EmulatorReadIo;
|
||||
EmulatorContext.IoWriteCallback = (SOFT386_IO_WRITE_PROC)EmulatorWriteIo;
|
||||
|
||||
/* Reset the CPU */
|
||||
Soft386Reset(&EmulatorContext);
|
||||
#endif
|
||||
|
||||
/* Enable interrupts */
|
||||
|
@ -426,13 +433,15 @@ VOID EmulatorSetStack(WORD Segment, DWORD Offset)
|
|||
#endif
|
||||
}
|
||||
|
||||
// FIXME: This function assumes 16-bit mode!!!
|
||||
VOID EmulatorExecute(WORD Segment, WORD Offset)
|
||||
{
|
||||
#ifndef NEW_EMULATOR
|
||||
/* Call the softx86 API */
|
||||
softx86_set_instruction_ptr(&EmulatorContext, Segment, Offset);
|
||||
#else
|
||||
// TODO: NOT IMPLEMENTED
|
||||
/* Tell Soft386 to move the instruction pointer */
|
||||
Soft386ExecuteAt(&EmulatorContext, Segment, Offset);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -572,7 +581,11 @@ VOID EmulatorStep(VOID)
|
|||
EmulatorInterrupt(EMULATOR_EXCEPTION_INVALID_OPCODE);
|
||||
}
|
||||
#else
|
||||
// TODO: NOT IMPLEMENTED
|
||||
/* Dump the state for debugging purposes */
|
||||
Soft386DumpState(&EmulatorContext);
|
||||
|
||||
/* Execute the next instruction */
|
||||
Soft386StepInto(&EmulatorContext);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
#define FAR_POINTER(x) ((ULONG_PTR)BaseAddress + TO_LINEAR(HIWORD(x), LOWORD(x)))
|
||||
#define STEPS_PER_CYCLE 256
|
||||
|
||||
// Uncomment the following to use the new Soft386 CPU emulator (EXPERIMENTAL)
|
||||
// #define NEW_EMULATOR
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
extern LPVOID BaseAddress;
|
||||
|
|
Loading…
Reference in a new issue