# Relation between size of address bus and memory size; memory Segmentation in 8086

My question is related to memory segmentation in 8086. I learnt that,

8086 has a 20 bit address bus. And so it can address 2^20 different addresses. Which means it has an memory size of 2^20, i.e, 1MB.

I have a few doubts:

1. What I understand from the fact that 8086 has a 20 bit address bus is that it could have 2^20 different combinations of 0s and 1s, each of which represents one physical address. What I don't understand is that how does 2^20 different address locations mean 1 MB of addressable memory? How is total number of different addresses locations related to memory size (in Megabytes)?

2. Also, correct me if I'm wrong, the 16 bit segment registers in 8086 hold the starting address of the different segments in the memory (Code, Stack, Data, Extra).My question is, aren't the addresses in memory of 20 bits? Then how can the 16 bit register hold 20 bit addresses? If it contains the upper 16 bit of the 20 bit address, how does the processor make out to which exact address location it has to point?

P.S: I am a beginner is micro-processors and total reliant on self study, so kindly excuse if my questions seem a bit silly.

As for your first question, the memory size and the address space are the same thing. The memory is composed of addresses, where each address contains a value. In the 8086, each address contains 8bit of data. Then, $$2^{20}$$ addresses means $$2^{20}$$ records of size 8bit each. As you known, $$2^{20}=1$$Mega and 8bit=1Byte so 20bits of address means 1Mega addresses x 8bit = 1MegaByte memory.

As for your second question, you are right - the address needs 20bits, and each register is only 16bits. So the solution is to use two registers to address each address in the memory. With 2 registers we potentially have 32bits, but the address space needs only 20, so the 8086 actually manipulates the two registers to get only 20 bits. Basically, it concatenates 4bits (all zeros) to the first register (so now it is 20bits), and adds the result to the other register. It is easy to verify that every combination of 20bits is accessible via two registers (actually, multiple combinations lead to the same address).

• just a simple point that each address location contains 8 bit of data solves my first problem. Why isn't that mentioned in any text i read. Mar 3, 2020 at 6:09
• That's implied by the data-bus width. But it is explicit in many places, see, e.g., the 8086 technical specification, "memory organization" subsection: "The processor provides a 20-bit address to memory which locates the byte being referenced." Mar 3, 2020 at 17:47

I wish to add an adjustment to the fine response by @Ran G. His explanation of what the address space is, is entirely correct. However, this matches the memory size only if each and every address is backed by memory hardware. And this is NOT necessarily the case!

Why could there be less memory hardware than can cover the address space? One trivial answer is cost: Memory hardware can be expensive, so someone wishing to sell a cheaper computer could build one with less than the maximum amount of memory hardware, and this can work because there are people out there who don't need 'that much' memory. For example, no current computer which has 64-bit addressing is ever sold with $$2^{64}$$ bytes worth of addressable memory (that's over a billion billion bytes!).

A more interesting reason is memory-mapped I/O. Strictly speaking, one can attach to a processor's address lines any hardware which behaves like memory hardware (with respect to the sent address and data read/write action). Normally this is of course memory hardware, but other kinds of devices can use the same protocols. For example: If one has a robot arm with motors in its several joints, plus pressure sensors on its gripper, then one can control the arm with a computer via a card which maps the signals sent to the motors and received from the sensors to specific addresses, and install that card on the computer's address lines. The advantage being that one can use ordinary instructions to control the device (i.e control becomes a pure software problem). This technique is in fact quite ubiquitous.

• That's a great comment. Not the entire memory-space is actually utilized. Mar 3, 2020 at 17:44

That's the beauty of cisc machines. For starters as you can see address bus is 20bit wide but resisters are 16bit wide, so microprocessor will process 16bit at a time.