Mit is a simple virtual machine designed for study and experiment. It uses a byte-stream code designed for efficient execution which is binary portable between implementations. It has been implemented in C for POSIX systems. Mit is designed to be embedded in other programs; Python 3 bindings are provided that demonstrate this ability and provide a convenient REPL and debugger. In the C implementation, all memory references are bounds checked. An I/O library is implemented; access to native code routines is also possible, allowing Mit and C programs to call each other.
This package comprises the definition of the Mit virtual machine and an implementation in ISO C99 using POSIX APIs.
The package is distributed under the MIT/X11 License (see the file
COPYING). Note that some files are in the public domain, notably the
specification of Mit; they are marked as such.
THIS PROGRAM IS PROVIDED AS IS, WITH NO WARRANTY. USE IS AT THE USER’S RISK.
Mit should work on any POSIX-1.2001-compatible system. Mit has been tested on x86_64 GNU/Linux with GNU C.
Reports on compatibility, whether positive or negative, are welcomed.
Building from a release tarball
Perl and help2man are required to build from source. For building from git, see below.
To build Mit from a release tarball, run
./configure && make && make check
./configure --help for build options; note in particular the
WORD_BYTES, and the flag
For the bibliographies in the documentation to be built correctly, GNU Make should be used.
Building Mit from git
The GNU autotools are required: automake, autoconf and libtool.
Gnulib is also used, with a
bootstrap module; these are installed automatically.
To build from a Git repository, first run
./bootstrap, then see "Building
from source" above.
To build the PDF documentation, a comprehensive TeX system such as TeXLive is required. This is only necessary when building from Git, as pre-built PDFs are supplied in release archives.
mit OBJECT-FILE (see
mit --help for documentation). To run the
mit/mit.h (see this file for its documentation), and link with
libmit. In addition,
mit/opcodes.h contains an enumeration type of
Mit’s instruction set.
The documentation consists of:
- The Mit Virtual Machine
The design of the Mit virtual machine is described. Essential reading for those programming or implementing the VM.
- The comments in
- Comments in the Python modules.
HACKING.mdcontains further information for maintainers.
Mit is based on Beetle, which I developed for my BA dissertation project.
pForth is an ANSI Forth compiler that targets Mit.
Running Mit object files
The C implementation of Mit allows a hash-bang line to be prepended to an object file, so that they can be run directly. A suggested line is:
A magic file for the file(1) command is also provided: mit.magic.
Bugs and comments
Please send bug reports (preferably as GitHub issues) and comments. I’m especially interested to know of portability bugs.