Path: utzoo!mnetor!tmsoft!torsqnt!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!cs.utexas.edu!uunet!olivea!tymix!cirrusl!sunstorm!dhesi From: dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) Newsgroups: comp.os.msdos.programmer Subject: Re: farmolloc and malloc Message-ID: <2936@cirrusl.UUCP> Date: 9 Feb 91 02:31:29 GMT References: <30456@shamash.cdc.com> Sender: news@cirrusl.UUCP Organization: Cirrus Logic Inc. Lines: 30 In <30456@shamash.cdc.com> jeff@u02.svl.cdc.com (Jeff Needham) writes: >No matter what I try, or how small my program is, I find that "malloc" and >"farmalloc" allocate space in the same segment, which starts out at about >62000 bytes long. At the very least, I wish they could use two different >segments of that size. Typically when you call malloc or farmalloc, they will allocate memory sequentially, allocating as many bytes as you ask for, and always allocating the next block from roughly where the previous bllocation left off. In Intel CPU-based machines, the concept of "same segment" exists only before the program is linked. Once it is linked and loaded, memory is in a linear address space, and only its *addressing* is segmented. (The CPU knows about segments but the memory hardware does not.) The real memory address is always linear, but it can be expressed in different ways using different values for segment and offset. So, if you want to treat different blocks of memory as being in different segments, you can do so, but it has nothing to do with how it is allocated. Just assign any combination of segment and offset to your registers. Any two memory addresses that are within 64K of each other can be assumed to be either in the same segment or in different segments, as you prefer. Memory addresses that are further than 64K apart as in different segments because you must reload your segment register between references. -- Rahul Dhesi UUCP: oliveb!cirrusl!dhesi