figForth WORDs - Stack Requirements
Some parts of this page/site are currently incomplete & will be updated asap
Other parts will change continually so use “Refresh” in your browser !!
There is extensive use of “Tooltips” text to support learning which do not seem to render on a Smartphone. This site is best viewed via a computer’s HD monitor
Forth is a “Stack-Based” Language
A Stack is a common data-structure
Forth has two stacks; a Parameter Stack (for passing values before and after execution of Forth Words) and a Return Stack as the Forth virtual machine equivalent of the low-level microprocessor “machine stack”…
The Parameter Stack
Virtual Machine Register SP
The Return Stack
Virtual Machine Register RP
Stack Rules
The granularity of the stacks is 16-bits; one word
However, that does not limit the data in any way; it just means Forth looks at data in 16-bit “chunks” 1
The Forth Parser rules place numerical values on the stack implicitly, but they have to be taken off explicitly
Forth has a way of treating “double-number” (32-bit) values on the stack, as shown below…
eZ80 figForth Development Software R01
By David Husband (c) Friday 30th July 2021
ALL RIGHTS RESERVED
HEX ok
ok
1234 ok
P-Stack Base> 1234
12.34 ok
P-Stack Base> 1234 0
DPL ? 2 ok
Some Examples…
All based upon (Haydon 1982, pp. 6-214)
]
(1) - No Stack effect at all
(2) - But it IS taking text from the "Input Stream"
[’]
(1) - No Stack effect During Compilation
(2) - But there is a Stack effect upon Execution
(3) - This is an "IMMEDIATE" Word
(4) - But it IS taking text from the "Input Stream"
(5) - "How you say: ['] ?
(FIND)
(1) - No Stack effect During Compilation
(2) - But there is a Stack effect upon Execution
[COMPILE]
(1) - No Stack effect During Compilation
(2) - But there is a Stack effect upon Execution
(3) - This is an "IMMEDIATE" Word
(4) - But it IS taking text from the "Input Stream"
(5) - "How you say: "[']" ?
DIGIT
(1) - No Stack effect During Compilation
(2) - But there is a Stack effect upon Execution
WORD
(1) - No Stack effect During Compilation
(2) - But there is a Stack effect upon Execution
ENCLOSE
(1) - No Stack effect During Compilation
-FIND
(1) - No Stack effect During Compilation
(2) - But there is a Stack effect upon Execution
?DUP
(1) - No Stack effect During Compilation
TRAVERSE
(1) - No Stack effect During Compilation
U<
(1) - No Stack effect During Compilation
UNTIL
(1) - No Stack effect During Compilation
(2) - But there is a Stack effect upon Execution
(3) - This is an "IMMEDIATE" Word
(4) - But it IS taking text from the "Input Stream"
U/MOD
(1) - No Stack effect During Compilation
(2) - But there is a Stack effect upon Execution
WHILE
(1) - No Stack effect During Compilation
(2) - But there is a Stack effect upon Execution
(3) - This is an "IMMEDIATE" Word
(4) - But it IS taking text from the "Input Stream"
(5) - "How you say: ['] ?
References:
Haydon, G. B., 1982. All About Forth - An Annotated Forth Glossary [online]. Available from: Http://figforth.org.uk/library/All.About.Forth.pdf.
This means Forth IS typed, even if only very weakly… ↩