The following tips should help you port existing code so that it compiles and runs on a PC:

Creating a harness is easier if your software is cleanly partitioned between Application Code and Driver Code and if it has been designed with portability in mind. You may want to make some general portability improvements to your code.

Certain source files are not required in the MSVC environment. These include start-up source files.

If you need to make changes to your code just for testing it under MxVDev, wrap these changes in #ifdef MXVDEV... #endif sections. This value is defined in the MSVC project. Changes to your code should be of the form:

#ifdef MXVDEV

  //New code

#else

  //Old code

#endif

Non-ANSI C Keywords such as interrupt, near, and far should be #defined to nothing. This can be done in MSVC under Project‑>Properties C/C++‑>Preprocessor.

For low-level microcontroller code, supply an altered register header file and “stub out” the registers to plain variables:

oCopy the system provided register definition file into the MxVHarness project folder and then modify the header file to compile with MSVC.

oRemove any embedded compiler extensions such as @0x0400 and instead declare a variable for the register or make it a macro to index a register array.

If you have a closed-source library you can either:

oStub the entry points to the library.

oRe-implement the library in the MSVC environment.

oRequest a MSVC compatible library from your vendor linked against the Multi-threaded DLL version of the CRT.

Related Topics:

MxVMC - The Virtual MicroController

Harnessing Application Code for Testing

Tips on Stubbing

C Portability Guidelines