0
48kviews
What is segmentation? Give usages, advantages of segmentation
1 Answer
4
2.5kviews

The need of memory segmentation is explained below:

  1. The BIU (Bus Interfacing Unit) contains four special purpose registers called as segment registers. These are Code Segment (CS) register, Stack Segment (SS) register, Extra Segment (ES) register and Data Segment (DS) register.
  2. All these are 16 bit registers.
  3. The number of address lines in 8086 is 20. So the 8086 BIU will send out a 20 bit address in order to access one of the 1,048,576 or 1MB memory locations.
  4. But it is interesting to note that the 8086 does not work the whole 1MB memory at any given time. However it works with only four 64 KB segments within the whole 1 MB memory.
  5. The four segment registers actually contain the upper 16 bits of the starting addresses of the four memory segments of 64 KB each with which the 8086 is working at that instant of time.
  6. A segment is a logical unit of memory that may be up to 64 kilo bytes long.
  7. Each segment is made up of memory contiguous memory locations. It is independent, separately addressable unit.
  8. Starting addresses will always be changing. They are not fixed.
  9. Figure shows one of the possible ways to position the four 64 KB segments within the 1 MB memory space of 8086.

enter image description here

  1. There is no restriction on the locations of these segments in the memory. These segments can be separate from each other or they can overlap.
  2. In the users program there can be many segments but 8086 can deal with only four of them at any given time because it has only four segment registers.
  3. Whenever the segment orientation is to be changed, the base addresses have to be changed and load the upper 16 bits into the corresponding segment registers.
  4. Segment registers are very useful for large programming tasks that require isolation of program code from the data code or isolation of module data from the stack information etc.
  5. Segmentation builds relocatable and re-entrant programs easily. In many cases the task of relocating a program simply requires moving the program code and then adjusting the code segment register to point to the base of the new code area.

Advantages of memory segmentation:

  1. Segmentation provides a powerful memory management mechanism.
  2. It allows programmers to partition their programs into modules that operate independently of one another.
  3. Segments allow two processes to easily share data.
  4. It allows to extend the address ability of a processor i.e. segmentation allows the use of 16 bit registers to give an addressing capability of 1 MB. Without segmentation, it would require 20 bit registers.
  5. Segmentation makes it possible to separate the memory areas for stack, code and data.
  6. It is possible to increase the memory size of code data or stack segments beyond 64 KB by allotting more than one segment for each area.
Please log in to add an answer.