Is there a way to dynamically allocate memory in the data segment? If so, how?
Printable View
Is there a way to dynamically allocate memory in the data segment? If so, how?
Which data segment? The segment referenced by ds or the .data segment in your exe?
Dynamic allocation is OS-dependent. In Windows, you must call one of LocalAlloc, GlobalAlloc, HeapAlloc or VirtualAlloc (with the first two being deprecated). In Linux there's some system call too. In DOS, you need to implement a memory manager (I think).
And of course you can't dynamically allocate space within your exe.
Well this is all implemented for as a 16-bit DOS .exe (after linking of course.) I could use either DS or ES (maybe FS or GS if need be)
This is all in assembler. Not one bit of it is in a higher level PL. (A very sick learning activity that I assigned myself so to learn the second of the five PLs that I need to know.)
I might be able to implement a memory manager if need be and give an overflow if there is a problem. If you have any sources to accomplish this, please share.
I have this:
http://cboard.cprogramming.com/
They have a DOS board, and as I never have programmed for DOS (too young back then) I don't know that much about it.
Basically, this is for a MS-DOS window that does not use the protected features of the processor.
Thx for the source though.