The goal of this project is to adapt the original C.H. Ting stm8ef.asm.org file to be assembled with sdasstm8 (part of sdcc project). By the same the project as been extented to add features and to support other boards.
- project source is on https://github.com/Picatout/stm8_eforth
This open source project is distributed under GPL V3 license.
- make
sudo apt install make
- sdcc, open source Small Device C Compiler. sdasstm8 is part of it.
sudo apt install sdcc
- stm8flash. This one must be build and installed from project sources.
- In inc/config.inc file select the target board or MCU by setting its variable to 1 and all other to 0.
NUCLEO_8S207K8=1
NUCLEO_8S208RB=0
DISCOVERY=0
DOORBELL=0
-
For WANT_ options set to 1 the ones to include in the binary and others to 0.
-
There is a makefile "*.mk" for every target. It define 3 variables and launch main Makefile.
####################################
# Make file for NUCLEO_8S207K8 board
####################################
BOARD=stm8s207k8
PROGRAMMER=stlinkv21
FLASH_SIZE=65536
include Makefile
- The files resulting from build process are stored in subdirectory of build holding the name of target BOARD variable.
~/github/stm8_eforth$ ls build
stm8s105c6 stm8s105k6 stm8s207k8 stm8s208rb
- To build and flash the target with binary type the following command.
make -fnucleo_8s207.mk
Here nucleo_8s207.mk is the makefile of selected target.
- If you want to compile without flashing
make -fnucleo_8s207.mk compile
STM8 eForth user interface is through a serial port. When a NUCLEO board is connected to PC a virtural port is created on the PC which is used for this purpose.
The serial port parameters are the following:
- 115200 BAUD
- 8 BITS
- 1 STOP
- NO PARITY BIT
Here a configuration example using GTKTerm on Ubuntu/Linux
Another example with Tera Term on Windows
STM8 eForth use CR character as line terminator by default but there is an option in config.inc file to change it for LF.
At this time documentation is only available in french in PDF format in docs folder.
Originally eForth has been designed by Bill Muench to be easily portable from one processor to another. This objective was acheived by writting a minimum of words in assembly (about 35) and the rest was written in eForth itself. This was in the 80's, the glorious years of Forth when each 8 bits PC had Forth software available for it. Apple II, TRS-80, SX-SPECTRUM, etc. Forth was also available for CP/M systems.
Years after when microcontrollers became commonly available to hobbyists, C.H. Ting started to port eForth on many microncontrollers platforms, 8,16,32 bits varieties. Even GreenArrays GA144
chip which is 144 Forth computer on a single chip has eForth in ROM on 1 of is computer.
Mr Ting is known if Forth universe for porting eForth on many platforms but he also published books on the subject.
In 2011 he ported eForth on STM8-Discovery. This project is based on Mr Ting original source file. I ignore which dev tools was used by Mr Ting but I decided to port it to SDCC assembler-compiler.
Aside from recoding large parts of the project, I expanded by adding many modules:
-
const_ratio.asm This module define a set 2 constants that by their ratio approximates real numbers like PI and others. Their use is with the word */MOD. The first constant is multiplied by an integer which product is kept as double integer then divided by the second constant.
-
ctable.asm Define a set of words to facilitate the creation of constants table to be stored in flash memory.
-
double.asm Define words for arithmetics operations on double integers i.e. 32 bits integers.
-
float.asm Define words for arithmetics operations on 32 bits floatting point numbers.
-
float24.asm Define words for arithmetics operations on 24 bits floatting point numbers.
-
flash.asm Define words to write to FLASH en EEPROM memory.