Welcome, Guest. Please login or register.

Author Topic: Threaded Code  (Read 6401 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline ganyaik

  • Newbie
  • *
  • Join Date: Jan 2007
  • Posts: 7
    • Show all replies
Re: Threaded Code
« on: November 25, 2010, 06:01:06 AM »
Hi,

I did(/am doing) something similar: a VM on a resource constrained system. I made some experiments with jump tables, ifs and such and settled with plain "switch/case".

In my VM the opcode is always the first byte of the instruction so I can branch on it easily and the C compiler(gcc) generates a nice big jumptable. The code, that jumps to the case: which executes the emulated instruction is a few instructions to create pointer and an indirect jump in assembly. No register saving and such involved.

Hope this helps,
Chris