MV4th Terminal Version 2.0

Tuesday, 15 May 2012 12:47 Shael
Print
This article highlights some of the changes to MV4th Terminal for version 2.0. MV4th Terminal was originally written as a tool to help develop the MV4th16 forth system.  Starting with version 2.0 MV4th Terminal has developed into a simple forth development tool.  MV4th Terminal version 2.0 has many bug fixes and functional improvements.  The biggest change to MV4th terminal is to allow for the creation and deployment of forth source code to the MV4th16 system. 
MV4th Terminal can now connect the terminal using a TCP connection rather then using the COM ports.  I use this when testing programs developed for the SpinNet board from Parallax.
MV4thTermTCP
MV4th Terminal TCP Connection Settings
 
Over time while developing forth source code I noticed a pattern in the way I created forth programs.  First I would write the code in a simple text editor. To test the code as I was creating it I would copy text from the text editor and paste it in to the forth system using the MV4th Terminal program.  The text in the editor would contain many semantic comments and data stack contents comments. Most of the projects I worked on had far more bytes of comments text then actual forth source code.  To conserve space on the block device (eeprom) once the code worked I would strip out most of the comments and reformat the source code to fit in to one or more forth blocks (1K bytes).  The final source code would be reformatted by pasting the text editor contents in to the block editor in the MV4th Terminal program.  Finally the block file would be uploaded to the MV4th16 system using the MV4th Terminal program.
 
Starting with MV4th Terminal version 2.0 a forth project is composed of two main files the "xxx.forth" source code file and the "xxx.blk" block file.  There is an optional file that can be used when converting a .forth source code file to a .blk file, I will talk about that later.  The MV4th Terminal now contains a simple source code editor.  The contents of the source code editor can be converted in to a forth block file by simply changing to the block manager or saving the forth source code file.  If required these feature can be disabled in the program options dialog.
 
Mv4th Terminal New Edit Tab
New Code Editor Tab
 
Using version 2.0 of MV4th Terminal it is now possible to develop your forth source code in the code editor and have it instantly converted in a packed block file with all comments removed.  This means you have all your semantic comments and data stack comments and code indenting while editing the source code but can generate a tightly packed forth block format suitable for upload to the forth block device or to be pasted into the MV4th console using the paste function of MV4th Terminal program.  As an example the original BlockEditor example required 16 blocks to store. By packing the source code the block editor now fits in 9 blocks on the forth block device.  Currently the conversion from a forth source code file to a block format is one way.  If you make changes to the block data in the block manager tab remember to save it to a different file name or you will loose your changes next time you change from the code editor tab to the block manager tab.
 
MV4thEditSettings
Code Editor Setting In Options Dialog
 
As I eluded to above there is a problem with the packing of forth source in to block format and the reason for the optional third project file.  The issue resolves around the way MV4th16 reads its input stream when compiling and evaluating forth source text.  MV4th16 reads source one input buffer at a time.  If the input buffer is a block device screen the input buffer is 1024 bytes.  When the input buffer is the console device the input is broken in to lines with a maximum length of 160 bytes.  There are many forth words that read the token after the current word when evaluated by the forth system. As an example the forth word VARIABLE require that the name of the variable follow the word VARIABLE.  This means that the word VARIABLE and the name of the variable must be fully contained in a single input buffer or the forth word will fail to execute or compile.  This also applies when you paste code into the forth system using the MV4th terminal or any other terminal.  In this case it is the console input buffer (160 bytes) that must contain both tokens.
 
The MV4th terminal uses three methods to attempt to solve this problem;
 
1) MV4th terminal has a built in list of the core MV4th16 words that must be read as a token pairs and the converter will attempt to keep both tokens together.
 
2) MV4th treats any word created by the word CREATE as requiring a second token. Also any new forth word that uses any word containing CREATE is also treated as paired word.  All words which require a second token are referred to as paired words.
 
3) Since MV4th terminal can not know about all the words that require a second token a way to specify paired words is provided in the code editor.  The code editor "Paired Words" button can be used to view and change a list of forth words that require a second token.  Using this information the converter can format the block to assure that token pairs are in the same screen line.  While a token pair in a block only need to be in the same block the converter tries to get both tokens on the same screen line to allow for the block file to be pasted to the MV4th console.
 
 MV4thTermPairedWords
Code Editor Paired Words Dialog
 
MV4th terminal now supports downloading block files from the MV4th16 forth system.  When uploading or downloading block files there are some key points to keep in mind;
 
1) MV4th terminal must be connect via RS232 to the development board running MV4th16 forth.  The TCP connection can not be used at this time.
 
2) The forth system must have its deferred words "KEY, KEY?, EMIT, EMIT?, and EMPTY-KEYS" assigned to either COM1 forth words or your own serial port forth words. The forth word COM1>CON can be used to reset the forth console to use COM1.
 
3) Make sure the forth system is waiting for input on the console and not running a program or is frozen.  This may seam silly but it has got me a number of times.
 
4) Do not use the "Block Manager" feature in MV4th Terminal to edit block files that contain binary data blocks.  The binary data blocks will be corrupted when the image is saved back to a block file.
 
5) Both block file uploads and downloads require forth code to execute on the MV4th16 system. MV4th terminal checks to see if the forth system contains the required forth words in its dictionary. If the words are not present MV4th terminal will paste the forth source code to the MV4th16 system then execute the forth code when required.  If you know you need to used the upload or download features a number of times in row while testing forth code particularly  after a reset, place a copy of the forth source on the MV4th16 system block device and set it to be loaded by the auto run feature in MV4th16 version 0.92 and higher. The block files; "UploadBlock.txt.blk" and "SaveBlock.txt.blk" are included with the project files for MV4th16 forth.
 
MV4thDownload
MV4th Terminal Download Blocks Dialog
 
When using the download blocks dialog remember to set the first block and source blocks (number of blocks to download) before pressing the Download button.
 
 
Last Updated on Friday, 01 June 2012 14:51