Light-weight PC Emulator
Neko's x86 Virtual Machine, a portable x86 PC emulator with debugger
Author: Xu Ha (firstname.lastname@example.org)
This project includes an integrated implementation of a light-weight x86 PC emulator, which is written in 40,000 lines of C codes and a few Assembly codes.
It emulated a PC machine which serves as a software container. The emulator has an Intel 80386 CPU and all other necessary devices, such as RAM, DMA, PIC, Floppy, Hard Drive, Keyboard, Display and so on.
Therefore it supports the operating systems based on x86, such as MS-DOS.
The emulator provides two modes of display: Win32 Console and Win32 App Window.
In the previous mode, the keyboard and display are emulated using Win32 Console APIs, while in the later mode, emulator accepts input and provides output using a Window controlled by message loop.
The Win32 App Window mode is preferred for two reasons:
- The bitmap font used in MS-DOS is applied in Win32 App Window Mode.
- The NXVM console window still exists and won't be overrided by NXVM display.
The emulator runs in a terminal window of at least 80x25 size. It works like Win32 Console mode. It has some known issues which are not yet fixed.
The compiling options are defined in
src/global.h, to specify 32/64 bit compilation. It also has a macro to specify the platform WIN32/LINUX. In most cases, user doesn't need to change anything there.
For Visual Studio 2008 or higher:
- Create an empty Win32 Console project.
- Add all
src/, and remove the folder
- Compile the project under platform Release and x64.
- Install MinGW to
- Download PDCurses 3.4 (
pdc34dllw.zip, Win32 DLL for console w/ Unicode) from Sourceforge.com.
- Add files to
pdcurses.lib -> %MINGW_HOME%/lib/ncurses.lib
cursors.h -> %MINGW_HOME%/include/cursors.h
panels.h -> %MINGW_HOME%/include/panels.h
pdcures.dll -> %MINGW_HOME%/bin/pdcures.dll
pthreadif they do not exist.
- Change directory to NXVM project folder.
./configureto check libraries and generate makefile.
maketo build NXVM. Output binary is
nxvmin project folder.
- Prepare for a 1.44MB floppy disk image file as the startup disk.
- Start NXVM and type
helpfor available commands.
device fdd insert <filename>to load the floppy disk image file into NXVM floppy drive.
modeto switch display mode(Win32 Console/Win32 App Window).
infoto learn about emulator status.
startto start machine.
stopunder Win32 App Window mode, or press
F9at anytime to stop emulation.
- The emulation can be resumed by
resumecommand in NXVM console.
- Main Entry and Version Label (src/main.c)
- Virtual Machine Console (src/console.ch)
VM console provides a command-line interface which accepts user input and provides machine information.
- Platform-related Components (src/platform/)
- Basic I/O System (src/device/vbios.ch)
- Hardware Emulation Modules (src/device/vmachine.ch)
The emulator is divided into 3 parts: Hardware Emulation, BIOS and Platform-related Part.
Hardware Emulation is the "hardware" part, which provides the hardware logic of all the devices emulated.
Basic I/O System is the "software" part, which provides POST and interrupt service routines.
Platform-related Part basically provides keyboard and display, and it is designed to work with different operating systems.
NXVM is NOT just an emulator. It does more than simply emulating a PC. Users may debug an operating system in NXVM using debugger.
Debugger Console (src/debug.ch, src/device/vdebug.ch)
The debugger is used to test and debug the guest operating system running inside NXVM.
User may print/modify CPU registers, print/modify/search/compare/fill/watch RAM area, operate device through I/O ports, trace/dump CPU instructions and set breakpoints.
NXVM has both 16-bit and 32-bit debugger support. The command usage of 16-bit debugger is almost the same as the MS-DOS debugger, and all the memory addresses are represented in physical address. The 32-bit debugger uses linear address format. The help command
? introduces all available commands supported.
- i386 Assembler (src/xasm32/aasm32.ch)
- i386 Disassembler (src/xasm32/dasm32.ch)
The emulator includes an integral assembler and disassembler. They translates Assembly codes from/to machine codes. All Intel-format x86 instructions are supported.
The assembler and disassembler are used as a part of debugger, which provides readable instructions to user.
Some legacy MS-DOS applications are supported in NXVM.
Intel 80386 Reference Manual
IA-32 Intel Architecture Software Developer's Manual Volume 1: Basic Architecture
IA-32 Intel Architecture Software Developer's Manual Volume 2: Instruction Set Reference
IA-32 Intel Architecture Software Developer's Manual Volume 3: System Programming Guide
IBM PC/AT 5170 Technical Reference (1985)
and more ...