Create a managed memory HEAP inside the memory region that is allocated to the program. When the program is loaded into lower memory, this will be limited to amount of memory remaining above the program code and data in first 640kb of RAM.
%1 is the segment offset to the bottom of the heap. Generally, it requires a code label in the BSS section after all other uninitialized data.
If %2 if provided, it will be the minimum required size for the heap in kilobytes. The default is to require 0k. If it is unable to reserve the minimum amount of memory for the heap, the heap will remain as uninitialized and the macro will return with the Carry Flag set.
If %3 if provided, it will be the maximum size to reserve for the memory the heap in kilobytes. It will accept a value up to 1024. However, since lower memory is limited to 640kb, the actual maximum is around 630kb. It all depends on the hardware, DOS version, loaded drivers and the program's size.
Note: You can invoke the MemHeap macro to reset the Heap at any time. It can also be used to change the amount of memory used by the heap. Calling the macro will invalidate any pointers or data present in the Heap and mark all of the memory as free.
Example:
MemHeap HEAP, 10, 640 ; reserve up to 640k, require at leaset 10k MemHeap HEAP, 10 ; reserve all available program memory, at leaset 10k MemHeap HEAP ; reserve all available program memory, no minimum