Files
2024-02-19 00:25:23 -05:00

82 lines
2.7 KiB
HTML

<h2>Allocate DOS Memory Block
<img src="../0.9.gif" alt="[0.9]" width=22 height=17></h2>
Allocates a block of memory from the DOS memory pool, i.e.
memory below the 1 MB boundary that is controlled by DOS.
Such memory blocks are typically used to exchange data with
real mode programs, TSRs, or device drivers. The function
returns both the real mode segment base address of the block
and one or more descriptors that can be used by protected
mode applications to access the block.<p>
<b>Call With</b><br>
<img src="r/ax+bx.gif" alt="" width=245 height=59><br>
AX = 0100H<br>
BX = number of (16-byte) paragraphs desired<p>
<b>Returns</b><br>
<img src="r/ax+bx+dx+c.gif" alt="" width=245 height=59><br>
<i>if function successful</i><br>
Carry flag = clear<br>
AX = real mode segment base address of allocated
block<br>
DX = selector for allocated block<p>
<i>if function unsuccessful</i><br>
Carry flag = set<br>
AX = <a href="errors.html">error code</a>
<table border=1 cellspacing=0 cellpadding=4>
<tr><td>0007H</td><td>memory control blocks damaged (also returned by
DPMI 0.9 hosts)</td></tr>
<tr><td>0008H</td><td>insufficient memory (also returned by DPMI 0.9
hosts).</td></tr>
<tr><td>8011H</td><td>descriptor unavailable</td></tr>
</table>
BX = size of largest available block in paragraphs<p>
<h2>Notes</h2>
<ul>
<li>If the size of the block requested is greater than 64 KB (BX >
1000H) and the client is a 16-bit program, contiguous descriptors are
allocated and the base selector is returned. The consecutive
selectors for the memory block can be calculated using the value
returned by the Get Selector Increment Value function (<a
href="310003.html">Int 31H Function 0003H</a>). Each descriptor has a
limit of 64 KB, except for the last which has a limit of blocksize MOD
64 KB.<p>
<li>If the DPMI host is 32-bit, the client is 16-bit, and more than
one descriptor is allocated, the limit of the first descriptor will be
set to the size of the entire block. Subsequent descriptors have
limits as described in the previous Note. 16-bit DPMI hosts will
always set the limit of the first descriptor to 64 KB even when
running on an 80386 (or later) machine.<p>
<li>When the client is 32-bit, this function always allocates only one
descriptor.<p>
<li>Client programs should never modify or free any descriptors
allocated by this function. The Free DOS Memory Block function (<a
href="310101.html">Int 31H Function 0101H</a>) will deallocate the
descriptors automatically.<p>
<li>The DOS allocation function (Int 21H Function 48H) is used.<p>
<li>Refer to the rules for descriptor usage in <a href="../descriptor-rules.html">Appendix D</a>.<p>
</ul>