How to detect all available memory (used and free)

GFA, ASM, STOS, ...

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

mikro
Atari God
Atari God
Posts: 1582
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

How to detect all available memory (used and free)

Postby mikro » Fri May 11, 2018 2:55 pm

Hi,

I need to do a simple task -- show how much memory I have in computer. And I have realised I have no clue how to do that. :) A series of Malloc(-1) + Malloc() calls could perhaps reveal how much free memory I have left but I'm clueless about already taken one.

Yes I know there's a zillion tools for this task but I need to do this as my own tool, even before reaching the desktop.

Zippy
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 146
Joined: Sun Feb 01, 2004 1:58 am

Re: How to detect all available memory (used and free)

Postby Zippy » Fri May 11, 2018 2:59 pm

For the total RAM size (as detected by the BIOS on boot) you can check the system variable "phystop" at address $42e.w , from super mode. eg. it'll be $80000 for a 512K machine or $100000 for a 1MB machine.

Or if you want user memory rather than total memory you could calculate it from the system variable "_memtop" at $436.w and "_membot" at $432.w , which are the top and bottom of user memory.

mikro
Atari God
Atari God
Posts: 1582
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

Re: How to detect all available memory (used and free)

Postby mikro » Fri May 11, 2018 3:18 pm

Thanks Zippy, that's exactly what I'm looking for. You saved me a while of searching in The Compendium. :)

User avatar
Arne
Captain Atari
Captain Atari
Posts: 437
Joined: Thu Nov 01, 2007 10:01 am

Re: How to detect all available memory (used and free)

Postby Arne » Fri May 11, 2018 3:39 pm

That method works for ST-RAM only, but not for Alt-RAM.
Image

User avatar
dhedberg
Atari Super Hero
Atari Super Hero
Posts: 702
Joined: Mon Aug 30, 2010 8:36 am
Contact:

Re: How to detect all available memory (used and free)

Postby dhedberg » Sat May 12, 2018 8:36 am

Arne wrote:That method works for ST-RAM only, but not for Alt-RAM.

What address space is Alt-RAM mapped to? I guess it depends on the card/accelerator?
Daniel, New Beat - http://newbeat.atari.org. Like demos? Have a look at our new Falcon030 demo MORE.

Moulinaie
Captain Atari
Captain Atari
Posts: 186
Joined: Wed Feb 01, 2012 9:34 pm

Re: How to detect all available memory (used and free)

Postby Moulinaie » Sat May 12, 2018 9:55 am

dhedberg wrote:
Arne wrote:That method works for ST-RAM only, but not for Alt-RAM.

What address space is Alt-RAM mapped to? I guess it depends on the card/accelerator?


Hi,

Check LONG at $5A8 (ramvalid) and if it's $1357BD13
then you have at $5A4 (ramtop) a pointer to the end of Alt Ram.

Usually, this ram should start at $01000000.

Guillaume.

joska
Hardware Guru
Hardware Guru
Posts: 3997
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: How to detect all available memory (used and free)

Postby joska » Sat May 12, 2018 10:47 am

What you are describing is TT-RAM. Alt-RAM can be "anywhere". I'm not sure how to properly detect alt-RAM (RAM added with Maddalt()), as theoretically you can add multiple chunks of alt-RAM.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
Arne
Captain Atari
Captain Atari
Posts: 437
Joined: Thu Nov 01, 2007 10:01 am

Re: How to detect all available memory (used and free)

Postby Arne » Sat May 12, 2018 11:09 am

Jo is right. You can have more than just one section of Alt.RAM at the same time - see MagnumST. Then the contents of $5A4 is probably not non-ambiguous.
Image

User avatar
dhedberg
Atari Super Hero
Atari Super Hero
Posts: 702
Joined: Mon Aug 30, 2010 8:36 am
Contact:

Re: How to detect all available memory (used and free)

Postby dhedberg » Sat May 19, 2018 7:12 pm

Ouch, what a mess!
Daniel, New Beat - http://newbeat.atari.org. Like demos? Have a look at our new Falcon030 demo MORE.

arf
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 138
Joined: Thu May 17, 2012 9:56 pm
Location: Germany

Re: How to detect all available memory (used and free)

Postby arf » Sat May 19, 2018 11:33 pm

dhedberg wrote:Ouch, what a mess!


Well, it wasn’t really planned when the ST was created. And for application programs it doesn’t really matter where the RAM is or where it is located.


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: No registered users and 1 guest