delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/12/05/05:33:26

Date: Tue, 5 Dec 2000 12:03:10 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Alex Oleynikov <alex AT compuweigh DOT com>
cc: DJGPP Mail List <djgpp AT delorie DOT com>
Subject: Re: Mapping a data structure into DOS memory space
In-Reply-To: <NEBBKABEDKFPFBKEMBFOCEEFCAAA.alex@compuweigh.com>
Message-ID: <Pine.SUN.3.91.1001205120252.27857I-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Mon, 4 Dec 2000, Alex Oleynikov wrote:

> Now I have a problem - how can I neatly access that data from my program? As
> far as I understand, there is no way to tell the linker to use the physical
> address for relocation of the data structures, since it is below the 1MB
> limit. I have investigated different possibilities of accessing that data
> ( through _farX functions, or using "Fat DS" trick ), but they all
> effectively limit my ability to use trivial "dot-style" variable access
> within the structures.

??? The ``Fat DS'' (a.k.a. ``nearptr'') method should allow you to use
the normal C operators for accessing the struct members.  Why did you
think it doesn't?

> Now I have to play with the offsets of my elements
> off the structure's starting address, which complicates the code and
> decreases its readability.
> Is there any other possible variant, which would allow me to still use
> simple access to the data structures' elements?

You could write a C++ class which overrides the . and -> operators
with functions that use _far* to access the data.

Alternatively, you could copy the struct's data between the
conventional memory and your program's data segment (e.g., with
dosmemget and dosmemput), and then access the copy with normal C
code.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019