Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FORGET for CamelForth (Z80)?

138 views
Skip to first unread message

Peter Heitzer

unread,
Jun 1, 2015, 10:30:26 AM6/1/15
to
Hello folks,
for some old Z80 SBC I managed to adopt camel forth 1.2 for standalone
use. Unfortunately camel forth has not FORGET in its dictionary.
I'd like to implement it for I find it useful in the develop phase
but I have not enought knowledge to do it by myself. If anyone already
has a definition for FORGET I would highly appreciate if he could
post it.
Thanks a lot in advance.


--
Dipl.-Inform(FH) Peter Heitzer, peter....@rz.uni-regensburg.de
HTML mails will be forwarded to /dev/null.

Bob

unread,
Jun 1, 2015, 1:15:06 PM6/1/15
to
On 06/01/2015 10:30 AM, Peter Heitzer wrote:
> Hello folks,
> for some old Z80 SBC I managed to adopt camel forth 1.2 for standalone
> use. Unfortunately camel forth has not FORGET in its dictionary.
> I'd like to implement it for I find it useful in the develop phase
> but I have not enought knowledge to do it by myself. If anyone already
> has a definition for FORGET I would highly appreciate if he could
> post it.
> Thanks a lot in advance.
>
>
FORGET needs to find the newest definition to keep then set
the dictionary search pointer and the pointer to the end of
used memory.

: FORGET [COMPILE] ' ( LOOKUP NAME FROM INPUT STREAM )
DUP NFA DP ! ( DP IS USED BY HERE, THIS FREES UP MEMORY )
LFA @ CURRENT @ ! ; ( LINK TO PRIOR WORD, SET CURRENT )
( VOCABULARY TO START SEARCH THERE )

This is what I used on a Z80 long ago. Today it is politically
incorrect because it depends on knowing what is in the dictionary
and then touching that. NFA takes what tick gives and adjusts to
the name field address. LFA takes what tick gives and adjusts to
the link field address. DP is end of dictionary pointer.

Warning, don't forget stuff that will cause a problem. If you
create another vocabulary and delete some of its words then the
unforgotten vocabulary head points to deleted stuff that will
soon be written over. If you forget an entire vocabulary that
may be OK. If you have a vectoring word that has been pointed
to forgotten code it will soon fail. Failures will happen at
some time in the future, far from the cause, generating
confusion.

Albert van der Horst

unread,
Jun 1, 2015, 2:43:03 PM6/1/15
to
In article <ct38jv...@mid.individual.net>,
Peter Heitzer <peter....@rz.uni-regensburg.de> wrote:
>Hello folks,
>for some old Z80 SBC I managed to adopt camel forth 1.2 for standalone
>use. Unfortunately camel forth has not FORGET in its dictionary.
>I'd like to implement it for I find it useful in the develop phase
>but I have not enought knowledge to do it by myself. If anyone already
>has a definition for FORGET I would highly appreciate if he could
>post it.
>Thanks a lot in advance.

I have the source of 6809 camelforth here.

1. LATEST is a user variable. There is just one list, no
vocabularies.
This means that getting something appropriate into LATEST,
cuts the dictionary short.

2. From the code of FIND I see that this must be a NFA address.

The code field address (xt) sits after the name.

So to forget from the word APE you could try:
if NOTE is the word defined after APE
' NOTE
' APE 3 ( length of name) - 1- LATEST !
DP !

You can try storing in LATEST first, then try WORDS.
If that doesn't crash you're halfway through.

Disclaimer :
This may or may not be similar to the Z80 code.

Just experiment a bit, you'll figure it out.

>
>
>--
>Dipl.-Inform(FH) Peter Heitzer, peter....@rz.uni-regensburg.de

Groetjes Albert
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

Coos Haak

unread,
Jun 1, 2015, 4:16:39 PM6/1/15
to
Op 01 Jun 2015 18:43:02 GMT schreef Albert van der Horst:
This works on CamelForth 1802.

: >NAME ( xt -- nfa )
DUP >R
BEGIN DUP COUNT + R@ <> \ Walk back to the count byte
WHILE 1-
REPEAT
R> DROP ;

: FORGET ( "name" -- )
' >NAME 3 - \ this becomes the dictionary pointer
DUP DP !
@ LATEST ! ; \ and contained the link to the previous word

--
Coos

CHForth, 16 bit DOS applications
http://home.hccnet.nl/j.j.haak/forth.html

Albert van der Horst

unread,
Jun 1, 2015, 4:43:10 PM6/1/15
to
In article <bv73617h0gvz.y00tgkoxvnhu$.d...@40tude.net>,
There may information in the sign bit, so `` COUNT 7F AND '' may be needed.
>
>: FORGET ( "name" -- )
> ' >NAME 3 - \ this becomes the dictionary pointer
> DUP DP !
> @ LATEST ! ; \ and contained the link to the previous word

And don't forget, DUMP is your friend!

>
>--
>Coos

Coos Haak

unread,
Jun 1, 2015, 6:08:03 PM6/1/15
to
Op 01 Jun 2015 20:43:08 GMT schreef Albert van der Horst:
Don't worry, IMMEDIATE sets the byte just before the name:
: IMMEDIATE 1 LATEST @ 1- C! ;
There is no TRAVERSE like as in Figforth.

Something similar
: MARKER ( "name" -- ) CREATE LATEST @ 3 - ,
DOES> @ DUP DP ! @ LATEST ! ;

This runs on the 1802sim simulater on Cygwin and Rasberry Pi.

Forgeting an essential word like QUIT is trapped by the simulator.
A working system remains.
I don't expect that to be the case on ans SBC tough.

Elizabeth D. Rather

unread,
Jun 1, 2015, 7:21:40 PM6/1/15
to
On 6/1/15 7:12 AM, Bob wrote:
> On 06/01/2015 10:30 AM, Peter Heitzer wrote:
>> Hello folks,
>> for some old Z80 SBC I managed to adopt camel forth 1.2 for standalone
>> use. Unfortunately camel forth has not FORGET in its dictionary.
>> I'd like to implement it for I find it useful in the develop phase
>> but I have not enought knowledge to do it by myself. If anyone already
>> has a definition for FORGET I would highly appreciate if he could
>> post it.
>> Thanks a lot in advance.
>>
>>
> FORGET needs to find the newest definition to keep then set
> the dictionary search pointer and the pointer to the end of
> used memory.
>
> : FORGET [COMPILE] ' ( LOOKUP NAME FROM INPUT STREAM )
> DUP NFA DP ! ( DP IS USED BY HERE, THIS FREES UP MEMORY )
> LFA @ CURRENT @ ! ; ( LINK TO PRIOR WORD, SET CURRENT )
> ( VOCABULARY TO START SEARCH THERE )
>
> This is what I used on a Z80 long ago. Today it is politically
> incorrect because it depends on knowing what is in the dictionary
> and then touching that. NFA takes what tick gives and adjusts to
> the name field address. LFA takes what tick gives and adjusts to
> the link field address. DP is end of dictionary pointer.

I don't see anything "politically incorrect" about having to use
implementation knowledge to implement FORGET. This is why it was
included in ANS Forth (though marked "Obsolescent"). We standardize
words that are useful but would be hard to implement without
implementation details.

> Warning, don't forget stuff that will cause a problem. If you
> create another vocabulary and delete some of its words then the
> unforgotten vocabulary head points to deleted stuff that will
> soon be written over. If you forget an entire vocabulary that
> may be OK. If you have a vectoring word that has been pointed
> to forgotten code it will soon fail. Failures will happen at
> some time in the future, far from the cause, generating
> confusion.

This is an important warning!

Cheers,
Elizabeth

--
==================================================
Elizabeth D. Rather (US & Canada) 800-55-FORTH
FORTH Inc. +1 310.999.6784
5959 West Century Blvd. Suite 700
Los Angeles, CA 90045
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
==================================================

Peter Heitzer

unread,
Jun 2, 2015, 6:36:34 AM6/2/15
to
Coos Haak <chf...@hccnet.nl> wrote:
>This works on CamelForth 1802.

>: >NAME ( xt -- nfa )
> DUP >R
> BEGIN DUP COUNT + R@ <> \ Walk back to the count byte
> WHILE 1-
> REPEAT
> R> DROP ;

>: FORGET ( "name" -- )
> ' >NAME 3 - \ this becomes the dictionary pointer
> DUP DP !
> @ LATEST ! ; \ and contained the link to the previous word

This also works for the Z80 version, thanks.
If anyone wants to have FORGET already in PROM here is the source
for ZMASM

;Z >NAME ( xt -- nfa)
; DUP >R
; BEGIN DUP COUNT + R@ <> \ Walk back to the count byte
; WHILE 1-
; REPEAT
; R> DROP ;

head TONAME,5,">NAME",docolon
DW DUP,TOR
$$ DW DUP,COUNT,PLUS,RFETCH,NOTEQUAL,QBRANCH,$F
DW ONEMINUS,BRANCH,$B
$$ DW RFROM,DROP,EXIT

;Z FORGET ( "name" -- )
; ' >NAME 3 - \ this becomes the dictionary pointer
; DUP DP !
; @ LATEST ! ; \ and contained the link to the previous word
head FORGET,6,"FORGET",docolon
DW TICK,TONAME,LIT,3,MINUS,DUP,DP,STORE,FETCH,LATEST,STORE,EXIT

For a more fool prof version one has to check if the word to forget is
in RAM. Doing a FORGET for words in ROM makes the system kinda upset.

--
Dipl.-Inform(FH) Peter Heitzer, peter....@rz.uni-regensburg.de

HAA

unread,
Jun 2, 2015, 11:19:45 PM6/2/15
to
Bob wrote:
> ...
> Warning, don't forget stuff that will cause a problem. If you
> create another vocabulary and delete some of its words then the
> unforgotten vocabulary head points to deleted stuff that will
> soon be written over.

Yes. This occurs in Fig-Forth. A fix was published in FD which
involved traversing all vocabs.

Simple systems like CamelForth & Eforth usually don't need
vocabs - unless perhaps you want a resident assembler and
names clash.

> If you have a vectoring word that has been pointed
> to forgotten code it will soon fail. Failures will happen at
> some time in the future, far from the cause, generating
> confusion.

It's why ANS introduced MARKER. FORGET can be likened
to a sling-shot whereas MARKER is a cannon.



0 new messages