2 - 8086 Memory Management

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Chapter 1 : The Intel 8086

Microprocessor
Next

▪ Why study The Intel 8086 Microprocessor


▪ The 8086’s architecture
▪ The 8086’s/8088’s registers
▪ The 8086’s memory management
▪ The 8086’s Assembly Program Structure
▪ The 8086’s addressing mode

Chapter 3 : The Intel 8086 Microprocessor Dr. Wael Mohamed CCSE YANBU 2
Memory Organization
❑ The 1MB memory of the 8086 is organized as follows:
FFFFF
➢ The operating system is located starting Rom BIOS
from address 00000 A0000
➢ After OS, the Residents programs installed
by the OS is located
➢ The last area of the memory from address
Applications
A0000 to FFFFF is reserved for the ROM
BIOS
➢ ROM BIOS usually contains the startup
program that enable the computer to boot- Residents
up probably Programs
➢ The remaining area is free for user’s
applications Operating System
00000

Chapter 3 : The Intel 8086 Microprocessor Dr. Wael Mohamed CCSE YANBU 3
Memory Segmentation
❑ Two types of memory organizations are commonly used
➢ Linear Addressing ➢ Segmented Addressing
❑ In Linear addressing the whole memory is available as one linear array
❑ In Segmented addressing, memory space is divided into segments where
only one segment can be accessed at a time
Segmented Addressing Linear Addressing
FFFFF FFFFF
PC size3can be
Segment
less then 20
where it only
PC must have
addresses part
Segment 2 20 bits to
of the memory
address the
entire memory
Segment 1

PC

Segment 0

Chapter 3 : The Intel 8086 Microprocessor 00000 PC


Dr. Wael Mohamed CCSE YANBU 00000
4
8086 Memory Segmentation
❑ The total memory “1 MB” is divided into 64 kb segments
❑ Each segment is addressed by one of the segment registers
❑ The 16-bit contents of the segment register gives the starting/base address
of a particular segment
❑ Another part called offset-address is used to address a byte within the
selected segment
❑ The offset address is also 16-bit wide, so it can select one byte out of 216
bytes (64KB)
❑ The offset address can be one of the index/pointer registers
❑ In 8086, an address is presented always in the form [segment : offset]

Chapter 3 : The Intel 8086 Microprocessor Dr. Wael Mohamed CCSE YANBU 5
Accessible memory by the 8086
FFFF:FFFF
❑ At a given moment, the 8086 has
access to four segments whose
addresses are in the segment registers Extra ES:DI
CS, DS, ES and SS. Segment OFFSET = DI
ES:0000
❑ The code segment contains the program
instructions Stack SS:SP
Segment OFFSET = SP
❑ The data segment contains the data SS:0000
manipulated by the program

❑ The stack segment contains the Data DS:SI


backup stack Segment OFFSET = SI
DS:0000
❑ The extra segment ES may also contain
Code CS:IP
additional data
Segment OFFSET = IP
CS:0000
00000H
Chapter 3 : The Intel 8086 Microprocessor Dr. Wael Mohamed CCSE YANBU 6
Rules of 8086 Memory Segmentation
❑ The four segments can overlap for small programs
❖ In a minimum system all segments can start at address 0000H
❑ The segment can start at any memory address divisible by 16
FFFF:FFFF

ES:DI
SS:SP
DS:SI
CS:IP
ES SP DS CS 0000:0000
Chapter 3 : The Intel 8086 Microprocessor Dr. Wael Mohamed CCSE YANBU 7
Advantages of Memory Segmentation

❑ It allows the addressing of 1MB memory with only 16-bit registers


❑ It facilitates the use of separate memory areas of code, data and
stack
❑ It permits a program or its data to be put in different areas of
memory, each time the program is executed
❑ Program can be relocated which is a very useful feature for
multiprogramming

Chapter 3 : The Intel 8086 Microprocessor Dr. Wael Mohamed CCSE YANBU 8
How does 8086 generate 20-bit address?
❑ Consider that 𝑆𝑅 = 2000𝐻, 𝑎𝑛𝑑 𝑂𝑅 = 350𝐻:
➢ Left shifting one hex digit of (SR)
➢ Performs the addition of two registers
➢ Send the physical address on the address bus of 20 bits

S3 S32 S21 S10 S00 Segment 2 0 0 0 0 Segment

+ O3 O2 O1 O0 Offset + 0 3 5 0 Offset

S3 Y3 Y2 Y1 O0 Physical Address 2 0 3 5 0 Physical Address

This technique called memory segmentation

Chapter 3 : The Intel 8086 Microprocessor Dr. Wael Mohamed CCSE YANBU 9
How does 8086 generate 20-bit address?
❑ An address as a 20-bit quantity (5 hex digits) is called the physical address
because it is the actually value sent on the address bus A0 - A19
❑ The physical address is calculated by the expression:
FFFFF
𝒑𝒉𝒚𝒔𝒊𝒄𝒂𝒍 𝒂𝒅𝒅𝒓𝒆𝒔𝒔 = 𝟏𝟔 × 𝒔𝒆𝒈𝒎𝒆𝒏𝒕 + 𝒐𝒇𝒇𝒔𝒆𝒕

16 bits 4 bits 2FFFF

64 kB
Segment 0000
20 bits
20000
+ Offset
16 bits

Physical address
20 bits 00020
00010
Note : inject 4 zeros ≡ multiplication by 24 = 16 00000
Chapter 3 : The Intel 8086 Microprocessor Dr. Wael Mohamed CCSE YANBU 10
Segment Starts every 16-Bytes
left shifting of 1 hex digit the Segment register
Bit : 11-15 Bit : 8-11 Bit : 4-7 Bit : 0-3 Offset 4 Segment starting
bits
0000 0000 0000 0000 0000 0
0000 0000 0000 0001 0000 16
▪ 1 MB of addressable
0000 0000 0000 0010 0000 32
memory, divided into 0000 0000 0000 0011 0000 48
segments of 64 KB 0000 0000 0000 0100 0000 64
(216) 0000 0000 0000 0101 0000 80

▪ A segment starting
0000 0000 0000 1111 0000 240
every 16 bytes because
0000 0000 0001 0000 0000 256
of offset 4-bits 0000 0000 0001 0001 0000 272

▪ We can place a
0000 0000 0001 1111 0000 496
segment anywhere in
0000 0000 0010 0000 0000 512
the memory every 16
0000 0000 0010 00001 0000 528
bytes, then access at
64 kb space from the 0111 1111 1111 1111 0000 1048560
segments position 1111 1111 1111 1111 0000 1048575
Chapter 3 : The Intel 8086 Microprocessor Dr. Wael Mohamed CCSE YANBU 11
Overlap of Segments
❑ Areas allocated to segments can overlap.
❑ The only rule when selecting a segment is the hex LSD is zero.
❑ So we can begin a segment every 16 bytes
0000:FFFF

F0FFF E100:FFFF
EFFFF E000:FFFF

Overlap
E1000 E100:0000
E0000 E000:0000

0000:0000
❑ We can address the same physical address 00105 with various
[segment : offset] combinations (0010:0005, 0000:0105, 0002:00E5 )

Chapter 3 : The Intel 8086 Microprocessor Dr. Wael Mohamed CCSE YANBU 12
Your Turn (Example)

What physical address corresponds to logical address 028F:0030?

Solution: 028F0 + 0030 = 02920 (hex)

Always use hexadecimal notation for addresses

What logical address corresponds to the physical address


28F30h?

Many different segment: offset (logical) addresses can produce


the same physical address 28F30h. Examples:
28F3:0000, 28F2:0010, 28F0:0030, 28B0:0430, . . .

Chapter 3 : The Intel 8086 Microprocessor Dr. Wael Mohamed CCSE YANBU 13
Accessible memory by the 8086

❑ The CS register is associated with the instruction pointer IP, and the next
instruction to run is at the logical address CS: IP
❑ The segment registers DS and ES may be associated with an index
register.
➢ Example: DS:SI, ES:DI.
❑ The DS/ES segments allow the processor to fetch data stored at an
address.
❑ The stack segment register may be associated with the pointer registers:
SS: SP or SS: BP

Chapter 3 : The Intel 8086 Microprocessor Dr. Wael Mohamed CCSE YANBU 14
Initial Values of Segment Registers
❑ Contents of registers after a RESET of the microprocessor:
➢ IP = 0000H
➢ CS = FFFFH
➢ DS = 0000H
➢ ES = 0000H
➢ SS = 0000H
❑ Since CS contains the value FFFFH and IP the value 0000H,
the first instruction executed by 8086 is at the logical address
FFFFH:0000H, corresponding to the physical address FFFF0H
(bootstrap loader)
❑ This statement is typically a jump to the main program that
start up the computer and initializes other segment registers

Chapter 3 : The Intel 8086 Microprocessor Dr. Wael Mohamed CCSE YANBU 15

You might also like