Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

SEGMENT REGISTERS

Segments: Segments are the specific areas defined in program containing data, code and stack
Segment registers: The registers specify the location of segments are called segment
registers.

8086 Segment Registers


The 8086 has four special segment registers:
1.Code segment Register: Starting address of the section of memory holding code.
2.Data segment Register: Stores the starting address of data segment.
3.Extra segment Register: Used by string instruction to hold destination data.
4.Stack segment Register: Defines the area of memory used for the stack.
These registers are all 16 bits wide. They deal with selecting blocks (segments) of main memory.
A segment register (e.g., CS) points at the beginning of a segment in memory.
Segments of memory on the 8086 can be no larger than 65,536 bytes long. This infamous “64K
segment limitation” has disturbed many a programmer.
The CS register points at the segment containing the currently executing machine instructions.
Note that, despite the 64K segment limitation, 8086 programs can be longer than 64K. You simply
need multiple code segments in memory. Since you can change the value of the CS register, you
can switch to a new code segment when you want to execute the code located there.
The data segment register, DS, generally points at global variables for the program. Again, you’re
limited to 65,536 bytes of data in the data segment; but you can always change the value of the ds
register to access additional data in other segments.
The extra segment register, ES, is exactly that – an extra segment register. 8086 programs often
use this segment register to gain access to segments when it is difficult or impossible to modify
the other segment registers.
The SS register points at the segment containing the 8086 stacks. The stack is where the 8086
stores important machine state information, subroutine return addresses, procedure parameters,
and local variables. In general, you do not modify the stack segment register because too many
things in the system depend upon it.

1
Physical Address Calculation
Segment address+ offset = memory address

Segment Offset Registers Function

CS IP Address of the next instruction

DS BX,DI,SI Address of the data

SS SP,BP Address in the stack

ES BX,DI,SI Address of designation data

Example:
 CS+IP= Instruction (code) address 348A0+4214=38AB4
 DS+DI= Data address 12340+0022=12362
 SS+SP= Stack address 50000+FFE0=5FFE

Advantages of the Segmentation

 It provides a powerful memory management mechanism.


 Data related or stack related operations can be performed in different segments.
 Code related operation can be done in separate code segments.
 It allows to processes to easily share data.
 It allows to extend the address ability of the processor, i.e. segmentation allows the use of
16 bit registers to give an addressing capability of 1 Megabytes. Without segmentation, it
would require 20 bit registers.
 It is possible to enhance the memory size of code data or stack segments beyond 64 KB by
allotting more than one segment for each area.

2
Reference:
 https://www.slideshare.net/ravianand000/8086-
56333707?from_action=save
 https://www.slideshare.net/maamirfarooq/segment-registers
 https://www.geeksforgeeks.org/memory-segmentation-8086-
microprocessor/

You might also like