What are the advantages of using segment registers in the 8086 microprocessor?

already exists.

Would you like to merge this question into it?

already exists as an alternate of this question.

Would you like to make it the primary and merge this question into it?

exists and is an alternate of .

Segmented addressing probably originated with Burroughs.but I could be wrong.

Suppose you have a flat memory model, and a program starting at location 4000. Here I'll write some pseudocode assembly.

4000 load A with 20h
4002 jump to subroutine at 4006h
4005 return from subroutine
4006 load X with 512
4009 store A at location X
400A increment X
400B compare X to 1024
400E branch if not equal to 4009h
4010 return from subroutine

Now this code mentions an absolute address: 4006h, then address of the subroutine. (The other address is part of a branch, and probably stored as a relative offset.) Suppose we store this code on disk, and then later we read it in. If we read it in starting at location 4000h, we are fine. If we read it in elsewhere, we might have a problem.

Now suppose we have a timeshare system, and we want to page programs in and out, and manage memory for the system. We have a problem; we have to correct all the addresses of a program when it is read in. And we can't do that.

Programs often use "jump tables" to look up an address. How do we detect a jump table and correct the address? Further, suppose I *compute* an address. I might do this by taking a value and shifting it a few places. For example, I might have a lookup table for the sine of angles. The sine of angle X is stored as a four-byte floating-point value, starting at location 2000h. I compute the sine by reading the four bytes starting at 2000h + X<<2.

ASL EAX
ASL EAX
ADD EAX, 2000h

Now how do I correct this? There's no way to know that 2000h is a memory address, and not just some value that needs to be added to EAX for some other purpose.

Now suppose I have segmented addressing. I can now write my programs as if they started at location zero. I write all my programs that way, and the loader sets my segment correctly when the program is loaded. Now I don't have to worry about correcting addresses. I can load the program almost anywhere I want in memory, and adjust the segment registers accordingly. I can also have a segment for data and the stack, so that I can lay the program out in memory however I want.

Suppose I need 16K for the program, 8K for the stack, and 8K for data. If I don't have 32K of contiguous memory I can't load the program. However thanks to segmented addressing I can load the parts of the program into different areas.

Now, segmented addressing is falling out of favor. This is because people typically use assemblers and compilers that produce symbolic object code ready for a loader to resolve all symbols when the program is loaded. This is a more complicated process. Early segmented memory allowed loaders to be simpler, and made memory management possible.

Further, when you have a device such as a disk mapped to memory, you can just point the segment there and directly read and write from offset zero.
5 people found this useful

A Explain the use of Code Segment CS and data segment DS register in 8086 microprocessor?

Code segment (CS) is a 16-bit register containing address of 64 KB segment with processor instructions. The processor uses CS segment for all accesses to instructions referen

What are advantages of 8086 microprocessor?

The advantages of 8086 microprocessor are: 1. It is a 16 bit processor 2. it can perform operation of 16 bit data at a time 3. It has a pipeline architecture 4

Explain the use of Code Segment and Data Segment register in 8086 microprocessor?

In the 8086 microprocessor, the Code Segment (CS) register contains the paragraph address that will be added to the Instruction Pointer to obtain the address of the next instr

What is the need of segmentation in microprocessor 8086?

At this point you may be wondering why Intel designed the 8086 family devices to access memory using the segment: offset approach rather than accessing memory directly with 20

Explain the register organization in 8086 microprocessor?

In the 8086/8088 microprocessor, there are eight 8 bit general registers, AH, AL, BH, BL, CH, CL, and DH, DL. They can be used as four 16 bit registers AX, BX, CX, and DX.. T

What is the purpose of DI register in microprocessor in 8086?

DI is the Index register in Data segment(16-bit, 64 KB) . Destination Index (DI) is a 16-bit register. DI is used for indexed, based indexed and register indirect addressin

What are the advantages of memory segmentation in the 8086 microprocessor?

There are four 16-bit segment registers that allowed the 8086 CPU to access one megabyte of memory in an unusual way. Rather than concatenating the segment register with the a

What are the advantages of memory segmentation of 8086 microprocessor?

Segmented memory allowed a bigger memory model than would otherwise be possible with a 16-bit processor. In effect, the physical address is found by shifting the segment by fo

Why you Use Memory Segmentation In 8086 Microprocessor?

Memory segmentation in the 8086/8088 is used to allow the processor to access more than 64kb of memory, even though it is only a 16-bit processor. Each segment register allows
In Intel 8086 and 8088

What is memory segmentation and explain different segments in 8086 microprocessor?

Memory segmentation is an attempt to address more memory than the processor architecture would normally allow. In the case of the 8086/8088, a 16 bit processor, you would n