Re: Threaded code (was Re: P-Code and virtual machines) (David Keppel)
Tue, 29 Mar 1994 04:37:27 GMT

          From comp.compilers

Related articles
P-Code and virtual machines (1994-03-23)
Threaded code (was Re: P-Code and virtual machines) mark@godzilla.Quotron.COM) (1994-03-26)
Threaded code (was Re: P-Code and virtual machines) (Stephen J Bevan) (1994-03-27)
Re: Threaded code (was Re: P-Code and virtual machines) (1994-03-29)
Re: Threaded code (was Re: P-Code and virtual machines) (Ulrich Hoffmann) (1994-03-30)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (David Keppel)
Keywords: interpreter
Organization: Computer Science & Engineering, U. of Washington, Seattle
References: 94-03-104 94-03-148
Date: Tue, 29 Mar 1994 04:37:27 GMT

mark@godzilla.Quotron.COM (Mark T. Price (sg)) writes:
>[What's threaded code? What's a reference for threaded code?]

The general idea is that code for

foo (10);
foo (11);
foo (12);

is encoded as an array of words/bytes/whatever such as:


Initially, a variable `tp' is set to point at the first word (&foo) and
there is a jump to address pointed to by tp; in this case `foo'. Each
code fragment performs some processing and also increments `tp' past any
arguments (e.g., 10). Finally, the code fragment ends by performing
another indirect branch through the value of `tp'.

References include:

%A James R. Bell
%T Threaded Code
%J Communications of the ACM (CACM)
%V 16
%N 2
%D June 1973
%P 370-372

%A Richard H. Eckhouse Jr.
%A L. Robert Morris
%T Minicomputer Systems Organization, Programming, and Applications
(PDP-11). 2nd Ed.
%I Prentice-Hall, Inc.
%D 1979
%P 290-298

%A Peter M. Kogge
%T An Architectural Trail to Threaded Code Systems
%J IEEE Computer
%P 22-33
%D March 1982

The second one ([EM79]) includes a cute variation on threaded code called
`knotted code' for use where certain routines are invoked in series e.g.,
the above example is encoded as


where `foo2' is like `foo' but it iterates until it reaches the

There is also something called `indirect threaded code' which is described

%A B. K. Dewar
%T Indirect Threaded Code
%D June 1975
%V 18
%N 6
%P 330-331

(Unfortunately there's an error in the example, so don't expect it to make
total sense; I spoke with the author a few years ago and he didn't have a
quick'n'ready patch to fix it.)

There is also a discussion of threaded code in the `comp.compilers'
archives from some time in 1991.

;-D on ( What was that about user-level threads? ) Pardo

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.