Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #51350 > unrolled thread

Forth implementation in pure Forth?

Started byAlex Dowad <alexinbeijing@gmail.com>
First post2016-09-26 18:54 -0700
Last post2016-09-28 07:59 +0100
Articles 20 on this page of 29 — 16 participants

Back to article view | Back to comp.lang.forth


Contents

  Forth implementation in pure Forth? Alex Dowad <alexinbeijing@gmail.com> - 2016-09-26 18:54 -0700
    Re: Forth implementation in pure Forth? Michael Barry <barrym95838@yahoo.com> - 2016-09-26 20:20 -0700
    Re: Forth implementation in pure Forth? Paul Rubin <no.email@nospam.invalid> - 2016-09-26 21:37 -0700
      Re: Forth implementation in pure Forth? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-27 08:27 +0200
        Re: Forth implementation in pure Forth? Cecil Bayona <cbayona@cbayona.com> - 2016-09-27 02:22 -0500
        Re: Forth implementation in pure Forth? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-27 14:22 +0200
          Re: Forth implementation in pure Forth? Alex Dowad <alexinbeijing@gmail.com> - 2016-09-27 05:42 -0700
            Re: Forth implementation in pure Forth? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-27 15:23 +0200
              Re: Forth implementation in pure Forth? rickman <gnuarm@gmail.com> - 2016-09-28 11:13 -0400
            Re: Forth implementation in pure Forth? Alex <alex@rivadpm.com> - 2016-09-27 14:25 +0100
              Re: Forth implementation in pure Forth? Alex <alex@rivadpm.com> - 2016-09-27 14:27 +0100
        Re: Forth implementation in pure Forth? Alex Dowad <alexinbeijing@gmail.com> - 2016-09-27 05:40 -0700
          Re: Forth implementation in pure Forth? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-27 15:47 +0200
          Re: Forth implementation in pure Forth? hughaguilar96@gmail.com - 2016-09-27 11:43 -0700
            Re: Forth implementation in pure Forth? Jan Coombs <jenfhaomndgfwutc@murmic.plus.com> - 2016-09-27 21:51 +0100
              Re: Forth implementation in pure Forth? Cecil Bayona <cbayona@cbayona.com> - 2016-09-27 16:04 -0500
      Re: Forth implementation in pure Forth? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-26 21:10 -1000
    Re: Forth implementation in pure Forth? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-27 14:18 +0200
    Re: Forth implementation in pure Forth? stephen@mpeforth.com (Stephen Pelc) - 2016-09-27 12:12 +0000
    Re: Forth implementation in pure Forth? Rod Pemberton <NoHaveNotOne@zxdehrnyya.cam> - 2016-09-27 21:04 -0400
      Re: Forth implementation in pure Forth? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-28 10:57 +0200
        Re: Forth implementation in pure Forth? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-27 23:19 -1000
          Re: Forth implementation in pure Forth? rickman <gnuarm@gmail.com> - 2016-09-28 11:42 -0400
        Re: Forth implementation in pure Forth? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-28 04:51 -0500
        Re: Forth implementation in pure Forth? Alex Dowad <alexinbeijing@gmail.com> - 2016-09-28 03:41 -0700
          Re: Forth implementation in pure Forth? Alex Dowad <alexinbeijing@gmail.com> - 2016-09-28 03:51 -0700
          Re: Forth implementation in pure Forth? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-09-28 20:42 +0100
    Re: Forth implementation in pure Forth? Chris Curl <ccurl609@gmail.com> - 2016-09-27 20:40 -0700
    Re: Forth implementation in pure Forth? Jan Coombs <jenfhaomndgfwutc@murmic.plus.com> - 2016-09-28 07:59 +0100

Page 1 of 2  [1] 2  Next page →


#51350 — Forth implementation in pure Forth?

FromAlex Dowad <alexinbeijing@gmail.com>
Date2016-09-26 18:54 -0700
SubjectForth implementation in pure Forth?
Message-ID<874b78c5-4f2d-4485-851d-2095e710f615@googlegroups.com>
Greetings all,

A Google search reveals many free Forths written in C, assembler, Java, etc. But none written in Forth itself. Does anybody have one available?

If your answer is "write one yourself"... well, I've written several, but would like to compare.

Thanks, AD

[toc] | [next] | [standalone]


#51352

FromMichael Barry <barrym95838@yahoo.com>
Date2016-09-26 20:20 -0700
Message-ID<b03982d1-1989-4b7e-bd32-7b7f1786cfbe@googlegroups.com>
In reply to#51350
On Monday, September 26, 2016 at 6:54:38 PM UTC-7, Alex Dowad wrote:
> Greetings all,
> 
> A Google search reveals many free Forths written in C, assembler, Java, etc. But none written in Forth itself. Does anybody have one available?
> 
> If your answer is "write one yourself"... well, I've written several, but would like to compare.
> 
> Thanks, AD

Something like this (I might not have understood your request)?

http://www.camelforth.com/download.php?view.4

Mike B.

[toc] | [prev] | [next] | [standalone]


#51355

FromPaul Rubin <no.email@nospam.invalid>
Date2016-09-26 21:37 -0700
Message-ID<87shsm6jre.fsf@jester.gateway.pace.com>
In reply to#51350
Alex Dowad <alexinbeijing@gmail.com> writes:
> But none written in Forth itself. Does anybody have one available?

That's the usual way to do it, I thought.  eForth is a good readable
example that's not too fancy.  Look also at Brad Rodriguez's web
pages about Forth implementation.

[toc] | [prev] | [next] | [standalone]


#51361

FromLars Brinkhoff <lars.spam@nocrew.org>
Date2016-09-27 08:27 +0200
Message-ID<86intheu1z.fsf@molnjunk.nocrew.org>
In reply to#51355
Paul Rubin wrote:
> Alex Dowad wrote:
>> But none written in Forth itself. Does anybody have one available?
> That's the usual way to do it, I thought.

Depends on what you mean.  Maybe Alex wanted a Forth implemented with
only high-level Forth, and no assembler CODE words.  I think I saw one
of those once.

[toc] | [prev] | [next] | [standalone]


#51364

FromCecil Bayona <cbayona@cbayona.com>
Date2016-09-27 02:22 -0500
Message-ID<nsd6mi$ksj$1@dont-email.me>
In reply to#51361

On 9/27/2016 1:27 AM, Lars Brinkhoff wrote:
> Paul Rubin wrote:
>> Alex Dowad wrote:
>>> But none written in Forth itself. Does anybody have one available?
>> That's the usual way to do it, I thought.
>
> Depends on what you mean.  Maybe Alex wanted a Forth implemented with
> only high-level Forth, and no assembler CODE words.  I think I saw one
> of those once.
>
There are versions of eForth for the ep16 and ep32 FPGA CPUs and it's 
all Forth, the trick is those two processors the native code is Forth.

It's late here and I'm tired, but I do remember seeing several Forth 
that were written in Forth, you used a Meta-compiler to create a working 
version. Pygmy is one that comes to mind, it has assembler primitives 
but they are words compiled by the Pygmy meta-compiler so its all Forth 
no external assembler of C compiler is used, only Pygmy itself..
-- 
Cecil - k5nwa

[toc] | [prev] | [next] | [standalone]


#51376

Fromalbert@cherry.spenarnc.xs4all.nl (Albert van der Horst)
Date2016-09-27 14:22 +0200
Message-ID<nsdo9g$iis$1@cherry.spenarnc.xs4all.nl>
In reply to#51361
In article <86intheu1z.fsf@molnjunk.nocrew.org>,
Lars Brinkhoff  <lars.spam@nocrew.org> wrote:
>Paul Rubin wrote:
>> Alex Dowad wrote:
>>> But none written in Forth itself. Does anybody have one available?
>> That's the usual way to do it, I thought.
>
>Depends on what you mean.  Maybe Alex wanted a Forth implemented with
>only high-level Forth, and no assembler CODE words.  I think I saw one
>of those once.

And of course that is straight impossible.
Unless you consider Chuck Moores
CODE + 58 C, 5B C, 48 C, 1 C, D8 C, 50 C, 48 C, AD C, FF C, 20 C, END-CODE
a good idea.

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

[toc] | [prev] | [next] | [standalone]


#51379

FromAlex Dowad <alexinbeijing@gmail.com>
Date2016-09-27 05:42 -0700
Message-ID<d1894ddb-ce19-4aa5-bdba-d09dbb6f974f@googlegroups.com>
In reply to#51376
On Tuesday, 27 September 2016 21:13:43 UTC+9, Albert van der Horst  wrote:
> In article <86intheu1z.fsf@molnjunk.nocrew.org>,
> Lars Brinkhoff  <lars.spam@nocrew.org> wrote:
> >Paul Rubin wrote:
> >> Alex Dowad wrote:
> >>> But none written in Forth itself. Does anybody have one available?
> >> That's the usual way to do it, I thought.
> >
> >Depends on what you mean.  Maybe Alex wanted a Forth implemented with
> >only high-level Forth, and no assembler CODE words.  I think I saw one
> >of those once.
> 
> And of course that is straight impossible.

Of course it's possible. Forth is Turing-complete, so you can write a Forth interpreter/compiler in Forth.

You do need a separate Forth interpreter/compiler to run it on; that is a given.

[toc] | [prev] | [next] | [standalone]


#51382

Fromalbert@cherry.spenarnc.xs4all.nl (Albert van der Horst)
Date2016-09-27 15:23 +0200
Message-ID<nsdrsg$ivn$1@cherry.spenarnc.xs4all.nl>
In reply to#51379
In article <d1894ddb-ce19-4aa5-bdba-d09dbb6f974f@googlegroups.com>,
Alex Dowad  <alexinbeijing@gmail.com> wrote:
>On Tuesday, 27 September 2016 21:13:43 UTC+9, Albert van der Horst  wrote:
>> In article <86intheu1z.fsf@molnjunk.nocrew.org>,
>> Lars Brinkhoff  <lars.spam@nocrew.org> wrote:
>> >Paul Rubin wrote:
>> >> Alex Dowad wrote:
>> >>> But none written in Forth itself. Does anybody have one available?
>> >> That's the usual way to do it, I thought.
>> >
>> >Depends on what you mean.  Maybe Alex wanted a Forth implemented with
>> >only high-level Forth, and no assembler CODE words.  I think I saw one
>> >of those once.
>>
>> And of course that is straight impossible.
>
>Of course it's possible. Forth is Turing-complete, so you can write a Forth interpreter/compiler in Forth.
>
>You do need a separate Forth interpreter/compiler to run it on; that is a given.

That is trivial. You don't need to implement anything in your
compilation system if it already understands Forth.
Why do you summon the ghost of Turing?

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

[toc] | [prev] | [next] | [standalone]


#51440

Fromrickman <gnuarm@gmail.com>
Date2016-09-28 11:13 -0400
Message-ID<nsgmn4$ln4$1@dont-email.me>
In reply to#51382
On 9/27/2016 9:23 AM, Albert van der Horst wrote:
> In article <d1894ddb-ce19-4aa5-bdba-d09dbb6f974f@googlegroups.com>,
> Alex Dowad  <alexinbeijing@gmail.com> wrote:
>> On Tuesday, 27 September 2016 21:13:43 UTC+9, Albert van der Horst  wrote:
>>> In article <86intheu1z.fsf@molnjunk.nocrew.org>,
>>> Lars Brinkhoff  <lars.spam@nocrew.org> wrote:
>>>> Paul Rubin wrote:
>>>>> Alex Dowad wrote:
>>>>>> But none written in Forth itself. Does anybody have one available?
>>>>> That's the usual way to do it, I thought.
>>>>
>>>> Depends on what you mean.  Maybe Alex wanted a Forth implemented with
>>>> only high-level Forth, and no assembler CODE words.  I think I saw one
>>>> of those once.
>>>
>>> And of course that is straight impossible.
>>
>> Of course it's possible. Forth is Turing-complete, so you can write a Forth interpreter/compiler in Forth.
>>
>> You do need a separate Forth interpreter/compiler to run it on; that is a given.
>
> That is trivial. You don't need to implement anything in your
> compilation system if it already understands Forth.
> Why do you summon the ghost of Turing?

I believe the idea is to run the Forth defined in Forth on a host system 
to produce a Forth system for the target.  Isn't that just cross compiling?

-- 

Rick C

[toc] | [prev] | [next] | [standalone]


#51384

FromAlex <alex@rivadpm.com>
Date2016-09-27 14:25 +0100
Message-ID<nsdrvi$qii$1@dont-email.me>
In reply to#51379
On 27/09/16 13:42, Alex Dowad wrote:
> On Tuesday, 27 September 2016 21:13:43 UTC+9, Albert van der Horst  wrote:
>> In article <86intheu1z.fsf@molnjunk.nocrew.org>,
>> Lars Brinkhoff  <lars.spam@nocrew.org> wrote:
>>> Paul Rubin wrote:
>>>> Alex Dowad wrote:
>>>>> But none written in Forth itself. Does anybody have one available?
>>>> That's the usual way to do it, I thought.
>>>
>>> Depends on what you mean.  Maybe Alex wanted a Forth implemented with
>>> only high-level Forth, and no assembler CODE words.  I think I saw one
>>> of those once.
>>
>> And of course that is straight impossible.
>
> Of course it's possible. Forth is Turing-complete, so you can write a Forth interpreter/compiler in Forth.
>
> You do need a separate Forth interpreter/compiler to run it on; that is a given.
>

Well, this:

ALSO MYFORTH DEFINITIONS PREVIOUS
: DUP DUP ;
: SWAP SWAP ;
: FLEA FLEA ;

is the ultimate in Forth on Forth. And yes, there are Forth's that have 
code like this*, because : defines DUP in my new Forth's dictionary 
MYFORTH, and uses the source system's DUP to do the heavy lifting. The 
process is called metacompilation.

* Win32Forth is an example. Version N-1 of Win32Forth is used to build 
version N. The code is now so far removed from the original version 0 
that it's not possible to compile version N with all prior versions; 
just those close enough to the current version.

No assembler is required either, if the source system and the target are 
the same; we can copy the code for DUP from the source to the target 
system without needing to understand what machine code it consists of.

-- 
Alex

[toc] | [prev] | [next] | [standalone]


#51385

FromAlex <alex@rivadpm.com>
Date2016-09-27 14:27 +0100
Message-ID<nsds3i$qii$2@dont-email.me>
In reply to#51384
On 27/09/16 14:25, Alex wrote:
> On 27/09/16 13:42, Alex Dowad wrote:
>> On Tuesday, 27 September 2016 21:13:43 UTC+9, Albert van der Horst
>> wrote:
>>> In article <86intheu1z.fsf@molnjunk.nocrew.org>,
>>> Lars Brinkhoff  <lars.spam@nocrew.org> wrote:
>>>> Paul Rubin wrote:
>>>>> Alex Dowad wrote:
>>>>>> But none written in Forth itself. Does anybody have one available?
>>>>> That's the usual way to do it, I thought.
>>>>
>>>> Depends on what you mean.  Maybe Alex wanted a Forth implemented with
>>>> only high-level Forth, and no assembler CODE words.  I think I saw one
>>>> of those once.
>>>
>>> And of course that is straight impossible.
>>
>> Of course it's possible. Forth is Turing-complete, so you can write a
>> Forth interpreter/compiler in Forth.
>>
>> You do need a separate Forth interpreter/compiler to run it on; that
>> is a given.
>>
>
> Well, this:
>
> ALSO MYFORTH DEFINITIONS PREVIOUS
> : DUP DUP ;
> : SWAP SWAP ;
> : FLEA FLEA ;

Or, alternatively;

: DUP ['] DUP COMPILE, ;

etc

>
> is the ultimate in Forth on Forth. And yes, there are Forth's that have
> code like this*, because : defines DUP in my new Forth's dictionary
> MYFORTH, and uses the source system's DUP to do the heavy lifting. The
> process is called metacompilation.
>
> * Win32Forth is an example. Version N-1 of Win32Forth is used to build
> version N. The code is now so far removed from the original version 0
> that it's not possible to compile version N with all prior versions;
> just those close enough to the current version.
>
> No assembler is required either, if the source system and the target are
> the same; we can copy the code for DUP from the source to the target
> system without needing to understand what machine code it consists of.
>


-- 
Alex

[toc] | [prev] | [next] | [standalone]


#51378

FromAlex Dowad <alexinbeijing@gmail.com>
Date2016-09-27 05:40 -0700
Message-ID<9935759f-8bdc-4291-9ba2-4efdcc3d8c98@googlegroups.com>
In reply to#51361
On Tuesday, 27 September 2016 15:31:06 UTC+9, Lars Brinkhoff  wrote:
> Paul Rubin wrote:
> > Alex Dowad wrote:
> >> But none written in Forth itself. Does anybody have one available?
> > That's the usual way to do it, I thought.
> 
> Depends on what you mean.  Maybe Alex wanted a Forth implemented with
> only high-level Forth, and no assembler CODE words.  I think I saw one
> of those once.

A Forth implemented in only high-level Forth (no assembler) is exactly what I am looking for. Sorry for not specifying that.

[toc] | [prev] | [next] | [standalone]


#51386

FromLars Brinkhoff <lars.spam@nocrew.org>
Date2016-09-27 15:47 +0200
Message-ID<86zimtcv41.fsf@molnjunk.nocrew.org>
In reply to#51378
Alex Dowad <alexinbeijing@gmail.com> writes:
> A Forth implemented in only high-level Forth (no assembler) is exactly
> what I am looking for. Sorry for not specifying that.

I went looking for one, but of course it's impossible to google for
anything Forth.  I seem to recall there was one written as an
educational tool.

I did something vaguely like that not long ago.  It was an
implementation of a 16-bit Forth inside top of a 32- or 64-bit Forth.
It's on GitHub.

[toc] | [prev] | [next] | [standalone]


#51396

Fromhughaguilar96@gmail.com
Date2016-09-27 11:43 -0700
Message-ID<f73521ee-6a98-451d-a23a-f26aee5d12ec@googlegroups.com>
In reply to#51378
On Tuesday, September 27, 2016 at 5:40:25 AM UTC-7, Alex Dowad wrote:
> On Tuesday, 27 September 2016 15:31:06 UTC+9, Lars Brinkhoff  wrote:
> > Paul Rubin wrote:
> > > Alex Dowad wrote:
> > >> But none written in Forth itself. Does anybody have one available?
> > > That's the usual way to do it, I thought.
> > 
> > Depends on what you mean.  Maybe Alex wanted a Forth implemented with
> > only high-level Forth, and no assembler CODE words.  I think I saw one
> > of those once.
> 
> A Forth implemented in only high-level Forth (no assembler) is exactly what I am looking for. Sorry for not specifying that.

All Forths involve assembler, because machine-code is how processors do stuff, and assemblers are needed to produce machine-code. In many cases the assembler is written in Forth though, which would seem to satisfy your "only high-level Forth" criteria. My MFX was like this (it was a new processor, so there was no assembler available from the chip-maker; I was employed by the chip-maker and writing the development system for the chip was my job).

In other cases, the primitives are written in a traditional assembler. This is typical for threaded systems. My Straight Forth is like this (it is ITC and I use FASM) --- I'm mostly doing this because the VFX assembler is limited to 32-bit, and I need 64-bit --- Straight Forth may be upgraded to STC in the future though.

Why are you asking this? What difference does it make? My read on this is that you are trying to prove that Forth is a toy language that can only be implemented in C (like Lua, except without any support for general-purpose data-structures) --- Rod Pemberton says: "C is the god language" --- is that your agenda here?

[toc] | [prev] | [next] | [standalone]


#51405

FromJan Coombs <jenfhaomndgfwutc@murmic.plus.com>
Date2016-09-27 21:51 +0100
Message-ID<20160927215126.18798892@HP-6550b>
In reply to#51396
On Tue, 27 Sep 2016 11:43:28 -0700 (PDT)
hughaguilar96@gmail.com wrote:

> On Tuesday, September 27, 2016 at 5:40:25 AM UTC-7, Alex Dowad
> wrote:

> > A Forth implemented in only high-level Forth (no assembler)
> > is exactly what I am looking for. Sorry for not specifying
> > that.
> 
> All Forths involve assembler, ...

I only needed 2'30" of therapy after reading that:

https://youtu.be/hnTmBjk-M0c

Jan Coombs

[toc] | [prev] | [next] | [standalone]


#51406

FromCecil Bayona <cbayona@cbayona.com>
Date2016-09-27 16:04 -0500
Message-ID<nsemt3$2od$1@dont-email.me>
In reply to#51405

On 9/27/2016 3:51 PM, Jan Coombs wrote:
> On Tue, 27 Sep 2016 11:43:28 -0700 (PDT)
> hughaguilar96@gmail.com wrote:
>
>> On Tuesday, September 27, 2016 at 5:40:25 AM UTC-7, Alex Dowad
>> wrote:
>
>>> A Forth implemented in only high-level Forth (no assembler)
>>> is exactly what I am looking for. Sorry for not specifying
>>> that.
>>
>> All Forths involve assembler, ...
>
> I only needed 2'30" of therapy after reading that:
>
> https://youtu.be/hnTmBjk-M0c
>
> Jan Coombs
>

I needed that too, thanks.

I mentioned before eForth for the ep16 and 1p32 processors is all Forth 
since the PC executes forth instructions. All Forth all the time.


-- 
Cecil - k5nwa

[toc] | [prev] | [next] | [standalone]


#51363

From"Elizabeth D. Rather" <erather@forth.com>
Date2016-09-26 21:10 -1000
Message-ID<xJOdnRTzSaXohnfKnZ2dnUU7-S3NnZ2d@supernews.com>
In reply to#51355
On 9/26/16 6:37 PM, Paul Rubin wrote:
> Alex Dowad <alexinbeijing@gmail.com> writes:
>> But none written in Forth itself. Does anybody have one available?
>
> That's the usual way to do it, I thought.  eForth is a good readable
> example that's not too fancy.  Look also at Brad Rodriguez's web
> pages about Forth implementation.
>

Depends on what you mean by "written in Forth." FORTH, Inc. has not used 
any compiler or assembler that was not written in Forth since 1971. We 
use a meta-compiler with an assmebler (written in Forth) for the new 
target to generate the first kernel for a new target.

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

[toc] | [prev] | [next] | [standalone]


#51373

Fromalbert@cherry.spenarnc.xs4all.nl (Albert van der Horst)
Date2016-09-27 14:18 +0200
Message-ID<nsdo32$ihd$1@cherry.spenarnc.xs4all.nl>
In reply to#51350
In article <874b78c5-4f2d-4485-851d-2095e710f615@googlegroups.com>,
Alex Dowad  <alexinbeijing@gmail.com> wrote:
>Greetings all,
>
>A Google search reveals many free Forths written in C, assembler, Java, etc. But none written in Forth itself. Does anybody have one available?

That is because for some reason one uses the name meta-compilation.
for Forth written in Forth.

>
>If your answer is "write one yourself"... well, I've written several, but would like to compare.
>
>Thanks, AD
-- 
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

[toc] | [prev] | [next] | [standalone]


#51374

Fromstephen@mpeforth.com (Stephen Pelc)
Date2016-09-27 12:12 +0000
Message-ID<57ea60c1.680869670@news.eternal-september.org>
In reply to#51350
On Mon, 26 Sep 2016 18:54:37 -0700 (PDT), Alex Dowad
<alexinbeijing@gmail.com> wrote:

>A Google search reveals many free Forths written in C, assembler,
>Java, etc. But none written in Forth itself. Does anybody have one
>available?

A free (beer) Forth and cross compiler can be found in the MPE
MSP430 and ARM Cortex Lite compilers. See:
  http://www.mpeforth.com

Stephen

-- 
Stephen Pelc, stephenXXX@mpeforth.com
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: http://www.mpeforth.com - free VFX Forth downloads

[toc] | [prev] | [next] | [standalone]


#51412

FromRod Pemberton <NoHaveNotOne@zxdehrnyya.cam>
Date2016-09-27 21:04 -0400
Message-ID<20160927210406.432a22dc@_>
In reply to#51350
On Mon, 26 Sep 2016 18:54:37 -0700 (PDT)
Alex Dowad <alexinbeijing@gmail.com> wrote:

> A Google search reveals many free Forths written in C, assembler,
> Java, etc. But none written in Forth itself. Does anybody have one
> available?
> 
> If your answer is "write one yourself"... well, I've written several,
> but would like to compare.
> 

This idea of "Forth in Forth" should be a FAQ, well, technically, it'd
be a FEC (frequently explained concept).

The best that most seem to be able to do is to write a Forth mostly in
Forth, but not completely.  Such Forths usually use threaded-code (DTC
or ITC).  They don't compile Forth directly to machine language like
modern Forths do.  The threaded-code Forths are able to eliminate all
but a handful of Forth words which must be coded in another language.
These words are mostly low-level words that do the work.  They're
usually referred to as "primitives".  These can vary from a minimum of
around 9 or so and up to 72 or more.  General "consensus" is that you
need around 35 primitives.  Fewer than that and the threaded-code Forth
becomes too slow.  The reason that you need primitives for
threaded-code Forths is that threaded-code colon-definitions only store
the sequence of operations as an address list.  The colon-definitions
don't do any actual work in a threaded interpreter.  They just group
Forth words (or instructions) together.  So, you must have some Forth
words that do some actual work, i.e., some which aren't coded in
high-level Forth.  These are coded in another language, which must be
compiled to machine language, e.g., using assembly or C etc.

eForth by Bill Muench was one of the first to attempt to write a Forth
using only a small set of primitives.

From what I've seen, I'd say that the typical threaded-code Forth
interpreter is usually built up this way:

1) inner or address interpreter  (coded in assembly or C etc)
2) 35 primitives  (varies from 9 to 72, also in assembly or C etc)
3) outer or text interpreter  (pre-compiled threaded-code Forth, also
coded in assembly or C)
4) remainder of dictionary words in high-level (text) Forth

The inner or address interpreter is coded in assembly or C etc and
compiled to machine language.  Next, a bunch of low-level Forth words
called "primitives" which do basic work are coded.  Then, the outer or
text interpreter is coded using the primitives.  This is pre-compiled
Forth code or an address list since the outer or text interpreter,
dictionary, and colon-definitions aren't implemented at this point.
Next, some related words are needed to compile words, and some
bootstrap words may also be needed.  Finally, the other Forth words can
be coded in high-level Forth.  You can also create more complete
versions of built-in Forth words now by using high-level Forth.


eForth
http://www.forth.org/eforth.html

Forths
https://www.taygeta.com/forthcomp.html

Itsy
http://www.retroprogramming.com/2012/09/itsy-documenting-bit-twiddling-voodoo.html

JonesForth
http://git.annexia.org/?p=jonesforth.git;a=tree;hb=HEAD

An old post of mine with the quantity of primitives per various Forths:
https://groups.google.com/d/msg/comp.lang.forth/KHw28PKZXUk/JrXcjrYshxAJ
(Usenet msg id g4gqv4$qk9$1@aioe.org)


Rod Pemberton

P.S.  Please remind Hugh that some C compilers can produce machine-code
directly without using assembly.
P.P.S.  Please remind Hugh that Bradford Rodriguez, PhD, of "Moving
Forth" fame, also recognizes that Forth in C has advantages.  See "Part
4: Assemble or Metacompile?" at bottom.

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.forth


csiph-web