Listing 2: Code from a typical bytecode interpreter.
void func(void) { unsigned char *ip; // byte code instruction pointer int *stack; int spi; // stack pointer ... #define POP() (stack[--spi]) #define PUSH(i) (stack[spi++] = (i)) while (1) { switch (*ip++) { case ADD: op1 = POP(); op2 = POP(); result = op1 + op2; PUSH(result); break; case SUB: ... } } }