You need to make a Vm with pointers to an array of bytes and so that there are convenient macros. But an error occurs:
#include <stdio.h> #define my_print 1 #define my_print_with_dec 2 //#define NEXTOP() *(next_instr)++ #define TARGET(op) \ case op: #define TARGET_NOARG(op)\ case op: #define DISPATCH() continue int next_instr[5]= {my_print,my_print,my_print,0}; int opcode=0; int oparg=0; int main(int argc, char** argv) { for(;;){ //opcode=NEXTOP(); opcode=*(next_instr)++; printf("opcode: %d",opcode); switch(opcode){ TARGET(my_print) { printf("me-me-me!\n"); DISPATCH(); } TARGET(0){ break; } } } return 0; } //<--main.cpp: In function 'int main(int, char**)': //main.cpp:39:24: error: lvalue required as increment operand // opcode=*(next_instr)++;