Simple Virtual Machine in C
I recently did a similar project but I tried something different in an attempt to avoid large switch statements. I created a collection of functions which could mutate my version of the "Frame" object, created an array of pointers to these functions, and called them as their opcodes were encountered. [0] It's a little over complicated for a simple example but adding a new opcode will never be more work then this [1].<p>I hope one day my VM/Assembler will become as fully featured as this.<p>My last major achievement was implementing multiplication in my assembly language [2] so I've got a lot of catching up to do with this author!<p>[0] - <a href="https://github.com/gravypod/computer/blob/master/isa/main.c#L89-L120" rel="nofollow">https://github.com/gravypod/computer/blob/master/isa/main.c#...</a><p>[1] - <a href="https://github.com/gravypod/computer/blob/master/isa/instructions/add.c#L3-L11" rel="nofollow">https://github.com/gravypod/computer/blob/master/isa/instruc...</a><p>[2] - <a href="https://github.com/gravypod/computer/blob/master/examples/mul.asm" rel="nofollow">https://github.com/gravypod/computer/blob/master/examples/mu...</a>