Bytecode interpreter

A bytecode interpreter is basically a loop and a lookup table. The interpreter starts at the beginning of an array of bytes. Each byte in this array is an index into the lookup table. For each key in this table there is a piece of code that needs to be executed. Code for that may look like this: typedef unsigned char byte; // the simplest program byte program[] = { 0, }; byte* ip = program; // instruction pointer while ((ip=(lookup_table[*ip])(ip))!...

October 26, 2009