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

65 lines
2.0 KiB
HTML

<h2>Allocate Memory Block
<img src="../0.9.gif" alt="[0.9]" width=22 height=17></h2>
Allocates and commits a block of linear memory.<p>
<b>Call With</b><br>
<img src="r/ax+bx+cx.gif" alt="" width=245 height=59><br>
AX = 0501H<br>
BX:CX = size of block (bytes, must be nonzero)<p>
<b>Returns</b><br>
<img src="r/ax+bx+cx+si+di+c.gif" alt="" width=245 height=59><br>
<i>if function successful</i><br>
Carry flag = clear<br>
BX:CX = linear address of allocated memory block<br>
SI:DI = memory block handle (used to resize and free
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>8012H</td><td>linear memory unavailable</td></tr>
<tr><td>8013H</td><td>physical memory unavailable</td></tr>
<tr><td>8014H</td><td>backing store unavailable</td></tr>
<tr><td>8016H</td><td>handle unavailable</td></tr>
<tr><td>8021H</td><td>invalid value (BX:CX = 0)</td></tr>
</table>
<h2>Notes</h2><ul>
<li>The allocated block is guaranteed to have at least paragraph
alignment.<p>
<li>This function always creates committed pages.<p>
<li>This function does not allocate any descriptors for the memory
block. It is the responsibility of the client to allocate and
initialize any descriptors needed to access the memory with additional
DPMI function calls.<p>
<li>Under DPMI hosts that support virtual memory, the memory block
will be allocated unlocked. The client can lock some or all of the
memory after it is allocated with the Lock Linear Region function (<a
href="310600.html">Int 31H Function 0600H</a>).<p>
<li>Under many DPMI hosts, allocations by this function are page
granular. This means, for example, that if the DPMI host uses a page
size of 4 KB (1000H), an allocation of 1001H bytes will actually
result in an allocation of 2000H bytes. Therefore, it is best to
always allocate memory in multiples of the unit of granularity (under
DPMI 0.9, use 4K bytes), which can be obtained with <a
href="310604.html">Int 31H Function 0604H</a>.<p>
</ul>