• Microprocessor Video Tutorials

Memory Segmentation in 8086 Microprocessor



The 8086 Microprocessor is one of the most popular microprocessors developed by Intel Corporation. The 8086 microprocessor introduces a very useful concept related to memory management, which is called memory segmentation. Memory segmentation generally means a technique of splitting the primary memory of the system into multiple logical segments. The primary aim of memory segmentation is to improve the memory management and the performance of the microprocessor.

Memory Segmentation in 8086 Microprocessor

In this chapter, we will learn about memory segmentation in 8086-microprocessor, its significance, types, and working.

What is Memory Segmentation in 8086?

In the 8086-microprocessor, the memory segmentation is a concept which allows to logically divide the main memory of the system into smaller components, called memory segments.

In memory segmentation, a unique base address is assigned to each memory segment. Each segment is used for a specific purpose like storage of data, code, or stack information. The memory segmentation allows the microprocessor to access and execute instructions in a more efficient manner.

Need for Memory Segmentation

In early days computing devices, microprocessors like 8085 were used for data processing. Those microprocessors were capable in handling only small memory sizes like 64 kB. In the case of these small memory sizes, the memory management was relatively simple. But, with the increasing memory sizes to MBs and GBs, memory management became complex. In large memory sizes, it becomes difficult for programmers to monitor every byte manually and it increases the risk of memory overwriting. This issue arises the need for introducing the concept of memory segmentation in the 8086-microprocessor.

The 8086-microprocessor comprises 20 address lines, and hence it can access up to 1 MB of memory locations. However, the memory segmentation divides this 1 MB memory into smaller segments, each of 64 kB, which are easily manageable by the microprocessor.

These smaller memory segments allow the microprocessor to efficiently execute tasks, such as data access, program execution, managing stack information, etc.

Types of Memory Segments in 8086

In the 8086-microprocessor, the memory is divided into the following four logical memory segments −

  • Code Segment (CS) − This segment is used for storing executable codes of the program.
  • Data Segment (DS) − This segment is used to hold data that required during program execution.
  • Stack Segment (SS) − This segment is used to manage the stack information.
  • Extra Segment (ES) − It is an additional data segment used for holding overflowed or auxiliary information.

Here, it is important to note that these four memory segments are logical and do not physically divide in the memory. The microprocessor manages these memory segments according the requirement of user.

Working of Memory Segmentation in 8086

In memory segmentation, each segment consists of two main components which are −

  • Segment Address − It is a 16-bit address which points to the first location of the segment.
  • Offset Address − It is also a 16-bit address which specifies the location within the memory segment, with respect to its starting address.

When the microprocessor accesses the memory, it combines the segment and offset addresses to calculate the physical address of the memory location. It is done by using the following formula −

PA = (Segment Address 10H) + Offset Address

Let us understand the working of memory segmentation with the help of an example given below −

Let segment address be (1356)H and the offset address be (2E20)H. Then, the physical address will be,

PA = (1356H 10H) + 2E20H = 16380H

Hence, (16380)H is the actual physical address, where the microprocessor will store or retrieve the information.

Types of Memory Segmentation

Memory segmentations in the 8086-microprocessor is of the following two types −

1. Overlapping Segmentation

In this type of memory segmentation, two memory segments overlap that means they share some part of memory space. For example, if one segment starts at a particular memory address and it goes up to 64 kB. Also, another memory segment starts along with the 64 kB memory address of the first segment, then these two segments are called overlapped segments.

2. Non-Overlapping Segmentation

In this type of memory segmentation, no memory spaces are shared between two segments. For example, if one segment starts at a specific memory address and goes up to 64 kB, and another segment starts before this 64 kB, then there is no common point between these two segments and they are called non-overlapping segments.

Rules of Memory Segmentation

In 8086-microprocessor, the following two rules are to be followed for proper memory segmentation −

  • The staring address of a memory segment must be such that it can be evenly divided by 16.
  • One memory segment must have a minimum size of 16 bytes and a maximum size of 64 kB.

Advantage of Memory Segmentation

Memory segmentation in the 8086-microprocessor offers the following key advantages −

  • It provides an efficient mechanism for memory management.
  • It improves the addressing capability and allows programmers to access 1 MB of memory using only 16-bit address.
  • It makes the program organization better by providing separate logical storage for code, data, and stack.
  • It provides supports for large programs exceeding the 64 kB memory size by splitting them into multiple segments.
  • It provides easy data sharing facilities among different processes.

Conclusion

Memory segmentation is an important concept that simplifies and enhances the memory management. It logically divides the total memory into multiple segments namely, code, data, stack, and extra for providing efficient and error-free execution of instructions.

Advertisements