Memory segmentation
Memory segmentation
SEGMENTATION OF
INTEL 8086
Engr. M.Zakir Shaikh
Star Laureate Science and Technology
Visiting Faculty I.B.T LUMHS
Research Associate Merhan UET
1
Memory Segmentation
⦿ The total memory size is divided into
segments of various sizes.
⦿ A segment is just an area in memory.
⦿ The process of dividing memory this
way is called Segmentation.
2
Memory Segmentation
⦿ In memory, data is stored as bytes.
⦿ Each byte has a specific address.
⦿ Intel 8086 has 20 lines address bus.
⦿ With 20 address lines, the memory that can
be addressed is 220 bytes.
⦿ 220 = 1,048,576 bytes (1 MB).
⦿ 8086 can access memory with address
ranging from 00000 H to FFFFF H.
3
Memory Segmentation
⦿ In 8086, memory has four different types
of segments.
⦿ These are:
⚫ Code Segment
⚫ Data Segment
⚫ Stack Segment
⚫ Extra Segment
4
Segment Registers
⦿ Each of these segments are addressed by
an address stored in corresponding
segment register.
⦿ These registers are 16-bit in size.
⦿ Each register stores the base address
(starting address) of the corresponding
segment.
⦿ Because the segment registers cannot
store 20 bits, they only store the upper 16
bits.
5
Segment Registers
6
Segment Registers
⦿ How is a 20-bit address obtained if there are only
16-bit registers?
⦿ The answer lies in the next few slides.
⦿ The 20-bit address of a byte is called its Physical
Address.
⦿ But, it is specified as a Logical Address.
⦿ Logical address is in the form of:
Base Address : Offset
⦿ Offset is the displacement of the memory location
from the starting location of the segment.
7
Example
⦿ The value of Data Segment Register
(DS) is 2222 H.
⦿ To convert this 16-bit address into
20-bit, the BIU appends 0H to the LSBs
of the address.
⦿ After appending, the starting address of
the Data Segment becomes 22220H.
8
Example (Contd.)
⦿ If the data at any location has a logical
address specified as:
2222 H : 0016 H
9
Example (Contd.)
⦿ To calculate the effective address of the
memory, BIU uses the following formula:
⦿ Effective Address = Starting Address of
Segment + Offset
10
Example (Contd.)
⦿ Therefore:
⦿ EA = 22220 H
+ 0016 H
------------
22236 H
11
Example (Contd.)
12
Max. Size of Segment
⦿ All offsets are limited to 16-bits.
⦿ It means that the maximum size
possible for segment is 216 = 65,535
bytes (64 KB).
⦿ The offset of the first location within the
segment is 0000 H.
⦿ The offset of the last location in the
segment is FFFF H.
13
Where to Look for the Offset
14
Question
⦿ The contents of the following registers are:
⦿ CS = 1111 H
⦿ DS = 3333 H
⦿ SS = 2526 H
⦿ IP = 1232 H
⦿ SP = 1100 H
⦿ DI = 0020 H
⦿ Calculate the corresponding physical addresses for
the address bytes in CS, DS and SS.
15
Solution
1. CS = 1111 H
2. DS = 3333 H
3. SS = 2526 H
16
Thank
You
Have a Nice Day
17