Obsolete 21.feb.2017 – New design.
The Call & Raise instructions are identical in design, it is only the op-code that differs. I re-use the extended length option from Assign and add an array of 32 bit Data Descriptors to define the parameters.
Moving on I have several unsolved design questions with the VM:
One is the details around the stack as we enter and leave a function + the details of how we return an event. I have loose ends here I need to dig into.
The second is that parameters in a call can be expressions. My initial thought was to let the assembler split this into a sequence of Assign and a Call if required, but it is fully possible to embed the P-Code directly as a sub-table to a special “type”. The Win on this is that we move back to a 1:1 between Assembler and Instructions as we can also do this on If and While. The VM actually have 6 different If instructions that we could replace with one if we embed the expression P-Code directly.
The third issue is how to handle different data types during math. If we add a uint32 with a float32 the VM need to convert one of them meaning the VM need to know what types they are. Using the 32 bit Data Descriptor solves this, but that would bloat the instructions as every register reference now becomes 32 bits rather than 16. The alternative that I was planning was to use 8 bits extra on each register – if I go down this path I will be using more SRAM.
Another related question is if we should ditch the 32 bit register part and only use Objects? We have the objects anyway and having a generic 32 bit register array in addition complicate things. My original idea was to let the VM only use 32 bit values + it was a bit of influence from legacy Modbus/CAN – But, what if we change this to become a 64K index of objects and let even simple data values be objects … I need to think this one through and calculate on SRAM impact.
As mentioned before – work in progress –