TinyVM is a virtual machine with the goal of having a small footprint. Low memory usage, a small amount of code, and a small binary. Building can be accomplished on UNIX-like systems with make and GCC. There are no external dependencies, save the C standard library. Building can be accomplished using "make," or "make rebuild". To build a debug version, add "DEBUG=yes" after "make". To build a binary with profiling enabled, add "PROFILE=yes" after "make". I can be reached at "joseph.kogut(at)gmail.com"
TinyVM is a small, fast, lightweight virtual machine written in pure ANSI C.
Overview
Issues
-
Modify htab to have generic function names, and find to be nonredundant.
This addresses @GenTiradentes' note at the end of #27. It's relatively small.
- htab_find_core is a static method that finds a node based on the key and returns a pointer to the node or NULL
- htab_ find calls this and returns the value of that node, or -1 if it was not found
- htab_find_ref calls this and returns the valptr of that node, or NULL if it was not found
-
Implementation for Preprocessor Defines
I've done some work on the defines item in the TODO. It is a big pull request, and I mostly did it this way so that all the changes were easily viewable. I can isolate changes and provide patch files where needed if this fork is to be merged.
Valgrind ~~likes~~ fails to reject it, and a test file is included in programs/tinyvm/preprocessor, linked here.
What I've been doing for my tests is
make clean && make DEBUG=yes valgrind --leak-check=full -v bin/tvmi programs/tinyvm/preprocessor/define.vm
in case recreating those steps is necessary in figuring something out.
I was rather unsure of the decision to make an entirely new structure for storing strings, but my intention, if you like this direction, was to also use it for storing variable names when adding the feature to define bytes, words, and double words.
Thanks ahead of time for taking a look! This has been a fun virtual machine to learn assembly on.
-
i have a complier error,please help
my environment is macos , when i make.
clang src/tvmi.c -ltvm -Wall -pipe -Iinclude/ -std=gnu11 -Werror -pedantic -pedantic-errors -O3 -Llib/ -o bin/tvmi
ld: library not found for -ltvm
clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [tvmi] Error 1
-
Fix hash collisions
Hi,
I read about hashtables in K&R. It seems avoiding collisions is fairly easy.
I have used the technique of "Separate chaining" here (http://en.wikipedia.org/wiki/Hash_table#Separate_chaining).
(that might be exactly the same as the technique shown in K&R, I'm not sure).
I hope you find the code isn't too messy :)
I've tested it by running a program that actually hash-collided on my machine, and also by changing the hash function to always return the same hash.
-
Add hash-collision demo program
The included program contains two labels that should hash to the same value on x86 or amd64 (i.e. 32-bit or 64-bit PC hardware).
Running it with the original hash table code prints out the error "Label 'verdict' defined twice".
-
Changing actual tab characters with escaped ones
With some editors, these actual tab characters are implicitly replaced with spaces, causing the lexer to break on the next compilation. These changes may need to be applied to the other branches.
-
I got this ported to my OS.
without modifying one line of codes. https://github.com/chillancezen/ZeldaOS/tree/master/application/tinyvm
I do realize how portable the code written with ANSI C is. much appreciated!
-
How to run the program?
I have successfully build the program , but how can I run it. I am on linux mint. Every time I try ./tvmi it gives the following error File was not found, or does not exist. Unable to interpret.
-
Scan build fixes
This fixes a number of diagnostics which were shown with
scan-build make
on a Debian Stretch system (clang version 3.8.1-24).Testing performed: at each ref, the software compiles, and
./bin/tvmi programs/tinyvm/euler/euler1.vm
produces the same output. -
tvm_vm_create() fixed
Removed filename parameter in tvm_vm_create() definition (its declaration doesn't contain this parameter). Fixed possible NULL pointer dereferencing in tvm_vm_create() function.
-
Make program objects track defines.
Program objects will now track defines. The htab for defines will be passed to the parser module in future committs, which will scan and replace any instances of the defined string.
Possible modifications in future commits:
- Do not use an htab for defines; rather a list of structs with a key/val
- Use the integer value allocated for htab elements as a pointer to the value string instead of an integer.
-
Love this project. Get rid of the preprocessor?
Even the newer C++ standards have lareayd decided the preprocessor for C is now just "part of the language" Maybe find a way to integrate that?
-
Minor update and added VS solution.
Changed: process_defines now uses a calloc'd tempstr like process_includes. Using a variable-length array was the only barrier for the MS compiler.
Added Visual Studio solution and project files.
-
Comments.
Please comment this code. It looks like a really excellent project for learning about virtual machines but people wont use it that way if its a pain to figure out whats going on.
If not comments then please provide documentation.
A very minimal type-2 hypervisor built using Linux Kernel Virtual Machine for Linux.
wiser A very minimal type-2 hypervisor built using Linux Kernel Virtual Machine for Linux. Following project is under-development expect unfinished co
kvm-host is a minimalist type 2 hypervisor using Linux Kernel-based Virtual Machine (KVM), capable of running Linux kernel partially.
kvm-host kvm-host is a minimalist type 2 hypervisor using Linux Kernel-based Virtual Machine (KVM), capable of running Linux kernel partially. Build a
A virtual machine hardware tool that gives you an escape option for when your VM locks you in (when it freezes, and also traps your mouse).
A virtual machine hardware tool that gives you an escape option for when your VM locks you in (when it freezes, and also traps your mouse). A secondary mouse that only activates once you press it.
A virtual processor with a unique instruction set written in C++
Processor-Project A virtual processor with an instruction set similar to ARM made in C++. How it works This virtual processor allows the user to write
A C program to retrieve information about your Linux machine
Reporter A C program to retrieve information about your Linux machine How to Install Open the terminal and type following commands apt update apt inst
kvm based x86 partitioned hypervisor written in cpp
mumu is a hobby hypervisor-ish. mumu can be a good resource to learn virtualization, hypervisors and KVM right now. In the future, who knows, it may become a real hypervisor.
A modern dynamically typed programming language that gets compiled to bytecode and is run in a virtual machine called SVM (Strawbry Virtual Machine).
Strawbry A bytecode programming language. Here is what I want Strawbry to look like: var a = 1 var b = 2 var c = a + b print(c) func sqrt(x) { re
Professor Terence Parr has taught us how to create a virtual machine Now it is time to pwn virtual machine
My First real world CTF Simple Virtual Machine Challenge description Professor Terence Parr has taught us how to create a virtual machine Now it is ti
Read file to console, automatically recognize file encoding, include ansi, utf16le, utf16be, utf8. Currently output ansi as gbk for chinese text search.
rgpre A tool for rg --pre. Read file to console, automatically recognize file encoding, include ansi, utf16le, utf16be, utf8. Currently output ansi as
A virtual machine for executing programs written in Hack.
HHVM HHVM page | HHVM documentation | Hacklang page | General group | Dev group | Twitter HHVM is an open-source virtual machine designed for executin
A virtual network Differential GNSS server-client project using Precise Point Positioning (PPP). Global coverage. Without physical base station construction needed. An open-source virtual base station approach.
Virtual-Network-DGNSS-Project This project is the software implementation for a publicly available, open-source, client/server VN-DGNSS implementation
A lightweight, portable pure C99 onnx inference engine for embedded devices with hardware acceleration support.
Libonnx A lightweight, portable pure C99 onnx inference engine for embedded devices with hardware acceleration support. Getting Started The library's
Microshell - a lightweight pure C implementation of shell emulator dedicated for embedded bare-metal systems.
MicroShell Lightweight pure C implementation of virtual shell, compatible with VT100 terminal. Support root tree, run-time mounting paths, global comm
ThreadPool - Lightweight, Generic, Pure C++11 ThreadPool
ThreadPool Lightweight, Generic, Pure C++11 ThreadPool Rational I needed a Thread Pool for something I was writing, and I didn't see any that I liked.
Very low footprint JSON parser written in portable ANSI C
Very low footprint JSON parser written in portable ANSI C. BSD licensed with no dependencies (i.e. just drop the C file into your project) Never recur
Semantic version library written in ANSI C
semver.c Semantic version v2.0 parser and render written in ANSI C with zero dependencies. Features Standard compliant (otherwise, open an issue) Vers
JSFuck obfuscator written in ANSI C.
jsfuck.h JSFuck obfuscator written in ANSI C. For more info/context, visit www.jsfuck.com. Tested on MinGW (Windows) and GCC (Linux, Ubuntu). Build To
ASMotor is a portable and generic assembler engine and development system written in ANSI C99
ASMotor is a portable and generic assembler engine and development system written in ANSI C99 and licensed under the GNU Public License v3. The package consists of the assembler, the librarian and the linker. It can be used as either a cross or native development system.
Very low footprint JSON parser written in portable ANSI C
Very low footprint JSON parser written in portable C89 (sometimes referred to as ANSI C). BSD licensed with no dependencies (i.e. just drop the C file
This is a minimal state immediate mode graphical user interface toolkit written in ANSI C and licensed under public domain
This is a minimal state immediate mode graphical user interface toolkit written in ANSI C and licensed under public domain. It was designed as a simple embeddable user interface for application and does not have any dependencies, a default render backend or OS window and input handling but instead provides a very modular library approach by using simple input state for input and draw commands describing primitive shapes as output.
A tiny, portable, immediate-mode UI library written in ANSI C
A tiny, portable, immediate-mode UI library written in ANSI C Features Tiny: around 1100 sloc of ANSI C Works within a fixed-sized memory region: no a
Simple Virtual Machine with its own Bytecode and Assembly language.
BM Simple Virtual Machine with its own Bytecode and Assembly language. Build We are using nobuild build system which requires a bootstrapping step wit
RISC-V Virtual Machine
RVVM - The RISC-V Virtual Machine RISC-V CPU & System software implementation written in С What's working OpenSBI, custom firmwares boot and execute p
NDS port of the uxn virtual machine
uxnds Quick and simple port of the uxn virtual machine to the NDS console. By default, uxnds will run /uxn/boot.rom. It also supports reading files fr
Microvm is a virtual machine and compiler
The aim of this project is to create a stack based language and virtual machine for microcontrollers. A mix of approaches is used. Separate memory is used for program and variable space (Harvard architecture). An interpreter, virtual machine and compiler are available. A demostration of the interpreter in action is presented below.
Web runtime for the uxn virtual machine.
webuxn A light-weight port of the uxn virtual machine to the web via WebAssembly. Demos life.rom darena.rom animation.rom musictracker.rom Bring Your
WasmEdge Runtime is a high-performance, extensible, and hardware optimized WebAssembly Virtual Machine for automotive, cloud, AI, and blockchain applications.
WasmEdge Runtime is a high-performance, extensible, and hardware optimized WebAssembly Virtual Machine for automotive, cloud, AI, and blockchain applications.
A port of the Uxn virtual machine to the ESP32
Uxn An assembler and emulator for the Uxn stack-machine, written in ANSI C. Build Linux To build the Uxn emulator, you must have SDL2. If you wish to
A very minimal type-2 hypervisor built using Linux Kernel Virtual Machine for Linux.
wiser A very minimal type-2 hypervisor built using Linux Kernel Virtual Machine for Linux. Following project is under-development expect unfinished co