I may have sorted out the memory limitation issue.
BBC BASIC's program memory is in the range ≥
PAGE and <
HIMEM. By default
PAGE is set to &A100 and
HIMEM is clamped to &C000. By increasing
HIMEM you could give more memory to BBC BASIC and by decreasing it you could give more memory to the TI-OS for new program variables.
However, there's a problem; BBC BASIC does not know of the existance of the TI-OS. Currently memory is allocated by the host interface when it loads so that the TI-OS does not run into it, but once
HIMEM is changed BBC BASIC is free to overflow this allocated memory and corrupt user variables (if
HIMEM is increased) or leaves a gap that the TI-OS can't identify as free memory (if
HIMEM is decreased).
To get around this problem I have created a
*HIMEM OS command. For example,
Code:
*HIMEM D000
would move
HIMEM to &D000. As it goes via the host interface it can perform additional safety checks, relocate the stack and insert more memory to accomodate BASIC's new area. The opposite also rings true; decreasing
HIMEM this way frees memory back to the TI-OS.
Decreasing
HIMEM the "usual" way (decreasing it via the BASIC
HIMEM pseudo-variable) has its advantages; you can use it to set aside an area of memory that isn't cleared when variables are
CLEARed (eg by running a new program). For example, if you had a 2KB assembly library you could decrement
HIMEM by 2KB, assemble the library to
HIMEM then unload the BASIC program from memory. The assembly routine is now outside BBC BASIC's memory space (though still inside the space allocated when BBC BASIC was initialised as that has not been updated by
*HIMEM) so can still be accessed.
In addition to this I have modified the
EXT# function. Usually this is used to retrieve the size of a an open file handle (eg
PRINT EXT#2 would display the size of the open file with a handle of 2). If you pass -1 to
EXT# it returns the amount of free memory to the TI-OS (as reported by
_MemChk). You could use this, for example, to allocate
all of the TI-83+ free memory to BBC BASIC:
Code:
OSCLI "HIMEM "+STR$~(HIMEM+EXT#-1)