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:

    “I know of no pursuit in which more real and important services can be rendered to any country than by improving its agriculture, its breed of useful animals, and other branches of a husbandman’s cares.”
    —George Washington (1732–1799)

    “Different persons growing up in the same language are like different bushes trimmed and trained to take the shape of identical elephants. The anatomical details of twigs and branches will fulfill the elephantine form differently from bush to bush, but the overall outward results are alike.”
    —Willard Van Orman Quine (b. 1908)

    “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)