-
Notifications
You must be signed in to change notification settings - Fork 66
STM8 eForth Hands On with uCsim
You don't even need to buy hardware to try STM8 eForth. If your OS supports Docker the following steps will bring you to the Forth console:
# 1. clone STM8 eForth
git clone git@github.com:TG9541/stm8ef.git
cd stm8ef
# 2. pull and run the SDCC environment
docker pull tg9541/docker-sdcc
docker run -it -v `pwd`:/home tg9541/docker-sdcc
Depending on your Internet connection, pulling tg9541/docker-sdcc
can take a while but you need to do it only once.
Next we will build the Forth core for the board MINDEV
. Of course you can build a different board or download a Binary Release.
# 3. now we're in a Docker container - let's get started
cd home
make BOARD=MINDEV
sstm8 -G -w -Z10001 -tS103 -Suart=1,port=10000 out/MINDEV/MINDEV.ihx &
telnet localhost 10000
Your output should look like this:
root@22de4a529a1b:/home# sstm8 -G -w -Z10001 -tS103 -Suart=1,port=10000 out/MINDEV/MINDEV.ihx &
[1] 69
root@22de4a529a1b:/home# Loading from out/MINDEV/MINDEV.ihx
4762 words read from out/MINDEV/MINDEV.ihx
root@22de4a529a1b:/home# telnet localhost 10000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
uart[1] terminal display, press ^x to access control menu
ok
You're now on a STM8 eForth console - backspace is ^h
(CRTL-h
). On most machines the instruction set simulator uCsim will be a lot slower than the chip.
If you type words
you should see the following:
words
IRET SAVEC RESET RAM NVM LOCK ULOCK WORDS .S DUMP IMMEDIATE ALLOT VARIABLE CON
STANT CREATE DOES> ] : ; OVERT ." $" ABORT" AFT REPEAT WHILE ELSE THEN IF AGAIN
UNTIL BEGIN +LOOP LOOP DO NEXT FOR COMPILE LITERAL CALL, C, , [COMPILE] ' hi CR
[ NAME> \ ( .( ? . U. TYPE U.R .R SPACE KEY DECIMAL HEX <# SIGN HOLD #S # #> ERA
SE FILL CMOVE HERE COUNT +! DEPTH PICK 0= ABS NEGATE NOT 1+ 1- 2+ 2- 2* 2/ EXG *
/ */MOD M* * UM* / MOD /MOD M/MOD UM/MOD WITHIN MIN MAX < U< = 2DUP ROT ?DUP BG
TIM -1 1 0 last '?KEY 'EMIT BASE - 0< OR AND XOR + UM+ I OVER SWAP DUP 2DROP DRO
P NIP >R R@ R> C! C@ ! @ B! 2C@ 2C! 2@ 2! EXIT EXECUTE LEAVE EMIT ?KEY TX! ?RX C
OLD 'BOOT ADC@ ADC! OUT! ok
It's also possible to use make BOARD=... forth
to load STM8 eForth code into a simulated device and store the Flash contents to a hex file.