kenjennings Posted April 5, 2015 Share Posted April 5, 2015 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. Quote Link to comment Share on other sites More sharing options...
Rybags Posted April 5, 2015 Share Posted April 5, 2015 (edited) 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 April 5, 2015 by Rybags 1 Quote Link to comment Share on other sites More sharing options...
ac.tomo Posted April 5, 2015 Share Posted April 5, 2015 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.