+Ripdubski Posted January 23, 2021 Share Posted January 23, 2021 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 Quote Link to comment Share on other sites More sharing options...
Rybags Posted January 23, 2021 Share Posted January 23, 2021 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. Quote Link to comment Share on other sites More sharing options...
zbyti Posted January 23, 2021 Share Posted January 23, 2021 (edited) 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 January 23, 2021 by zbyti code Quote Link to comment Share on other sites More sharing options...
+Ripdubski Posted January 24, 2021 Author Share Posted January 24, 2021 Thanks to both! I learned multiple things with the replies. The latter is what I was ultimately after. 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.