ldinterpret.c - intcode.h (by BoumPower)
Think that code will be more efficient by adding some primitive :
INT_SET_VARIABLE_ADD_LITERAL (V1 = V2 + literal)
INT_SET_VARIABLE_SUB_LITERAL (V1 = V2 - literal)
INT_SET_VARIABLE_LITERAL_SUB (V1 = literal - V3)
and so more with multitly, divide, if....
For example, the two less significants bits of the INT codes (intcode.h) could specify if name2/name3 refer to variable or literal ? :
INT_SET_VARIABLE_ADD 0b00001100 // V2+V3
INT_SET_VARIABLE_ADD_LITERAL 0b00001101 // V2 + literal
INT_SET_VARIABLE_LITERAL_ADD 0b00001110 // literal + V3
INT_SET_VARIABLE_ADD_NOSENSE 0b00001111 // literal + literal
this coding leave 64 opcode in byte size
having efficient intermediate code will allow efficient VM machine on MCU
(no subject) (by Jonathan Westhues)
It's a tradeoff between efficiency and ease of implementation. There are many other intermediate code ops that would improve the efficiency and code size if they existed; but that would add complexity to all of the back ends, so I have chosen not to do so.
Of course, if you don't like the code that LDmicro generates, then the source code is available for download. So you are free to make whatever changes you prefer.