CamelForth/6809 - CamelForth (2024)

Version 1.0 - 7 May 1995

CamelForth/6809 is an ANSI compliant Forth system for the Motorola 6809 microprocessor. It includes the Forth kernel, interpreter, and compiler. This is an alpha test version. which means that, although I have tested the bulk of this code for correct functioning, you are likely to discover bugs. I'd appreciate hearing of any such, via the contact link on this web site.

Download CamelForth/6809

System Requirements

CamelForth is distributed to run on the ScroungeMaster II 6809 board, as described in The Computer Journal. The program compiles to run in ROM at address E000 hex, allowing the use of either an 8K (2764), 16K (27128), or 32K (27256) EPROM. CamelForth's initialization code will map the ScroungeMaster RAM to the address space 0000-7BFF hex, and the on-board I/O to the space 7C00-7FFF hex. As distributed, CamelForth only uses RAM locations 6000-7BFF hex, allowing the use of either an 8K (6264), 32K (62256), or 128K (628128) static RAM.

CamelForth/6809 can be adapted to run on any 6809 processor with at least 8K of PROM, 1K of RAM, and a serial port.

Licensing

CamelForth for the Motorola 6809 is copyright (c) 1995 Bradford J. Rodriguez. Chromium 2 metacompiler copyright (c) 1995 Bradford J. Rodriguez.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

For a copy of the GNU General Public License, see http://www.gnu.org/licenses/.

Commercial inquiries should be directed to the author at 115 First St., #105, Collingwood, Ontario L9Y 4W3 Canada or via the contact link on this web site.

Recompiling the Kernel

CamelForth/09 is supplied as source code, and is compiled with a Forth metacompiler, Chromium 2. This compiler, and the corresponding 6809 cross-assembler, are distributed with CamelForth/09. To run this compiler you must have Laxen & Perry F83 for the IBM PC (available for download from the Forth Interest Group, ftp://ftp.forth.org, and from many IBM PC shareware distributors).

To compile CamelForth/09, put CHROMIUM.SCR and F83.COM in your working directory, and then type the two commands

 F83 CHROMIUM.SCR
1 LOAD

This will start F83, load the compiler, compile the 6809 kernel, and save the result to an Intel hex file 6809.HEX. This file can be downloaded to an EPROM emulator or burned into an EPROM.

The Chromium compiler should work with any version of F83 (such as for the Atari ST or for CP/M)...but this has not yet been tested. Unfortunately, the hex file utility is specific to the IBM PC, and must be rewritten for any other computer system.

Uploading Forth Programs

On the ScroungeMaster II, CamelForth uses serial port A (port A of the first Zilog 8530 SCC, U10). With a 4 MHz crystal oscillator, this port will be set to 4800 baud; with an 8 MHz crystal, 9600 baud.

You can communicate with the 6809 using a terminal program such as Procomm. You can type new words from the keyboard, test them as they are defined, and re-define them to make changes. Or you can edit an ASCII text file, and upload this file from the PC to the 6809.

A line of Forth code takes an appreciable fraction of a second to compile, so you can't send it "full blast" at 4800 or 9600 baud. Instead, set Procomm's ASCII Transfer "pace character" to 10 decimal (line feed). CamelForth will not send the CR/LF pair until it has finished processing the line, so you can use LF as a synchronization character. You should also set Procomm to strip LF characters from the uploaded file. (Other terminal programs should have similar options.) Be sure that no line in your file exceeds 80 characters.

Cross-compiling Forth Programs

If you want to burn your program into PROM, you can add it to the kernel source code in CHROMIUM.SCR. I recommend you use a contiguous set of screens for your source code, and add them as a separate line to screen 1 (the master load screen), immediately after the line

 DECIMAL 61 119 THRU

which loads the 6809 Forth kernel. The CHROMIUM.SCR file contains:

 0 +---------------+ 120 +---------------+
| metacompiler | | "shadow" |
| source code | | documentation |
30 +---------------+ 150 +---------------+
| 6809 assembler| | |
45 +---------------+ | unused |
| unused | | |
| | 176 +---------------+
60 +---------------+ | 6809 |
| 6809 Forth | | binary |
| source code | | image |
119 +---------------+ 239 +---------------+

You may use screens 45-59, and 150-175, for your source code. Do not use screens 176-239, even if they appear empty. These 64 screens hold a copy of the 64K binary image being generated by the metacompiler, and a mistake in the source code could corrupt any of these screens.

The metacompiler will accept "normal-looking" Forth code: colon definitions, CODE definitions, VARIABLEs, CONSTANTs, CREATEs, ALLOTs, etc. -- look at the CamelForth source code for examples. Vocabularies are not yet supported. IMMEDIATE words (e.g. CASE) and defining words (CREATE..DOES>) can be metacompiled, but require special metacompiler phrases to be added to your source code. If you are not familiar with Forth metacompilers, I suggest you refrain from using these features until the next release of the Chromium metacompiler.

Memory and I/O Map

 0000 +--------------------+
| unused |
| |
6000 +--------------------+
|Forth RAM dictionary|
| |
7980 +--------------------+
| TIB |
7A00 +--------------------+
| user area |
7A80 +--------------------+
| parameter stack |
7B00 +--------------------+
| HOLD,PAD areas |
7B80 +--------------------+
| return stack |
7C00 +--------------------+
| on-board I/O |
8000 +====================+
| unused |
| |
E000 +--------------------+
| Forth kernel |
| |
FFF0 +--------------------+
| 6809 reset vectors |
FFFF +--------------------+

This memory map is controlled by screen 61 of the CHROMIUM.SCR file:

 HEX 0E000 FFFF DICTIONARY ROM ROM ( A )
7A00 EQU UP-INIT ( B )
7A EQU UP-INIT-HI ( C )
6000 EQU DP-INIT ( D )

Line A specifies the lower and upper ROM limits. Thus, to use a full 32K ROM, you would change '0E000' to '8000'. Do not change the 'FFFF' limit, since the reset vectors must be compiled.

Lines B and C control the location of the RAM data area. This area extends from 80h bytes before UP-INIT, to 200h bytes after (7980h to 7C00h in this example). You may move these by changing UP-INIT, provided that UP-INIT is always on a 256-byte boundary (i.e., has the value xx00 hex), and provided that you change Line C to match Line B (i.e., the corresponding value xx hex).

Line D controls the starting location of the RAM dictionary. This is where the CamelForth compiler/interpreter adds new Forth words. This can be changed to any RAM address. Thus to use a full 32K RAM you could change this to '0000'.

I recommend that you leave the I/O mapping alone (controlled by the 6809 initialization code in screen 118). Its location at 7C00h gives the largest contiguous RAM space if 32K or 128K RAMs are used. If you are not using a ScroungeMaster II, you should delete this memory mapping code, and you should adjust the CamelForth memory map to suit your hardware. (You will also need to change the serial I/O initialization, and rewrite the words KEY KEY? and EMIT.)

Application Notes

Report on the FM/MOD bug corrected in the 8051 version.

CamelForth/6809 - CamelForth (2024)
Top Articles
Latest Posts
Article information

Author: Horacio Brakus JD

Last Updated:

Views: 6237

Rating: 4 / 5 (71 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Horacio Brakus JD

Birthday: 1999-08-21

Address: Apt. 524 43384 Minnie Prairie, South Edda, MA 62804

Phone: +5931039998219

Job: Sales Strategist

Hobby: Sculling, Kitesurfing, Orienteering, Painting, Computer programming, Creative writing, Scuba diving

Introduction: My name is Horacio Brakus JD, I am a lively, splendid, jolly, vivacious, vast, cheerful, agreeable person who loves writing and wants to share my knowledge and understanding with you.