# 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. – Abhijit Singh Mar 3 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." – Ran G. Mar 3 at 17:47

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.

1) Address size has nothing to do with architecture size. You can have instructions that can map 64bit or 128 bit address space in instructions. For example mov can be hard coded in hardware itself to fetch next addressing scheme as required which eliminates requirements of same size bus and resistors. The same mov command with proper bit masking can use address of special resistors instead of memory spaces. It drills down to the choice of system architecture. Thus the name complex instruction set. It goes beyond this simple explanation, but to give an idea, instructions are flexible enough to understand addressing schemes.

So answer is no when you are storing resistor data into memory, it refers to 16bit wide data bus. It is still storing data as usual way. But micro processor can operate on 8bit, 16bit or divide 32bit operation in sub operations as well depending on instruction.

It uses segments to divide memory into usable chunks which is mapped by combing 16bit address scheme but by shifting it to 4bit and adding offset bits to get actual physical address. Modern cpu uses dedicated hardware called memory management unit having multiple operating mode of direct memory access and IO access as well.

Here's the quote :

Rather than concatenating the segment register with the address register, as in most processors whose address space exceeds their register size, the 8086 shifts the 16-bit segment only four bits left before adding it to the 16-bit offset (16×segment + offset), therefore producing a 20-bit external (or effective or physical) address from the 32-bit segment:offset pair. As a result, each external address can be referred to by 212 = 4096 different segment:offset pairs.

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!).