Allocate DOS Memory Block


This function will allocate a block of memory from the
DOS free memory pool. It returns both the real mode
segment and one or more descriptors that can be used by
protected mode applications to access the block.

To Call

AX = 0100h
BX = Number of paragraphs (16 byte blocks) desired

Returns

If function was successful:
Carry flag is clear.
AX = Initial real mode segment of allocated block
DX = Selector for allocated block

If function was not successful:
Carry flag is set.
AX = DOS error code:
07h memory control blocks damaged
08h insufficient memory available to allocate as
requested
BX = Size of largest available block in paragraphs

Programmer's Notes

o If the size of the block requested is greater than
64K bytes (BX > 1000h) then contiguous descriptors
will be allocated. To access the next descriptor
for the memory block add the value return by
function 0003h (see Function 0008H) to the base
selector.
If more than one descriptor is allocated under 32-
bit DPMI implementations, the limit of the first
descriptor will be set to the size of the entire
block. All subsequent descriptors will have a
limit of 64K except for the final descriptor which
will have a limit of Block size MOD 64K. 16-bit
DPMI implementations will always set the limit of
the first descriptor to 64K even when running on
an 80386.
o Your program should never modify or deallocate any
descriptors allocated by this function. The Free
DOS Memory Block function will deallocate the
descriptors automatically