A virtual machine implementation from scratch, featuring a custom instruction set architecture and runtime environment.
- Custom 32-bit instruction set architecture
- Register-based virtual machine
- Built-in assembler for creating bytecode
- Memory management with stack and heap
- Basic I/O operations
- Debugging and monitoring tools
- 8 general-purpose registers (R0-R7)
- Stack pointer (SP)
- Program counter (PC)
- Flags register (FLAGS)
- Code segment: Stores program instructions
- Data segment: Stores global variables
- Stack: Function calls and local variables
- Heap: Dynamic memory allocation
- Arithmetic operations (ADD, SUB, MUL, DIV)
- Logical operations (AND, OR, XOR, NOT)
- Memory operations (LOAD, STORE)
- Control flow (JMP, JEQ, JNE, CALL, RET)
- I/O operations (PRINT, READ)
- System operations (HALT, NOP)
# Build the VM
make build
# Run a program
./amethyst-vm program.avm
# Assemble source code
./assembler program.asm -o program.avmSee the examples/ directory for sample programs that demonstrate the VM capabilities.
src/- Source code for the VM implementationexamples/- Example programstests/- Test suitedocs/- Documentation
MIT License