getting the amount of avilable memory

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
aymanmadkour
Posts: 11
Joined: Sat Feb 05, 2005 12:00 am

getting the amount of avilable memory

Post by aymanmadkour »

Hi...
I am working on a memory manger. I am trying to get the amount of available memory FROM PROTECTED MODE. Any ideas?[/b]
Last edited by aymanmadkour on Thu Apr 28, 2005 11:00 pm, edited 1 time in total.
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re: getting the amount of avilable memory

Post by bubach »

Best ways to get RAM size is with the BIOS:
http://my.execpc.com/~geezer/osd/boot/biosmem.asm

Otherwise you can get it from CMOS, will only report up to 64mb, or by directly probing for memory.
When probing you simply write something at memroy positions like 0xdeadbeef at every megabyte, and then you read it and compare, if it's the same then the memory position exists.

Directly probing for memory won't work on machines where you might write your little test thing ( for ex. 0xdeadbeef) onto a "bad area" like memory mapped IO devices or hitting a memory hole.

/ Christoffer
Last edited by bubach on Thu Apr 28, 2005 11:00 pm, edited 1 time in total.
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
aymanmadkour
Posts: 11
Joined: Sat Feb 05, 2005 12:00 am

Re: getting the amount of avilable memory

Post by aymanmadkour »

I used the direct memory probing solution... It is not the best one, but it worked.
Thanks :)
beppe85
Posts: 4
Joined: Sun May 01, 2005 11:00 pm
Contact:

Re: getting the amount of avilable memory

Post by beppe85 »

I dunno if there's a easy(and safe) way to do that in protected mode...because the usual way is to do BIOS calls. If you cannot get memory size while still in real mode and store in a variable, write a virtual-8086 monitor to call the BIOS services from protected mode.

This handles getting memory size from real mode. Works for me.

Code: Select all

mov     ax, 0xe801
int     15h
shl     eax, 10
shl     ebx, 16
add     eax, 1 * BytesPerMega
add     eax, ebx
mov     [TotalMemory], eax
This is my code, so it may not work in other machines.
Last edited by beppe85 on Sun May 01, 2005 11:00 pm, edited 1 time in total.
Post Reply