[comp.os.msdos.programmer] XMS programming

weiss@theory.lcs.mit.edu (Paul G. Weiss) (11/16/90)

Does anyone have any experience programming to the XMS (extended
memory specification)?  I am using Microsoft's HIMEM.SYS which is
available free from Microsoft.  The version number is 2.04.

I have two questions.

(1) The High Memory Area.  XMS provides several different functions
which pertain to the High Memory Area (the first 64K bytes of memory
above 1Mb, which is addressable in real mode).  To use this memory you
must enable the A20 address line.  XMS provides four different
functions which relate to this:

	Function 03h - Global Enable A20
	Function 04h - Global Disable A20
	Function 05h - Local Enable A20
	Function 06h - Local Disable A20

What is the difference between enabling/disabling the A20 line locally
or globally?

(2) The second question has to do with Upper Memory Blocks (UMB's).
These are blocks of memory that are located between 640K and 1MB which
DOS ignores, but which may be mapped using XMS.  There are two
functions which pertain to this:

	Function 10h - Request Upper Memory Block
		ARGS: AH = 10h
		      DX = Size of requested block in paragraphs
		RETS: AX = 0001h if request is granted
			   0000h if request failed
		      if request was granted then
		      BX = segment number of block
		      DX = actual size of block in paragraphs
		      if request was not granted then
		      DX = size of largest available block in paragraphs

	Function 11h - Release Upper Memory Block

As you can see, Function 10h is very much like DOS subfunction 48h,
which allocates conventional memory, in that if it fails it tells you
the size of the largest available block.  The problem is that I have
tried this on three different machines and in each case I initially
call Function 10h with DX=FFFFh and it fails as it should and DX is
set to some value.  I then call Function 10h again, to allocate that
block, and it fails again - which is surprising because it just told
me that the block was available.  In fact I have not been able to
successfully allocate a UMB of any size.  Has anyone used these
functions successfully?