Jump to content
IGNORED

Action! : Compute Free Memory?


Recommended Posts

Whats the best way to determine the amount of free memory in Action!?

RAMTOP - MEMLO ?

 

CARD RAMTOP=106
CARD MEMLO=743

MODULE 

PROC Main()
CARD dT,dL,dF

dT=RAMTOP*256
dL=MEMLO
dF=dT-dL

PrintF("%EFrom:%E")
PrintF("RAMTOP=%B%E",RAMTOP)
PrintF("Top=%U (%H)%E", dT, dT)
PrintF("Bot=%U (%H)%E", dL, dL)
PrintF("Fre=%U (%H)%E", dF, dF)

PrintF("%EReserving 1K...%E")
RAMTOP==-4

dT=RAMTOP*256
dL=MEMLO
dF=dT-dL

PrintF("%ETo:%E")
PrintF("RAMTOP=%B%E",RAMTOP)
PrintF("Top=%U (%H)%E", dT, dT)
PrintF("Bot=%U (%H)%E", dL, dL)
PrintF("Fre=%U (%H)%E", dF, dF)

RETURN

 

Link to comment
Share on other sites

No.  RAMTOP is set by the OS to be the first non RAM page, then the screen will open immediately below it.

 

MEMTOP (2E5, 2E6) is maintained by the OS and will point to the address just below the Display List which should be the top of free RAM.

 

MEMLO is also wrong, it's the first free location once the OS has started then updated if a Dos or handler reserving memory is booted.

 

APPMHI (E,F) is maintained by language processors as the highest location in use (+1) - the OS refers to it when opening a screen to ensure memory corruption doesn't occur.

 

So, to deduce free RAM you'd subtract the value held in APPMHI from that in MEMTOP.

Link to comment
Share on other sites

Allocaling free memory

Quote

There isn't a function in Action! that approximates BASIC's FRE(0) command. It isn't as simple as checking the monitor to see where the end of your program is, because Action! tries to help you out by placing some non-initialized arrays beyond the end of your program code, instead of inside your program, where they're declared (specifically, CARD ARRAYs and, generally, BYTE ARRAYs over a page in length).

 

Luckily, there's an easy method for determining where the end of the program and variable space actually is. The first CARD ARRAY declared in a program is the last actually allocated during compilation.

MODULE ; Sample 1

CARD
  MEMT0P=$2E5, freemem=[0]
CARD ARRAY
  EndOfProgram(1)

PROC Main()
  freemem=MEMTOP - EndOfProgram
  PrintF("Total free memory=%U%E", 
             freemem)
RETURN

 

Edited by zbyti
code
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...