Quick Forth Question
John R. Hogerhuis
jhoger at pobox.com
Tue Jan 24 03:04:30 CST 2006
On Tue, 2006-01-24 at 02:10 -0500, Roger Merchberger wrote:
> Dudez & Dudettez:
>
> I'm trying to get some SnapForth ROMs running for the Panasonic HHC 'puter
> - and I'm having a bit'o'difficulty, mainly as I know... ummm... "squat"
> about Forth. ;^>
>
> I've gotten the ROMs to be able to start SnapForth, ask for a filename,
> create the filename & filespace (about 1K of RAM goes "buh-bye" for every
> filename I make... ;-) but no matter what I type, all I get is "Can't Find
> xxxxx" where xxxxx seems to be any durned thing I type.
>
> It can't seem to make new words, and every simple "Hello World" type
> proggie I've found on the net makes *no* sense to the 'puter.
>
That's odd.
Usually ." Hello, world." words on all forths.
Keep in mind you do need the space between ." and the first letter of
the string, since ." is a word (a "parsing" word since it reads ahead in
the stream till the ending ")
> It looks like it has a max. of 4-character words... duh, waitaminit...
> lemme check the ROMs again... *maybe* 5-character words, as it looks like
> the last character of the word is OR'ed with $80... It looks like it's got
> quite a few words, looking at the ROMs in ASCII - I found VARIA, CONST,
> STRIN, CVECT, JUMP....
>
The way old Forths worked was that they saved space by matching the
first 3 characters of the name and the length. So VARIABLE != VARIANT
since the lengths are different. Maybe yours does have 5 character
words.
> I could provide a clip of the ROM word table if it would help...
>
Might help. Sometimes you can also type WORDS at the command prompt and
see all the words.
> I've tried:
>
> 100 LLL !
> [[ To try to store the variable 100 in LLL ]]
You mean try to store the value 100 in the variable LLL.
Well, first you need to create the variable:
VARIABLE LLL
Then you store a value in it:
100 LLL !
> 100 VAR DORK
> 100 VARI DORK
> 100 VARIA DORK
> 100 VARIABLE DORK
Type the whole word.
Are you trying to make a variable or a constant?
VARIABLE DORK
100 DORK !
DORK @ .
or...
100 CONSTANT DORK
DORK .
Newer Forths have a word called VALUE which is close to the semantics
you made up for VARIABLE.
Also, you can just use CREATE as so:
CREATE DORK
> [[ To try to store the variable 100 in DORK ]]
> 100 CONS BURP
> 100 CONST BURP
> [[ To try to make BURP a constant of 100 ]]
>
the word is CONSTANT
> I've also tried:
>
> .S
This word prints out the contents of the stack. If you put something on
there first, it should print something.
1 2 3 4 5 .S
> DROP
Don't do this unless you have something on the stack to drop. Actually,
try it it should give you an error if there's nothing on the stack.
> ." Hello World"
>
That should work in most Forths.
> and other things I'd seen in various webpages thanks to Google.
>
> Anyone got any other idears for me?
Try to do some arithmetic ala
100 2 * .
Next step is a simple word like SQUARE
: SQUARE DUP * ;
5 SQUARE .
-- John.
More information about the cctalk
mailing list