Languages like Java C# etc all use a virtual machine. This is a software package that need to start and execute some kind assembly code. Languages like C/C++ compile into native assembly code that is much faster, but also tied to the hardware it run’s on.
A virtual machine have the advantage that we extend the platform with build in features made available in C/C++. This high level code occupy less space than binary code and executes under our control. The drawback is that it executes slower than native code, but I plan to challenge that by introducing very high level assembly instructions.
I would like to introduce a native assembler at some point, but I want to play around with a Virtual Machine for now.
The diagram above show how we link things together in the firmware. We use easyIPC protocols to communicate, RTOS and HAL + other modules tom access electronics and do complex stuff. The VM executes logic that control what we do.
Our VM needs it’s own assembly language so we use a 16 bit design as indicated above. A6 bit Op-Code + 4 bit Category code leaves pages of 64 instructions. Category 0 is the build in one, but other categories can be used for extended instructions. Length is the added number of 162 bit register, meaning an instruction can be 64 x 16 bits.
This diagram above illustrates the internal VM Core. We have a table holding 16 bit instructions stored in Flash. A Registers table that are in SRAM for generic use in our logic, and an object table that use address 0x8000 to 0xFFFF to access content mapped into C or other Plain Modules. Notice that the total register size is 64Kb to make the most of a 16 bit parameter. Stack is located in SRAM at 0x7FFF and up. Each PLAIN Module have it’s own, private stack, registers and Object view.
PLAIN contains a set of registers known as easyIPC object registers located between 8000h and FFFFh. These are accessed the same way as stack and generic registers, but are wired to other software or hardware. If these registers are changed events will be generated to allow PLAIN or C/C++ to process changes.