| DSFORTH2.2 * PROGRAMMERS MANUAL * DRAFTS * (c)Delosoft,2002
Created: MAY-2000 Last revised: MAY-2002 | |||
|
2.2. PRIMITIVES AND THREADED CODETo be easy portable for some CPU types, DSFORTH2.2 is divided up both logically and in the address space into a VFM and MODULE parts. The VFM (Virtual Forth Machine) is a machine code unit. It need to be directly executed by target CPU. The MODULE part is machine independent unit and it is used for all of CPU types. The working of described system may be considered as VFM's execution of MODULE. The MODULE contains the FORTH words in threaded code. It is the traditional machanism of Forth systems implementing. The threaded code needs to be executed by the special primitives EXNEXT and RETURN. The execution of threaded codes is slower than the execution of primitives, but it allows to make the machine independent part of DSFORTH system. The most of ANS FORTH words are presented in threaded code. See the primitive's set for DSFORTH2.2 in Appendix 1 of the given manual. Theoretically, the MODULE can be resident or loaded. In DSFORTH2.2 the resident version of MODULE is implemented. VFM and MODULE are located in various sections of PE executable and booted with 2000h and 3000h bytes offsets from the IMAGE-BASE accordingly. The value of IMAGE-BASE is always 0x10000h for Windows CE and 0x400000h for desktop Windows. Current implementation of DSFORTH2.2 uses the threaded code named DS2-S "SURA". It can be classified as direct threaded code with special organization of high level calls. In that calls the role of CFA code is carried out by special primitives EXNEXT and RETURN. All codes in MODULE allocates the units divided by 4 and always aligned on 4. The primitive allocated the 4 bytes in MODULE and it represents by its begin address. The high level word allocated 8 bytes in the MODULE: addresses of a primitive EXNEXT and following 4 byte address of a high-level word. Thus, the colon definition allocates 8 bytes in the dictionary. LISTING 1 shows dis-Forth of high-level word 2R>.
LISTING 1. Dis-Forth of two variants of high-level word 2R>.
As it was pointed above, the colon definition allocates of 8 bytes in the dictionary. This is a solution for preset conditions: the DSFORTH2's MODULE must be a processor-independent. It allows to make the fast address interpreter, but magnifies sizes of the dictionary. We are counted the frequensy of using primitives/higfh-level-words in DSFORTH2.2 with 50 primitives. The approximate relation is 2,5/1, and the file size is increases only on 25-30% in comparison with 4 byte variant of threaded code. But the overage performance is increases over than 10 times relative the using of indirect threaded code with more tasks performing by AI. And really we wins. The extending of primitives set is able to additionally increase system performance. In DSFORTH2.2 TURBO and PROFESSIONAL versions the VFM was extended to about 70 primitives and it runs in order faster than FREEWARE version. The quantity of primitives for different machines can be various. A DSFORTH2.2 TURBO VFM for the ARM/SH/i386 contains the primitives for accelerating math, search, parsing etc and allows to make smaller size of the executable and working faster. ### Taking into account, that at compilation of the applications on ds.forth it is possible to delete names of words, the size of the exe-file essentially is not magnified.
| |||
| Generated by DSFORTH SCRIPTER from : doc/pr02_02.txt |