CamelForth

CamelForth is a Forth implementation for embedded microprocessors (8051, 8086, Z80, and 6809, with more to come). It is compatible with ANS Forth. It was originally developed as an educational project for The Computer Journal, but has since become popular for embedded systems programming.


Custom Ports/Embedded Programming: Custom ports of CamelForth to new processors can be done for a fee. I'm also available for embedded programming on a contract basis. Reach me via the Contact page. - Brad



CamelForth on Vintage Computer Festival 8031
CamelForth user Raymond (channelmaniac AT yahoo.com) reports,

I built an 8031 based kit last year for VCF (Vintage Computer Festival) Southwest and for this year I built a module that would run CamelForth at A000 with dual-space RAM at E000.

I extended BASIC-52 v.1.2a (stripped down version for the 8031/8051) to add in a "camel" key word to start CamelForth and thought I'd share it with you. Feel free to include it on your site if you wish, no attribution necessary. It's simple code that came from sample in the BASIC-52 documentation from Intel. Note that you cannot use "forth" as a key word as that conflicts with the BASIC command "for"

He adds,

The only troubleshooting note I'd say that goes with that code is "If the 80xx CPU does not see the ROM and a CBY(2000H) returns a 00 then try a different part number EPROM." I had trouble with AM2764A-10DC not being seen.

Copy and paste his source code below, or find it at his GitHub repository.


;        .command -ai    ; output Intel hex format
; ===============================================
; Add command table entry to start CamelForth on 8031
; Show Computer for VCF Southwest
;
;
        .ORG    2002H
        .DB        5AH            ;Tell BASIC expansion options available
;
        .ORG    2048H
        SETB    2DH                ;Set bit 45 to enable expansion
        RET                        ;command lookups in BASIC
;
        .ORG    2070H
        MOV    DPTR, #VECTOR_TABLE    ;LOCATION BASIC CALLS TO GET
        RET                        ;USER VECTOR_TABLE LOOKUP ADDRESS
;

        .ORG    2078H
        MOV    DPTR, #USER_TABLE    ;LOCATION BASIC CALLS TO GET 
        RET                        ;COMMAND TOKEN LOOKUP TABLE
;
USER_TABLE:    .ORG    2200H
        .DB    10H                ;FIRST TOKEN
        .DB    "CAMEL"            ;CAMEL KEYWORD
        .DB    0FFH                ;END OF USER TABLE
;
VECTOR_TABLE: .ORG    2300H
        .DW    RUN_CAMEL
;
RUN_CAMEL:    .ORG     2400H
        LJMP    H'A000
        RET
;




Forth2020 Presentation, 14 May 2022
On Saturday 14 May, I will be speaking again at the Forth2020 virtual meeting. The topic: "Breaking the 64K Limit: handling Extended Memory in Forth."

This refers to the days when many Forths were limited to a 16-bit address space. You can think of this as a "historical" talk, though it it still relevant to some microcontrollers today (such as the MSP430X).

The meeting begins at 14:00 UTC (10:00 EDT). I am scheduled to be the first presenter. The full agenda is here.

Forth2020 Presentation, 12 MARCH 2022
For those who might be interested, I will be participating in the Forth2020 virtual meeting on Saturday, February 12 March 12, where I will make a short presentation on "Token Threading on the MSP430." I've been tinkering with this for a while, and it's almost ready for release.

I do not yet have the day's agenda, so I don't yet know what time I'll be speaking.

Update: Presentations begin at 14:00 UTC, which is 09:00 EST. There are two scheduled presentations; I don't know if I go first or second. Social gathering begins at 13:00 UTC (08:00 EST).

Update #2: This presentation has been rescheduled to Saturday, March 12, at 9:00 am EST (14:00 UTC).

Update #3: The video of this presentation can be viewed at https://www.youtube.com/watch?v=5MVHa3TPgUE

24/48 bit CamelForth for eZ80
Jürgen S. has announced a new port of CamelForth, a 24/48 bit eZ80 port for the eZ80 Acclaim! The source code is published at GitHub. Thanks, Jürgen!

CamelForth in C for RPi Pico RP2040
Chris H. has ported CamelForth in C to the Raspberry Pi "Pico" microcontroller board (RP2040 processor). You can find it here on GitHub. Thanks, Chris!


Camel Inspired 65C02 Port
I received this email from Dr. Bruce McFarling, and am sharing it with his permission.

I am working on a port of Forth for the 65C02 based Commander X16 project. I started with Camel Forth for the Z80 but got bogged down, and switched to eForth v1.0 for the Z80, which I've got up and running with substantial ANS Forth alignment based on some Camel Forth words.

It is not strictly speaking a Camel Forth port, but Moving Forth and the Camel Forth Z80 source have been invaluable to the porting effort. It can be seen and tried out online at https://www.commanderx16.com/forum/index.php?/files/file/67-alpha-xforth-compiler/

Starting Forth and Thinking Forth
A few days back I was asked for recommendations of Forth books. I always start with the two classics by Leo Brodie: Starting Forth as a primer, and Thinking Forth for advanced programmers. On further investigation I discovered that both are now available as free downloads.

Starting Forth is owned and published by Forth, Inc. (who, as I recall, commissioned the original book many years ago). Both the original edition (as PDF) and the updated online edition are available for download, but not for redistribution, at their website.

Thinking Forth now exists as a SourceForge project, and is published under a Creative Commons license (attribute, non-commercial, share-alike). I have added a local archive of the "book" PDF format, but this and three other formats can be downloaded from their project page.

Continuing thanks to Forth, Inc. and Leo Brodie for making these works available!

"Moving Forth" now on Amazon Kindle!
Thanks to the extremely dedicated efforts of Forth enthuiast Juergen Pintaske, "Moving Forth" -- the series of articles that led to the creation of CamelForth -- is now available as an Amazon Kindle e-book!

Juergen writes:

In 2018 we have 50 Years of Forth. When I looked for a new project for an eBook I realized that one area is not very well covered:
How do the Forth internals work?
How can you build a Minimal Processor executing Forth directly?
How do you write an Assembler in Forth?
When I looked around for some documentation, I remembered this series of articles again. They seem to fit very well together.
I contacted Brad and asked for permission to publish them as part of the Forth Bookshelf.
He liked the idea so I started formatting. I did not change any of the original material. The only part I added was an appendix, where I redid some of the pictures, so I could understand them better.
As in many cases, additional material can be found on the Forth-eV.de Wiki, and we will start with the appendix added here, and what else we might come up.

This is just the latest addition to Juergen's Forth Bookshelf project. He has been diligently resurrecting and preserving historic Forth works, such as Leo Brodie's Starting Forth, Chuck Moore's Forth - The Early Years, and C. H. Ting's eForth Overview, to name just three. I am delighted to see this achievement, and happy that I could offer my own small contribution. Go see it all!

CamelForth in C!
About two years ago I set out to write a version of CamelForth entirely in the C language. This was mainly so that I could run Forth on my Texas Instruments TM4C129 Launchpad board -- I didn't want to get bogged down in the specifics of one particular ARM processor. I had much of the kernel implemented in early 2016, but then got sidetracked by more mundane concerns.

But I kept tinkering with it, and it has now reached a state where I'm willing to let others tinker with it. So, newly added to the Downloads section, you will find CamelForth in C, version 0.1.

Please note that this is very much an "alpha test" release. I have compiled this for 32-bit Linux (using gcc), and successfully run the Hayes validation suite on that platform. I have also compiled this for the TM4C129 Launchpad, but have done practically no testing there. So please try it out, but expect to find some lingering bugs. And note that I haven't tried it on either 16-bit or 64-bit CPUs.

Questions, comments, and bug reports can be addressed to me here on the forum, or by email.

James Bowman's 8051 Forth
CamelForth user James Bowman is making available, on Github, a modified CamelForth/8051:

  1. now uses a modified version PJRC's as31 assembler, included in this project
  2. minor changes to Brad's code to build with as31
  3. a software emulator based on emu8051, included in this project
  4. regression test using the ANS test suite, CI by Travis
  5. a version tuned for the TI CC1110 SoCs

Find it at https://github.com/jamesbowman/8051forth . Thanks James!


Go to page       >>