Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Nov 1995 23:37:00 +0100 (MEZ)
From:      wolf@prz.tu-berlin.de
To:        mrami@minerva.cis.yale.edu
Cc:        sysseh@devetir.qld.gov.au, chat@freebsd.org
Subject:   Re: Anybody with a Turbo C++ compiler able to answer a couple of questions?
Message-ID:  <199511282237.XAA26907@tubkom.prz.tu-berlin.de>
In-Reply-To: <Pine.BSF.3.91.951128003600.2639E-100000@mramirez.sy.yale.edu> from "Marc Ramirez" at Nov 28, 95 00:43:00 am

next in thread | previous in thread | raw e-mail | index | archive | help

Marc Ramirez wrote:
> 
> On Tue, 28 Nov 1995, Stephen Hocking wrote:
> 
> > What do the macros FP_SEG & FP_OFF do? I think that they are for getting the 
> > segment number & offset respectively of a pointer, but am not sure.
> 
> I believe you're right.  Grep (TC comes with grep!  I love that!) through 
> dos.h.  If I remember correctly, it's in there (god, I haven't used Turbo 
> C since I was 15 or so).  It should, of course, say something like
> 
> #define FP_SEG(x) ((long)(x)<<16L)
> #define FP_OFF(x) ((long)(x)&65535L)
> 

At least in Borland C++ the definition is actually:

#define FP_SEG( fp ) ( (unsigned) (void _seg *)(void far *)( fp ))
#define FP_OFF( fp ) ( (unsigned) ( fp ))

This is because a "far" pointer ("far" means more then 64k) is
32 bits long but not stored as any normal human expects, but instead
with a 16 bit offset in the first two bytes and a 16 bit segment
in the second two bytes, as in the 8086/8088 days (at least in
the classical "memory models").

Thomas
-- 
Thomas Wolfram        <thomas@aeon.in-berlin.de>    Germany:    0 30 31421171
PRZ TU Berlin         <wolf@prz.tu-berlin.de>        abroad:  +49 30 31421171
EANTC                 WWW:                  http://www.prz.tu-berlin.de/~wolf
_____________________________________________________________________________
_____S__I__C____T__R__A__N__S__I__T____G__L__O__R__I__A____M__U__N__D__I_____



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199511282237.XAA26907>