Slimelite BBS

Segemented Mem Addressing

Back to EMULATE

From Blaise Gassend · 1996-04-09 22:46 · #73693 in EMULATE

Salut Chris,

Le 29 Mars 1996  23h46 Chris Neale disait  Tous:

CN>Hi,

CN>Anyway, the quibbles I have is that - how does it all work. I get what I
CN>have said above. I see the problem. I don't understand the solution,
CN>segmented addressing, it suggests and am lost as to how the

It's quite simple you have two 16 bit values to address a 20 bit address
space. Let's call the two values Seg and Offset. Here is how the
processor accesses memory given a segment and an address:

PhysicalAddress = Seg << 4 + Ofs;

this is the same as:

PhysicalAddress = Seg * 16 + Ofs;

You will note that using this system we can actually address a little
more than 2^20 bytes if Seg and Offset are both FFFFh, for ehample.
There is just under 64k of extra addressable space. On the older
processors (8086, 8088) The physical address wraped around to the
begining of memory. On the later processors we get to address extra
memory in this zone: the HMA (High Memory Area) It's just under 64k but
every little bit helps when you are working in the address space limited
real mode.

CN>segment:offset system works. The other thing is that - is this really a
CN>problem with todays 32/64 bit CPUS. Nevertheless I've still seen the
CN>system used in assembler.

It sure is a problem! As you know the more recent processors are all
downward compatible (otherwise programs ment to run on the older
processors wouldn't be able to work and we would have a different kind
oc computer instead on an extended one.) Most of the time when you write
for a 386 or 486 you are working in exactly the same way as on an 8086.
The only changes are in the speed of instructions and there are extra
instructions on the newer processors. It's only in protected mode that
we get to part with all the problems of real mode programming, but
that's another problem...

If you have anymore questions, feel free to ask.

Amicalement
Blaise

 * SLMR 2.1a * Don't take life too seriously... It's not even permanent.

--- FMail 1.02+   
 * Origin: LoLo BBS - Nice France (+33)9392.4752 - (2:323/23)