Skip to content
/ mvm Public

c++ library for building virtual machine for minimal instruction sets from a static descriptive model

License

Notifications You must be signed in to change notification settings

kenavolic/mvm

Repository files navigation

Mvm

Build Status

Mvm (meta virtual machine) is a c++ 17 headers-only library that supports the construction of interpretive systems (interpreter, assembler, disassembler) by generating the code for executing and dealing with stack-based virtual machine instructions from static descriptions of the instructions.

It can be seen as a full compile-time vmgen at the cost of performance and some flexibility!

The descriptive model mimics boost msm one with a clear separation between front-end and back-end.

Current State

As it has no real applications for now, the project is very opened to any feedbacks that could make it useful in the future.

Feel free to browse the TODO list to view a possible list of improvements.

Features

  • Assembler/disassembler generation
  • Interpreter generation
  • Generated bytecode handled types: signed integer (2'complement), unsigned integer, floating point number (IEEE754)

Limitations

  • Instruction set of 256 instructions max
  • No advanced language feature (call stack, garbage collection)
  • No vm high-performance feature (tos, caching, super instr)

Supported Platforms

Tests have been performed on the following platforms:

  • Linux with cmake 3.10
  • compilers: gcc 7.3.0 & clang-7

Install

  • Clone project
    > git clone https://github.com/kenavolic/mvm.git
  • Generate build system
    > mkdir mvm_build
    > cd mvm_build
    > cmake -DCMAKE_INSTALL_PREFIX=$path_to_mvm_install_dir -DMVM_BUILD_EXAMPLES=[ON|OFF] -DMVM_BUILD_TESTS=[ON|OFF] -DMVM_BUILD_WITH_TRACES=[ON|OFF] -DMVM_BUILD_WITH_FAST_INSTR=[ON|OFF] ../mvm
  • Compilation
    > make
    > make install

Usage

Import mvm to your project

  • In your CMakeLists.txt, import mvm
    find_package(Mvm REQUIRED)
    ...
    target_link_libraries(my_proj mvm::mvm)
  • Configure your project to find pipet package
    > cmake -DCMAKE_PREFIX_PATH=$path_to_mvm_install_dir/cmake $path_to_your_proj_source_dir

Define a new instruction set

  • The mini example shows a typical usage of this toy project with an assembly script
    ./mini square_sum.mas
  • The exta example just shows how you can extend current concept and instances in your instruction set definition

About

c++ library for building virtual machine for minimal instruction sets from a static descriptive model

Resources

License

Stars

Watchers

Forks

Packages

No packages published