====== eForth - a small Forth in many incarnations by Dr. Chen-Hanson Ting ====== There are many eForth variants that Ting developed over the years. In the past the TI MSP430 was a good target, as the TI Launchpad was a low-cost option with included programmer. [[https://www.amazon.co.uk/s/ref=nb_sb_noss?url=node%3D341689031&field-keywords=Chen-Hanson+Ting+Zen+and+the+Forth+Language|Link zum eForth eBook]] - Vorschau auf den [[en:projects:430eforth:start:Contents_of_Tings_latest_eBook|Inhalt des Buches]]\\ [[https://www.amazon.com/-/e/B00N8HVEZM|Link zur Forth-eBook-Serie]]\\ {{ :projects:430eforth:eforth_appendix_wordsv3_9.pdf |Appendix}}- Die 430eForth Kommandos\\ Here you can find the documentation of a complete Forth on one page - ok it is a large one, e.g.A1 size, but there is a link to print it as normal A4 pages https://wiki.forth-ev.de/doku.php/en:projects:430eforth:start {{ :projects:430eforth:eforth_publisher_2018_09_16_v2.pdf |eForth Poster A1}} - DOS Version. [[projects:microbox:start|MicroBox]]\\ links to be added later - or use google [[projects:mmt4ue2:start|MMT]]\\ links to be added later - or use google Hoffentlich bald mehr dazu((Oktober 2016)). Manfred Mahlow hat auf der [[events:tagung-2017|Forthtagung 2017]] einen Vortrag zum eForth gehalten, in dem die Eigenschaften des eForth herausgestellt worden sind. Das Video des Vortrags ist in Deutsch, die Folien des Vortrags gibt es in Deutsch und Englisch. ====== TI Launchpad ====== Nur etwa 4k gross fuer den MSP430G2553 im 20 Pin DIP.\\ Passt ideal in die MicroBox. {{ :projects:430eforth:430eforth-ide.zip |430eforth-ide}} - die Hex-Datei des eForth ist in der IDE((Die 430eForth-IDE ist eine angepasste Reimplementation der 4e4th-IDE von Dirk Brühl - http://www.somersetweb.com/430eForth/430eForth-IDE.zip )) enthalten, um mit dem [[http://www.ti.com/tool/MSP-EXP430G2|TI Launchpad]] zu programmieren\\ {{ :projects:430eforth:eforth_lessons.pdf |Lektionen}} - Beispiele in eForth 430G2553((eForth ist //case sensitive//, alle Forth Worte sind in GROSSCHREIBUNG. ))\\ Und hier ist Ting's Quelle: {{ :projects:430eforth:eforth.zip}} ====== Arduino UNO and Arduino Nano ceFORTH as SKETCH to get started with Forth ====== for example using an ATmega328P Nano V3 Development Board (Geekcreit).\\ {{projects:430eforth:eforth328.zip|eForth as Arduino Sketch (C Sourcecode), and in txt.}} **( This part is in English, as the link to this location is shared )** ===== How can you simply carry out a few Forth instructions? ===== And understand how Forth works? OK, the execution of commands online without additional hardware has already been shown elsewhere in this Wiki, in the **A Start With Forth** documentation, especially in chapters 4, 5, 6 and 7;\\ in [[projects:a-start-with-forth:start0|German]] and in [[en:projects:a-start-with-forth:start0#a_start_with_forth_-_many_c_hapters_here_and_as_ebook_and_print_book|English]]. But it is something else to test this locally in your own (or borrowed) controller board. ((By the way - this ceForth version is //not// sensitive to upper and lower case use.))\\ Arduino UNO and Arduino nano are widely used, so probably a good basis.\\ Normally, a programmer and special know-how is almost always required to get the Forth into the chip, as the Forth also needs the bootloader area. So, this area has to be overwritten which the Arduino IDE cannot do. But we recently discovered this special eForth version from Ting, which unfortunately had been hidden very well until now. Only this Arduino-specific sketch has to be downloaded using the link above and unpacked again. Upload it via the Aruino IDE and you're ready to program in Forth. OK you have to get the Terminal software ready as well, but this is easy - all in the next PDF. We want to make it easy for anybody to try it out. ===== The "39 Steps" to see HELLO WORLD on your display ===== So, Juergen sat down and recorded all of the steps necessery, from switching on the UNO/nano to displaying the usual **HELLO WORLD.** It turns out to take {{how_to_get_started_and_control_some_leds_in_forth_v4_a4.pdf|39 Steps}} And you will end by programming the ''HELLO WORLD'' and see the result: {{publication2.jpg}} [[https://uk.banggood.com/Geekcreit-ATmega328P-Nano-V3-Controller-Board-Improved-Version-Module-Development-Board-p-940937.html?gpla=1&gmcCountry=GB¤cy=GBP&createTmp=1&utm_source=googleshopping&utm_medium=cpc_bgcs&utm_content=lijing&utm_campaign=pla-gbg-rm-all-purchase-pc&ad_id=323612825005&gclid=Cj0KCQjw-_j1BRDkARIsAJcfmTHNbV23Sl9zuJK9eh8oCP9oIJHQtR3dcUMdgcX3EYMRVgHzdnaJYtYaAiUTEALw_wcB&cur_warehouse=CN|Here a link to a low cost ATmega328P Nano V3 Development Board]] as example (Geekcreit) if you need one. We soldered the headers on a nano pointing downwards, and the Arduino nano then fits wonderfully onto a solderless breadboard for experiments. {{arduino_nano_on_breadboard.jpg?250}} The eForth is loaded as {{projects:430eforth:eforth328.zip| Arduino Sketch (C Sourcecode)}}, similar to a text file, then compiled via the Arduino IDE and uploaded into the board. Generate a folder on your PC, download the ZIP, unpack it and flash it into the Arduino UNO or the nano via the Arduino IDE. ===== A little bit of background from Ting’s documentation ===== Ting’s introductory chapter and background to this version: This Forth can be easily loaded as an Arduino sketch and is immediately executable via a terminal program on the PC. OK, with a few drawbacks - but nothing is for free, {{:projects:430eforth::ceforth_328.pdf_ting_introduction_v1.pdf|please read the introductory chapter.}} ===== Terminal Program on your PC ===== Download and install a terminal program, if you do not have one already, e.g. [[https://ttssh2.osdn.jp/index.html.en|Teraterm]] or termite, and then you are ready to go. Set to 115k baud rate. Enter (**CR)** and you see **0 0 0 0 ok>** Test by entering **words (CR)** showing the list od words/commands ===== The original command list of this Forth ===== {{ting_eforth_words.pdf |List as in the original documentation}} All 180 words may be too much for someone who is just starting out, so let’s sort them a bit - {{forth_words_v2_-_simper_ones_at_the_beginning.pdf|sort by function for the easy ones}} - and the more difficult ones at the end. **A quick Word Overview is helpful - can be used as a Mug Wraparound - or folded as smaller Version** And you are ready to go and test some commands, e.g. see what is happening on the stack.\\ {{some_examples_part_1.pdf|Here are some examples.}} [[https://www.amazon.co.uk/dp/B088P1CW83/ref=sr_1_fkmr0_2?dchild=1&keywords=sforth+as+Arduino+Sketch&qid=1589713127&s=books&sr=1-2-fkmr0|And the additional information in the book]]. ===== Some small Examples ===== The terminal display shows: 0 0 0 0 ok> These four zeros show the top 4 values of the Data stack.\\ With(( Press Carriage Return Button (enter). )): 1 2 3 4 it changes to: 1 2 3 4 ok> Now try . . . . and the 4 values are displayed and disappear from the stack which is back to: 0 0 0 0 ok> ==== The usual HELLO WORLD we can achieve like this: ==== Define a new Forth Word: : HELLO1 ." HELLO WORLD " ; '':'' starts a new Word definition, ''HELLO1'' is the name of the new Word. '' ." '' starts a text definition. ''HELLO WORLD'' is the text to be printed. And ''"'' marks the end of the text. Finaly '';'' ends new Word definition. And try it out: hello1 HELLO WORLD and format the output a bit. A few additional CRs will make it better readable: : HELLO2 CR CR ." HELLO WORLD " CR ; hello2 HELLO WORLD ==== And now let us control one Bit in the IO. Here the on-board LED ==== 20 24 POKE \ Will set bit 5 of the port to OUTPUT in the Data Direction Register 0 0 1 0 0 0 0 0 \ 20 is the data bit to be stored, and 24 is the DDR Register address in hex 20 25 POKE (CR) \ Will set Bit 5 in the OUTPUT Register to HIGH - LED is on 0 0 1 0 0 0 0 0 \ 20 is the OUTPUT bit to be stored and 25 in hex is the Output Port Register 00 25 POKE (CR) \ Will set Bit 5 in the OUTPUT Register to LOW - LED is off \ here 00 is stored in the Output Register I used this [[http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf |ATmega328P Datasheet]]. And for now only page 280 is important, which shows the addresses for the ports, especially here now those two Port-B-addresses: *24 HEX is the DDR (DDR = Data Direction Register) to set bits to OUTPUT and *25 HEX for the OUTPUT Register to set bits to 1 or 0 HIGH or LOW. **And the relevant file of these examples** Try out other bits, or other ports, but then you have to add LEDs to the relevant output. **More to come** ===== An important difference between the Arduino IDE and Forth ===== With Forth we can poke around in all internals using the Forth commands, read and write IOs - even mess up the CPU – so please be careful as you might have to restart the Forth and loose the work done before. And this is done using only 2 commands, added especially to this eForth version: *PEEK - Read the contents at memory location xx *POKE - Overwrite contents at memory location xx with new data yy. And if you have now licked blood and have the appropriate know-how and tools, you can flash in the extended version of this eForth - but then the bootloader will be overwritten. The complete zip of this project you can find at http://forth.org/OffeteStore/OffeteStore.html and here especially, as this version working with RAM http://forth.org/OffeteStore/2162_ceForth_328.zip and the full version where new Words are stored permanently in flash memory but then you have to find a way or sombody to flash the hex file - overwriting the Bootloader permanently. http://forth.org/OffeteStore/2159_328eforth.zip or as well as book at [[https://www.amazon.co.uk/gp/product/1726868478/ref=dbs_a_def_rwt_bibl_vppi_i21|amazon]]. \\ \\ //This page is work in progress! Last change and more to come as time allows: 05/05/_2020 now 08/06/2020 //