1

I was told that segment:offset pairs were used to represent 20 bits. The segment is 4 bit shifted, and the value plus the offset becomes the physical address. I don't have to worry anymore at 32-bit system, but I'm still curious.

  1. Why were offsets allocated 16 bits, not 4 bits?
  2. Is there no problem with many virtual addresses correspond to one physical address?
2

You are referring to the early 80s of the last century. The 8086 architecture used this way of addressing 20-bit physical memory, the then tremendous amount of 1 (One!) MByte, or "one million bytes of memory", as Intel calls it in /1/, p.2-7.

These "logical addresses", as Intel called them in /1/, served primarily two purposes:

  1. One idea behind this segment:offset scheme was to have segments of each 64kB in size which could be used anywhere (at 16Byte boundaries) in the available 20-Bit address space (8086), making these segments independent of the physical address. Intel writes in /1/, p2-8:

"Segmentation makes it easy to build relocatable and reentrant programs. ... (relocation means having the ability to run the same program in several different areas of memory without changing the adresses in the program itself)..."

  1. Another idea was to separate logical different parts of the memory in different segemts. The main identified memory regions were: Code, Data. Stack and Extra (the latter e.g. used as destination for data transfers). As a consequence the segment registers were named accordingly as CS, DS, SS and ES. These names survived until today (in the 32-bit world). Later FS and GS segment registers were added, used for specific regions for the Operating System.

Thus, to answer your first question, offsets of four instead of 16 bits could not have been used to build the segments of 64kB each, intended to be relocated if necessary. 64kB segment size are a "natural" value in a 16-Bit system like the 8086.

Regarding your second question, there might of course be a problem with overlapping segments if they are not treated carefully, e.g. when code and data overlap. But it was explicitly intended by Intel that segments could overlap in the most possible way, by giving them all the same value, allowing this segmented architecture be used in systems with only 64kByte of memory.

According to Intel (/1/, p.2-8): "In a system where the total amount of memory is 64K bytes or less, it is possible to set all segment registers equal and have fully overlapping segments."

/1/: iAPX 86, 88, 168 and 188 User's Manual, Programmers Reference, Intel 1983

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.