Because Fig-forth v2 is a dual segment machine language program, several words and addresses have significance to both the proper operation of the package and to the programmer attempting to direct that performance. Some of these words and addresses have Forth language definitions and meaning to the programmer, while the others are specific to the current build and subject to change. For this reason any attempt at using these values should be managed with extreme care, and are not guaranteed to remain as defined in this chapter.
Quirks: the EXPECT word will filter out any ASCII Line Feed character received from the current input device, treating the value as an invalid character. This allows the process to accept a text file or modem input if a suitable redirection word is defined. Version 2.26 and up saves the count of characters received into the system variable HLD.
This system variable defines the end of the compiler dictionary, marking that point beyond which using FORGET would damage the user search chain. While programmers may change this value to include any vocabularies or words relevant to the current project, setting this value below the location of TASK in the Forth vocabulary may cause the system to crash.
This variable holds the offset of the next character to be processed in the current input buffer.
This currently returns a zero though is reserved for the multi-processing version of the software.
This variable contains a count of the number of characters sent to the current display device since the last carriage return, including un-write and backspace keys.
This variable holds the last edited screen block number.
This variable contains the memory location of the text input buffer.
This system variable holds the size of the symbols involved in the compiler process, normally 32 characters as the limit. While the user is not expected to change this value doing so will limit the number of characters saved into the user space, however the original count of characters is retained by the compiler. E.g.;
: NOW_IS_A_LONG_WORD ; -- will store all 18 letters
HIDDEN 5 WIDTH ! FORTH -- change value
: NOW_IS_A_LONG_WORD ; -- will store 4 letters
: NOW_IS_A_LONGER_WORD ; -- does not conflict
: NOW_IS_A_SAME_WORD ; Isn't Unique! -- does conflict
The location of the font table within the kernel space is located at offset location 4 in the user space, pointing to the following structure;
font_tbl: | word | offset fnt1 |
word | offset fnt2 | |
word | offset fnt3 | |
word | offset fnt4 | |
word | 0 | |
word | 0 | |
word | 0 | |
word | 0 |
This table contains the offsets within the kernel to the four internal fonts, with four additional entries for user based fonts. User based programs may use these entries to load other fonts or modify an existing font as the need arises, however a check for sufficient kernel space must be performed before using the area and font. Note that this table cannot be extended beyond 8 entries and that the end of the last font in kernel memory is not indicated.
This value is stored at offset 6 within the user space and points between two tables inside the Forth kernel, the top of the Modem Buffer and the bottom of the Video Address Table. The Modem Buffer is a character ring buffer described under Basic Input Output, while the Video Address Table is a double word table containing the bank and memory offsets for each screen line in the graphics mode. At present the Modem Buffer is 1024 bytes in size and the Video Address Table is 8192, the video table defining a maximum of 2048 line positions. In location EMJ+1024 Fig-Forth stores the type of card the compiler believes it located upon video detection start-up.
This location is stored at offset 8 in the user space, and points to the 512 byte signature returned by VESA if it is installed when Fig-Forth makes its video card detection. (The spec says 256, but I leave twice that for future versions.)
This word will return the file control block location of the open file given it, with the following definitions of the record structure;
word handle ; returned by DOS
word offset ; in block screens
word address of name string ; in user space
double-word size on open ; (as a Forth Double)
The word FILES return the value of 0 >FILES, or the first file control block to be assigned.
The word CONTEXT returns the address of the Top of the Search Order Buffer, while CURRENT returns the address plus two. The values contained in these locations point to the address containing the location of the top-most word in the vocabulary being searched, pointing to the Name Field Address of the first entry in the search chain.
As of version 2.30 Fig-Forth v2 now contains an internal token thread optimizer. Based upon 24 occurences of source code in which Fig-Forth contains more effective operations, the compiler replaces the token generated code fragments listed below with their optimized equivalents;
Source code fragment | Resulting token thread equivalent |
drop drop |
2drop |
2drop drop |
3drop |
drop 2drop |
3drop |
2drop 2drop |
4drop |
3drop drop |
4drop |
drop 3drop |
4drop |
nip nip |
2nip |
2nip nip |
3nip |
3nip nip |
4nip |
nip 2nip |
3nip |
2nip 2nip |
4nip |
3nip nip |
4nip |
nip 3nip |
4nip |
swap drop |
nip |
2swap 2drop |
dnip |
rdrop rdrop |
unloop |
over swap |
pleat |
2over 2swap |
2pleat |
over over |
2dup |
dup n = if |
n case: |
over = if |
case: |
variable +constant |
[effective address literal] |
n +constant |
[effective value literal] |
constant +constant |
[effective value literal] |
Note that optimizer operations are cumulative, such that a NIP NIP NIP sequence will result in a single 3NIP token. As to the reason behind the use of an optimizer it was easier than going back and correcting the code of earlier versions, particularly to take advantage of the CASE: and offset variable operations. Once the peephole was made, creating the above list became rather obvious.
One should note however that the compile only word of ?EXIT literally compiles an IF EXIT THEN sequence. (3 tokens as opposed to one.)
Return to Contents. Next Chapter. Previous Chapter.