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

Gforth-EC, the underappreciated embedded Forth

303 views
Skip to first unread message

David Kuehling

unread,
Feb 6, 2012, 5:07:36 PM2/6/12
to
Hi,

I've been having a look at Gforth-EC lately, that's the embedded
cross-compiled Forth support that has been included with Gforth all the
time, but as it's well hidden and pretty undocumented, I guess most
people wouldn't have noticed it.

Now it turns out it only takes a few commands to generate a usable 8086
gforth-ec executable, running in dosbox (i.e. emulated under Linux):

From the Gforth source directory, run:

./build-ec 8086
mv kernl-8086.fi gforthec.com # need to rename for dosbox to execute it
dosbox gforthec.com

And voila, it prints the standard Gforth welcome message. Some testing:

here . 14334 ok
unused u. 47162 ok
words
[..]
dup lit branch >r r> c! c@ (emit) (key) lastkey and xor + rp!
rp@ sp! sp@ ! @ ?branch execute ;s ok

More Forth-code to cross-compile can be added in arch/8086/prims.fs.

Now 8086 code isn't really very interesting to most modern computer
users, but 8086 isn't the only architecture supported by gforth-ec. I
can successfully run build-ec for 8086, r8c and misc. Other targets
that seem to have been supported at some time are m68k, shboom, 6502,
c165 and 4stack, but with current Gforth-CVS compilation fails for
those.

Adding support for new target is not too difficult. Currently I'm
trying to make it work for the LatticeMico32 CPU (the Milkymist SoC).

cheers,

David
--
GnuPG public key: http://dvdkhlng.users.sourceforge.net/dk.gpg
Fingerprint: B17A DC95 D293 657B 4205 D016 7DEF 5323 C174 7D40

Albert van der Horst

unread,
Feb 7, 2012, 11:07:47 AM2/7/12
to
In article <87fwen6...@snail.Pool>,
David Kuehling <dvdk...@gmx.de> wrote:
>Hi,
>
>I've been having a look at Gforth-EC lately, that's the embedded
>cross-compiled Forth support that has been included with Gforth all the
>time, but as it's well hidden and pretty undocumented, I guess most
>people wouldn't have noticed it.
>
>Now it turns out it only takes a few commands to generate a usable 8086
>gforth-ec executable, running in dosbox (i.e. emulated under Linux):
>
>From the Gforth source directory, run:
>
>./build-ec 8086
>mv kernl-8086.fi gforthec.com # need to rename for dosbox to execute it
>dosbox gforthec.com

Slightly surprising. I expect a Forth only to run on a dosbox if
it does INT 21 io. I expect an embedded Forth to work independant
from MSDOS INT 21 stuff.

>
>And voila, it prints the standard Gforth welcome message. Some testing:
>
>here . 14334 ok
>unused u. 47162 ok
>words
>[..]

<SNIP>
>David
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

BruceMcF

unread,
Feb 7, 2012, 10:51:49 AM2/7/12
to
On Feb 7, 11:07 am, Albert van der Horst <alb...@spenarnc.xs4all.nl>
wrote:
> Slightly surprising. I expect a Forth only to run on a dosbox if
> it does INT 21 io.  I expect an embedded Forth to work independant
> from MSDOS INT 21 stuff.

But there is no single standard way for an embedded '86 system to do
IO. Embedded msdos compatible boards are certainly not unknown, and a
dosbox is convenient as a sandbox for testing on a Linux system, so
its not surprising that an embedded '86 Forth would have msdos IO as
the shipping system. Certainly whoever is using it on a board other
than an embedded msdos board would replace that with IO appropriate to
their board.

David Kuehling

unread,
Feb 7, 2012, 10:55:56 AM2/7/12
to
>>>>> "Albert" == Albert van der Horst <alb...@spenarnc.xs4all.nl> writes:

> In article <87fwen6...@snail.Pool>,
> David Kuehling <dvdk...@gmx.de> wrote:
>> Hi,
>>
>> I've been having a look at Gforth-EC lately, that's the embedded
>> cross-compiled Forth support that has been included with Gforth all
>> the time, but as it's well hidden and pretty undocumented, I guess
>> most people wouldn't have noticed it.
>>
>> Now it turns out it only takes a few commands to generate a usable
>> 8086 gforth-ec executable, running in dosbox (i.e. emulated under
>> Linux):
>>
>> From the Gforth source directory, run:
>>
>> ./build-ec 8086 mv kernl-8086.fi gforthec.com # need to rename for
>> dosbox to execute it dosbox gforthec.com

> Slightly surprising. I expect a Forth only to run on a dosbox if it
> does INT 21 io. I expect an embedded Forth to work independant from
> MSDOS INT 21 stuff.

It does use int 21 io, see definition of (emit) &friends in [1]. The
nice thing is that this is really completely compiled&assembled from
forth. No binutils, GCC etc. involved.

cheers,

David

[1] http://www.complang.tuwien.ac.at/cvsweb/cgi-bin/cvsweb/gforth/arch/8086/prim.fs?rev=1.6;content-type=text%2Fplain

Coos Haak

unread,
Feb 7, 2012, 7:30:08 PM2/7/12
to
Op Mon, 06 Feb 2012 23:07:36 +0100 schreef David Kuehling:

> Hi,
>
> I've been having a look at Gforth-EC lately, that's the embedded
> cross-compiled Forth support that has been included with Gforth all the
> time, but as it's well hidden and pretty undocumented, I guess most
> people wouldn't have noticed it.
>
> Now it turns out it only takes a few commands to generate a usable 8086
> gforth-ec executable, running in dosbox (i.e. emulated under Linux):
>
> From the Gforth source directory, run:
>
> ./build-ec 8086
> mv kernl-8086.fi gforthec.com # need to rename for dosbox to execute it
> dosbox gforthec.com
>
> And voila, it prints the standard Gforth welcome message. Some testing:
>
What version of Gforth are you using, I get:

coos@donald:~/work/forth/gforth-0.7.0$ ./build-ec 8086

in file included from *OS command line*:-1
in file included from kernel/main.fs:43
cross.fs:1156: No such file or directory
[IF] >>>included<<< hex
Backtrace:
$9C5D6C throw
cp: kan status van ‘kernl-8086.fi-’ niet opvragen: Bestand of map bestaat
niet

--
Coos

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

David Kuehling

unread,
Feb 8, 2012, 3:52:16 AM2/8/12
to
Ah, this could be caused by missing installation step. Try 'sudo make
install' first.

BTW I'm using the latest GForth from CVS. Try

cvs -d :pserver:anon...@c1.complang.tuwien.ac.at:/nfs/unsafe/cvs-repository/src-master co gforth
cd gforth
./BUILD-FROM-SCRATCH
sudo make install
./build-ec 8086

David Kuehling

unread,
Feb 9, 2012, 7:45:31 PM2/9/12
to
>>>>> "Coos" == Coos Haak <chf...@hccnet.nl> writes:

> Op Mon, 06 Feb 2012 23:07:36 +0100 schreef David Kuehling:
[..]
>> From the Gforth source directory, run:
>>
>> ./build-ec 8086 mv kernl-8086.fi gforthec.com # need to rename for
>> dosbox to execute it dosbox gforthec.com
>>
>> And voila, it prints the standard Gforth welcome message. Some
>> testing:
>>
> What version of Gforth are you using, I get:

> coos@donald:~/work/forth/gforth-0.7.0$ ./build-ec 8086

> in file included from *OS command line*:-1 in file included from
> kernel/main.fs:43 cross.fs:1156: No such file or directory [IF]
> >>>included<<< hex Backtrace: $9C5D6C throw cp: kan status van
> ‘kernl-8086.fi-’ niet opvragen: Bestand of map bestaat niet

Right, the arch/8086 directory is not included in Gforth's distribution
tarballs. Here's a current snapshot tarball that has it:

http://downloads.qi-hardware.com/people/dvdkhlng/gforth-0.7.9-20120210.tar.gz

(this also fixes building of the c165 gforth-ec target, btw)
0 new messages