I have written a little function which writes all the free memory addresses above 16MB in an Array.
When i want to put the address on screen i got nothing there.
Here is my code for listing the free memory and getting a free block:
Code: Select all
unsigned long free_blocks_index = 0;
unsigned long free_blocks[1024];
void make_free_blocks_list()
{
unsigned int x;
int i=0;
for(x = 0x000000; x < (1024 * 1024 * 64); x += MEMORY_BLOCK)
{
// this is a page (considered a block)
// if block is above 16MB.. then it should have a great chance of not being used?
if(x > 0x100000 + (1024 * 1024 * 16))
{
free_blocks[free_blocks_index] = x;
free_blocks_index = free_blocks_index + 1;
}
}
}
unsigned long get_free_block()
{
free_blocks_index = free_blocks_index - 1;
return(free_blocks[free_blocks_index]);
}
which counts the memory, for example 512MB or so. When i use instead of the 64 in make_free_blocks_list the function
GetMemSize() then there is an endless loop.
This is the Sourcecode:
Code: Select all
; Function for Memorytesting
global _GetMemSize
_GetMemSize:
push ebp
mov ebp, esp
push eax
push edx
mov eax, 0
mov edx, 0x1EFFFC
.1:
inc eax
mov DWORD [edx], 0xAAAAAAAA
mov ebx, [edx]
add edx, 0x100000
cmp ebx, 0xAAAAAAAA
je .1
pop edx
pop eax
mov esp, ebp
pop ebp
ret
Code: Select all
puts("There is a free block od memory at this address:");
puts(get_free_block());
Code: Select all
There is a free block od memory at this address: