sandbox/misc/kforth/doc/fst83/fst83-9.txt

200 lines
6.3 KiB
Plaintext

9. USAGE
9. USAGE
9.1 Words Names and Word Definitions
A Standard Program may reference only the definitions of the
Required Word Set and Standard Extensions and definitions which
are subsequently defined in terms of these words. Furthermore, A
Standard Program must use the standard words as required by any
conventions of this Standard. Equivalent execution must result
from Standard Programs.
The implementation of a Standard System may use words and
techniques outside the scope of the Standard, provided that no
program running on that system is required to use words outside
the Standard for normal operation.
If a Standard System or Standard Program redefines Standard
definitions within the FORTH vocabulary, these definitions must
comply with the Standard.
9.2 Addressable Memory
The FORTH system may share the dictionary space with the user's
application. The native addressing protocol of the host computer
is beyond the scope of this Standard.
Therefore, in a Standard Program, the user may only operate on
data which was stored by the application. No exceptions!
A Standard Program may address:
1. parameter fields of words created with CREATE , VARIABLE ,
and user defined words which execute CREATE ;
2. dictionary space ALLOTted;
3. data in a valid mass storage block buffer.
See: "9.7 Multiprogramming Impact";
4. data area of user variables;
5. text input buffer and PAD up to the amount specified as the
minimum for each area.
A Standard Program may NOT address:
1. directly into the data or return stacks;
2. into a definition's name field, link field, or code field;
18
9. USAGE
3. into a definition's parameter field if not stored by the
application.
9.3 Return Stack
A Standard Program may cautiously use the return stack with the
following restrictions:
The return stack may not be accessed inside a do-loop for values
placed on the return stack before the loop was entered. Further,
neither I nor J may be used to obtain the index of a loop if
values are placed and remain on the return stack within the loop.
When the do-loop is executed all values placed on the return
stack within that loop must be removed before LOOP , +LOOP , or
LEAVE is executed. Similarly, all values placed on the return
stack within a colon definition must be removed before the colon
definition is terminated at ; or before EXIT is executed.
9.4 Compilation
The system uses the return stack and the dictionary in a system
dependent manner during the compilation of colon definitions.
Some words use the data stack in a system dependent manner during
compilation. See: "sys (11.7)"
9.5 Terminal Input and Output
9.5.1 KEY
A Standard System must receive all valid ASCII characters. Each
KEY receives one ASCII character, with more-significant bits
environmentally dependent and might be zero. KEY must receive as
many bits as are obtainable. A Standard Program without
environmental dependencies may only use the least significant 7-
bit ASCII character received by KEY . For example: KEY 127 AND
9.5.2 EXPECT
Control characters may be processed to allow system dependent
editing of the characters prior to receipt. Therefore, a
Standard Program may not anticipated that control characters can
be received.
19
9. USAGE
9.5.3 EMIT
Because of the potential non-transportable action by terminal
devices of control characters, the use of ASCII control
characters is an environmental dependency. Each EMIT deals with
only one ASCII character. The ASCII character occupies the
least-significant 7 bits; the more-significant bits may be
environmentally dependent. Using the more-significant bits when
other than zero is an environmentally dependent usage. EMIT must
display as many bits as can be sent.
9.5.4 TYPE
Because of the potential non-transportable action by terminal
devices of control characters, the use of ASCII control
characters is an environmental dependency.
9.6 Transporting Programs Between Standard Systems
Further usage requirements are expected to be added for
transporting programs between Standard Systems.
9.7 Multiprogramming Impact
In a multiprogrammed system, Device Layer words and those words
which implicitly reference the Device Layer words may relinquish
control of the processor to other tasks. Although there is
insufficient experience to specify a standard for
multiprogramming, historical usage dictates that a programmer be
aware of the potential impact with regard to resources shared
between tasks. The only shared resources specified within the
Standard are block buffers. Therefore the address of a block
buffer returned by BLOCK or BUFFER becomes invalid during and
after the execution of any word marked by the attribute M in the
glossary or any words executing them. A block buffer is valid
only if its address is valid. See: "11.4 Attributes"
9.8 Numbers
Interpreted or compiled numbers are in the range
{-32,768..65,535}. See: "number conversion"
9.9 Control Structures
Control structures are compiled inside colon definitions.
Control structures can be nested but cannot overlap. For
additional limitations see DO .
20