Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

VM instruction implementation without huge switch()?

Name: Anonymous 2014-06-09 23:26

How would one go about making a virtual machine without using a huge and clumsy switch( opcode ) statement?

The architecture I'm implementing (DCPU-16) has about 35-40 different instructions.

Name: Anonymous 2016-10-25 1:43

>>41

You're insane. Or joking. One of the two.

>>1

As far as maintainability and whatnot go, branch tables using arrays of function pointers are the way to go. But the compiler can't optimize as well.

Better yet, write a perl script that takes an input file mapping opcodes to functions and generates the switch table for you.

This is a great idea, and totally can't go wrong in literally 100s of ways.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List