Maximite test ver 2.4A - with EDITING


Author Message
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3372
Posted: 04:24am 26 Jun 2011      

On my travels I have been adding some often requested features to the Maximite firmware (it beats doing crosswords while hiding from the mosquitoes at night).

The new version can be downloaded from:
http://geoffg.net/Downloads/Maximite/Maximite_Update_V2.4A.z ip

This is a test version so it might include a newly introduced bug or two.

New features are:
- Fixed a bug where the MOD operator did not throw an error on an attempted divide by zero.
- Added the EDIT command to allow convenient editing of program lines held in memory.
- Added the OPTION PROMPT command to enable customisation of the command prompt.
- Added the function CWD$ which returns the current working directory on the SD card.
- Added PEEK/POKE commands for manipulating memory within the PIC32 processor.
- Added a preset read only variable MM.VER which returns the version number of the firmware.

The syntax of the edit command is:
EDIT line-number

If no line number is used this command will edit the previous entry typed at the command prompt. On entering the edit mode the line will be displayed and the cursor placed at the beginning of the line.

The editing commands are:
Space - Step the cursor one character to the right
Backspace - Step the cursor one character to the left
D - Delete the character over the cursor
nnD - Delete nn characters at the cursor and to the right
X - Jump to the end of the line and enter insert mode
I - Enter insert mode. All keystrokes will be inserted before the cursor. Use escape to exit insert mode.

Use Enter (or Return) to finish editing (even in insert mode). When Enter is pressed the line is added to the program just as if it had been typed in at the command prompt. If the line number had been changed a new (edited) copy of the line will be added to memory, if it is unchanged the line will replace 'line-number'. The maximum line length that can be edited is 79 chars in VGA mode and 49 chars in composite mode.

This is a temporary facility. In the future I would like to use the full keyboard keys (insert, delete, arrows, etc) for editing.

The prompt option was very easy to do and consists of:
OPTION PROMPT string$

Sets the command prompt to the contents of 'string$' (which can also be an expression which is evaluated when the prompt is printed).

For example:
OPTION PROMPT "Ok "
or OPTION PROMPT TIME$ + ": "
or OPTION PROMPT CWD$ + ": "

Maximum length of the prompt string is 48 characters. The prompt is reset to the default ("> ") on power up but you can automatically set it by saving the following example program as "AUTORUN.BAS" on the SD card.

10 OPTION PROMPT "My prompt: "
20 NEW

The new function CWD$ simply returns the current working directory as a string.

The syntax of the poke command is:
POKE hiword, loword, val

Will set a byte within the PIC32 virtual memory space to 'val'.
'hiword' is the top 16 bits of the address while 'loword' is the bottom 16 bits.

This command is for expert users only. Via the Bus Matrix the PIC32 maps all control registers, flash (program) memory and volatile (RAM) memory into a single virtual address space (so there is no need for INP or OUT commands). The PIC32MX5XX/6XX/7XX Family Data Sheet lists the details of this address space while the source code will provide the symbolic names used in the firmware and the Maximite.map file (produced after a successful compile) will list the addresses of these symbols. These addresses could easily change with each version of the firmware so programs should use the predefined variable MM.VER to determine the currently running version.

For anyone who wants to play with the video memory - in this version it can be found at hiword = &Ha000, loword = &Hd250.

WARNING: If you use this facility access an invalid memory address the MIPS CPU will throw an exception which causes the processor to reset - with the resulting loss of the program and data in memory. To see this effect try POKE 0,0,0 (it won't hurt your Maximite!)

The PEEK function is:
PEEK( hiword, loword )

Will return a byte within the PIC32 virtual memory space. See the POKE command for notes and warnings related to memory access.

The read only variable MM.VER returns the version number of the firmware in the form aa.bbcc where aa is the major version number, bb is the minor version number and cc is the revision number (normally zero but A = 01, B = 02, etc).

Please let me know if you find any bugs or issues.

Thanks,
Geoff
Geoff Graham - http://geoffg.net