markz@microsoft.UUCP (Mark Zbikowski) (01/09/84)
When a program is loaded into memory, it is allocated a certain amount of memory that is removed from the system pool. For upward compatability, all .COM files and all .EXE files that have not had their header modified are allocated the largest available free block. In most cases, this is equivalent to being allocated "all of memory". Please do not rely on this equivalence! When the program begins execution, the initial ES and DS are set to point to the PSP which turns out to be the first address of the program's allocation block. Any use of the Alloc system call without any prior release of memory will result in an out-of-memory condition. To free some of this, you need to place the initial contents of DS/ES into ES and then issue the SetBlock system call. To modify .EXE files so that they are allocated the minimal amount of space when invoked, you need to set the values for MinAlloc and MaxAlloc (the words at 0x0A and 0x0C in the .EXE file header) to be the same value. Note the following restrictions: Values of 0 for both fields indicate that the file is load-high. The linker will place non zero values into the MinAlloc field for unallocated data. Reducing this value will probably result in very bizarre results. The allocation scheme used in 2.0 is a boundary-tag with rover pointer. Accessing memory not specifically allocated to you will have disastrous results. Do not rely on this allocation method to remain the same.