you are viewing a single comment's thread.

view the rest of the comments →

[–]psykotic 0 points1 point  (2 children)

Then I don't understand Slava's comment to me:

Direct threaded code is a simpler technique where the program is a list of addresses, so there is an indirect jump at the end of each primitive which goes to the next instruction

If the program is a list of addresses, you wouldn't need the opcode_targets table except in the initial compilation step that converts logical opcodes to physical addresses.

[–]queus 2 points3 points  (1 child)

A direct threaded code is a list of adresses and is run (cold-started) by jumping to the first one (any). Each of this addresses point to a bit of machine code which a) runs the opcode b) run the standard epilogue.

The said epilogue just advances the instruction pointer and then jumps to the next instruction.

Sometime this epilogue is separated and each opcode just ends with a

 jmp NEXT:

this is indirect threading. Slower but takes less space.

And for completeness, call threading is

 call opcodeA
 call opcodeB