intel manuals

Programming, for all ages and all languages.
Post Reply
sweetgum
Member
Member
Posts: 37
Joined: Thu Sep 18, 2008 11:17 pm

intel manuals

Post by sweetgum »

im reading the intel manuals and it says the following:
a 16 bit registers and a 16 bit external databus, with 20 bit addressing giving a 1 mbyte address space, what is an external databus? and how does that information imply a 1 mbyte address space
another question
the 20 bit addresses that can be formed using a segment register and an additional 16 bit pointer pointer provide a total address range of 1 mbyte, how can 20 bits combined with 16 bits lead to a 1mbyte address range? this is about the 8086/8088
page 2-1 vol 1 basic architecture
any help would be appreciated
JohnnyTheDon
Member
Member
Posts: 524
Joined: Sun Nov 09, 2008 2:55 am
Location: Pennsylvania, USA

Re: intel manuals

Post by JohnnyTheDon »

20 bit addressing giving a 1 mbyte
2^20 = 1024^2 = 1 megabyte. This is why you need to enable A20 before accessing memory above 1MB, address lines A0-A19 form the 20 bit address bus. AFAIK the 16-bit external data bus means the processor can pull 16-bits from memory in one bus cycle.
the 20 bit addresses that can be formed using a segment register and an additional 16 bit pointer pointer provide a total address range of 1 mbyte, how can 20 bits combined with 16 bits lead to a 1mbyte address range?
In real mode, the CPU uses segment:offset addressing. It uses the formula:

(segment<<4 + offset) = address

This creates a 20 bit address.
Hangin10
Member
Member
Posts: 162
Joined: Wed Feb 27, 2008 12:40 am

Re: intel manuals

Post by Hangin10 »

The 16bit databus means that, at least on the 8086 if I remember correctly, that there are 16 pins for data in/out to RAM.
It's been a long time since I've looked at how one would connect an 8086, although next to me I have one (and a Z80) just waiting for an interesting project to come along.

So the 8086 can move 16bits at one time to/from memory. As for the 20bit addresses, that's formed by:
segment * 0x10 + address. So if the segment is 0xFFFF, and the address in that segment is 0xFFFF, you end up
with 0x10FFEF. But there are only 20 address bits, so it wraps around.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: intel manuals

Post by Brendan »

Hi,
sweetgum wrote:im reading the intel manuals and it says the following:
a 16 bit registers and a 16 bit external databus, with 20 bit addressing giving a 1 mbyte address space, what is an external databus? and how does that information imply a 1 mbyte address space
The "external databus" would be a bus that connects the CPU to everything else (the front-side-bus). One bit can be used to represent values from 0 to 1 (which is 2 values). 2 bits can be used to represent values from 0 to 3 (which is 4 values). 20 bits can be used to represent values from 0 to 1048575 (which is 1048576 values); and if those 20 bits are used as an address then they can represent 1048576 addresses, and if there's one byte at each address that means 1048576 bytes, which is 1 MiB.
sweetgum wrote:another question
the 20 bit addresses that can be formed using a segment register and an additional 16 bit pointer pointer provide a total address range of 1 mbyte, how can 20 bits combined with 16 bits lead to a 1mbyte address range? this is about the 8086/8088
page 2-1 vol 1 basic architecture
any help would be appreciated
It's "address = (segment << 4) + offset". Or (in binary):

Code: Select all

  0000000000000010.... (the segment, 2 << 4)
+     0000000000000010 (the offset, 2)
= 00000000000000100010 (the address, 34)
However, this can overflow and become a 21 bit result:

Code: Select all

   1111100000000010.... (the segment, 63490 << 4)
+      1000000000000000 (the offset, 32768)
= 100000000000000100000 (the address, 1048608)
If the CPU only has a 20-bit bus, then the result won't fit and it will be truncated:

Code: Select all

   1111100000000010.... (the segment, 63490 << 4)
+      1000000000000000 (the offset, 32768)
= 100000000000000100000 (the address, 1048608)
=  00000000000000100000 (the truncated 20-bit address, 32)
Note: The 8086/8088 had a 20-bit bus, but more modern CPUs have a larger bus (e.g. a 36-bit bus or a 48-bit bus). In this case truncation doesn't happen. This caused backward compatibility problems with software that expected the address to be truncated, so they added a hack called the "A20 gate" which disables the 21st address line (forces it to zero) which effectively truncates the result of the real mode address calculation.

In most cases, an operating system will use protected mode where the addressing is entirely different (e.g. 32-bit addressing instead of 20-bit addressing), and disable the A20 gate so it can use the 21st address line.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: intel manuals

Post by Troy Martin »

In other words, it's an ugly kludge for an even uglier limitation.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
Post Reply