A minimalistic virtual machine (kapoorvm) designed for low-level programming and experimentation.
The test result shows the following:
vm
indicates the starting address of the virtual machine's memory and its total size (65,552 bytes).prog
is the address of the program loaded into memory.System halted
: The virtual machine has completed its execution, and the system has been halted.ax = abcd
: The value in theAX
register is shown, indicating it has been set to "abcd" (or some equivalent hex representation).
This output showcases the virtual machine loading a program, executing it, and halting with the state of a register displayed at the end.
- 🖥️ Registers: General-purpose (
AX
,BX
,CX
,DX
) and specialized (SP
,IP
). - 📦 Memory Management: Supports 65 KB of virtual memory for program execution.
- 🎛️ Custom Instruction Set: Implements operations like data transfer, arithmetic, and more via opcodes.
- 🔍 Sub-register Access: Direct manipulation of high and low parts of registers (e.g.,
AH
,AL
).
Register | Type |
---|---|
AX |
General-purpose |
BX |
General-purpose |
CX |
General-purpose |
DX |
General-purpose |
SP |
Stack pointer |
IP |
Instruction ptr |
- 16-bit Address Space: Total virtual memory of 65 KB.
- Custom-designed opcodes for core CPU operations like
MOV
,HLT
,NOP
.
This project is a work in progress.
I’m actively:
- 🚀 Adding new features
- 🔧 Fixing bugs
- 📈 Expanding the instruction set
src/
: Source code for the VM.include/
: Header files for modularity.tests/
: Test cases for validating functionality.
- OS: Linux (recommended).
- C Compiler: GCC or Clang.
- Clone the repository:
git clone https://github.com/Ankush1626/Virtual-Machine-16bit.git
- Navigate to the project directory:
cd Virtual-Machine-16bit
- Compile the source code:
gcc -o kapoorvm src/kapoorvm.c
- Run the virtual machine:
./kaooorvm
- Load a program into memory with simple assembly-like instructions.
- Use the custom instruction set to execute operations and observe the results.
- 📜 Stack Operations: Add
PUSH
andPOP
instructions. - ➗ Advanced Arithmetic: Include
MUL
andDIV
operations.
Inspired by low-level CPU architectures and the x86 assembly language.
This project is under development and may have missing features or bugs.
I am continuously improving it—your feedback and support are invaluable!
This project is based on the tutorial video created by Dr. Jonas Birch on YouTube.
Dr. Birch is a phenomenal programmer whose work forms the foundation of this project.
- Several header files, such as
birchutils.h
, were authored by him. - Definitions and
typedef
s used for typecasting in this project are directly derived from his work.
Additionally, kapoorvm.h
includes birchutils.h
, and the functions within this header file rely on implementations found in birchutils.c
. The project compiles in accordance with birchutils.c
.
You can download birchutils.h
and birchutils.c
from Dr. Birch's official repository: https://repo.doctorbirch.com/.
A huge thanks to Dr. Birch for his invaluable resources and guidance!