Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Threaded code
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Common amenities== Separating the data and return stacks in a machine eliminates a great deal of stack management code, substantially reducing the size of the threaded code. The dual-stack principle originated three times independently: for [[Burroughs large systems]], [[Forth (programming language)|Forth]], and [[PostScript]]. It is used in some [[Java virtual machine]]s. Three [[processor register|registers]] are often present in a threaded virtual machine. Another one exists for passing data between [[subroutine]]s ('words'). These are: * ip or i ([[instruction pointer]]) of the virtual machine (not to be confused with the [[program counter]] of the underlying hardware implementing the VM) * w (work pointer) * rp or r (return [[stack (data structure)|stack]] pointer) * sp or s ([[parameter]] stack pointer for passing parameters between words) Often, threaded [[virtual machine]]s, such as implementations of Forth, have a simple virtual machine at heart, consisting of three ''primitives''. Those are: # ''nest'', also called ''docol'' # ''unnest'', or ''semi_s'' (;s) # ''next'' In an indirect-threaded virtual machine, the one given here, the operations are: <syntaxhighlight lang="c"> next: *ip++ -> w jump **w++ nest: ip -> *rp++ w -> ip next unnest: *--rp -> ip next </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)