2. Programming segment
•A typical Assembly language
program consists of at least
three segments:
• Code segment contains the
Assembly language
instructions that perform the
tasks that the program was
designed to accomplish.
• Data segment used to store
information (data) to be
processed by the instructions in
the code segment.
• Stack segment - used by the
CPU to store information
temporarily.
Stack segment
(64 KB)
6D26FH – 5D270H = FFFFH
00000H
…
5D270H
…
6D26FH
Code segment
(64 KB)
C3FEFH - B3FF0H = FFFFH
B3FF0H
…
C3FEFH
Data segment
(64 KB)
EFFFFH – E0000H = FFFFH
E0000H
…
EFFFFH
FFFFFH
3. Programming segment
Stack segment
(64 KB)
6D26FH – 5D270H = FFFFH
00000H
…
5D270H
…
6D26FH
Code segment
(64 KB)
C3FEFH - B3FF0H = FFFFH
B3FF0H
…
C3FEFH
Data segment
(64 KB)
EFFFFH – E0000H = FFFFH
E0000H
…
EFFFFH
FFFFFH
Starting address
of memory
Ending address
of memory
Starting address
of stack segment
Ending address
of stack segment
Starting address
of code segment
Ending address
of code segment
Starting address
of data segment
Ending address
of data segment
B2002H
Address belongs to the code segment
E7654H
Address belongs to the data segment
6A124H
Address belongs to the stack segment
5. What is a segment?
•A segment is an area of memory that includes up to
64K bytes, and begins on an address evenly divisible
by 16 (such an address ends in 0H):
•8085: addressed a maximum of 64K of physical
memory, since it had only 16 pins for address lines.
(216 = 64K)
• 64K bytes of memory for all code, data, and stack
information
•In 8088/86: there can be up to 64K bytes in each
category:
• The code segment, data segment, and stack segment.
6. Segment registers (CS, DS, ES, SS)
Stack segment
(64 KB)
00000H
5D270H
…
6D26FH
Code segment
(64 KB)
B3FF0H
…
C3FEFH
Data segment
(64 KB)
E0000H
…
EFFFFH
FFFFFH
Extra segment
(64 KB)
04000H
4FFFFH
Base address of
Extra segment
Base address of
Stack segment
Base address of
code segment
Base address of
data segment
ES (Extra segment)
0400H
SS (Stack segment)
5D27H
CS (Code segment)
B3FF
DS (Data segment)
E000
16 bits
20 bits. We append 4
bits in the end of
each register
Up to the coder to
define its usage
Points at the segment
containing the stack
Points at the segment
containing the current program
Points at the segment where
variables are defined
7. Logical and physical address
• Physical Address: - the 20-bit address
actually on the address pins of the
8086 processor, decoded by the
memory interfacing circuitry.
• This address can have a range of 00000H
to FFFFFH.
• Offset Address: a location in a 64K-
byte segment range, which can range
from 0000H to FFFFH.
• B3FF4H is a physical address with an
offset address of 4.
• C3FEFH is a physical address with an
offset address of FFFFH
• Logical Address- which consists of a
segment value and an offset address
• Logical address of B3FF4H is B3FF:
0004H
• Logical address of of C3FEFH is B3FF:
FFFFH
Stack segment
(64 KB)
00000H
5D270H
…
6D26FH
Code segment
(64 KB)
B3FF0H
…
C3FEFH
Data segment
(64 KB)
E0000H
…
EFFFFH
FFFFFH
Extra segment
(64 KB)
04000H
4FFFFH
B3FF4H is a physical address
(20 bits) which belongs to the
code segment