JJ wrote:
Hi all,
this is probably a dumb question to most folks here, in which case apologies for that.
I have seen this word "offset" in hex editors and wanted to know what
it means. Or to put it in other words, I know that the generic
definition for the word in the english language is something like "displacement". But what does it mean in hex editors and in assembler programming?
If it refers to displacement then displacement from what..?
An offset generally is the 'distance' from a
'reference point'. The reference point could
be anything, e.g.: the left bottom edge of a
sheet of paper lying on your desktop. If you
measured its width [x] as 100 and its height
[y] as 200 (whatever) units, its center will
be at offsets 50[x] and 100[y]. That is: You
had to draw one vertical line at 50[x] and a
horizontal line at 100[y] to mark the center
(where both lines cross each other).
The same applies to memory locations in your
computer. Physical memory is addressed using
continuously ascending numbers (= adresses).
Programs and allocated (reserved for private
use) memory blocks usually are accessed with
offsets (distances) to the first byte in the
program or memory block, our reference point
called 'base'. In case of programs, this re-
ference point is loaded into CS:rIP when the
program is started. In case of allocated me-
mory, the address of the first byte in that
block is our reference point. Usually, it is
stored in a register and any byte within the
block is addressed as an offset to this base
register. In iNTEL-speak, 'offset' is called
'displacement', but 'distance' might be more
picturesque and, hence, comprehensible.
The real advantage of offsets is their inde-
pencence from any real location. While their
reference points must be known locations, an
offset always is related to a reference - we
might use it to access multiple locations by
simply exchanging the reference (base).
Greetings from Augsburg
Bernhard Schornak
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 285 |
Nodes: | 16 (2 / 14) |
Uptime: | 66:50:44 |
Calls: | 6,488 |
Calls today: | 1 |
Files: | 12,096 |
Messages: | 5,275,150 |