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:

    What are the roots that clutch, what branches grow
    Out of this stony rubbish?
    —T.S. (Thomas Stearns)

    “I couldn’t afford to learn it,” said the Mock Turtle with a sigh. “I only took the regular course.”
    “What was that?” inquired Alice.
    “Reeling and Writhing, of course, to begin with,” the Mock Turtle replied; “and then the different branches of Arithmetic—Ambition, Distraction, Uglification, and Derision.”
    “I never heard of ‘Uglification,’” Alice ventured to say.
    Lewis Carroll [Charles Lutwidge Dodgson] (1832–1898)

    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)