Click to See Complete Forum and Search --> : Memory allocation in Virtual Mode


GreekS85
January 21st, 2005, 07:10 AM
Hi guys! i'm trying to allocate a modest amount of memory, merely 512 bytes, so i call the DOS interrupt 21h to allocate memory:

Input:
AH=48h (The code for memory allocation function)
BX=20h (paragraphs of 16 bytes, 20hx16=512d)

after return from the interrupt, i get:

Output
AX=0008 (error code, 8 stands for Insufficient memory)
BX=0007 (available paragraphs, only, what?! 70h bytes?)

My System runs on Mindows XP. The program is assembled using debug run through cmd.exe. I definately have more memory then that; 256mb.

My config files for the 16bit subsystem are:
AUTOEXEC.NT
@echo off
lh %SYSTEMROOT%\system32\mscdexnt.exe
lh %SYSTEMROOT%\system32\redir
lh %SYSTEMROOT%\system32\dosx
SET BLASTER=A220 I5 D1 P330 T3

CONFIG.NT
dos=high, umb
device=%SystemRoot%\system32\himem.sys
files=40

I wouldn't like to use anything else for that small an amount! XMS is way too complicated. I also need something not depending on HIMEM.sys or 386 processors. Do you suggest any othe memory management system?

japheth
January 22nd, 2005, 01:36 PM
you possibly have to free the memory first. DOS usually loads an app into the largest free conventional memory block and marsk the whole block as being used by the app. Very often this block was the only free block, so any further memory alloc request will fail.

GreekS85
January 23rd, 2005, 10:40 AM
Thanks Japheth!
You gave me a some ideas on how to overcome that problem.

Is there a way to find out the descriptor i have to feed to the int21 function 4A(Modify memory allocation - Resizes allocated memory block)?

Is this number located somewhere in the psp? how can i find out the PSP location from the debug program?
If in virtual mode DOS allocates so much memory for debug, then i guess i have to reduce its memory, right?

japheth
January 23rd, 2005, 02:50 PM
> If in virtual mode DOS allocates so much memory for debug, then i guess i have to > reduce its memory, right?

> Is there a way to find out the descriptor i have to feed to the int21 function
> 4A(Modify memory allocation - Resizes allocated memory block)?

Its the value of the PSP itself (DS or ES register when program starts, or get it with int 21h, ah=62h)