Point to free memory Hi ,
my problem is :
How cloud i get the point of free memory, after an prog, is loaded and started!!
Compiled with tcc.
I need these to construct some kind of alloc. (Needs starpoint of free memory)
Thanks
tonyMac- 03-20-2008
I would have the compiler stick a variable at the very end of the app after the ret. That is the end of the app, and by getting it's address you can base everything off of that. That's how I did the text viewer and a few other apps.
Dex- 03-20-2008
As tonyMac pointed out you can do this:
StartOfUseableMemory dd ProgramEnd ; Marks the start of useable memory.
; Rest of your code here
ProgramEnd ; This should be you last label
To get start of useable memory and use this to get top of useable memory:
call [TopOfMemory]
mov dword[TopOfUseableMemory],eax ;return size in bytes
Note: if you use the code as above to get "StartOfUseableMemory" it will be the size of program, plus ORG , eg: if you used it in a normal DexOS program and the program was 20k in size and the org was 0x400000, it would be 0x405000 returned.
Regards Dex.
princeharrry- 03-20-2008
MEMORY Hi, Thanks for reply
@tonyMac Yes you are right! Thats the way i use it in my scc, The compiler puts the
_I_END variable at the end of the *.asm-source!!
The point is , I do not use my scc nor fasm!! I tried tcc, ported/hacked by 0x4e71,( and as I hate gas) and there i have no plan how to get pointer of free memory??#
@DEX ,with the call the result is always 0x08000000 ???
(I use qemu)
Bye
Dex- 03-21-2008
Re: MEMORY
@DEX ,with the call the result is always 0x08000000 ???
(I use qemu)Bye
That means you have no DexOS drivers loaded and you set qemu to use 128 MB of ram (is that right).
As it return the top of memory in bytes, so if you share 0x08000000 with 0x100000 (1MB) you will get 0x80 which is 128 in decimal.
So if your start of free memory (eg: "StartOfUseableMemory") returned 0x500000 (eg: org 0x400000 + program 1MB in size), you are free to use from 5MB to 128MB.
Hope this helps.
Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.