The LazyBoy Library Manual - DOS_Alloc

Part of the Memory Management group.

%imacro DOS_Alloc 1
Prefers: BX

Allocate a DOS memory block.

%1 is the size of memory requested in paragraphs.

If successful on return, %1 will be the segment of the block and the Carry Flag will be clear.

If not successful because there was insufficient memory available, the Carry Flag will be set and the largest available block size will be returned as %1.

The only other reason for a request to possibly fail is when the MCB chain has been damaged. If the MCB chain is damaged, the operating system is unstable and will require a reboot. When DEBUG is enabled, the program will Terminate with an error code. When DEBUG is not enabled, the macro will store the error in EXIT_CODE. It will return with the Carry flag set and no free memory blocks available. The program should terminate as soon as possible.

I may change this behaviour to always Terminate the program if the MCB chain has been damaged.

Example:

    DOS_Alloc BX

See also: DOS_Release and DOS_Resize.and EXIT_CODE.