Version 1.6 - Updated 18 Aug 1999
CamelForth/8051 is an ANSI compliant Forth system for the Intel 8051 family of microprocessors. It includes the Forth kernel, interpreter, and compiler, all of which reside on the 8051 processor.
Version 1.6 (18 Aug 1999) fixes a bug in FM/MOD. (No other changes.)
Version 1.5 includes an 8051 multitasker that is in development. (That's the stage before Alpha test.) It is not yet documented. Use it at your own risk. The rest of this release is well tested and relatively stable, and includes all known bug fixes.
Download CamelForth/8051System Requirements
CamelForth/8051 requires an 8051 family microprocessor with a serial port and at least 8K of PROM and 1K of RAM. To use the resident Forth compiler, additional RAM must be "dual-mapped" (accessible in both Program and Data spaces).
Some 8051 derivatives with more than 256 bytes of internal RAM -- such as the Philips 80C592 and 80C528 -- are not suitable for CamelForth. This is because those processors use MOVX @R0 and MOVX @R1 to access the expanded internal RAM, and CamelForth uses these instructions (in conjunction with output port P2) to address external RAM. We hope to support these processors soon.
CamelForth/8051 is assembled with PseudoCorp's freeware 8051 cross-assembler, A51. This program is archived here:
Download A51 AssemblerLicensing
CamelForth for the Intel 8051 (c) 1994,1997,1999 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.
System Configuration
As distributed, CamelForth will assemble to run in ROM at address 0000. It initializes the 8051 assuming an 11.0592 MHz crystal. You can freely change the program origin:
; RESET AND INTERRUPT VECTORS ===================
.org 0
ljmp reset
| reset | is the main entry point of the CamelForth kernel. If you are combining this kernel with some other 8051 program, you may want to delete the 8051 initialization code. |
As distributed, CamelForth assumes 4K bytes of program/data RAM starting at address E000 hex, and 4K bytes of data RAM starting at F000 hex. (Or just 8K bytes of Program/Data RAM at E000 hex.) You can change the RAM addresses by changing the following equates:
; Initial RAM & ROM pointers for CamelForth.
.equ coderam,h'0e000 ; where new code goes
.equ dataram,h'0f000 ; where data goes
.equ UPHI,h'FE ; User area at FE00 hex
| dataram | is where VARIABLEs, arrays, and all user-defined data structures begin. This is external RAM on the 8051. This RAM is also required to run the Forth command interpreter. |
| coderam | is where new code is compiled by CamelForth's built-in compiler. This RAM must appear as both data RAM and program ROM. |
| UPHI | is the high 8 bits of the User Area address. CamelForth requires a 512-byte User Area in RAM, starting on a 256-byte boundary (i.e., having an address xx00 hex). Thus, setting UPHI to h'FE specifies a User Area from FE00 to FFFF hex. |
Note that the Forth compiler requires a writable program RAM. On the 8051 this means that the program RAM must appear both in data space (so it can be written), and in program space (so it can be executed). The easiest way to achieve this is to logically AND the 8051 signals PSEN\ and RD\, and use this as the read strobe for all memory. This will cause all memory to appear as both Program and Data, which means you can only have a total of 64K bytes. Some 8051 boards include this feature. Others allow you to specify a limited range of addresses to appear as both Program and Data. Set the "coderam" equate to the start of this Program/Data region.
Please note that you can use the Forth interpreter even if you don't have combined Program/Data RAM. In this case you can type Forth commands, but you can't define new words. (Beware: trying to define new words in this case -- even VARIABLEs -- will crash the system.) Set the "coderam" equate to a "safe" address, away from the data RAM.
Program Development
CamelForth/8051 is not (yet) equipped for cross-development.
Development proceeds in three stages:
1. Assemble the CamelForth kernel and put it on your 8051 board. You assemble the CamelForth source file with the command
a51 camel51.asm
As distributed, this will produce an Intel hex file camel51.obj. Intel hex files are supported by many PROM programmers, PROM emulators, and debug programs. You may need to rename this file camel51.hex.
2. Download Forth code to the 8051 board. Once you have CamelForth running on your 8051 board, and if you have some Program RAM, 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. You can also edit an ASCII text file, and use a program such as Procomm or Windows Terminal to send this file over the serial port to your 8051. Depending on the speed of your 8051 board, it can take a few seconds to compile each line, so be sure to leave plenty of delay after the line. (See the application note on handshaking.) Also, be sure that no line exceeds 80 characters.
3. Add your Forth code to the CamelForth kernel (optional). If your board won't support Program RAM, or you want to burn your program into PROM, you can add your code to the file CAMEL51.ASM. 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 CAMEL51.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.
Application Notes
Application note #1: Downloading Source Files
Application note #2: 8051 Port I/O
Report on the FM/MOD bug corrected in version 1.6
Related Links

This 80x51 WebRing site owned by Bradford J. Rodriguez.
[Previous Site | Next | Random | List All Sites | Join Ring]