0% found this document useful (0 votes)
280 views

8086 Memory Segmentation

This document discusses memory segmentation in the Intel 8086 microprocessor. It explains that the 8086 has a 1 MB memory address space using a 20-bit address bus. Memory is divided into logical segments like code, data, stack, and extra segments. Each segment is specified by a 16-bit register, with the upper 16 bits of the 20-bit physical address coming from the segment register. The offset is combined with the segment base address to calculate the effective physical address. Common segment registers are CS, DS, SS, and ES, which are used with instruction pointer (IP) and indexes like BX, DI, SI, and stack pointer (SP) to address memory locations.

Uploaded by

mash
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
280 views

8086 Memory Segmentation

This document discusses memory segmentation in the Intel 8086 microprocessor. It explains that the 8086 has a 1 MB memory address space using a 20-bit address bus. Memory is divided into logical segments like code, data, stack, and extra segments. Each segment is specified by a 16-bit register, with the upper 16 bits of the 20-bit physical address coming from the segment register. The offset is combined with the segment base address to calculate the effective physical address. Common segment registers are CS, DS, SS, and ES, which are used with instruction pointer (IP) and indexes like BX, DI, SI, and stack pointer (SP) to address memory locations.

Uploaded by

mash
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

MICROPROCESSOR AND ASSEMBLY

LANGUAGE
CSE 311
TOPIC: MEMORY SEGMENTATION

Shaila Rahman
Assistant Professor
8086 MEMORY

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.

SHAILA RAHMAN 2
MEMORY CAPACITY
• 8086 memory capacity is 1 MB
• Capacity can be defined as,
• = No of bytes*size
• For 20-bit address lines it is 2 20
• Thus total capacity
220 *1 byte = 1 MB
• Thus physical address is 20-bit, as all registers are 16-bit, so 8086 generates a
32-bit logical address combination.
• 16-bit segment : 16-bit offset
• 16-bit segment value is given by appropriate segment register. Actually the upper
16-bit of a segment starting address is given by a segment register.
• And 16-bit offset is the displacement of data from segment base.

SHAILA RAHMAN 3
MEMORY SEGMENTATION

The process of dividing memory into


logical blocks is called Segmentation.

According to this the total memory


size is divided into segments of
various sizes.
A segment is just a logical area in
memory.

SHAILA RAHMAN 4
PHYSICAL ADDRESS CALCULATION
Segment value is 4-bit left
shifted then added with offset.
A segment offset may
range from 0000H to FFFFH.

SHAILA RAHMAN 5
AN EXAMPLE OF PROCEDURE

SHAILA RAHMAN 6
FINDING THE STARTING AND ENDING
ADDRESSES

SHAILA RAHMAN 7
ADVANTAGES OF SEGMENTATION
i. Managing memory efficiently
ii. keeping different data in different address spaces. E.g. data, code, stack
iii. Searching easy and fast.
iv. Faster access and thus execution.
v. Helps and improves multiprogramming
vi. Possible to access 1 MB memory using 16-bit structure.

SHAILA RAHMAN 8
MEMORY SEGMENTATION

In 8086, memory has four different types


of segments.
These are:
Code Segment
Data Segment
Stack Segment
Extra Segment

SHAILA RAHMAN 9
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.

SHAILA RAHMAN 10
SEGMENT REGISTERS

SHAILA RAHMAN 11
EXAMPLE
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.

SHAILA RAHMAN 12
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.

SHAILA RAHMAN 13
EXAMPLE

If the data at any location has a logical


address specified as:
2222 H : 0016 H

Then, the number 0016 H is the offset.


2222 H is the value of DS.

SHAILA RAHMAN 14
EXAMPLE (CONTD.)

To calculate the effective address of the


memory, BIU uses the following formula:
Effective Address = Starting Address of
Segment + Offset

To find the starting address of the


segment, BIU appends the contents of
Segment Register with 0H.
Then, it adds offset to it.

SHAILA RAHMAN 15
EXAMPLE (CONTD.)

Therefore:
EA = 22220 H
+ 0016 H

22236 H

SHAILA RAHMAN 16
EXAMPLE (CONTD.)

2222 H BYTE – 0 22220 H


DS Register BYTE – 1
BYTE – 2
-
Offset = 0016 H -
-
-
-
Addressed Byte 22236 H

SHAILA RAHMAN 17
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.
SHAILA RAHMAN 18
WHERE TO LOOK FOR THE OFFSET

Segment Offset Registers Function


CS IP Address of the next instruction
DS BX, DI, SI Address of data
SS SP, BP Address in the stack
ES DI Address of destination data
(for string operations)

SHAILA RAHMAN 19
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.

SHAILA RAHMAN 20
SOLUTION
1. CS = 1111 H

The base address of the code segment is 11110 H.

Effective address of memory is given by 11110H + 1232H = 12342H.

2. DS = 3333 H

The base address of the data segment is 33330 H.

Effective address of memory is given by 33330H + 0020H = 33350H.

3. SS = 2526 H

The base address of the stack segment is 25260 H.

Effective address of memory is given by 25260H + 1100H = 26350H.

SHAILA RAHMAN 21

You might also like