text
stringlengths
0
99.6k
A user variable which contains the address below which FORGET will not operate. This may be changed by the user, but caution must be observed.
VIEW?
A user variable which controls whether or not a view field will be compiled by CREATE. The view field is the field used by LOCATE to find the source code for definitions in the dictionary. If VIEW? is 0 , then no view field will be compiled. To compile view fields, VIEW? must contain a 2. Any other value will cause the system to behave oddly. Note that turning VIEW? off will save memory, but it does not affect execution speed. You should also be aware that executing SAVE-FORTH will save the current values of certain system variables, such as FENCE, VIEW?, WIDTH and WARNING.
WARNING
A variable which controls the printing of non-fatal error messages (such as NAME ALREADY EXISTS). If warning is false, no messages will be printed.
WIDTH
Controls the number of characters actually stored in the dictionary. The default is 31, which is specified by the Forth-83 standard. This may be changed by the user. Note that using fewer characters will save memory.
Although not variables, the following are used so often, this is probably a good place to tell you about them:
OFF
Stores a false (0) in a variable. VARIABLENAME OFF is the same as FALSE VARIABLENAME ! , but much quicker.
ON
Stores a true (-1) in a variable. VARIABLENAME ON is the same as TRUE VARIABLENAME ! , but much quicker.
MATH
(Note: The stack notation below uses n as an abbreviation for single numbers, and d to represent double numbers. Also note that floored division is used, to be consistant with the rest of the standard)
2* ( n -- 2*n)
Performs an arithmetic left shift of n, leaving the result on the top of the stack.
D2* ( d -- d*2)
Same as 2* , but for double numbers.
M* ( n1 n2 -- d )
D is the doublenumber product of the single numbers n1 n2.
M*/ ( d1 n1 n2 -- d2 )
d2 is the result of multiplying d1 by n1 and dividing the resulting product by n2. An triple-precision intermediate product is used, and all values are signed.
M+ ( d1 n -- d2 )
d2 is the sum of d1 and n. All values are signed.
M/ ( d1 n -- n2 n3)
n3 is the remainder and n2 is the quotient of the division of d by n1. All values are signed.
M/MOD ( ud1 u1 -- u2 ud2 )
ud2 is the quotient and u2 is the remainder of the division of ud1 by u1.
S>D ( n -- d )
n is sign extended to form the double number d.
MISC:
ASCII
A handy word. Used in the form
ASCII *
to either leave the ascii code for the following character on the top of the stack, or compile it as a literal for later execution. ASCII makes programs much more readable, and also saves much time spent looking up ascii codes in tables.
*fp0
CONTROL
Also handy. Used in the form
CONTROL "c"
where c is one of the 64's weird reversed control characters, such as a cursor left or a clear screen.
FREE ( -- #bytes)
Leaves the number of bytes free on the stack. This may be changed by CONFIGURE. (Note that the amount of memory occupied by the disk buffers is not considered FREE, although it may be used by user programs if no disk accesses are to be performed.)
//
Causes the rest of the line to be viewed as a comment. Corresponds to a backslash, found on some computers, but, regrettably, not on the C64.
Blazin' Forth also includes Kim Harris's experimental proposals for dictionary operators. See the text of the Forth-83 standard for more information.
*lk:blazin.doc3
*hd3:Blazin' Forth Documentation,Strings,-#-
*cn1;String Extensions*cn0
Overview:
There are two values associated with every string variable in Blazin' Forth. The first is the maximum allowable length of the string, which is set when you create a string variable. The second is the actual length of the string, which is set when you actually store the string in the variable. It is important to keep this in mind when using strings, since the string operators will truncate the string if you try to store more characters in the string than you have allotted room for. Of course, you don't have to use the whole space, but you can't overflow it.
STRING STRINGS
These two words are used to reserve variable space for the strings in memory. STRING is used to allocate a single string variable, while STRINGS allocates a string array. You must always tell Forth how long your string is going to be. It can be any length, within the maximum limit of 255. Example:
10 STRING NAME$
Creates a string variable called NAME$ in the dictionary. Space is reserved for 10 characters. This variable will behave exactly like a regulation Forth variable, and leave its address on the stack. Note that the address is the address of the count byte, which allows you to use COUNT TYPE on the string to type it out.
STRINGS requires the number of strings you intend to store, as well as their maximum length. Example:
5 20 STRINGS ARRAY$
Reserves room in the dictionary for 5 strings of 20 characters each. To access the 3rd string in ARRAY$, you simply type:
*fp0
3 ARRAY$
And the address of the third 20 character string in ARRAY$ will be left on the stack. Each string in a string array is stored with its own count byte, and the address left when you access a string in a string array will be the address of the length byte for that string. Note that both STRING and STRINGS initialize the string length to zero.
"
" is used to compile string literals. When it is executed, it leaves the address of the count byte of the string on the stack. For example:
: JOHN$ " JOHN" COUNT TYPE ;
When executed, JOHN$ will print JOHN on the terminal. Note that " may also be used outside a definition. In this case, the string will be stored at PAD, and the current address of PAD will be left on the stack.