In developing a Forth for the Raspberry Pico I was wondering how
welcoming that community would be to Forth intricacies.
So here is the one page definition of lucky 7 a languages that might
address that. It is actually Forth without the weird terminology.
Notable missing is the stack.
A "recipe" "finds" one or two "things" to work on.
Instead of the like of "a noname definition is a word that has no name"
(Huh?).
Yes locals are in there, build/does is in there.
\--------------------------------------------------
The basic construct of the language is the recipe.
{ A B C } leaves a thing that when RUN performs A B C in sequence.
Such a recipe can be given a name by :
{ A B C } : MYRECIPE
MYRECIPE becomes a new command that runs the recipe and
can be used in new recipe's.
{ A B } : C { C D C } : Q
Note that a recipe can leave things that are used by other ones.
We say that MYRECIPE is a new definition that is added to the glossary.
'MYRECIPE gets the recipe itself back.
{ 7 } : LUCKY
is the way to define constants.
By adding a | , recipes can be used to do loops and conditional
actions. They then run directly and do not leave a recipe,
but rather the things that result from performing the instructions.
| checks a thing and leaves true/false, whether the thing is zero.
{ A | B } performs A , then if | finds false it terminates,
otherwise it does B and starts over again at A.
{ A }|{ B } | checks a thing, if it finds true it performs A else B.
{ A }|{ } can be abbreviated to { A }|
lucky7 has build in actions on one or two things that are
interpreted as either a signed number or a bitmask.
A truth value (logical) is a bitmask with all bits the same.
A number can identify a byte in computer memory,
then it is called an address.
Signed number pairs (including addresses):
+ - * / arithmetic result
< <= > >= logic result
bitmasks:
OR AND XOR << >> bitmask result
The following actions work on a single thing.
Signed number:
NEGATE arithmetic result
Bit-mask
INVERT bitmask
Pair of whatever things.
= <> logic result
Comparing, subtracting of addresses are meaningful; negative
addresses are not allowed.
The next level, the word META and nested compilation.
{ A } { B } META DEFINER
DEFINED X adds a word X to the glossary. It remembers the
position of HERE and then performs A. Then if later X is
to run, it finds that position of HERE and performs B.
A predefined META word is DATA
{ } { } META DATA
Building a recipe between { and } is called compilation.
A compilation can be interrupted by a matched pair [ ].
Any code can be run between the square brackets, in particular
adding definitions to the glossary. However those definitions
only are visible until the } of the enclosing recipe.
A [ ] pair shall leave nor consume things.
Loops, the word DO.
7 { A B C } DO performs the recipe 7 times.
IX will give the loop counter, starting from 0.
Expressions like 1234 leave a thing that is a signed number.
Expressions like "1234" leaves two things, an address and a count.
\--------------------------------------------------
It is my belief that one could do interesting things with the
Pico using lucky7.
Notes for the Forthers
Notably missing:
AGAIN UNTIL AHEAD CREATE DOES> :NONAME [:
<< >> are contrary to 2* 2/ a logical shift.
No double precision shit, no local shit.
Not really missing, may lay under the hood:
USER <os calls> PREFIX IMMEDIATE PAD
Any advanced wordlist:
<# and friends,
WORDLIST and friends
CLASS and friends
ASSEMBLER
floating point.
Development stuff: .S WORDS SEE LOCATE REGRESS T{ DEBUG
Maybe I'll keep it a secret for the unwashed masses that it is
based on Forth.
Groetjes Albert
--
"in our communism country Viet Nam, people are forced to be
alive and in the western country like US, people are free to
die from Covid 19 lol" duc ha
albert@spe&ar&
c.xs4all.nl &=n
http://home.hccnet.nl/a.w.m.van.der.horst