Int 21H [2.0] Function 4AH (74) Resize memory block

Dynamically shrinks or extends a memory block, according to the needs of an application program.

Call with:

AH = 4AH

BX = desired new block size in paragraphs

ES = segment of block to be modified

Returns:

If function successful

Carry flag = clear

If function unsuccessful

Carry flag = set

AX = error code

BX = maximum block size available (paragraphs)

Notes:

This function modifies the size of a memory block that was previously allocated with a call to Int 21H Function 48H.

If the program is requesting an increase in the size of an allocated block, and this function fails, the maximum possible size for the specified block is returned in register BX. The program can use this value to determine whether it should terminate, or continue in a degraded fashion with less memory.

A program that uses EXEC (Int 21H Function 4BH) to load and execute a child program must call this function first to make memory available for the child, passing the address of its PSP in register ES and the amount of memory needed for its own code, data, and stacks in register BX.

Example:

Resize the memory block that was allocated in the example for Int 21H Function 48H (page 438), shrinking it to 32 KB.

bufseg dw ? ; segment base of block

.

.

.

mov ah,4ah ; function number

mov bx,0800h ; new size (paragraphs)

mov es,bufseg ; segment base of block

int 21h ; transfer to MS-DOS

jc error ; jump, resize failed

.

.

.