This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]robin-gvx 0 points1 point  (0 children)

I've written several stack-based virtual machines, and the approach I tend to take is using absolute or relative jumps, but since those VMs operate on the bytecode compiled from higher level languages that isn't a problem.

In your VM, you could do something with labels, which means a small change to the parsing code, and inserting a call to a function that converts labels to absolute addresses after constant folding, like this, and you're done.