Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sharing HMA with DOS 1

Status
Not open for further replies.

AmkG

Programmer
May 12, 2001
366
PH
Now, according to the XMS [Footnote 1] standard, one, and only one, program can use the HMA [Footnote 2]. So essentially, the program who uses the HMA hogs all the HMA for itself, even if it only wants to use maybe 1024 bytes of the HMA. Most DOS users set DOS to use the HMA for the buffers it needs via DOS=HIGH, but DOS rather unfortunately needs usually just about 40K or so, wasting some 24K of HMA. So MS-DOS provided a "secret" way of allowing some other program (notably Microsoft Mouse) to use the HMA it didn't use. Here's How

Int 2fh Function 4Ah Subfunction 01h
Request size of HMA free.
input:
AX=4a01h
output:
BX=Bytes free in HMA
ES:DI=First byte free in HMA
(ES=0FFFFh,DI=0FFF0h - BX)

Int 2fh Function 4Ah Subfunction 02h
Allocate extra HMA
input:
AX=4a02h
BX=Bytes to allocate
output:
ES:DI=First byte allocated.


How to use:
1) Within a stand-alone program:
Call function 4a01h int 2fh (note it is 2Fh NOT 21h). Check if there is enough space in the HMA for your application. Then, just use it.
2) Within a TSR [Footnote 3] program:
Call function 4a01h int 2Fh and check if there is enough space. Then call function 4a02h int 2Fh and allocate the space you need. NOTE: you cannot deallocate HMA from DOS, so allocate only if your program is permanently in memory. Drivers are good candidates for this.





[Footnote
1] XMS - Extended Memory Specification, a standard which gives a method of using extended memory while in Real Mode DOS.
2] HMA - High Memory Area, located at 0FFFFh:0010h. It happens to be the first 65520 bytes of the Extended Memory.
3] TSR - TErminate and Stay Resident programs. They exit in a different manner, so that they are not removed from the memory of the computer. Usually they lock into one or more interrupts so they can provide a service while in memory.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top