University of Salahaddin
College of Engineering
Software & Informatics Dep.
COMPUTER ARCHITECTURE
2 N D S TA G E
A S S I S TA N T L E C T U R E R : E S I L S E M I R K H U R S H E D
[Lec 3]
2020 – 2019
Memory Segmentation
• Total memory size is divided into segments of
various sizes.
• Memory data is stored as bytes.
• 8086 has 20 lines address bus.
• With 20 add line the memory can be
addressed as 220 bytes = 1MB
• Address ranging from 00000F to FFFFF H
Segment Registers of 8086 (cont..)
16-bit register containing address of 64 KB segment
1. Code segment (CS)
Processor use it for all accesses to instructions referenced by
instruction pointer (IP) .
The CS register is automatically updated during jump, call and
return instructions.
2. Stack segment (SS)
Used in the stack processing .
used two registers to referencing to it :
SP : Stack pointer
BP: Base pointer
Segment Registers of 8086 (cont..)
3. Data segment (DS)
The processor assumes that all data referenced by general
registers (AX, BX, CX, DX) and index register (SI, DI) is
located in the data segment.
4. Extra segment (ES)
The processor assumes that the DI register references the ES
segment in string manipulation instructions.
• It is possible to change default segments used by general and
index registers by prefixing instructions with a CS, SS, DS or
ES prefix.
Segment Register
• 8086 has 20-bit Address Bus. Thus, it can
address 1MB memory location.
• This 1MB memory can be accessed with the
help the above mentioned 4 Segment
Registers (CS, SS, DS & ES).
• This 1MB memory is divided into 16-bit logical
segments, each with a memory of 64KB.
• To locate any address in the memory, it needs
the Physical address of that memory location.
• It cannot directly get the 20-bit Physical
address using the 16-bit segment registers. It
needs to calculate the 20-bit Physical address.
Segment : Offset Address
• Logical Address is specified as segment: offset
• Physical address is obtained by shifting the
segment address one bit to the left and adding
the offset address.
• Thus the physical address of the logical address
2000:1000 is:
20000
+ 1000
21000
Segments, Segment Registers & Offset
Registers
• Segment Size = 64KB
• Maximum number of segments possible = 14
• Logical Address – 16 bits
• Physical Address – 20 bits
• 2 Logical Addresses for each Segments.
• Base Address (16 bits)
• Offset Address (16 bits)
• Segment registers are used to store the Base
address of the segment.
Segment and offsets
• Combination of Segment with Offset. Each
segment addressing 64 K byte.
Example :
let segment register=1000
Start Location = shift to left one hexadecimal digit
To be (10000 h)
End location= start location + FFFF h
So the end of this segment to be 1FFFF h.
Shift left
• 1000 H 10000 H
+ FFFF
1FFFF
More Examples:
Segment Register Start End
•
2000H
2001 H
2100 H
AB00 H
1234 H
Default Segment and Offset Registers
Segment Offset Special Purpose
CS IP Instruction addressing
SS SP, BP Stack addressing
DS BX, DI, SI, Data addressing
ES DI String Destination
addressing
Examples:
• Find the physical address if the logical address
SS:BP , SS=2000 H, BP=3000H
sol:
Physical Address = 20000+3000=23000 H to
addressing 1 M of memory from registers
consist of only 16 bit.
Home work:
If the Segment register was ( 100B h), with Offset (12 h )
Find the Physical Address?