www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/09/09:24:28

From: Chris Holmes <cholmes AT surfsouth DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Question on Pointer
Date: Sun, 08 Aug 1999 13:27:18 -0400
Organization: Georgia Institute of Technology, Atlanta GA, USA
Lines: 27
Message-ID: <37ADBDF6.550A@surfsouth.com>
References: <01BEDFF7 DOT 34B8E040 AT hpfront>
NNTP-Posting-Host: r69h109.res.gatech.edu
Mime-Version: 1.0
X-Trace: news-int.gatech.edu 934144023 16249 128.61.69.109 (8 Aug 1999 20:27:03 GMT)
X-Complaints-To: usenet AT news DOT gatech DOT edu
NNTP-Posting-Date: 8 Aug 1999 20:27:03 GMT
X-Mailer: Mozilla 3.04Gold (Win95; I)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

George Kinney wrote:
> 
> >>     I would like to convert an address into a segment and an offset,I know
> >> how to do it with Borland C (use of FTP_SEG and FP_OFF), but with djgpp I
> >> have not found how to do it
> >>
> >> Thanks

  Simple.  
  In protected mode, you have a selector and an offset.  The final 
address is simply selector + offset.
  In real mode, you have a segment and an offset.  The final address
is: segment * 16 + offset.  That's where the 1 meg limit came from 
(by multiplying the segment by 16 (or bit-shifting left by 4), that
gives
a 20 bit pointer, which makes the upward limit 1 meg (1 meg + 64K-15 if
you want to access some memory slightly over the top.  This was used
as a hack for years to access more than 1 meg in real mode).

  Chris

-- 
I know that I will never be politically correct,
and I don't give a damn about my lack of etiquette!
-- Meatloaf


- Raw text -


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