Re:Implementing a Virtual Machine in C
by stevekemp on Tuesday June 23, 2015 @10:33AM
(#9764852)
Funny you mention that - I used that structure in my simple virtual machine (which includes a compiler, a decompiler, support for conditionals, and also an example of embedding):
Rather than having an enum of opcodes I have a array of pointers to functions - one for each opcode I implement. It is a logical/clean way of implementing things, but i think it is not necessarily better.
(In my case I lose due to inline strings, and variable length opcodes which make complications.)
https://github.com/skx/simple.vm
Rather than having an enum of opcodes I have a array of pointers to functions - one for each opcode I implement. It is a logical/clean way of implementing things, but i think it is not necessarily better.
(In my case I lose due to inline strings, and variable length opcodes which make complications.)