[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Applesoft Basic size limitations?
Brian wrote:
I seem to be doing something wrong. I created a hello file with the
following code:
1 REM BWAS 16384
10 B = 24576
20 HOME : TEXT : PRINT "ADDRESS TO LOAD NEXT BASIC PROGRAM IS:": PRINT
B
30 POKE 103,(B + 1) - INT ((B + 1) / 256) * 256
40 POKE 104, INT ((B + 1) / 256):
50 POKE B,0
60 PRINT chr$(4);"run file"
I tried a few different memory location values for B (although 24576
is what I should use for an hgr2 program thats about 14-15k correct?
I replaced "file" with the name of my bas file. Is there anything
else I'm forgetting. Never loaded a program from a different address
location than its default.
A handy way of handling this is to start a program that needs
to be relocated with this kind of code, but executed conditionally
based on the current contents of 104. That way, there's only one
program to run, and it relocates itself by re-RUNning itself.
A simpler and faster way to POKE a 16-bit value "X" into
locations Y and Y+1 is:
POKE Y+1,X/256 : POKE Y,X - PEEK(Y+1)*256
POKE implicitly takes the INT of its second argument.
If you need to relocate above the HGR2 page, then 24576 is the
correct address. If you only need to get above HGR1, then
16384 is the correct address.
In both cases, the program and its non-string variables grow
upward from the load address, and its string variables grow
downward from HIMEM (for DOS, $9600, or 38400 decimal).
You can change where non-string variables start by setting
LOMEM as the first thing in your program. That may make it
possible to get more code in before hitting HGR1 ($2000) or
HGR2.
For example, if you only need HGR2, you keep loading your
program at $800 (actually, $801, of course), but set LOMEM
to above HGR2. This will give you another 8KB, plus whatever
space your variables require.
It's worth taking some time to plan how memory will be used
when writing a large program. Try to keep it simple, but
avoid wasting large areas of memory.
-michael
NadaNet 3.1 for Apple II parallel computing!
Home page: http://home.comcast.net/~mjmahon/
"The wastebasket is our most important design
tool--and it's seriously underused."