Jump to content
IGNORED

Where is the end of memory used by BASIC?


Recommended Posts

Should a BASIC program reference APPMHI ($0E/$0F), or MEMTOP ($90/$91) to determine the end of the memory used by the BASIC program? Or does it not really matter?

 

Some peeking around shows they have the same value in all the situations tested so far. Is there a circumstance where they would not be the same?

 

Oddly, the description of each location in Mapping The Atari does not mention the alternate location, though they seem to be doing the same thing. My theory here is that APPMHI is specific for the OS, and works to limit OS functions (allocating screen memory) for any program, not just the BASIC cart. And MEMTOP is specific to BASIC and redundantly tracks the same value.

Link to comment
Share on other sites

APPMHI is supposed to be maintained by the main running application. The OS uses it to determine if a screen Open operation is permissable.

So, normal mode of operation is that an application like Basic would dynamically update it to reflect it's top of memory.

 

MEMTOP ($90) is maintained by Basic and copied to APPMHI either periodically or every time MEMTOP is updated. Probably the latter as the user can upset things by pressing Reset.

 

The 400/800 OS has a bug where if you set APPMHI higher than the normal Gr. 0 DList starts, then press Reset, the machine gets stuck in an unrecoverable situation.

The XL OS fixed it by use of a flag - if the initial screen open failed, next time you pressed Reset APPMHI would be reinitialized to a value that allowed the screen to open.

 

Which one to reference? I'd use MEMTOP.

Edited by Rybags
  • Like 1
Link to comment
Share on other sites

RAMTOP is the top of RAM and MEMTOP is the top of your BASIC program + 1 byte, BASIC obtains how much free memory is available by deducting MEMTOP from RAMTOP, and that figure is shown by using: ? FRE(0). If you want to reserve & protect some memory for display lists, display memory, character-sets or misc. data, then you lower RAMTOP location 106 (each digit is a multiple of 256 bytes) & then do a GRAPHICs call, this way, memory from PEEK(106)*256 to the old RAMTOP value*256 (typically 160 in 48K machines) will not be accessible by the OS or BASIC.

Generally, with the other locations, such as 14 & 15 are in memory down that low for a reason and are usually accessed by both BASIC and the OS.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...