MV4th16 Version 0.92

Friday, 11 May 2012 09:22 Shael
Print
Over the past few months I have been working on an update to the MV4th16 forth project.  When I started the MV4th16 project I wanted to evaluate the abilities of the forth language on a Propeller micro controller. This release of MV4th16 as with the prior release uses the Parallax Propeller IDE to build the project.  
With version 0.92 MV4th16 has become a stand alone development environment.  MV4th16 no longer supports the use of Parallax spin code after start up, instead all code is now written in MV4th16 forth and Propeller chip assembly language.  MV4th16 forth has been reworked to add; better Propeller chip integration, faster compile and execution speed, better use of limited chip global memory, faster base I/O functions, auto run at start up, as well as many changes and bug fixes to the core library. Some of the key changes are listed in the sections below.
 
Reworked memory utilization:
Starting with version 0.92 MV4th16 implements a new memory map. The new memory map allows MV4th16 to increase free memory from 15K to over 20K after the core dictionary is loaded and all I/O buffers have been allocated. This additional free space can be used to load larger forth programs. The main methods used to gain a larger free memory region was;  drop support for using spin objects and variables, and moving the core I/O into a COG. With the requirement to support spin code removed the entire global memory can now be used by the forth system.  The main COG executing spin code is no longer required after start up and is now used to run the forth virtual CPU.  MV4th16 version 0.91 required 4 COGs with base I/O while version 0.92 uses three.
 
Base I/O moved from spin code to a COG:
The base I/O provides the forth system with the system console, block device, and I2C buss control. These I/O words use the standard Propeller chip pins 30, 31 for console serial data and pins 28 and 29 for I2C buss.  The base I/O COG in MV4th16 can be configured to use 32K to 128K eeproms as the block device.
 
The MV4th16 image requires less then 16K of the boot eeprom space. The new I/O COG code allows you to specify the starting offset for the eeprom block device. This allows the block device to reclaim the unused 16K and map them to the block device. Thus even if you only have a 32K eeprom boot device MV4th16 can now provide 16 forth 1K blocks of storage. A 64K eeprom allows for 48 forth 1K  blocks, and a 128K eeprom will allow for 112 forth 1K blocks.  The down side to using the additional 16K is that when the Propeller chip is programed by the Spin IDE the first 16 forth blocks will be erased and set to all zeros and will need to be reloaded.
 
Version 0.92 MV4th16 core dictionary now supports I2C functions; I2C-START,  I2C-STOP,  I2C-READ, I2C-WRITE, I2C-FAST, and I2C-SLOW. The last two words control the I2C speed ( 1 Mbs or 400 Kbs). See the forth code file S-35390A for an example of using the I2C buss.  To use the I2C buss functionality to access any device other then the I2C eeprom you must load the I2C forth words provided in the separate forth code file, I2C Interface .
 
Use of defered words to remap console device
A deferred word in forth allows the word to be added to the dictionary and later remapped to execute any code desired. In  MV4th16 version 0.92 the forth words; EMIT EMIT? KEY KEY? and EMPTY-KEYS have been changed to be deferred words. The forth words that access the serial console device have been changed to COM1-OUT COM1-OUT? COM-IN? COM1-IN and COM1-CLR. Additionally there is a new forth word called COM1-BAUD to allow the baud rate to be set.  At start up the new COM1-xxx words are mapped to the forth console words. Thus the forth word COM1-OUT is mapped to the deferred word EMIT, COM1-OUT? is mapped to EMIT? and so on..  There is a new forth word called COM1>CON that can be used to remap the COM1-xxx words to there standard forth deferred words.  An example of remapping of the forth console is the NET-CONSOLE code included in the W5100 folder. The NET-CONSOLE code maps the forth console to a TCP socket.
 
Use of deferred words to remap terminal device
Starting with version 0.92 MV4th16 core dictionary supports the concept of a simple terminal device. All of the base terminal forth words are defined as deferred words and do nothing after start up. The new terminal words include; AT-XY to set the cursor position,  MAX-XY to read the screen size,  XY to read the current cursor position, CURSOR to show/hide the cursor, PAGE to clear and home the terminal, and CLR-EOL to blank the display line from the current cursor position.  There are two examples of terminal drivers provided with version 0.92; ForthTerm used to control the MV4th terminal program and AnsiTerm that can be used with a standard ansi terminal.  The forth screen editor contained in the BlockEditor forth code file now requires a terminal driver be loaded to operate.
 
Improved support for Propeller chip
In version 0.92 the MV4th16 core dictionary has improved support for the Propeller chip.  New forth words such as; COG-CNT. to read the COG cnt register, CLKFREQ, to read the Propeller clock speed,  and COG-LOAD, to load and run a 1K or 2K COG binary image stored in the block device. In addition I have added a couple of forth words to allocate variables on a quad byte aligned boundary to make it simple to pass parameters to and from a given COG. The new forth word QBYTES "name" ( uBytes -- ) allocates a variable of specified number of bytes starting on a quad byte address (0,4,8,12...).  The new forth word QALIGNED ( uAdr -- uAdr' ) aligns the TOS value to a quad based boundary ( div 4 evenly ).  I have also added the forth word QVARIABLE  "name" ( -- ), that can be used to define a forth variable to hold a double cell value that is quad byte aligned (0 4 8 ...).  The forth word REBOOT was added to reset the forth system.
 
Expanded support for numeric literal syntax
Starting with version 0.92 numeric literals can be prefixed by one of there numeric base specifiers. The dollar sign "$" is used to specify that the number is a BASE 16 number.  The pound symbol "#" indicates a BASE 10 numeric literal. The percent symbol "%" is used to indicate a binary number.  These numeric BASE indicators can be used on 16 bit single cell values and 32 bit double cell values. Thus the numeric literals "#16 $10 and %10000 all evaluate to the same numeric value.
 
Auto Run feature
MV4th16 forth can now execute user provided forth code at start up.  The start up code can automatically load and execute any code stored on the forth block device. In MV4th16 version 0.91 block index 0 is reserved for comments.  In version 0.92 block index 1 is reserved to hold the auto run forth code.
 
The auto run feature can be disabled by connecting a terminal to the forth system on the default console device (COM1).  When the system is starting up it will display a message to cancel the auto run feature by pressing the ESC key.  The forth system will wait for @ 3 seconds then execute the auto run code in block index 1.
Last Updated on Sunday, 03 June 2012 09:22