[comp.sys.ibm.pc.programmer] adding to the heap?

braner@batcomputer.tn.cornell.edu (Moshe Braner) (03/13/90)

Hello net.people!

I had this really hooky idea, that it aught to be possible to take
areas of memory that are known to be available, and telling malloc()
somehow that they are OK free blocks.  I am thinking of the malloc()
library function of the C compiler packages, in the large-data
models (compact, large), or the farmalloc() function in the small
model.  The holes I'd like to use include: unused parts of "shadow"
RAM above 640K but below 1 meg, an EMS window, and even the first
64K (minus 16 bytes) of extended RAM, which supposedly you can cheat
and read from "real" mode (using the segment FFFFH, offsets over 000FH
- is that really possible?).  Together it should be possible to gain
well over 100K, to be used in your program in a completely transparent
manner (if you program does a lot of small malloc()s).

So, has anybody tried this?  Does anybody have code to do this?
(You'd have to set up the block with the right stuff before you
call free() on it -- unless you compiler's library has a function
for adding a new block.)  I am looking for such code for Turbo C 2.0,
but I am sure other people could use examples for MS C or other
languages (Pascal, Modula 2).

- Moshe Braner

Cornell Theory Center, 265 Olin Hall,
Cornell University, Ithaca, NY 14853	USA
(607) 255-9401
<braner@tcgould.tn.cornell.edu>		(INTERNET)
<braner@crnlthry>			(BITNET)

stever@Octopus.COM (Steve Resnick ) (03/14/90)

In article <9898@batcomputer.tn.cornell.edu> braner@tcgould.tn.cornell.edu (Moshe Braner) writes:
>and even the first
>64K (minus 16 bytes) of extended RAM, which supposedly you can cheat
>and read from "real" mode (using the segment FFFFH, offsets over 000FH
>- is that really possible?).

It is really possible on some machines which have a way to toggle the A20
line on the CPU address bus. Normally this is disabled. The problem with
using memory between FFFF:10 and FFFF:FFFF is that other programs may assume
this memory is usable, including TSR's and device drivers..Microsoft, Lotus,
Intel and AST Research came up with an eXtended Memory Specification (XMS)
which MS has drivers free for the asking. Just call 'em up and they will send
you a manual and diskette describing the specification and provding a device driver
which implements the XMS 2.0 specification (Which is similar in function to EMS)
They also include source code for those interested assembler hackers... :)


Steve