GOPHERSPACE.DE - P H O X Y
gophering on sdf.org
                         Forth Notebook

Learning Forth

I  started  learning Forth by reading Starting Forth[1] and doing
the most of the exercises in each chapter.  I downloaded and  in-
stalled  Gforth[2] on my Debian machine.  There were a few places
in Starting Forth where the exercise didn't line up with the  be-
havior of Gforth, especially around double-length numbers.  Where
Starting forth would suggest entering a double-length  number  by
including  a  comma  or period, Gforth would give me an error.  I
found that it was best to enter a number followed by a zero  when
using words that operated on double-length numbers.

I  also  installed  pForth[3] and spent some time with the pForth
tutorial[4].  pForth didn't include some things,  like  M*/,  and
the behavior of some words was different from gforth.

I subscribed to the Gforth mailing list[5].  I also started lurk-
ing in the #forth channel on Freenode.  A lot of  the  discussion
in  there  is  about  implementing  Forth itself, not necessarily
writing programs in forth.  I also subscribed to the  Forth  sub-
reddit[6].

After  reading the math-centric tutorials above, watching a video
about text processing in forth by Andreas Wagner[7] was  an  eye-
opener.

Thinking  Forth by Leo Brodie[8] is also recommended as an impor-
tant text for aspiring forthwrights, but I haven't read it, yet.

Some more forth links:

  +o theForth.net[9] - Package manager and repository for Forth. I
    understand this targets Gforth.

  +o The Evolution of Forth[10]

  +o Forth on a DIP[11]

  +o A Beginner's Guide to Forth by J.V. Noble[12]

  +o Forth Lessons[13]

Embedded Forth

Forth  lends itself to embedded environments.  There are a number
of embedded forth environments available.   The  one  that  seems
most  interesting to me is mecrisp[14] by Matthias Koch.  Mecrisp
targets TI MSP430[15] microcontrollers.  Mecrisp-Stellaris[16] is
a  distribution  of  Mecrisp that includes support for additional
MCs, the STM32 family, in particular.  I believe Terry Porter has
mentioned  that  he often uses an STM32F0 Discovery board[17] for
prototyping.  Terry Porter's YouTube Channel[18] includes a  num-
ber of short but interesting videos demonstrating his development
method.  0033mer's YouTube Channel[19] also includes some  videos
on using Mecrisp-Stellaris.

The  more  I  read  about  development using Mecrisp, the more it
seemed I would have a lot of work to do to integrate with periph-
erals  like  input  and  output devices and mass storage.  Having
even a minimal GNU/Linux  environment  (with  a  network  stack!)
would cut out a lot of that work, though at the cost of some min-
imalist  cach.   All  is  not  lost,  however,  because   wiring-
Pi_gforth[20]  provides  an interface to the GPIO pins on a Rasp-
berry Pi from within Gforth.

So, I could implement my first version of the event logger  using
Perl  on  a  Pi  Zero, (using Steve Bertrand's RPi::WiringPi[21])
then in gforth on the same device and, later, port the forth  ap-
plication  to  Mecrisp-Stellaris on an STM32.  Another article on
Accessing GPIO pins from gforth[22].  I also looked  pretty  hard
at the STM32F303 Nucleo board.

More MC Forth links:

  +o The Mite[23] - A 65C02-based microcomputer

  +o Egel Project[24]

References

[1]: https://www.forth.com/starting-forth/
[2]: https://www.gnu.org/software/gforth/
[3]: http://www.softsynth.com/pforth/
[4]: http://www.softsynth.com/pforth/pf_tut.php
[5]: https://lists.gnu.org/mailman/listinfo/gforth
[6]: https://www.reddit.com/r/Forth/
[7]: https://www.youtube.com/watch?v=mvrE2ZGe-rs
[8]: http://thinking-forth.sourceforge.net/
[9]: http://theforth.net
[10]: https://www.forth.com/resources/forth-programming-language/
[11]: https://jeelabs.org/2015/07/22/forth-on-a-dip/
[12]: http://galileo.phys.virginia.edu/classes/551.jvn.fall01/primer.htm
[13]: http://wiki.laptop.org/go/Forth_Lessons
[14]: http://mecrisp.sourceforge.net/
[15]: http://www.ti.com/microcontrollers/msp430-ultra-low-power-mcus/overview.html
[16]: https://mecrisp-stellaris-folkdoc.sourceforge.io/index.html
[17]: https://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-mpu-eval-tools/stm32-mcu-mpu-
eval-tools/stm32-discovery-kits/32f0308discovery.html
[18]: https://www.youtube.com/channel/UCEOYYu1bSPFf-EVaY9akRcg
[19]: https://www.youtube.com/channel/UCSBspfcqX5QuK4XBLsh1rLw
[20]: https://github.com/kristopherjohnson/wiringPi_gforth
[21]: https://metacpan.org/pod/RPi%3A%3AWiringPi
[22]: https://www.raspberrypi.org/forums/viewtopic.php?p=1283928
[23]: http://dourish/com/projects/mith/html
[24]: http://home.hccnet.nl/willem.ouwerkerk/egel-for-msp430/egel%20for%20launchpad.html