psuvm%cjs@psuvax.UUCP (01/03/84)
Has anyone had success using DOS 2.0 function 48h to allocate memory (page D-43 of DOS 2.0 manual)? I've been using code like: mov bx,10h ;number of paragraphs mov ah,48h int 21h Pretty simple. Carry flag gets set to indicated an error, and AX contains the error code 8 -- which means not enough memory. I've been able to allocate only 3 paragraphs without error, and these were put way down in DOS. Shoot, I got a 640K machine, so there is pleanty of memory available. I'd like to allocate a large buffer (4k or more) dynamically. Don't want it taking space in my .COM files. Cannot find any information on how DOS allocates memory other than that one page in the manual. Any suggestions?
starr@shell.UUCP (Bob Starr) (01/11/84)
printf("hello world") When DOS invokes a program, all of available memory is assigned to it (see p. E7, paragraph 2 in DOS 2.0 manual). You need to free some memory before you can allocate it (using function 49h). But what to set ES to when invoking function 49h is another story. If your program does not terminate and stay resident, then just figure out where the end of the program you are running is (after the end of the data segment), add a few bytes (for safety), and choose a segment around there to pass to function 49h. Or, for that matter, since DOS has already assigned the space to you, just use it! If your routine terminates and stays resident, I know of no easy way to determine where to begin freeing and allocating memory.