Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How forth works?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Hannu Vuolasaho  
View profile  
 More options Oct 31 2012, 5:48 pm
Newsgroups: comp.lang.forth
From: Hannu Vuolasaho <hannu.vuolas...@nospam.tut.fi.invalid>
Date: Wed, 31 Oct 2012 21:43:12 +0000 (UTC)
Local: Wed, Oct 31 2012 5:43 pm
Subject: How forth works?
Hello everyone!

Earlier today I wrote few nice words that had create and does and I
started wondering how I just did what I did. After few hours of surfing
and reading I'm not really enlightned.

I'm interested understanding how the system behind ok prompt works. So
far I have grasped idea that QUIT reads from keyboard INTERPRET seeks
from dictionary and if found EXECUTE it and then triest convert number.
And then there is inner interpreter.

Reading source code isn't very useful as it shows how nice assembler
someone has written.

Anyway good webpage but still not exactly what I looked for is:
http://www.jimbrooks.org/web/forth/forthInternals.php

What I'm looking for is to some good information how interpreter starts
and executes like standard says. And also how the compilation is done
with branching. Which I believe is much implementation defined.

--
Hannu Vuolasaho


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Wills  
View profile  
 More options Oct 31 2012, 6:09 pm
Newsgroups: comp.lang.forth
From: Mark Wills <forthfr...@gmail.com>
Date: Wed, 31 Oct 2012 15:09:26 -0700 (PDT)
Local: Wed, Oct 31 2012 6:09 pm
Subject: Re: How forth works?
On Oct 31, 9:48 pm, Hannu Vuolasaho

This is an excellent starting point for understanding how a threaded
interpreter works:

http://www.eighty-twenty.org/repos/jonesforth/jonesforth.S


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rod Pemberton  
View profile  
 More options Oct 31 2012, 8:43 pm
Newsgroups: comp.lang.forth
From: "Rod Pemberton" <do_not_h...@notemailnotz.cnm>
Date: Wed, 31 Oct 2012 20:47:25 -0400
Local: Wed, Oct 31 2012 8:47 pm
Subject: Re: How forth works?
"Hannu Vuolasaho" <hannu.vuolas...@nospam.tut.fi.invalid> wrote in message

news:slrnk936rg.lmg.hannu.vuolasaho@haikara.cs.tut.fi...

> Earlier today I wrote few nice words that had create and does and I
> started wondering how I just did what I did. After few hours of surfing
> and reading I'm not really enlightned.

CREATE and DOES> are somewhat complicated.

> I'm interested understanding how the system behind ok prompt works. So
> far I have grasped idea that QUIT reads from keyboard INTERPRET seeks
> from dictionary and if found EXECUTE it and then triest convert number.
> And then there is inner interpreter.

You found the first link, but there are other good sources out there too:

Jim Brooks "FIG-FORTH Internals"
http://www.jimbrooks.org/web/forth/forthInternals.php

Peter Knagg's "Forth: An underview"
http://dec.bournemouth.ac.uk/forth/forth.html

Bradford Rodriquez "Moving Forth" series
http://www.bradrodriguez.com/papers/

figinst.zip  fig-Forth November 1980
ftp://ftp.taygeta.com/pub/forth/Archive/docs/FIGINST.ZIP

figdoc.zip   fig-Forth May 1979
http://home.hccnet.nl/a.w.m.van.der.horst/figdoc.zip

PFE documentation
http://pfe.sourceforge.net/manual/index.html

eForth overview
http://www.offete.com/files/zeneForth.htm

> Reading source code isn't very useful as it shows how nice assembler
> someone has written.

> Anyway good webpage but still not exactly what I looked for is:
> http://www.jimbrooks.org/web/forth/forthInternals.php

> What I'm looking for is to some good information how interpreter starts
> and executes like standard says.

First, you have to be able to create an executable program using assembly or
another high-level language, like C, for your operating system (OS) if your
Forth is hosted, and not standalone, nor embedded.  This will contain a few
small routines for the interpreter, one of which is known as NEXT.  Others
are DOCOL or ENTER and EXIT or SEMIS, etc.

Second, you set the interpreter's instruction pointer (IP) to the address of
COLD.  COLD is the traditional name for the initial entry routine.  Then,
you call or jump to the interpreter's NEXT routine.  NEXT sets the working
pointer (W), adjusts IP to the next instruction, and calls or jumps to an
executable procedure or assembled instructions at the working pointer (W) to
be executed.  The interpreter is now interpreting the code.  The addresses
that are called or jumped to are the CFA (code-field address) of Forth words
in the dictionary.  If a Forth word is high-level Forth word, the CFA is a
special routine called DOCOL or ENTER.  It saves the current interpreter
state and starts interpreting another word.  There are other such low-level
CFA routines in Forth: DOVAR, DOCON, DOUSER.  These are routines which
handles the contents of each type of Forth word.  I.e., just as DOCOL is for
interpreted Forth words, DOCON is for Forth words that store constants.  It
a low-level routine calls some assembled code or a procedure directly, that
routine is called a "primitive".

As an aside, some low-level routines you'd expect in Forth, say DOSTR to
handle Forth words consisting of strings, aren't present in Forth ...

> And also how the compilation is done
> with branching. Which I believe is much implementation defined.

I'm not quite sure what you're asking about here.

Rod Pemberton


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hugh Aguilar  
View profile  
 More options Oct 31 2012, 8:44 pm
Newsgroups: comp.lang.forth
From: Hugh Aguilar <hughaguila...@yahoo.com>
Date: Wed, 31 Oct 2012 17:44:31 -0700 (PDT)
Local: Wed, Oct 31 2012 8:44 pm
Subject: Re: How forth works?
On Oct 31, 2:48 pm, Hannu Vuolasaho

You might try "Threaded Interpretive Languages" (R.G.Loeliger). I read
that when I was a senior in H.S. (1984). I later lent the book out and
never got it back. :-( It may be available on pdf now though. It is
for the Z80, so you should know Z80 assembly-language to read the book
--- it documents everything however, so you don't have to just figure
it out from the source-code.

Branching isn't any more implementation-specific than anything else.
You compile BRANCH or 0BRANCH, followed by an offset. These just add
the offset to the IP (interpretive pointer) to effect the branch. All
of the primitive words are in assembly-language, so they are processor-
specific, but the overall plan is the same no matter what processor
you are using. It is theoretically possible for the same threaded-code
to run on more than one processor without recompiling, although I've
never heard of that being done. Threaded code is pretty simple ---
also, pretty slow, which is why I don't recommend messing with
threaded schemes in this modern era in which processors do branch-
prediction.

Why are you interested in the internal workings of Forth? Your
experience is: "today I wrote few nice words." You are getting way
ahead of yourself. I have said many times here that it is a mistake
for people to think of Forth as a science-fair project and immediately
delve into the internal workings. I recommend instead that you start
out by writing application programs --- that is the best way to learn
Forth. You can use my novice package:
http://www.forth.org/novice.html


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hannu Vuolasaho  
View profile  
 More options Oct 31 2012, 9:35 pm
Newsgroups: comp.lang.forth
From: Hannu Vuolasaho <hannu.vuolas...@nospam.tut.fi.invalid>
Date: Thu, 1 Nov 2012 01:35:33 +0000 (UTC)
Local: Wed, Oct 31 2012 9:35 pm
Subject: Re: How forth works?
On 2012-11-01, Rod Pemberton <do_not_h...@notemailnotz.cnm> wrote:

> "Hannu Vuolasaho" <hannu.vuolas...@nospam.tut.fi.invalid> wrote in message
> news:slrnk936rg.lmg.hannu.vuolasaho@haikara.cs.tut.fi...

>> Earlier today I wrote few nice words that had create and does and I
>> started wondering how I just did what I did. After few hours of surfing
>> and reading I'm not really enlightned.

> CREATE and DOES> are somewhat complicated.

Indeed. It took quite long to figure out how they should be used.
Luckily there were some good threads in here.

Thanks. Bookmarked. I'll read them when I have more time.

Even bigger thanks. This makes much sense. I have been wondering how the
systems really work and you save much reading time.

>> And also how the compilation is done
>> with branching. Which I believe is much implementation defined.

> I'm not quite sure what you're asking about here.

Well I had little bit different ideas how the system works internally.

After reading jonesforth assembler listing implementation of IF and
other control structures came much clearer. Also the RISC and CISC
assembler notation had fooled me.

--
Hannu Vuolasaho


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hannu Vuolasaho  
View profile  
 More options Oct 31 2012, 10:04 pm
Newsgroups: comp.lang.forth
From: Hannu Vuolasaho <hannu.vuolas...@nospam.tut.fi.invalid>
Date: Thu, 1 Nov 2012 02:04:19 +0000 (UTC)
Local: Wed, Oct 31 2012 10:04 pm
Subject: Re: How forth works?
On 2012-11-01, Hugh Aguilar <hughaguila...@yahoo.com> wrote:

> Why are you interested in the internal workings of Forth? Your
> experience is: "today I wrote few nice words." You are getting way
> ahead of yourself. I have said many times here that it is a mistake
> for people to think of Forth as a science-fair project and immediately
> delve into the internal workings. I recommend instead that you start
> out by writing application programs --- that is the best way to learn
> Forth. You can use my novice package:
> http://www.forth.org/novice.html

I'm working on application. However when I get something I don't
understand I usually go to the root and figure out the reason. It's much
more interesting to study system and see why I made on error. However in
this case I tried to understand the CREATE DOES> success. What I did and
how it happened. The missing piece was the system. How it works what
makes my definitions work like they do and why I can see the differences
in the dictionary. Sometimes it isn't enough to something to just work.
I want to know why it works.

And I have your novice package. It is good reference and has good ideas.
However I have never used training wheels and I'm not starting now. I
started with small motorbike :)

--
Hannu Vuolasaho


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hugh Aguilar  
View profile  
 More options Oct 31 2012, 10:43 pm
Newsgroups: comp.lang.forth
From: Hugh Aguilar <hughaguila...@yahoo.com>
Date: Wed, 31 Oct 2012 19:43:14 -0700 (PDT)
Local: Wed, Oct 31 2012 10:43 pm
Subject: Re: How forth works?
On Oct 31, 7:04 pm, Hannu Vuolasaho

I can appreciate the idea of learning how something works, rather than
just a cookbook formula for making it work. I'm the same way. I am
just saying that one ought not to get too bogged down in the nitty-
gritty details prior to obtaining some practical experience --- the
essence of programming is writing programs, not tinkering with the
compiler.

BTW, I don't use CREATE DOES> at all --- that is something that can
and should be ignored entirely --- it seems complicated to you because
it is badly designed (it seems complicated to me too). CREATE DOES>
saves code memory compared to my technique, but memory is cheap these
days --- CREATE DOES> is solving a problem that hasn't been a problem
in over 20 years.

> And I have your novice package. It is good reference and has good ideas.
> However I have never used training wheels and I'm not starting now. I
> started with small motorbike :)

lol
I wouldn't really consider it to be "training wheels." I use it myself
for writing application programs!

How much customization do you really need for arrays and lists and so
forth? There are a few circumstances (mostly involving 16-bit x86
segments) in which data structures can be customized for a particular
application, but for the most part an array or list is going to be
implemented the same way for *every* application that you ever write.

That kind of low-level stuff can be written once and, assuming that it
was written in a robust manner, used repeatedly pretty much forever.
If you re-implement this stuff for every application, it will be
slightly different every time, which will hurt readability.

The data-structures in the novice package aren't a simplistic
implementation, and later on you will write an advanced implementation
yourself --- no, they are as advanced as you are ever going to get ---
the next step up is not to rewrite these basic data-structures, but
rather the next step up is to write application programs.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hugh Aguilar  
View profile  
 More options Oct 31 2012, 10:52 pm
Newsgroups: comp.lang.forth
From: Hugh Aguilar <hughaguila...@yahoo.com>
Date: Wed, 31 Oct 2012 19:52:55 -0700 (PDT)
Local: Wed, Oct 31 2012 10:52 pm
Subject: Re: How forth works?
On Oct 31, 7:04 pm, Hannu Vuolasaho

<hannu.vuolas...@nospam.tut.fi.invalid> wrote:
> I'm working on application.

Would you mind telling us what your program does? We might be able to
offer some suggestions. :-)

Also, which Forth system are you using?

BTW: Your name seems familiar --- do I remember you from the Factor
mailing list?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Elizabeth D. Rather  
View profile  
 More options Nov 1 2012, 12:33 am
Newsgroups: comp.lang.forth
From: "Elizabeth D. Rather" <erat...@forth.com>
Date: Wed, 31 Oct 2012 18:33:45 -1000
Local: Thurs, Nov 1 2012 12:33 am
Subject: Re: How forth works?
On 10/31/12 3:35 PM, Hannu Vuolasaho wrote:
...

> After reading jonesforth assembler listing implementation of IF and
> other control structures came much clearer. Also the RISC and CISC
> assembler notation had fooled me.

Watch out for jonesforth. It has many features that are different from
Standard Forth and most mainstream implementations.

As for you basic question, in addition to the links posted there are a
number of good books on Forth (I wrote two of them, but there are
others) which you can find by Googling.

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."
==================================================


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brad Eckert  
View profile  
 More options Nov 1 2012, 1:22 pm
Newsgroups: comp.lang.forth
From: Brad Eckert <hwfw...@gmail.com>
Date: Thu, 1 Nov 2012 10:22:03 -0700 (PDT)
Local: Thurs, Nov 1 2012 1:22 pm
Subject: Re: How forth works?
On Wednesday, October 31, 2012 7:43:14 PM UTC-7, Hugh Aguilar wrote:
> BTW, I don't use CREATE DOES> at all --- that is something that can
> and should be ignored entirely --- it seems complicated to you because
> it is badly designed (it seems complicated to me too). CREATE DOES>
> saves code memory compared to my technique, but memory is cheap these
> days --- CREATE DOES> is solving a problem that hasn't been a problem
> in over 20 years.

You can factor fine without CREATE DOES>. But think "make the language fit the problem", not the other way around as with other languages. Creating a custom syntax and language for your application domain is harder without DOES>.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Albert van der Horst  
View profile  
 More options Nov 1 2012, 6:24 pm
Newsgroups: comp.lang.forth
From: alb...@spenarnc.xs4all.nl (Albert van der Horst)
Date: 01 Nov 2012 22:24:24 GMT
Local: Thurs, Nov 1 2012 6:24 pm
Subject: Re: How forth works?
In article <slrnk936rg.lmg.hannu.vuolas...@haikara.cs.tut.fi>,
Hannu Vuolasaho  <hannu.vuolas...@nospam.tut.fi.invalid> wrote:

You can get an idea from how INTERPRET and QUIT work using SEE.
This is most helpful with the most simple and primitive Forth's.
(E.g. it would with lina, if the decompiler would reconstruct
BEGIN's and IF's instead of primitive branching.)
Alternatively some Forth's are written in Forth (metacompilation).
The source for the Launchpad is available. This too is a simple
Forth. Google for ``noforth''.

>--
>Hannu Vuolasaho

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

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Knaggs  
View profile  
 More options Nov 7 2012, 5:28 am
Newsgroups: comp.lang.forth
From: Peter Knaggs <p...@bcs.org.uk>
Date: Wed, 7 Nov 2012 10:28:04 +0000 (UTC)
Local: Wed, Nov 7 2012 5:28 am
Subject: Re: How forth works?

http://dec.bournemouth.ac.uk/forth/forth.html

I was written as an introduction to forth for my thesis, but it never made
it into the final document.  An forth underview goes into some detail about
the implementation techniques used.

--
Peter Knaggs


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »