Microsoft KB Archive/51908

How to Get Data into and out of High Memory Area PSS ID Number: Q51908 Article last modified on 03-25-1990

2.00

MS-DOS

Question:

In the XMS specification (Version 2.00), there is no mention of how to insert code/data into the HMA (high memory area). Can it be assumed that since the HMA starts immediately after the 1 MB boundary, the address of the HMA is fixed? What does an application need to do to use this HMA after the A20 line is enabled?

Response:

To access the HMA, you simply have to request it, turn the A20 line on, and then use it.

The HMA (if available) is at a fixed address (16 bytes above the 1 MB line). To access it, you need to make your code/data ORG at 16 bytes, deal with absolute addresses, or handle the fixups yourself.

To use the HMA for data, copy the bytes from where they are to the HMA.

To use the HMA for code, copy the code up to the HMA (movsb/w), and then jump to it. This is where the ORG 16 comes into play a little more, since code generally requires a fixup.

If you are going to write a TSR (terminate-and-stay-resident) program or a device driver that uses the HMA, make sure the entry point/interrupt address points to an entry point in conventional memory instead of the HMA, as the A20 line is not always going to be on and it will therefore make your code nonaddressable if you rely on this fact and put the entry point in the HMA.

Otherwise, functionality is very similar to writing/accessing code/data for conventional memory.

=
================================================================

Copyright Microsoft Corporation 1990.