Threaded code Guide, Meaning , Facts, Information and Description
For multi-threaded programming, see Thread (computer science)In computer science, the term threaded code refers to an implementation technique for programming languages that produces very compact code (at the expense of some speed).
It is used in the Forth and early versions of the B programming languages. It means a form of code consisting entirely of subroutine calls, written without the subroutine call instruction, and processed by an interpreter (Forth) or the CPU (B), which jumps to each successive piece of basic function code in turn.
In early computers, memory was very expensive. So programmers spent a lot of time trying to find ways to squeeze their programs so they would fit in the memory available. Also, the instruction sets were so primitive that even simple operations like printing a character or dividing one number by another number required quite a few instructions.
Instead of writing out every step of such operations in every part of the program where it was needed (possibly using a macro), programmers saved memory by writing out every step of such operations exactly once and placing it in a subroutine. Then the programmer replaced every copy of that operation with much shorter "call" instruction.
The top-level application usually consists of nothing but subroutine calls. And many of those subroutines, in turn, also consist of nothing but subroutine calls. This is called STC (Subroutine Threaded Code).
To save even more space, programmers squeezed those lists of subroutine calls into simple lists of subroutine addresses (leaving out the "call" instruction on each one), and used a small interpreter (later called a virtual machine) to call each subroutine in turn. This is called DTC (Direct Threaded Code).
Charles Moore invented an even more compact notation in 1970 for his Forth virtual machine: ITC (indirect threaded code).
This is an Article on Threaded code. Page Contains Information, Facts Details or Explanation Guide About Threaded code External links
