Author: aandrejevic Date: Thu Aug 22 22:54:59 2013 New Revision: 59795
URL: http://svn.reactos.org/svn/reactos?rev=59795&view=rev Log: [SOFT386] Halfplement Soft386ExecutionControl.
Added: branches/ntvdm/lib/soft386/opcodes.c (with props) branches/ntvdm/lib/soft386/opcodes.h (with props) Modified: branches/ntvdm/lib/soft386/CMakeLists.txt branches/ntvdm/lib/soft386/soft386.c
Modified: branches/ntvdm/lib/soft386/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/CMakeLists.txt... ============================================================================== --- branches/ntvdm/lib/soft386/CMakeLists.txt [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/CMakeLists.txt [iso-8859-1] Thu Aug 22 22:54:59 2013 @@ -2,6 +2,7 @@
list(APPEND SOURCE soft386.c + opcodes.c common.c)
add_library(soft386 ${SOURCE})
Added: branches/ntvdm/lib/soft386/opcodes.c URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/opcodes.c?rev=... ============================================================================== --- branches/ntvdm/lib/soft386/opcodes.c (added) +++ branches/ntvdm/lib/soft386/opcodes.c [iso-8859-1] Thu Aug 22 22:54:59 2013 @@ -0,0 +1,28 @@ +/* + * 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 +};
Propchange: branches/ntvdm/lib/soft386/opcodes.c ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/ntvdm/lib/soft386/opcodes.h URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/opcodes.h?rev=... ============================================================================== --- branches/ntvdm/lib/soft386/opcodes.h (added) +++ branches/ntvdm/lib/soft386/opcodes.h [iso-8859-1] Thu Aug 22 22:54:59 2013 @@ -0,0 +1,22 @@ +/* + * 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_
Propchange: branches/ntvdm/lib/soft386/opcodes.h ------------------------------------------------------------------------------ svn:eol-style = native
Modified: branches/ntvdm/lib/soft386/soft386.c URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/soft386.c?rev=... ============================================================================== --- branches/ntvdm/lib/soft386/soft386.c [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/soft386.c [iso-8859-1] Thu Aug 22 22:54:59 2013 @@ -14,6 +14,7 @@
#include <soft386.h> #include "common.h" +#include "opcodes.h"
// #define NDEBUG #include <debug.h> @@ -36,8 +37,31 @@ 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 ***********************************************************/