www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/06/08:28:59

Date: Fri, 6 Sep 1996 05:23:15 -0700 (PDT)
From: Samuel Vincent <svincent AT cs DOT sonoma DOT edu>
To: Matt <fame1 AT ix DOT netcom DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: FP_SEG & FP_OFF equivelent for DJGPP?
In-Reply-To: <322f8e29.841234@nntp.ix.netcom.com>
Message-ID: <Pine.GSO.3.94.960906051357.16292A-100000@zippy>
MIME-Version: 1.0

On Fri, 6 Sep 1996, Matt wrote:

> I am converting some real mode cd player code to djgpp and nowhere can
> I find the equivelent.  I need the seg and offset for a variable that
> is required for the real mode int.  Any Ideas?
> 
> {this is probably a very dumb question}
> 
> Matt Kittleson

This is probably in the FAQ somewhere...
FP_SEG in 16 bit compilers would deal with a real mode segment
FP_OFF in 16 bit compilers would deal with a real mode offset.
Both of these would be 16 bit values.

In DJGPP as in most 32-bit compilers, you deal mainly with one
large selector (the protected mode equivolent of a real mode segment, but
more complicated than just that.)  Every pointer is a 32-bit value and is
only the offset in the program space. (A 32-bit offset.)  This is much
like a near pointer in real mode, only, instead of being limited to 64k
near pointers due to the 16-bit value, you are 'limited' to 4 gigabytes of
memory with the new 32-bit value.

Now how, might you ask, do you get a "far pointer?"  I believe the answer
the your question is the functions in the header file <sys/farptr.h>.
There are macros in there which will retrieve or store values across
different selectors, and they are very efficient.  In most cases you will
want to use these.  Some may tell you about a method of disabling memory
protection and accessing the "far pointers" directly, but this will only
work in a ring 0 DPMI provider, such as CWSDPMI.  It will not work under
any Windows or OS/2 dos shell, or any linux dos emulator.  If you wish for
information on this technique, ask the others in/on this newsgroup/mailing
list.  I never use that technique.  The farptr.h macros and functions are
just as fast, when used correctly.

-Sam


- Raw text -


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