All Projects → mikaelpatel → Arduino-FVM

mikaelpatel / Arduino-FVM

Licence: other
Byte Token Threaded Forth Virtual Machine (FVM) for Arduino

Programming Languages

C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to Arduino-FVM

ciao
Ciao is a modern Prolog implementation that builds up from a logic-based simple kernel designed to be portable, extensible, and modular.
Stars: ✭ 190 (+442.86%)
Mutual labels:  interpreter, virtual-machine
lunatic
lunatic: a toy lua interpreter
Stars: ✭ 16 (-54.29%)
Mutual labels:  interpreter, virtual-machine
charm
A [ functional stack ] based language.
Stars: ✭ 26 (-25.71%)
Mutual labels:  interpreter, tail-call-optimization
Tagha
Minimal, low-level, fast, and self-contained register-based bytecode virtual machine/runtime environment.
Stars: ✭ 101 (+188.57%)
Mutual labels:  interpreter, virtual-machine
Arduino-Shell
RPN Postscript/Forth Command Shell for Arduino
Stars: ✭ 19 (-45.71%)
Mutual labels:  virtual-machine, arduino-library
wizard-engine
Research WebAssembly Engine
Stars: ✭ 164 (+368.57%)
Mutual labels:  interpreter, virtual-machine
embed
An embeddable, tiny Forth interpreter with metacompiler.
Stars: ✭ 80 (+128.57%)
Mutual labels:  interpreter, virtual-machine
Arturo
Simple, expressive & portable programming language for efficient scripting
Stars: ✭ 225 (+542.86%)
Mutual labels:  interpreter, virtual-machine
ol
Otus Lisp (Ol in short) is a purely* functional dialect of Lisp.
Stars: ✭ 157 (+348.57%)
Mutual labels:  interpreter, virtual-machine
thislang
A subset of javascript implemented in that subset of javascript. Yes, it can run itself.
Stars: ✭ 31 (-11.43%)
Mutual labels:  interpreter, virtual-machine
LLVM-JVM
[W.I.P] A Just-In-Time Java Virtual Machine written in Haskell
Stars: ✭ 22 (-37.14%)
Mutual labels:  interpreter, virtual-machine
clover2
Clover2 can be used as shell. The completion is powerfull like IDE. Also clover2 is a Ruby-like compiler language with static type like Java. This is high performnace. Please see the wiki for details
Stars: ✭ 100 (+185.71%)
Mutual labels:  interpreter, virtual-machine
clox
A virtual machine and a tree-walk interpreter for the Lox programming language in C89 🌀
Stars: ✭ 38 (+8.57%)
Mutual labels:  interpreter, virtual-machine
Freeze-OS
An Operating System that runs on top of an interpreter.
Stars: ✭ 24 (-31.43%)
Mutual labels:  interpreter, virtual-machine
Openj9
Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Stars: ✭ 2,802 (+7905.71%)
Mutual labels:  interpreter, virtual-machine
Laythe
A gradually typed language originally based on the crafting interpreters series
Stars: ✭ 58 (+65.71%)
Mutual labels:  interpreter, virtual-machine
Cub
The Cub Programming Language
Stars: ✭ 198 (+465.71%)
Mutual labels:  interpreter, virtual-machine
Swift Lispkit
Interpreter framework for Lisp-based extension and scripting languages on macOS and iOS. LispKit is based on the R7RS standard for Scheme. Its compiler generates bytecode for a virtual machine. LispKit is fully implemented in Swift 5.
Stars: ✭ 228 (+551.43%)
Mutual labels:  interpreter, virtual-machine
openj9
Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Stars: ✭ 2,973 (+8394.29%)
Mutual labels:  interpreter, virtual-machine
minima
A fast, byte-code interpreted language
Stars: ✭ 43 (+22.86%)
Mutual labels:  interpreter, virtual-machine

Arduino-FVM

This library provides a token threaded Forth kernel that may be embedded in Arduino sketches. The kernel can be used as a debug shell or even full scale Forth applications.

shell-screenshot

The Forth Virtual Machine allows multi-tasking which makes it easy to integrate with the Arduino core library functions. Context switch to and from the virtual machine is as low as 8 us (halt) and 10 us (yield/branch).

compiler-screenshot

A code generator, token compiler, example sketch is available. Forth declarations are translated to the Forth Virtual Machine instruction set and dictionary format. The token compiler is also an excellent example of mixing forth, C/C++ and Arduino library functions in the same sketch.

The Forth Virtual Machine (FVM) with 130 instructions is approx. 5.4 Kbyte without kernel dictionary table and strings. This adds approx. 1 Kbyte. The instruction level trace adds an additional 500 bytes. Many of the kernel instructions are defined in both C++ and FVM instructions. This allows tailoring for speed and/or size.

Tokens

The Forth Virtual Machine is byte token threaded. Most kernel and application tokens are a single byte. A prefix token is used to extend beyond 256 tokens. A total of 512 tokens are allowed; 0..255 are kernel tokens and 256..511 are application tokens. Kernel tokens are operations codes. These can be C++ code and/or threaded code (in FVM.cpp). The application tokens are always threaded code.

Kernel tokens 0..127 are direct operation codes while tokens 128..255 require a prefix token (OP_KERNEL). Application tokens 256..383 (-1..-128) are direct nested by the kernel. The token value are the one-complement index to threaded code in a table in program memory.

Application tokens 384..511 require a token prefix (OP_CALL) to the mapped values 0..127 which are the index to threaded code in a table in data memory (i.e. token minus 384).

Optimizations

The token threading inner interpreter uses several optimizations to reduce calls, i.e. return stack push and pop of return addresses.

The first optimization, the token mapping (-1..-128) allows the inner interpreter to directly handle calls of threaded code. The inner interpreter will perform the nesting.

The second optimization, tail call reduction, allows the inner interpreter to perform a jump to threaded code instead of call when the succeeding operation is EXIT. This reduces return stack depth, pushing and poping return address. The optimization is also used for prefix operations (OP_KERNEL and OP_CALL).

Install

Download and unzip the Arduino-FVM library into your sketchbook libraries directory. Rename from Arduino-FVM-master to FVM.

The FVM library and examples should be found in the Arduino IDE File>Examples menu.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].