An extension of the (split-stack branch) simple VM I did that codyebberson converted to C. I added CALL/RET and make VM a struct
. Added more tests.
Branches:
- master. This is a straight C port of the split-stack branch from Java.
- computed-goto. A version of the
exec()
method that uses computedgoto
s to directly jump from instruction to instruction like a threaded interpreter, thus, avoiding awhile
loop andswitch
for the decode part of the fetch-decode-execute cycle. Instead of:
while ( more opcodes ) {
switch ( code[ip] ) {
...
we use goto *dispatch[code[ip]]
to instantly jump to the code that interprets the next opcode via an appropriate label within the exec
method.
Build and run:
$ cc -o vm src/*.c
$ vm