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:

    Go to the adolescent who are smothered in family—
    Oh how hideous it is
    To see three generations of one house gathered together!
    It is like an old tree with shoots,
    And with some branches rotted and falling.
    Ezra Pound (1885–1972)

    In the woods in a winter afternoon one will see as readily the origin of the stained glass window, with which Gothic cathedrals are adorned, in the colors of the western sky seen through the bare and crossing branches of the forest.
    Ralph Waldo Emerson (1803–1882)

    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)