CamelForth

CamelForth/8086

Version 1.0 - 24 Dec 1996

CamelForth/8086 is an ANSI compliant Forth system for the Intel 8086 family of microprocessors. 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 page.

Download CamelForth/8086

System Requirements

CamelForth/8086 requires an IBM PC with MS-DOS 3.x or higher. It allocates three 64K segments, for code, data, and headers, plus 200h bytes in a fourth segment for stacks, so at least 200K of free RAM is required.

Licensing

CamelForth for the Intel 8086 is copyright (c) 1996 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.

Running the Program

To start CamelForth under MS-DOS, type the command

    CAMEL86

This version (1.0) of CamelForth/86 ignores the rest of the command line, and launches the Forth interpreter directly. To return to MS-DOS, use the Forth command

    BYE

Note that CamelForth is case sensitive, and all Forth words are in UPPER CASE.


CamelForth/86 uses the MS-DOS Standard Input and Standard Output. So, it is possible to provide keyboard input from a file, e.g.,

    CAMEL86 <script.txt

The last command in the file should be BYE. (If you forget this, you will need to use CTRL-BREAK to terminate CamelForth/86.) You cannot return to keyboard input after interpreting an input file. This is not intended as a way to load source code, but rather as a way to perform self-contained scripts (such as ANSITEST.TXT, the Hayes validation suite).

You can also redirect terminal output to a file, e.g.,

    CAMEL86 >log.txt

but since this disables the screen display, it's only useful when interpreting a script file. For example, the Hayes validation suite can be run, and the output saved, with the command

    CAMEL86 <ANSITEST.TXT >ANSITEST.LOG

Because this is a simple redirection of keyboard input, error messages and prompts (such as "ok") are still output, and (if redirected) will appear in the log file.

Recompiling the Kernel

This program was written using Borland Turbo Assembler. Every attempt was made to remain compatible with MASM, but I haven't actually tried MASM. (Anyone successfully doing so is invited to contact me!) Included in this distribution are two batch files; you can assemble and link the CamelForth source files with the commands

    tasm camel86
    tlink camel86

This will produce CAMEL86.EXE.

Standalone Use

CamelForth can be assembled for a standalone or embedded 8086. About 6K of PROM (4K code, 2K headers) and 1K of RAM are used by CamelForth, plus whatever additional PROM and RAM is needed by your program.

You will need to link CamelForth to your reset vector (or other startup procedure), and add any required hardware initialization. You must also add the Forth words KEY KEY? and EMIT for your hardware. Modify the segment allocation, and the "reset" routine (both in CAMEL86.ASM), to suit your memory map.

If you are putting CamelForth in PROM, but want to have a Forth dictionary in RAM (so you can add new definitions), you'll have to arrange for RAM in both the Code and Extra (headers) segments. This will probably require overlapping segments, and is not a trivial exercise. You'll need to change the 'headdict' and 'romdict' equates (at the end of camel86. asm) to the starting RAM addresses for code and headers. Do not change the lines

        ORG ilatest     ; set "latest" in UINIT data
        DW link

as these point the dictionary list head to the last word defined in the kernel.

Embedded Development

There are two ways to write embedded programs in CamelForth:

1. If you have CamelForth running on an embedded 8086, you can download Forth code directly to CamelForth. This lets you 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 use a program such as Procomm to send this file over the serial port to your 8086. It can take a few seconds to compile each line, so be sure to leave plenty of delay after the line. (I'm working on handshaking to improve this.) Also be sure that no line exceeds 80 characters.

2. If you you want to burn your program into PROM, you can add your code to the file CAMEL86.ASM. (I recommend creating a separate file and using the INCLUDE directive.) This requires you to convert your Forth code to assembler code. To show how this is done, every high-level Forth word in the file is shown with its equivalent Forth code in a comment. Be especially careful with control structures (IF..ELSE..THEN, BEGIN..UNTIL, DO..LOOP, and the like), and with the Forth word headers. Reassemble CAMEL86.ASM and burn a PROM (or download to a PROM emulator or debug monitor), then test. This is a much slower process, and is best saved for the final stage when you have a tested & debugged program that you want to put in PROM.

CamelForth/8086 is not (yet) equipped for cross-development.

Application Notes

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