This repository has been archived on 2025-11-10. You can view files and clone it. You cannot open issues or pull requests or push a commit.

Oreo's Virtual Machine (OVM)

A stack based virtual machine in C11, with a dynamic register setup which acts as variable space. Deals primarily in bytes, doesn't make assertions about typing and is very simple to target.

How to build

Requires GNU make, a compliant C11 compiler. Code base has been tested against gcc and clang, but given how the project has been written without use of GNU'isms it shouldn't be an issue to compile using something like tcc or another compiler (look at here to change the compiler).

To build everything simply run make. This will build:

  • instruction bytecode system which allows one to target the VM by writing and reading instruction bytecode
  • VM executable which can execute bytecode (your java executable)
  • Assembler executable which can assemble compliant assembly code to VM bytecode
  • Assembly examples which provide some source code examples on common programs one may write. Use this to figure out how to write compliant assembly.

One may also build each component individually through the corresponding recipe:

  • make lib
  • make vm
  • make asm
  • make examples

Instructions to target the virtual machine

You need to link with the object files for base.c, darr.c and inst.c to be able to properly target the OVM. The basic idea is to create instructions via inst_t then using the inst(s)_write_* API to generate bytecode (and write to a file).

Then to execute the program, the virtual machine interpreter ovm.out is used.

For clarity, one may build lib (make lib) then use the resulting object files to link and create bytecode for the virtual machine.

Lines of code

301 ./vm/runtime.h
93 ./vm/main.c
1058 ./vm/runtime.c
435 ./lib/inst.c
39 ./lib/darr.h
243 ./lib/inst.h
42 ./lib/heap.h
90 ./lib/base.h
101 ./lib/heap.c
39 ./lib/base.c
77 ./lib/darr.c
601 ./asm/parser.c
143 ./asm/main.c
82 ./asm/lexer.h
54 ./asm/parser.h
541 ./asm/lexer.c
Description
No description provided
Readme 401 KiB
Languages
C++ 93.8%
Makefile 6.2%