https://github.com/lostjared/mxvm
MXVM is a custom virtual machine and compiler/interpreter project designed as a personal learning tool.
https://github.com/lostjared/mxvm
Last synced: about 2 months ago
JSON representation
MXVM is a custom virtual machine and compiler/interpreter project designed as a personal learning tool.
- Host: GitHub
- URL: https://github.com/lostjared/mxvm
- Owner: lostjared
- License: gpl-3.0
- Created: 2025-07-19T15:04:17.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2026-04-04T03:10:45.000Z (about 2 months ago)
- Last Synced: 2026-04-04T03:28:20.907Z (about 2 months ago)
- Language: C++
- Homepage: https://lostsidedead.biz/MXVM
- Size: 9.52 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.html
- License: LICENSE
Awesome Lists containing this project
README
MXVM - Virtual Machine & Compiler
body { background-color: #000; color: #fff; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; padding: 0; line-height: 1.6; }
main { max-width: 900px; margin: 40px auto; padding: 0 20px; }
header { text-align: center; padding: 60px 20px 20px; }
header h1 { font-size: 3rem; margin: 0; }
header p { font-size: 1.2rem; color: #ccc; margin-top: 8px; }
section { margin-bottom: 40px; }
h2 { border-bottom: 2px solid #444; padding-bottom: 0.2em; margin-bottom: 0.5em; font-size: 1.8rem; }
h3 { font-size: 1.4rem; margin-top: 1em; margin-bottom: 0.5em; }
p, ul, pre, code, table, ol { margin-bottom: 1em; }
code, pre { background-color: #111; color: #0f0; padding: 4px 6px; border-radius: 4px; font-family: 'Courier New', Courier, monospace; }
pre { overflow-x: auto; padding: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid #444; padding: 8px 12px; text-align: left; }
th { background-color: #222; }
ul, ol { padding-left: 1.2em; }
footer { text-align: center; padding: 20px; border-top: 1px solid #444; color: #666; font-size: 0.9rem; margin-top: 40px; }
a { color: #fff; text-decoration: underline; }
a:hover { color: #ccc; }
MXVM
Custom RISC-style VM & Compiler Sandbox (C++)
Project Purpose
Not for production use. Use MXVM to explore:
- VM architecture & instruction execution
- Code parsing & AST generation
- Modular design & dynamic loading
- C++ code organization & CMake
- Cross-platform builds
- Debugging & memory management
Features
-
Custom VM: Small instruction set (arithmetic, control flow, memory, string). -
Parser & AST: Grammar → AST → intermediate code. -
Interpreter & JIT: Stack VM or native x86_64 code. -
Modular System: Load IO, string, math modules viainvoke. -
Debugging: HTML output, memory dumps, verbose errors. -
CMake Build: Linux, macOS & Windows support.
RISC-Style Bytecode
-
Load/Store Architecture:load/storeonly for memory access. -
Orthogonal Instructions: Single-purpose opcodes (e.g.,add,jmp). -
Fixed Format: One instruction per line; destination operand first. -
Explicit Control Flow:cmpsets flags; branches viaje,jne, etc.
Language Overview
program MyApp {
section data {
int counter = 0
string msg = "Hello, MXVM!\n"
}
section module { io, string }
section code {
start:
print msg
add counter, counter, 1
cmp counter, 10
jl start
done
}
}
data: Declare int, ptr, byte, string.
module: List modules for invoke.
code: Labeled, one instruction per line; operands: destination first.
Instruction Set Reference
Arithmetic & Logic
InstructionOperandsDescription
movdest, srcCopy value
adddest, a, bdest = a + b
subdest, a, bdest = a - b
muldest, a, bdest = a * b
divdest, a, bdest = a / b
moddest, a, bdest = a % b
negdest, adest = -a
ordest, a, bBitwise OR
anddest, a, bBitwise AND
xordest, a, bBitwise XOR
notdest, aBitwise NOT
Comparison & Branching
InstructionOperandsDescription
cmpa, bSet flags from a - b
jmplabelUnconditional jump
je/jne/jl/jle/jg/jgelabelConditional jumps
Memory & Stack
InstructionOperandsDescription
loaddest, ptr, idx, sizedest = *(ptr + idx*size)
storesrc, ptr, idx, size*(ptr + idx*size) = src
allocptr, bsize, countAllocate memory
freeptrRelease memory
I/O & Modules
InstructionOperandsDescription
printfmt, args…Formatted output
getlineptrRead line into buffer
invokefunc, args…Call external function
callModule.FuncInternal function call
ret—Return from function
done—End program
exitcodeTerminate VM
Conversion & Misc
InstructionOperandsDescription
to_intdest, ptrConvert string to integer
to_floatdest, ptrConvert string to float
Module System
Place compiled modules (.so/.dll) into modules/. Then:
section module { io, string, math }
invoke fopen, filename, mode
invoke strlen, mystr
Project Structure
MXVM-main/
├── CMakeLists.txt # Build rules
├── LICENSE # Apache-2.0 License
├── README.md # Project overview
├── about.html # Browser demo & docs
├── include/mxvm/ # Public headers
├── src/ # VM & codegen implementation
├── modules/ # Extension modules
└── mxvm_src/ # Example programs (.mxvm)
Building & Running
git clone https://github.com/yourname/MXVM.git
cd MXVM
mkdir build && cd build
cmake .. && make && sudo make install
Interpreter: mxvmc hello_world.mxvm --path /usr/local/lib --object-path .
Compile: mxvmc fibonacci.mxvm --path /usr/local/lib --object-path . --action translate
Contributing
- Fork the repository
- Create a feature branch
- Commit & push changes
- Open a Pull Request
© 2025 MXVM Project