7.12 What is a cell?. 4tH 4tH Forth compiler
إعلان
إعلان
CHAPTER 7. 4TH FUNDAMENTALS
7.12
What is a cell?
71
A cell is simply the space a number takes up. So the size of a variable is one cell. The size of a cell is important since it determines the range 4tH can handle. It also helps make code portable across machines with different cell sized, for example 16 bit and 32 big systems.
We’ll come to that further on.
7.13
What is a literal expression?
A literal expression is simply anything that compiles to a literal. All numbers, all defined constants and some expressions are compiled to a literal. In the glossary you can find what compiles to a literal, but we list them here too:
’ <name>
[’]
[DEFINED]
<name>
<name>
[UNDEFINED] <name>
CHAR <char>
[CHAR] <char>
<literal> [NOT]
<literal> [SIGN]
<literal> NEGATE
<literal> 1+
<literal> 1-
<literal> 2*
<literal> /FIELD
<literal> +FIELD <name>
<literal> ENUM <name>
<literal> <literal> *
<literal> <literal> /
<literal> <literal> +
<literal> <literal> -
<literal> <literal> [=]
<literal> <literal> [MAX]
7.14
Declaring arrays of numbers
You can make arrays of numbers very easily. It is very much like making a variable. Let’s say we want an array of 16 numbers:
16 array sixteen
That’s it, we’re done! You must omit the word ’CELLS’, since ’ARRAY’ implicates that you want an array of numbers, not characters. The size is a literal expression. You can’t take it from the stack, so this is invalid:
3 dup + array sixteen
4tH will let you know that this is not a valid construction, but in case you wonder..
تنزيل
إعلان