Content deleted Content added
All code is threaded code? |
Alextangent (talk | contribs) |
||
Line 8:
:''Early compilers for [[ALGOL]], [[Fortran]], [[Cobol]] and some [[Forth programming language|Forth]] systems often produced subroutine-threaded code.''
It sounds like someone was confused by the people who call native machine language, "subroutine threaded code", which most people would say is the .opposite of threaded code.
If "subroutine threaded code" is a kind of threaded code, then practically ''all'' code is threaded code of one kind or another. (The only exception is code that doesn't have *any* subroutines, right?).
Line 26:
--[[User:DavidCary|DavidCary]] 12:37, 13 July 2005 (UTC)
: Subroutine threaded code is different from native code in that everything is a call; including to constructs like IF. Take this code in Forth;
: X IF ." True" THEN ... etc
: An STC potentially generates (numbers are there to discuss in text)
(1) CALL <routine to put "label" on return stack>
(2) CALL IF
(3) CALL <routine to put address of string "True" on the stack>
(4) CALL ."
(5) <label>:
(6) CALL THEN
... etc
: (1) "tucks" the address of the label <label> on the return stack by popping the caller's return address, pushing address of <label> and returning. (2) IF pops and checks the top of the data stack; if it's zero, then jump to label, else return. And so on. (6) is in fact a no-op, but it's sometimes generated so that the code can be decompiled easily by printing off the labels in the symbol table (called a dictionary in Forth) associated with the CALLed address.
: There are very few Forths that use STC in this extreme form, and a blend between STC and NCC (native code compilation) is normally used. An ITC is the same code, but with addresses only and no CALL opcode; a small VM interpreter does the call/return management. [[User:Alextangent|Alex]] 12:00, 27 March 2006 (UTC)
== types of subroutine-call instructions supported by hardware ==
|