www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/07/15:22:31

From: Tudor <tudor AT cam DOT org>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: What's Segment and Offset?
Date: Mon, 05 May 1997 18:51:18 -0400
Organization: Communications Accesibles Montreal
Lines: 22
Message-ID: <336E6466.5778@cam.org>
References: <5kdl4b$lis AT news DOT interlog DOT com> <336DEC7B DOT 5782 AT cam DOT org> <5kl3u1$98n AT news DOT interlog DOT com>
Reply-To: tudor AT cam DOT org
NNTP-Posting-Host: dynamicppp-226.hip.cam.org
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Gautam N. Lad wrote:
> Ok, what's the 'definition' fo the term OFFSET!?
I don't know the exact definition. It's a displacement (movement) of
something relative to another thing... Hmm, that doesn't sound so
helpfull..

Let's say you have a variable in a segment. The adress of the variable
is 5 :). The segment's adress is 1000. Now FP_SEG(variable_pointer) will
give you 1000, and FP_OFF(variable_pointer) will give 5. Here, 5 is the
adress of the variable _realtive_ to the segments start adress-- it is
the offset (displacement) of your variable relative to the segment the
variable is in. So if you want the actual adress in memory you do FP_SEG
+ FP_OFF and get 1005. That is the actual adress of your variable in
memory...
Hope this is clearer...:) 
> Thanks!
> Bye!

-- 
tudor 'at' cam 'dot' org
http://www.cam.org/~tudor
'This is Scott Nudds of the Borg. C is irrelevant.'

- Raw text -


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