Welcome to KEMU, an experimental, lightweight virtual machine written in C. This project aims to simulate a simple 16-bit virtual machine with fundamental memory management, CPU emulation, and custom assembly instructions. Inspired by classic systems like the 386, KEMU provides a foundation for learning about computer architecture, CPU registers, stack management, and basic machine instructions.
- Learn and Experiment: This VM project was started as a hands-on experiment to learn how virtual machines work by building one from scratch.
- Build a Functional 16-bit VM: The initial goal is to create a 16-bit CPU with basic memory and CPU functionality.
- Introduce a Simple Instruction Set: Implement a custom assembly language and interpreter to process VM instructions.
- 16-bit CPU: KEMU includes a CPU structure with general-purpose registers (A, B, C, X), a stack pointer, and an instruction pointer.
- Memory Management: 65 KB of memory is accessible, modeled after classic systems.
- Custom Instruction Set: A simple set of opcodes enables basic operations, allowing for straightforward computation and memory handling.
- Modular Design: CPU, memory, and program components are modular, making it easy to extend with additional functionality.
KEMU.c
– Main implementation file with entry-level setup and initialization of VM structures.KEMU.h
– Header file defining data structures such as CPU, memory, and opcodes.Makefile
– Script to compile KEMU with virtual tools and dependencies.program.c
– Contains the sequence of instructions (custom opcodes) for KEMU to execute.
- Clone the project repository.
- Install dependencies:
sudo apt-get install gcc make
- Build the project:
make
- Build and Install Utils(you must check utils source code yourself):
cd utils ./build.sh
- Run KEMU:
cd src make ./KEMU
Suggestions and improvements are welcome! To contribute:
- Fork the project.
- Create a branch.
- Make your changes.
- Submit a pull request.
- This project is experimental and may not yet handle all edge cases.
- Community Feedback: Feedback on the data structure, register naming, and memory management is highly encouraged.
- Future Enhancements: Adding disk emulation, serial I/O, and expanding the instruction set.
Thank you for exploring KEMU!