FAST Forth Native-Language Embedded Computers
FAST Forth Native-Language Embedded Computers
FAST Forth Native-Language Embedded Computers
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
1<br />
Figure Six. Illustration of the pattern-matching process for a simple set of patterns. I<br />
@ + @ dup<br />
@ dup (vl is defined as a variable)<br />
ID<br />
;??::tf8Fgp2#yE: I :?;:.,:.: .A> .<br />
.L (token array full)<br />
,,:,:, J ~ & ~ & ~ ~ ; ~ & ~ ~ : : ~ : ~ ~ . 9 ma tc he+ pattern (1 )<br />
\ / Replace pattern with single entry<br />
V<br />
I<br />
j::: ... !.:.:.:.:.:.:.,.:::::fi:::::m::: matches pattern (2)<br />
I Generate code:<br />
state =I)<br />
MOV EBX, dword ptr ()<br />
(new state = 6)<br />
Set of matching token patterns (partial):<br />
/ (1) literal ; literal ; add I Replace pattern with single entry: literal <br />
(2) literal ; fetch<br />
(3) literal <br />
(4) add<br />
(5) dup<br />
(6) fetch<br />
VI. Macros and Macro Compilation<br />
One major problem with the foregoing optimization<br />
techniques is that, in many typical compiled <strong>Forth</strong> words,<br />
simple words may be thoroughly intermixed with calls to<br />
other compiled words. Unfortunately, calls to compiled<br />
words can severely limit the opportunities for code opti-<br />
mization, because of their nature:<br />
1. A monkey wrench gets thrown into optimization of<br />
operations on the data stack by calls to compiled<br />
words, because each call to a compiled word requires<br />
(stack state = 1) MOV EBX, dword ptr () (new state = 6)<br />
(stack state = 1 ) MOV EBX, off set () (new state = 6)<br />
(stackstate=l) ADD EAX, [EDI]+Voffs<br />
voffs += +4 (state unchanged)<br />
(stack state = 6) MOV EDX, EBX (new state = 13)<br />
(stack state = 6) MOV EBX, [EBX] (state unchanged)<br />
)<br />
that both the stack state and the value of Voffs be<br />
rectified to values consistent with the expectations<br />
already compiled into each and every compiled word.<br />
By contrast, when sequences of source code contain<br />
only simple words, the compiler has considerably<br />
more flexibility in how it generates its code with<br />
respect to the optimization of data-stack handling.<br />
2. In addition, there is simply no way to combine a call to<br />
a compiled word with any other machine instruction.<br />
Thus, opportunities for code optimization due to the<br />
March 1994 April 40 <strong>Forth</strong> Dimensions