5.3.2 Upper Memory Blocks

An upper memory block (UMB) is random-access memory (RAM) in the upper memory area that is available for program use. The upper memory area (addresses A000:0000 through FFFF:0000) is reserved primarily for read-only memory (ROM) and memory-mapped devices, but MS-DOS can map RAM to any addresses in this area that are not used by ROM or devices.

A program allocates an upper memory block by using Allocate Memory. Before allocating any memory, however, the program must set an appropriate allocation strategy and link the upper memory area. Just as it does with conventional memory, a program sets the allocation strategy by using Set Allocation Strategy. An allocation strategy such as FIRST_FIT_HIGH (0080h) directs Allocate Memory to search the upper memory area for a memory block and to continue searching in conventional memory if it finds no available block.

Note:

If a program changes the allocation strategy to permit allocations from the upper memory area, it must save the original allocation strategy and restore it before terminating.

Allocate Memory cannot search the upper memory area unless the area is linked to the rest of system memory. A program can link the upper memory area by using Set Upper-Memory Link (Interrupt 21h Function 5803h), and it can determine whether the area is linked by using Get Upper-Memory Link (Interrupt 21h Function 5802h).

Note:

If a program changes the upper-memory link, it should save the original state of the link and restore it before terminating.

A program can use Free Allocated Memory to free any upper memory blocks it no longer needs. It can also use Set Memory Block Size to reduce or increase the size of the allocated block.

If a program was started by using the loadhigh command, the system loads that program into memory allocated from the upper memory area. Although a program may be in upper memory, any memory it allocates is subject to the current allocation strategy.

Upper memory blocks are not accessible through MS-DOS system functions unless the dos=umb command is included in the CONFIG.SYS file and the HIMEM.SYS driver and memory-management software such as EMM386.EXE are loaded. If dos=umb is not specified in CONFIG.SYS but the memory-management software is loaded, programs can access the upper memory area by using direct calls to memory-management software. For information about these direct calls, see Get HIMEM.SYS Entry-Point Address (Interrupt 2Fh Function 4310h).