Alright, here is the situation; I want to allocate memory in the heap for a program in 16-bit Real-Mode. I have already debugged some Borland Pascal programs and know that variables allocated heap for, even if they are 1 byte long, are put into separate segment addressed. What I?d like to know is how you could possibly know what segment address is occupied by another process and what is not. Case in point, what if a TSR grabs a segment for a local variable? How could we know what segment address that is?

After inspecting a lot of Pascal program, I noticed that the ?GetMem? system procedure which allocates memory in the heap, grabs a fixed list of segment addresses as in ?0x7397? for the first allocation attempt, ?0x6329? for the second, ?0x7398? for the third, ?0x7410? for the fourth and etc. This would mean that these segment addresses are supposed to be used as a heap for various processes, right? So what if you are using it and another TSR attempts to use it too? Unfortunately, the Assembly code generated by the Turbo Pascal compiler that I own is excessively nested and the calls, either far or near, are not correctly translated by ?WDasm? to their actual segmented or normal address, making it much harder to trace the code.

By the way, I?m not looking for strategies like ?Worst fit? or ?First fit? as I?d just need to grab a segment per variable and let the variable maneuver there. I?ve already searched in a lot of web sites related to this topic but unfortunately, I couldn?t find any straightforward answers. However, I?ve read a bunch of theories but theory is not what I need!
Posted on 2006-10-26 02:41:35 by XCHG