冒号定义的代码指针中有什么?

What goes in the code pointer of a colon definition?

Leo Brodie 中描述的代码指针 Starting FORTH:

In the case of a colon definition, the pointer points to code that executes the rest of the words in the colon definition. In practice there are many ways to implement this concept, including native code realizations.

那是什么意思?那是指向解释器类型字的指针,例如 execute?

正如 Brodie 所说,有许多 种方法可以实现这一点。有关其中几个的出色解释,请参阅 Brad Rodriguez 的 "Moving Forth" series.

有关直接线程的(可能过于详细的)解释,请参阅 Direct Threading in TransForth

玩得开心!

在普通线程实现中,它很可能是指向原始机器代码的指针。机器代码通常会将内部解释器指令指针保存到 return 堆栈上,然后使用指向被调用字的线程代码开头的新值加载指令指针。

在 32 位机器的伪汇编语言中:

\ R is a register holding the return stack pointer
\ I is a register holding the inner interpreter instruction pointer
\ W is a register pointing to the code field of the word to be executed
\ NEXT is a macro that implements the inner interpreter
sub R, R, #4
mov (R), I
add I, W, #4
NEXT

NEXT 可能扩展为

mov W, (I)
add I, I, #4
jmp (W)