2016-09-06 26 views
1

在利奧布羅迪的Starting FORTH描述的代碼指針:冒號定義的代碼指針是什麼?

在結腸定義,該指針指向的代碼執行的在結腸定義的話,其餘的情況下。在實踐中,有很多方法可以實現這個概念,包括本地代碼實現。

這是什麼意思?這是一個指向解釋器類型詞的指針,如execute

回答

1

在一個普通的線程實現中,它很可能是指向原始機器代碼的指針。機器代碼通常會將內部解釋器指令指針保存到返回堆棧中,然後用指向被調用字的線程代碼開頭的新值裝載指令指針。

在用於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)