8085 microprocessor which has 16-address lines and also the memory registers, and SP is also 16-bit, the complete memory is organized as one contiguous block of memory. But, 8086 has 20-address lines whereas the size of all its registers is 16-bits, there is no way to hold this address in any memory address registers. For small, conventional and uni-programming(single program) applications utilizing less than 64KB memory size this may not be problem. But 8086 is design for developing utility programs like .com utilizing less than 64KB memory and .exe programs requiring more than 64KB of memory this pauses a problem.
For better management and utilization of memory, designers of 8086 came up with a new concept of logically dividing the memory into smaller 64KB size called segments. This process of dividing the memory into smaller logical segments is called memory segmentation. The memory segmentation allows the code and data and so is stack data to be stored on separate areas of memory called segments. 8086 system allows memory to be divided into the following segments where the maximum size of any segment can grow up to only 64 KB. :
i) Code Segment
ii) Data Segment
iii) Stack Segment
iv) Extra Segment
However, on one hand the use of fixed segment areas for code, data and its stack helps in better utilizing the memory for large program, but if the segment is underutilized for reason of less amount of data, code or stack data then it leads to wastage of memory.
So to overcome this problem, a concept of having multiple and overlapping segments was conceived. This permits us to fill the unutilized part of a segment to be overlapped with another code, data or stack segment.
This new and overlapping segment can start at an address within 16 bytes boundary of the end of previous segment. This is shown in figure-2
Advantages of memory segmentation in 8086:
- Manipulation of the address contained in segment register and the effective address, permit the memory size to be 1MB.
- It allows the size of the program or data to be more than 64 KB by utilizing multiple code or data segments as shown in figure.
- The above benefit allows you to keep the separate area of memory for code and data etc.
Calculation of Physical Address:
As the EA so formed by adding the index registers, base registers and the displacement is 16 bit, but the physical address that is to be put on the address bus is 20 bit. The extra 4 bits are obtained by appending 4 zeros on the right of segment registers and adding with the effective address (EA) as shown below: