Difference between revisions of "Threaded code"

From Computer History Wiki
Jump to: navigation, search
(Not as crisp and clear as it could be, but not bad)
 
(No difference)

Latest revision as of 01:06, 17 December 2024

Threaded code is an intermediate approach to the execution of programs on a computer - somewhere in between compiled and interpreted code, but closer to the latter. The original program is converted to a binary form - but not the low-level object code that the computer's CPU can interpret directly in hardware. Instead, each pseudo-'instruction' is a somewhat higher-level operation, which the threaded-code control/interpretation code has to implement (thus creating, effectively, a virtual machine with a more powerful instruction set).

That software maintains a pseudo-program counter (perhaps in another CPU register), which points to the current pseudo-instruction being 'executed'. In many threaded code systems, the pseudo-instructions are simply the address of the routines which implements the pseudo-instructions; when one routine is done, it simply jumps to the next routine (hence the name of this approach), the address of which is in the word pointed to by the pseudo-program counter. (Each implementation routine has to increment the pseudo-program counter, of course.)

A threaded code system thus is faster than interpreted code, but its binary is more compact than object code to perform the same computation on that machine would be.

External links