Taqoz Reloaded v2.8 - Running commands from SD card
Having compiled the following code, if you type a word that isn't found in the dictionary, then TAQOZ will search the SD card for a file of the same name, either with no extension, or .FTH, or .TXT extension. The file is then loaded as if it were being entered on the terminal. After loading, input is from the user terminal again. To enable this feature, type ON BATCH. To resume normal 'word not found' behaviour, type OFF BATCH. Don't forget to load some files containing Taqoz source code onto the SD card, before attempting to run them. Here's the code:-
--- Batch File ver 1 for Taqoz Reloaded v2.8 - Bob Edwards May 2022 TAQOZ IFDEF *BATCHFILE* FORGET *BATCHFILE* } pub *BATCHFILE* ." Run Batch File of same name when word not found ver 1" ; --- attempt to run SD card command, if word not found in dictionary --- to turn feature on use ON BATCH , to turn off OFF BATCH --- requires source code files on SD card with no extension, .TXT or .FTH --- leftmost len chars of str - destructive, uses same string pub LEFT$ ( str len -- str ) OVER+ C~ ; 20 bytes SFILE --- source file on SD card --- search for unknown word as file on SD card and execute --- files ending with no extension, .FTH or .TXT are valid --- NB this word does not run directly from the terminal pub SDEXEC ( -- TRUE | FALSE ) @WORD SFILE $! --- save unknown word SFILE FOPEN$ --- attempt to open the file DUP IF FLOADS TRUE --- load file with no extension if it exists ELSE DROP " .FTH" SFILE $+! SFILE FOPEN$ DUP IF FLOADS TRUE --- else load file ending in .TXT ELSE DROP SFILE DUP LEN$ 3 - LEFT$ --- remove FTH from the filename " TXT" SWAP $+! --- and add TXT SFILE FOPEN$ DUP IF FLOADS TRUE --- else loads file ending in .FTH ELSE DROP FALSE --- no file found, signal failure THEN THEN THEN ; --- enable / disable unknown word search on SD card pub BATCH ( ON | OFF -- ) IF ' SDEXEC unum W! --- if unknown word, attempt execute from SD card ELSE 0 unum W! --- else return normal operation THEN ; END
Could be useful for:-
1. Running a list of commands for test purposes - but you don't want it permanently in memory
2. Loading your favourite extensions
3. Turning TAQOZ into something similar to MSDOS
Here's a small program file - the filename can be anything, but I would choose COGRAM.FTH to match the name of the top level word. It just displays COG and LUT memory contents. Note that the program is compiled, run and then forgotten again - it leaves no permanent trace. Also note the use of NULL and CON to minimise unnecessary output to the console before and after the program runs:-
NULL pub COGRAM CON CRLF CRLF ." COG 0 COG memory" CRLF 0 $200 COG DUMP CRLF CRLF ." COG 0 LUT memory" CRLF 0 $200 LUT DUMP CRLF NULL ; COGRAM FORGET COGRAM CON
Thanks for sharing!
Version 2 of this utility adds the feature that file loading is nestable. If an unknown word is encountered in the file being loaded, then a file of the same name will be searched for and loaded. Afterwards, the rest of the original file is loaded. This is useful so that library filenames may be included in the source and those libraries will be loaded automatically from SD card. File parameters are saved and restored on the L stack.
N.B. Don't use the block load mode TAQOZ ... END if your file contains references to other files - nested loads only work with normal load mode.
Here's the code:-
I am not a FORTH fan at all, but played around a bit with it a while ago getting FORTH in lower RAM and Flexspin in higher RAM working together to present TAQOZ as a usable Object for Spin/Basic/C, whatever.
Basically I got it running, but lost interest while Peter was changing the binary almost daily so I could not really send something to Eric.
My plan was to present a TAQOZ object where you can send string commands to TAQOZ from any supported language and receiving the response and being able to use the power and speed from TAQOZ by letting TAQOZ doing the whole IO thing, just using it as coprocessor, somehow.
I started with ROM TAQOZ but needed to change serial I/O from TAQOZ to a Mailbox, then switched to including a changed version with serial already redirected and lost somehow the drive to do it because defining words in Spin Source looks ugly and takes away a lot of memory.
What you did here would eliminate the problem, I could use ONE TAQOZ binary and load the needed words from SD without compiling them into the Flexspin source (Spin Basic C whatever).
This is great. Really.
I hammered with real work right now, but you gave me some reason to look into that again, as soon I have more time.
Here the link to the old thread, if you are interested... https://forums.parallax.com/discussion/169620/hijacking-the-p2-eval-rom-now-hijacking-current-taqoz#latest
Hi Mike (@msrobots), thanks for the nice comments.
I remember your 'Taqoz as i/o coprocessor' conversation with Peter. Good to hear the sdcard utility has got you thinking about it again. Since Taqoz doesn't change much any more, it's been worthwhile writing forth libraries and documentation for it, which hopefully increases the number of users. A language needs to be stable for a community to grow around it. When you've more free time I hope you have another go and publish some code. A bridge to the other languages would also attract more users.
Hi Mike and Bob,
As there is a slowly growing amount of libraries, I have been thinking how to make them available to Forth. One way to achieve this would be to include a Forth written in C, like Atlast. https://www.fourmilab.ch/atlast/
Have you had a chance to try Atlast on the propeller, Christof ? It's certainly a unique add-on for any application written in C. It would be slower than Taqoz - but that isn't a big deal for the purpose it's been designed for.
No not yet.
I have tried a version for arduino (on Teensy4, I think) and a version for raspi Pico, where I was able to enable the usage of its 2 cores. So I am quiet confident, that it is possible.....