Threaded Code - Branches

Branches

Examples above show no branches. For all interpreters, a branch changes the thread pointer (ip above). As example, a conditional branch when the top-of-stack value is zero might be encoded as follows. Note that &thread is the location to jump to, not the address of a handler, and so must be skipped (ip++) whether or not the branch is taken.

thread: brz: ... tmp = *ip++ &brz if (*sp++ == 0) &thread ip = tmp ... jump *ip++

Read more about this topic:  Threaded Code

Famous quotes containing the word branches:

    Think how stood the white pine tree on the shore of the Chesuncook, its branches soughing with the four winds, and every individual needle trembling in the sunlight,—think how it stands with it now,—sold, perchance, to the New England Friction-Match Company!
    Henry David Thoreau (1817–1862)

    A woman is a branchy tree
    And man a singing wind;
    And from her branches carelessly
    He takes what he can find.
    James Kenneth Stephens (1882–1950)

    ...there is hope for a tree, if it is cut down, that it will sprout again, and that its shoots will not cease. Though its root grows old in the earth, and its stump dies in the ground, yet at the scent of water it will bud and put forth branches like a young plant. But mortals die, and are laid low; humans expire, and where are they?
    Bible: Hebrew, Job 14:7-10.