Memory Segment
Reference: Yu . Marut
Chapter 03
8086 Microprocessor
•
Accessing Memory
The 8086 has a 20 bit address bus. But all of its general
purpose register can store only 16 bits. So how does 8086
perform addressing of 20 bits by using 16 bit registers?
By using Memory Segmentation technique it is possible to
access 20 bit address by using 16 bit general purpose registers.
Memory Segmentation
• Entire memory space is partitioned in segments of
64kB, so that each segment is home to exactly 216
bytes, starting from 0000H to FFFFH.
• Since there are 216 different bytes in a segment, 16 bits
are required to address each of them. This 16 bit
number is called the offset address. Offset address also
works as a displacement from the beginning of the
segment.
Memory Segmentation
• We could have done with just 16 segments in a
functioning 8086 microprocessor. Instead we use 216
segments !
• So in order to address the 216 number of segments , we
will need 16 bit numbers , that are called Segment
numbers.
• A segment number also serves as the base address
(address of the first memory byte) of that particular
segment
Logical Address & Physical Address
• Address of a memory location is specified by giving a
segment address and an offset address. Usually they are
written in the form segment:offset, and called logical
address.
• On the other hand, the ‘real’ address is 20 bit long and
called the physical address.
• To obtain physical address from logical address, 8086
first shifts segment address by 4-bits left (equivalent to
multiplying by 10 H) and then adds the offset.
Memory Segmentation
Physical Address = Segment Address X 10H + Offset
• Calculate physical address for
segment number 5321H and offset
number 9876H.
53210 H
9876 H
5CA86 H
Examples
•
Examples
•
Examples
•
Examples
• Calculate physical address for segment number
5CA6H and offset number 0026H.
• Calculate segment address if physical address is
5CA86 H and offset is 22A6 H.
• Calculate offset if physical address is 5CA86 H and
segment is 4CA9 H.
Segment Overlap
• Each physical address can be accessed by various
segment:offset combinations.
• Since we have 216 number of segments, each segment
starts from 16 bytes apart. But remember each segment
has 216 offset members? The result is obvious- an
overlap between consecutive segments.
• Calculate the starting physical addresses of segment
0000H, segment 0001H, segment 0002H and segment
0003H .
*Starting physical address should definitely have an offset of 0.
Memory Segmentation
Memory Segmentation
Memory Segmentation
Memory Segmentation
Memory Segmentation
Memory Segmentation
Memory Segmentation
Memory Segmentation
Assignment
• Physical address in hexadecimal is the last 5
digits of your roll. Calculate segment address
if offset is F72X H, where X is the last digit of
your roll.
[Hint: segment address is 16 bits. Also, if you
subtract the offset from physical address, you
get segment address*10H.
Thank You