www.delorie.com/gnu/docs/gforth/gforth_196.html   search  
Buy GNU books!

Gforth Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.24 Threading Words

These words provide access to code addresses and other threading stuff in Gforth (and, possibly, other interpretive Forths). It more or less abstracts away the differences between direct and indirect threading (and, for direct threading, the machine dependences). However, at present this wordset is still incomplete. It is also pretty low-level; some day it will hopefully be made unnecessary by an internals wordset that abstracts implementation details away completely.

The terminology used here stems from indirect threaded Forth systems; in such a system, the XT of a word is represented by the CFA (code field address) of a word; the CFA points to a cell that contains the code address. The code address is the address of some machine code that performs the run-time action of invoking the word (e.g., the dovar: routine pushes the address of the body of the word (a variable) on the stack ).

In an indirect threaded Forth, you can get the code address of name with ' name @; in Gforth you can get it with ' name >code-address, independent of the threading method.

doc-threading-method doc->code-address doc-code-address!

For a word defined with DOES>, the code address usually points to a jump instruction (the does-handler) that jumps to the dodoes routine (in Gforth on some platforms, it can also point to the dodoes routine itself). What you are typically interested in, though, is whether a word is a DOES>-defined word, and what Forth code it executes; >does-code tells you that.


To create a DOES>-defined word with the following basic words, you have to set up a DOES>-handler with does-handler!; /does-handler aus behind you have to place your executable Forth code. Finally you have to create a word and modify its behaviour with does-handler!.

doc-does-code! doc-does-handler! doc-/does-handler

The code addresses produced by various defining words are produced by the following words:

doc-docol: doc-docon: doc-dovar: doc-douser: doc-dodefer: doc-dofield:

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003