PDA

View Full Version : MAX FORTH on 2107


alpierce
04-19-02, 10:27 PM
I'm a bit confused about the internal RAM on the 2107. How much is available for FORTH programs? It looks like part of it is used by the Boot Loader? I seem to run out of soace pretty quickly when doenloading source code in FORTH.

Also, what is with FORGET? I define a new word or words, but when I try to use FORGET I get a MSG # 21 as if the word is undefined. It appears when WORDS is used and executes normally, I just can't FORGET any new definitions. I thought I should be able to FORGET back to TASK at least.

rob
04-20-02, 03:48 AM
FORGET is broken. For now you can use UNDO and COLD. UNDO will remove the last definition from the dictionary even if it is not defined properly. COLD will remove all definitions from the dictionary back to TASK and is a good way to establish the same starting point when downloading code.

The internal RAM on the MCore is 8K. You can find out the current location in RAM by executing HERE. The RAM picture is a little bit complicated. There is 8K of it but it is
parcelled up like so:

+-------------+ 801FFF
| free space |
+-------------+ 801470
| C stack |
+-------------+ 800C70
| C data |
+-------------+ 80051C
| user dict |
+-------------+ 800134
| C data |
+-------------+ 800000

The boot loader does not use any RAM when it is not running such as when MaxForth is running. The user dictionary is about 1000 bytes. If that fills, then the free space can be used by setting DP to that location and this gives another 2900 bytes. As a last refuge, the C stack is 2K and grows down from 801470 but will never use all that stack space running Forth and probably up to 3/4 of it could be used in a pinch starting at 800C70.

Rob

alpierce
04-20-02, 12:57 PM
Wow, Quick reply or what?!!
Thanks Rob, that's exactly what I needed to know.

Al

les@windstream
04-22-02, 11:07 PM
Two questions following up on the previous answers: (And, let me second the thanks for the quick responses and good help they provide.)

* Is the UNDO just the last definition, or does it walk backwards down the dictionary with each invocation?

* What's the C "stack" and "data"? It's not a term I'm familiar with in FORTH. Is it used by MaxForth, especially the data space, or is that space available in RAM as well?

Thanks, again,

Les Snively

rob
04-23-02, 02:20 AM
UNDO will unwind the dictionary by one definition each time it is called even flubbed ones that are otherwise inaccessable.

The answer to the memory questions lie at the core of MaxForth. C is the the assembler. MaxForth has all the primitives like SWAP @ +, coded in C for portability while the C compilers do the last step and create an assembler version for the target micro. This also allows C code to be included and for those that want command line control, Forth heads can be added for the C functions and variables automatically. Care has been taken to achieve portability across 16 and 32 bit environments, big endian or little endian, harvard memory, with or without double integer support and other portability issues. So the pieces labeled data are referring to low level memory usage in the kernel such as pointers, variables or arrays in C while the C stack is the stack used for C function calls. The Forth data and return stack are separate stacks for the Forth engine and exist in the C data space. There is a forth stack as well, which is the floating point stack. The areas are taken unless you can figure out what isn't being used, such as the floating point stack and its pointers.

If you are having memory problems, you should be direct romming your downloads and free up RAM (but don't try and UNDO rommed code).

Rob