The DR-DOS/OpenDOS Enhancement Project


Re: Memory allocation in DOS precising ...... stack
Re: Re: Memory allocation in DOS precising ...... stack -- NTOSKRNL.VXE Post Reply Top of the thread Forum
Posted by: japheth
12/10/2006, 22:10:37


Most DOS MZ binaries do have this structure:

- code
- initialized data + constants
- uninitialized data
- stack

this is valid *after* DOS has loaded it into memory. In the binary file the uninitialized data and stack parts usually are missing, but DOS knows their total size from the bytes at offset 000Ah in the MZ header.

So yes, if you do a "sub sp,4000h, you have 4000h just behind your binary (+ stack).

You can also define 4000h bytes of uninitialized data, then it will be located just *below* your application's stack.

In both cases you *don't* need to hack the MZ header yourself, the linker will setup it properly.

What stack size is good? - Good is if it is "enough" :)
What is enough? - It depends.
Depends on what? - On what things your application is about to do.

"Usually" a stack size of 2 kB is enough for simple dos apps.



Post Reply Where am i? Original Post Top of the thread
Followups