The document discusses memory addressing in 8086. It explains that:
1) 8086 has a 20-bit address bus but 16-bit registers, so memory is divided into 64KB segments addressed by the upper 16 bits of the 20-bit address.
2) A logical address contains the segment address and 16-bit offset. The physical address is generated by adding the segment address to the offset.
3) Segment registers hold the 16-bit segment address while default registers hold the offset. Common segments are code, stack, and data, each using different default registers.
2. Revision,
8086 has a 20-bit address bus & thus can address
a maximum of 1MB (2^20) of memory
But 8086 has 16-bit registers which can hold only
16-bit addresses
Solution is to divide 1MB memory in 64KB
segments
(2^16)(total sixteen) as they can be accessed by
using 16-bit
addresses. However, only 4 segments are
accessible by
8086 at a time. These 4 segments are:
Code segment: Used for storing the
codes or instructions
Stack segment: Used as a stack
•
•
•
•
Data segment: Used for storing data
Extra segment: Used for storing in-excess data 2^20=1MB=1048576
2^16=65536= 64KB
1048576/65536=16
4. • Accessing to memory location there are four addresses that you all
have to understand
• Logical address
• Segment address
• Offset
• Physical address /Effective address
Memory Accessing Addresses
5. Logical Address
• Logical address is implemented practically by compiler through
different emulators or
• Logical Address is generated by CPU while a program is running.
• The logical address is virtual address as it does not exist physically,
therefore, it is also known as Virtual Address.
• Logical address = Segment Address : Offset
7. Segment address (Base Address of segment)
• segment address is a 4-digit hexadecimal address which points to the
start of a 64 kB chunk (a single segment )of data.
• Segment address relates to base address of a single memory
segments
• As memory is of 1MB= 2^20 bytes so segment address is of 20 bits as
00000 to FFFFFH
• Where, segment register are bit DS, CS, SS, ES
• Segment register hold only upper 16 bits that is 0000H to FFFFH
8. 1
Code Segment
3
4
Data Segment
Extra Segment
7
8
9
10
11
12
13
14
15
Stack Segment
Memory
00000H
FFFFFH
1MB
Address
Range
StartingAddresses
ofSegments
1000 0H
4000 0H
0H5000
F000 0H
CSR
DSR
ESR
SSR
We can take any value
of starting address of a
segments but it must be
divisible by 16 and
lowest 4 bits (lowest
hex digit) must be 0
Segment registers
(CSR, DSR, SSR &
ESR) hold upper
16-bits
starting
of 20-bits
address
of segments
SEGMENT REGISTERS
10. Offset
• The offset is also a 4-digit hexadecimal address which defines the
displacement from the segment base pointer
• Offset address indicates displacement address that is address
required to move in 64KB memory segment.
• Offset is of 16 bits 0000H to FFFFH
12. All offsets are limited to 16-bits.
It means that the maximum size
possible for segment is 2^16= 65,535
bytes (64 KB).
The offset of the first location within the
segment is 0000 H.
The offset of the last location in
segment is FFFF H
Limitation of offset
address
13. Physical Address
• Physical Address identifies a physical location of required data in a
memory. The user never directly deals with the physical address but
can access by its corresponding logical address.
• Physical Address is calculated by adding segment address (appended
by 0H ) to the offset.
14. Physical Address (20 Bits)
Adder
Segment Register (16 bits) 0 0 0 0
Offset Value (16 bits)
Physical Address Generation in 8086
Actual address for memory
Upper 16bit of starting address of a segment
20-bits
16-bits
Points to a memory
location within a segment
16. Question: How is a 20-bit address obtained if there are only
16- bit registers????????
The answer lies in the next few slides.
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:
Segment address(Base Address) : Offset
Offset is the displacement of the memory location from
the starting location of the segment.
17. Important points to remember:
Address of a segment is of 20-bits,
however, within a segment a memory location can be
specified or accessed using a 16-bit address called offset
• Physical address is generated for accessing memory
locations. Where Physical address will be calculated by
adding segment address to offset.
18. If the data at any location has a logical
address specified as:
2222 H : 0016 H
Ques :What will be its
physical address????
Example
20. • The number 0016 H is the offset.
• 2222 H is the value of DS.
To convert this 16-bit address into 20-bit, the BIU
(Bus interface unit )appends 0H to the LSBs of the
address.
After appending, the starting address of the Data
Segment becomes 22220H.
Then, it adds offset to it 22220+0016.
Solution:
23. Where to look offset for
respective segment
Default Registers Assigned to store offset values for different
segments
24. Offset is derived from the combination of
pointer registers, index registers the
Instruction Pointer, and immediate values
(called displacement)
0000
+
Segment address
Offset
Memory address
Examples
CS
IP+
Instruction
(code)
address
5 0 0 0 0
F F E 0
5 F F E 0
SS
SP
+
Stac
k
add
r
ess
3 4 8 A 0
4 2 1 4
3 8 A B 4
1 2 3 4 0
0 0 2 2
1 2 3 6 2
DS
DI +
Data
addr
ess
Physical Address Calculation
26. Memory
Segment Register
Offset
Physical Address
+ 0050
DS:
SI
05C0
0050
05C00H
05C50H
05C0 0
05C50H
Data is fetched with respect to the DS register which contains starting
or base address
The offset is in SI (default register for DS)
DS:EA
0H
0FFFFFH
Example of Physical Address Generation for Data Segment
27. Conclusions
• A 16-bit address bus addresses up to 64KB of memory from 0000h to FFFFh
• a 20-bit address bus addresses a total of 1 MB from 00000h to FFFFFh.
• The 80386/80486/Pentium processors have a 32-bit address bus and can address
from 00000000h to FFFFFFFFh.
• The 20-bit physical address is generated by:
• Adding 16-bit contents of a segment register with an 16-bit offset value
• Offset is stored in a corresponding default register (either in IP, BX, SI, DI, BP or SP. Different
segments have different default register for offset,
• BIU always appends 4 zeros automatically to the 16-bit address of a segment register (to make it
20-bit) because it knows the starting address of a segment always ends with 4 zeros
28. The contents of the following registers are:
CS = 111 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.
Examples to be solved on VLE
29. • Thank you for listening
• Queries will be answered on
VLE