Halfplement Soft386ExecutionControl.
svn path=/branches/ntvdm/; revision=59795
list(APPEND SOURCE
soft386.c
+ opcodes.c
common.c)
add_library(soft386 ${SOURCE})
--- /dev/null
+/*
+ * COPYRIGHT: GPL - See COPYING in the top level directory
+ * PROJECT: 386/486 CPU Emulation Library
+ * FILE: opcodes.c
+ * PURPOSE: Opcode handlers.
+ * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ */
+
+/* INCLUDES *******************************************************************/
+
+// #define WIN32_NO_STATUS
+// #define _INC_WINDOWS
+#include <windef.h>
+
+#include <soft386.h>
+#include "opcodes.h"
+#include "common.h"
+
+// #define NDEBUG
+#include <debug.h>
+
+/* PUBLIC VARIABLES ***********************************************************/
+
+SOFT386_OPCODE_HANDLER_PROC
+Soft386OpcodeHandlers[SOFT386_NUM_OPCODE_HANDLERS] =
+{
+ NULL
+};
--- /dev/null
+/*
+ * COPYRIGHT: GPL - See COPYING in the top level directory
+ * PROJECT: 386/486 CPU Emulation Library
+ * FILE: opcodes.h
+ * PURPOSE: Opcode handlers. (header file)
+ * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ */
+
+#ifndef _OPCODES_H_
+#define _OPCODES_H_
+
+/* DEFINES ********************************************************************/
+
+#define SOFT386_NUM_OPCODE_HANDLERS 256
+
+typedef BOOLEAN (__fastcall *SOFT386_OPCODE_HANDLER_PROC)(PSOFT386_STATE);
+
+extern
+SOFT386_OPCODE_HANDLER_PROC
+Soft386OpcodeHandlers[SOFT386_NUM_OPCODE_HANDLERS];
+
+#endif // _OPCODES_H_
#include <soft386.h>
#include "common.h"
+#include "opcodes.h"
// #define NDEBUG
#include <debug.h>
NTAPI
Soft386ExecutionControl(PSOFT386_STATE State, INT Command)
{
- // TODO: NOT IMPLEMENTED!!!
- UNIMPLEMENTED;
+ BYTE Opcode;
+ INT ProcedureCallCount = 0;
+
+ /* Main execution loop */
+ do
+ {
+ /* Perform an instruction fetch */
+ if (!Soft386FetchByte(State, &Opcode)) continue;
+
+ // TODO: Check for CALL/RET to update ProcedureCallCount.
+
+ if (Soft386OpcodeHandlers[Opcode] != NULL)
+ {
+ /* Call the opcode handler */
+ Soft386OpcodeHandlers[Opcode](State);
+ }
+ else
+ {
+ /* This is not a valid opcode */
+ Soft386Exception(State, SOFT386_EXCEPTION_UD);
+ }
+ }
+ while ((Command == SOFT386_CONTINUE)
+ || (Command == SOFT386_STEP_OVER && ProcedureCallCount > 0)
+ || (Command == SOFT386_STEP_OUT && ProcedureCallCount >= 0));
}
/* PUBLIC FUNCTIONS ***********************************************************/