10.1.
FORTH
curtains Texts and numbers that are scanned or scribed form the character
logs in the memory. (The string
of characters in English is string, say: string.) We can work with such a
string if we know its starting address and its length.
Frequent storage in FORTH is
the so-called " start with
the length of the string containing the length of the string and then the
character codes. The so-called
FORTH is called a FORTH garland.
Let's learn about the COUNT
basic word that produces the first character's address and the length of
the string (that is, the parameters needed to call the TYPE test word) from
the FORTH garland title.
Bytees of the FORTH rope of the word "LOVE":
The COUNT word source:
: COUNT (ff address --- title length)
DUP 1+ (first character address)
SWAP C @ (the length byte content)
;
The word FORTH is in the shape of a FORTH interpreter, the word WORD.
WORD (c ---)
(pronounced:
vord, meaning: word) breaks my influence based on the delimiter character
specified on the worm. That
is, WORD reads the characters of my influence all the way to the delimiter,
changes the appropriate system variables (that the closest WORD begins reading
where it is finished), and the scanned text is put into the HERE address
as FORTH. WORD feels the end
of the line boundaries.
Caution: in the viewers (see
section
2.5
), the end of the line is quite different;
we say (say) 64 lines of lines,
but the end of them is not indicated in the memory by a special character
than the lines in the terminal!
An example of using WORD is LEVEL, which can be used in this
way:
Let's see the realization:
: LEVEL
BL (constant code for the space)
WORD (reads the name given after LEVEL)
(in the form of the first space and in the form of a FORTH)
(put it in the HERE address)CR CR
. " Dear "
HERE COUNT
3 - TYPE
. ", Halalomig imadlak!"
CR 20 SPACES
. "Pityu" CR
;(start new line)
(name, length)
("no", "no")
I can see, with my spiritual eyes, the reckless look of the Elders, the Sisters, the Elements, not to mention the Eve and Annas. Why should Pityuk's life be easy? WORD can be called twice in one word; you can also change the name of the sender:
: .NEV (read, write)
(recipient and sender name)
BL WORD
HERE COUNT 3 -
TYPE
;: LEVEL
CR CE
"Dear" .NEV
. "Halalomig imadlak"
CR 20 SPACES .NEV CR
;
Using the word:
LEVEL JENONEK LUJZATOL
The Experiment Reader may try the following:
BL WORD ABRAKADABRA HERE COUNT TYPE
and waits for the ABRADADRA word to be answered in response to the WORD. Instead, you will get the TYPE word as the interpreter uses the WORD itself to parse the lines, so when TYPE is executed, the last executed WORD put it on the HERE address.
10.3.
How do you know him?
(
Basic Words
) In WORD, it is unusual not only to take
data from the stack, but also from the background, from the input and from
the input. We have already
encountered this phenomenon in some of the FORTH core words;
these words are called WORDs.
The simplest such basic word
is
( with which we also get acquainted with
the source:
: (41 WORD;
(41
is the code of the closing parenthesis).
The opening parenthesis reads
what you find behind it, up to the closing brace (or the end of the line).
WORD converts the appropriate
system variables so that the interpreter reads the next closing parenthesis;
so the part of my influence
between the two brackets simply does not kick.
A (
there will still be a note
in
Chapter 16.
We
'll get to know
the full source of the other basic word later (also in
Chapter
16
), here we can only see a reduced version:
:. "34 WORD HERE COUNT TYPE;
(34
is the code of the quotation mark).
WORD reads my influence to
the quotation mark and puts it in the form of FORTH garland at HERE;
From here you can place a COUNT
TYPE series.
How much more do you know the real
" word" The difference is when the word is
meant to be used inside the definition
.
specify
the text specified in the definition, the version here reads the text to
be written when the word is defined.
WORD
reads the name of the word being forgotten with FORGET as well.
WORD works inside any word that can be used to define other words:
VARIABLE,
CONSTANT:
Specifically, the word CREATE creates the new dictionary element; CREATE
and WORD read the name of the dictionary element to be created.
What was that about?
Summary
of Chapter 10
The words learned:
WORD | (c ---) | Read the influence to the delimiter character c; the scanned text is put into the HERE address in the form of FORTH. |
COUNT | (ff title --- title length) | Creates the title and length of the string in the starting address of the FORTH rope. |
Examples
10.1. Write a PELDANY (n ---) word that reads the text you specified after the end of the line and writes the scanned line as many times as we have given it to the worm! For example:
4 PELDANY HULL IS HERE
If WORD has a delimiter character that can not occur in my influence, WORD will read the end of the line. For example, code 1 (not character code):: PELDANY (n ---)
1 WORD
0 DO CR HERE COUNT TYPE LOOP
;
10.2. Write an ORD (--- c) word that says the code you entered afterwards (and adds a space-filled letter to the stack, for example:
ORD C.
: ORD (--- c)
BL WORD HERE 1+ (avoiding the counter)
C @
;
file: /Techref/language/FORTH/z80fig-Forth1_1g_files/words.htm, 19KB, , updated: 2018/11/8 20:17, local time: 2024/12/27 12:11,
3.145.110.145:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.org/techref/language/FORTH/z80fig-Forth1_1g_files/words.htm"> 10. The FORTH Garland and WORD </A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.