EmbedVM is a small embedded virtual machine for microcontrollers with a C-like language interface. It has been tested with GCC and AVR microcontrollers. But since the virtual machine is quite simple, it should be easy to port it to other architectures.
The VM mimics a 16-bit processor that can access 64 KB of memory. This can only work on 16-bit values and arrays of 16-bit and 8-bit values. There is no support for complex data structures (structure, objects, etc.). A function can have no more than 32 local variables and 32 arguments.
Besides the memory for the virtual machine, a small structure containing the state of the virtual machine and the reasonable amount of memory that the EmbedVM functions require on the stack there are no additional memory requirements for the virtual machine. In particular, the VM is independent of dymaic memory management.
EmbedVM is optimized for size and simplicity, and not for execution speed. The VM itself occupies about 3 KB of program memory on the AVR microcontroller. On an AVR ATmega168 running at 16 MHz, the VM can execute about 75 VM instructions per millisecond.
All memory accesses performed by the virtual machine are processed using the function callback. Thus, some or all of the VM memory may have external storage devices, flash memory, etc. or hardware "memory card" functions for the virtual machine.
The compiler is a UNIX / Linux command line tool that reads into a * .evm file and generates bytecode in various formats (binary file, intel hex, C array initializers and a special debug output format). It also generates a character file that can be used to access data in the memory virtual machine from the host application.