TI Forth
TI FORTH is supplied on a floppy disk and requires a disk system, 32k, and EITHER Editor/Assembler OR Extended Basic .... (separate disk for ExBas version).
You receive your disk with TI FORTH on it. FIRST: Copy the disk, using your Disk Manager module.
Note the TI supplied disk is Single Sided Single Density (90k). TI Forth as supplied assumes you are using 90k disk drives.
If you use double sided drives, initialise the copy disk as SINGLE sided: the double sided header is larger and makes a mess of the Forth screens. Later on maybe we'll go over formatting JUST the second side for your program screens... clever is Forth!
Now, put the original disk in a safe place!
System Disk
The SYSTEM DISK carries most of the FORTH language on its files "FORTH SCREENS".
It is a feature of FORTH that it rewrites the disk files, and it is easy to accidentally overwrite your system disk! So don't do ANYTHING until you have a nice safe copy!
Now... Editor Assembler: Select "LOAD AND RUN", File name is: DSK1.FORTH or EXTENDED BASIC: Put the disk in the drive and select ExBas. Autoload takes care of the rest.
You will see the message 'Booting Forth', followed by a menu of options, and after a short delay, a cursor will appear.
A menu will appear: only the 'kernel' of Forth has been loaded.
To use Forth, you must select portions from the menu: the more you load the less memory is free for your program.
We will use the menu to create a 'custom' Forth which loads pretty quickly...
Note as you use these Menu options just how slowly they function!
Fortunately, we can load our desired selection, then BSAVE the whole lot, to be BLOADed when required, in one piece, quickly!
Screen Dump
Now, the SCREEN DUMP is located on SCREEN 72, and may not be suitable for your printer. Lets have a look ....
In order to EDIT screen 72, we need to load an editor. Choose EITHER the 40 column editor (-EDITOR) or the 64 column editor (-64SUPPORT)
(NOTE: To start with do not use the 64 column editor, see note towards the end of this article). To load these just key in the name, with the dash in front, and press ENTER.
Now when the cursor reappears, type in 72 EDIT [enter] Screen 72 will be loaded and will appear on screen. As supplied, screen 72 is set up for RS232. If you use PIO, make the following changes: Line 2: Change >RS232 to >PIO Line 3: Change >RS232 to >PIO Line 4: Set the string to the actual file name used by your printer, that is " PIO" or " PIO.CR" and so on. Remember the single space after the first quotes!!!!! (quote, space, PIO, quote)
Check the screen: some versions have a typing error from TI! lf you see the word PAB_ADDR, you must change it to PAB-ADDR.
Now press FCTN 9 (BACK) to return the cursor to the bottom of the screen.
Now we write the amended screen to disk by typing FLUSH [enter]
Let's make sure everything really is been cleared out: type in COLD [enter] and when the cursor reappears, EMPTY-BUFFERS [ENTER]
Custom Forth Disk
We are ready to customise FORTH.
As a beginning we will need to boot most of Forth...
This is MY selection.
Type EMPTY-BUFFERS [enter] Now type in, on one line: -PRINT -COPY -VDPMODES -BSAVE [enter] Thats the essential FORTH.
When the disk stops at last and the cursor reappears, let's put a marker flag in there: type in:
: FLAG1 ; [enter] (colon, space, FLAG1, semicolon .... then [enter]
A bit more Forth: type in, on one line: -GRAPH -DUMP -FLOAT [enter] Now another flag. Type in : FLAG2 ; [enter]
and finally, your choice of editor, either -64SUPPORT (see note) or -EDITOR [enter]
Thats almost everything you are likely to need.
Lets save it! To save EVERYTHING in memory, and to locate it on the disk from screen 51 onwards (deleting what was previously on those screens!!!!:
Type in: ' TASK 51 BSAVE [enter] The first character there is a FCTN O, a single quote.
When the BSAVE has ended, you need to amend the "BOOT" screen, screen 3, to BLOAD your binary image.
New BOOT screen to load the new system disk
Type in 3 EDIT [enter]
and adjust your screen 3 to look something like this:
SCR #3 0 ( WELCOME SCREEN ) 1 BASE->R HEX 10 SYSTEM ( Clears Screen ) 2 0 0 GOTOXY ." Loading TI Forth " CR 10 83C2 C! ( Quit Off ) 3 DECIMAL 51 BLOAD 16 SYSTEM MENU 4 1 VDPMDE ! 5 0 DISK_LO ! 6 7 180 DISK_HI ! 8 9 : FREE SP@ HERE - . ; 10 11 : PAGE 0 0 GOTOXY CLS ; 12 13 -6392 FENCE ! 14 15 R->BASE
When copying, omit for the time being the FENCE line! See below...
Thats my WELCOME screen.
Explanation of bew Boot screen
180 DISK_HI ! on this screen sets the system up for two single sided drives 180 DISK_SIZE 9 on this screen sets up for one or more double sided drives 360 DISK_HI ! on this screen sets up for two double sided drives. The EXCLAMATION MARK (! is important here!) DISK_HI is the highest numbered screen, at the rate of 90 per single side. DISK_SIZE is the number of screens per DISK.
FREE will allow you to obtain the free memory at any time just by keying FREE.
PAGE will at any time clear the screen and home the cursor.
Once you have set up your screen three, as above or adjusted for your disk system, FLUSH it for the time being ..........
Press FCTN 9 (BACK) then enter FLUSH [enter]
One more step (about fences):
In Forth you can FORGET the basic Forth words, such as +... and in the course of doing so, FORGET everything above it in memory, which can be quite drastic. FORTH allows you to place a FENCE which prevents you FORGETting important things.
Having FLUSHed page 3, if you type ' PAGE . then you will receive a helpful ?.
This is because our new word PAGE is not yet in memory, we need to LOAD it!
To get our new page 3 in memory for the next step,
we now need to type EMPTY-BUFFERS and then 3 LOAD
Let's see where the top word in the COMMAND STACK is:
Type in ' PAGE . [enter] (single quote, space, PAGE, space, full stop, [enter] )
The number printed is where we want to put the FENCE, so again type 3 EDIT Add to the end of the screen (as above)
[number] FENCE ! and FLUSH the screen to disk as before.
Now... cover the write protect tab!!! And your disk is all ready.
To see how quickly FORTH now loads, type in COLD again.
Screens still available
It is always a good idea to keep your boot disk separate to your own programs, but if you do need to place any new screens on it, there are a few that you can use still.
Our fairly full Forth BSAVE took up from screen 51 to screen 61.
The following screens cannot then be used for our programs: 0/5 : Used by the system 44 : TRACE ( not Bsaved. You may want to load it later) 51/61 : Our Bsaved area! 68/71 : FILE ( not Bsaved. May wish to use it later) 74/75 : Code and Assembler. ( not Bsaved. May wish to use it later) 88 : CRU ( not Bsaved. May wish to use it later)
The Forth loading program which contains the "kernel" of Forth is held on Screens 5 to 21. You can use a small number of screens on spare disks to have most of Forth on it and lots of rooms for your programs.
They will have almost all of TI Forth on them to draw on. Then the other screens are available for you to use. Add any of the above screens as you need them.
Copy with SCOPY or SMOVE screens 0 to 21 (Kernel) and 51 to 61 (BSaved).
If you have loaded EDITOR into the Bsaved portion, you may wish to retain the 64Support on your disk: it is on screens 22 to 29
If you have used 64Support in your Bsaved version, then you may wish to retain the 40 column EDITOR which is on screens 34 to 38.
ALL other screens are in the Bsaved portion! Screens 0 to 5 remain used by the system. Screens 4 and 5 contain the error messages.
Errata
Various sources have form time to time indicated flaws in the original version of TI Forth released by Texas Instruments. Because all of Forth can be rewritten debugging is merely a question of opening the page with the faulty code, amending it, and saving it.
Unfortunately none of the amendments below can be said to be "official", so before making them, do keep a record of any changes you make in case you need to remove them. And keep a copy of the original disk somewhere safe. Just in case.
Screens 58 and 59 - Sprites
The Sprite definitions may have been a semi-official correction:
Check your disks - use 58 LIST then 59 LIST.
Look at the dates at the top of the page. what year? If 1982, you need to make the following amendments:
Type 58 EDIT. Change line 10 (part of SSDT definition): formerly: ... 80 0 VFILL ENDIF to become:... 80 0 VFILL 300 ! SATR ! ENDIF
Use FCTN 9 [back] and when back at the bottom of the screen (having removed the disk write protect tab!) type FLUSH.
Type 59 EDIT, and make amendments as follows: Line 7 (part of SPRITE definition) formerly .... I 2 VMBW ENDIF .... to become: .. I 2 VMBW DROP ENDIF .... Line 9 (part of MOTION definition:) Formerly: ... + >R 100 U* DROP + SP@ ... to become: .. + >R 8 SLA SWAP 00FF AND OR SP@ ... Use BACK and FLUSH to disk.
To be really efficient, you may wish to change the dates on the screens from 1982 to 2OOCT83!!!
Print a SCREEN
To PRINT a single screen, type in: SWCH 3 LIST UNSWCH to list screen 3 in this case.
List WORDS available
To see a list of words available to you, type in VLIST [enter]
Hold SPACE to halt the scrolling!
Entering lines in TI Forth
SPACES are IMPORTANT. If I show a space, put one in!
First, mark the beginning of the memory area you are about to use: ENTER:
: ME ; (that is: COLON,SPACE,ME,SPACE,SEMI COLON, then ENTER)
The word ok will appear, then the cursor will come back.
This is quite important. Every word you define in FORTH is entered into memory.
If you use FORGET ME, the definition of ME is removed AND EVERY WORD DEFINED AFTERNARDS. This can avoid annoying warning messages!
Putting that blank definition of ME at the start of your work is a useful way of scrubbing definitions.
Multiple definitions of words
Now that ME is in the library, lets experiment with multiple definitions):
ENTER : PRINT 4 . ; (Do type in the colon after ENTER) then ENTER : PRINT 5 , ;
The computer obtained a warning message from the disk: note it and continue:
ENTER : PRINT 6 , ; this time the warning message is brought from memory!
Now what does the word PRINT do? Let's try it:
ENTER PRINT Hmmm. It has the LAST definition we put in! ENTER FORGET PRINT
ENTER PRINT now it has the 2nd to last definition!
You are warned if you redefine a word, but the new definition is the one that will be used. If you FORGET the word, the previous definition now becomes current, and so on. You can have a full stack of definitions of PRINT, and then delete them backwards!
You can even redefine basic FORTH words such as +, so be very careful! To check to see if a word is already in FORTH, key in:
' WORD .
and if an address is printed, the word is in there already.
Redefining words is considered bad practice!!!!
Multiple markers
Using ME as the first defined word, (we could have used AUDREY or anything else), we can still use ME to place another marker on the stack, and delete first the second section with FORGET ME, then delete the first section with another FORGET ME!
Notes
FORTH is a useful language, as you are able to experiment with the stacks without having to actually enter and run a program. It is very like LOGO in this respect.
These simple tests have been in 'direct mode', we have not stored a program yet, merely tried defining some simple words.
That is the strength of FORTH: If a command you want does not exist, you can define it in terms of existing commands, and build up your own powerful vocabulary.
Entering a FORTH program
To enter a program onto a Forth screen, if you wish to use say Screen 15, type: 15 CLEAR 15 EDIT
Using Disk Drive 2
If the disk is in drive two, the position of screen 15 is now called Screen 105!!! (eg add 90). FORTH only uses the disk number for the FORMAT command.
When accessing screens you do so only by screen number. Disk one is 0-89, Disk two contains 90-189. .
64SUPPORT
note on -64SUPPORT: If you load -64SUPPORT, ensure that -TEXT is loaded before you use it (-VDPMODES includes -TEXT We loaded -VDPMODES into our newly BLOADED Forth just before FLAG1 way up in this article)
If -TEXT is not resident, you will not be able to leave the 64 column split screen.
To change from the 64 column screen to normal, just back out with FCTN 9, then at the bottom of the screen enter the word TEXT [enter].