Detecting free RAM and freeing unused RAM?
Posted: Tue Nov 23, 2010 11:01 pm
I can't seem to wrap my head around the concept of detecting free RAM when it uses multiple ranges of addresses. I thought about having a function to probe every single address within a certain range and then return if that address was null. However after reading around a little bit, it is not a good idea to probe the RAM.
I am making a 16-bit Real Mode OS in Nasm assembly. The whole OS is 1001 bytes large.
After working on the OS for a while It came to my attention that I was allocating data to RAM with no functions to show how much RAM was being used nor any functions to free the RAM.
I know that "0h00000500" to "0h00007BFF" can be used.
I also know that "0h00007E00" to "0h0007FFFF" can be used.
I also know that "0h00080000" to "0h0009FBFF" can be used.
This leads up to roughly 630 KB of RAM from these addresses however my memory detection function shows I have a total of 637 KB of RAM. Seven Kilobytes lost RAM really isn't that big of a deal to me but it does make me curious as to where it went.
Code I used to detect the amount of RAM:
Are there any bios functions available to show the amount of RAM being used and to free any unused RAM?
If you want me to post the entire source code of the OS I can.
I am making a 16-bit Real Mode OS in Nasm assembly. The whole OS is 1001 bytes large.
After working on the OS for a while It came to my attention that I was allocating data to RAM with no functions to show how much RAM was being used nor any functions to free the RAM.
I know that "0h00000500" to "0h00007BFF" can be used.
I also know that "0h00007E00" to "0h0007FFFF" can be used.
I also know that "0h00080000" to "0h0009FBFF" can be used.
This leads up to roughly 630 KB of RAM from these addresses however my memory detection function shows I have a total of 637 KB of RAM. Seven Kilobytes lost RAM really isn't that big of a deal to me but it does make me curious as to where it went.
Code I used to detect the amount of RAM:
Code: Select all
getmem:
mov ax, 0
mov si, 0
xor ax, ax
int 0x12
jc .Error
test ax, ax
jz .Error
mov si, ax ;The OS uses the si register for printing text to the screen
.Error:
ret
If you want me to post the entire source code of the OS I can.