3

I've read that in the days of the Intel 8086 CPU the biggest registers were 16-bits and everyone were looking for a way to access more than 65536 bytes of linear memory but instead of expanding the CPU registers they invented the segment:offset addressing scheme and the way I understand it you're able to "group" two 16-bit registers together into a 32-bit memory address. But the same place I have also read that the CPU could only access 1MB of memory. How does that work? 2^32 equals 4,294,967,296 so I don't understand, please enlighten me :)

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Benjamin
  • 541
  • 1
  • 9
  • 17

3 Answers3

3

The segment register value is shifted left by 4 (multiplied by 16) and added to the "offset" part of the address address.

16 * 65536 = 1 megabyte.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Could you please show me the largest segment:offset address that can be expressed in the old x86 manner? – Benjamin Jan 01 '12 at 19:59
  • The largest effective address is 0xffffff. There are multiple segment register and offset value combinations that accomplish that. Arbitrarily seg = 0xf000, offset = 0xffff. Is this homework? – Hans Passant Jan 01 '12 at 20:22
  • No it isn't homework. But to be precise, the 16-bit segment:offset addressing scheme can access 1114095 bytes right? (65535 * 16 + 65535) – Benjamin Jan 01 '12 at 21:07
  • 2
    Only on a processor with an address bus wider than 20 bits (286 and up) with the A20 gate disabled. The extra 0xfff0 of memory (0xffff0 + 0xffff - 1MB) was called the "DOS High Memory Area" iirc. On the original 8086 the effective address would wrap back around. – Hans Passant Jan 01 '12 at 21:37
  • What do you mean by "wrap back around"? – Benjamin Jan 02 '12 at 12:41
  • If you try to access segment 0xffff address 0xffff, it rolls over due to calculation overflow, ending up at segment 0x0000 address 0xfffe on an 8086/8/186/188. On a 286+, it depends on the state of the A20 gate as to whether or not it stays compatible with the 8086 or gives access to an extra (almost) 64k of RAM (the HMA that Hans references). – Brian Knoblauch Oct 14 '14 at 17:52
1

Only four more bits (or a four bit register) were actually needed to address up to 1,048,360 bytes ...(65,535 to 1 megabyte) but they had a sixteen bit register available ...and so they used a sixteen bit register instead looking forward to the days when the memory address bus would be expanded to 32 bits. The Intel 8088 had 20 address lines numbered A0-A19 This processor could address 1 Megabyte of memory. FFFFF would be the largest linear address...4 bits per hex digit, 5 digits = 20 address lines.

I think this linear address would require a segment of 000F and an offset of FFFF

0

8086 has 20bit address line. so the maximum it can address is 2^20 = 1MB. http://en.wikipedia.org/wiki/Intel_8086

varun
  • 341
  • 2
  • 17