Function 5801h Set Allocation Strategy

mov bx, Strategy ;allocation strategy

mov ax, 5801h ;Set Allocation Strategy

int 21h

jc error_handler ;carry set means error

Set Allocation Strategy (5801h) sets the method MS-DOS uses to allocate memory.

Parameter

Strategy

Specifies the allocation strategy. This parameter can be one of the following values:

Value Meaning

FIRST_FIT_LOW (0000h) Search conventional memory for the available block having the lowest address. This is the default strategy.
BEST_FIT_LOW (0001h) Search conventional memory for the available block that most closely matches the requested size.
LAST_FIT_LOW (0002h) Search conventional memory for the available block at the highest address.
FIRST_FIT_HIGH (0080h) Search the upper-memory area for the available block at the lowest address. If no block is found, the search continues in conventional memory.
BEST_FIT_HIGH (0081h) Search the upper-memory area for the available block that most closely matches the requested size. If no block is found, the search continues in conventional memory.
LAST_FIT_HIGH (0082h) Search the upper-memory area for the available block at the highest address. If no block is found, the search continues in conventional memory.
FIRST_FIT_HIGHONLY (0040h) Search the upper-memory area for the available block at the lowest address.
BEST_FIT_HIGHONLY (0041h) Search the upper-memory area for the available block that most closely matches the requested size.
LAST_FIT_HIGHONLY (0042h) Search the upper-memory area for the available block at the highest address.

Return Value

If the function is successful, the carry flag is clear. Otherwise, the carry flag is set and the AX register contains an error value, which may be 0001h (ERROR_INVALID_FUNCTION).

Comment

This function returns 0001h (ERROR_INVALID_FUNCTION) if Strategy is not one of the specified values.

If the current allocation strategy specifies the upper-memory area but the upper-memory area is not linked, MS-DOS searches conventional memory instead.

For more information about upper-memory blocks and memory allocation, see Chapter 5, “Program Management.”

See Also

Function 48h Allocate Memory
Function 5800h Get Allocation Strategy
Function 5802h Get Upper-Memory Link
Function 5803h Set Upper-Memory Link