GNU C’s labels as values extension (available since gcc-2.0
,
see Labels as Values in GNU C Manual)
makes it possible to take the address of label by writing
&&label
. This address can then be used in a statement like
goto *address
. I.e., goto *&&x
is the same as
goto x
.
With this feature an indirect threaded NEXT
looks like:
cfa = *ip++; ca = *cfa; goto *ca;
For those unfamiliar with the names: ip
is the Forth instruction
pointer; the cfa
(code-field address) corresponds to Standard Forth’s
execution token and points to the code field of the next word to be
executed; The ca
(code address) fetched from there points to some
executable code, e.g., a primitive or the colon definition handler
docol
.
Direct threading is even simpler:
ca = *ip++; goto *ca;
Of course we have packaged the whole thing neatly in macros called
NEXT
and NEXT1
(the part of NEXT
after fetching the cfa).