Professional Documents
Culture Documents
UNIT-4
1. Explain the real address mode and virtual 8086 mode of 80386
Real Address Mode of 80386
After reset, the 80386 starts from memory location FFFFFFF0H under the real
address mode. In the real mode, 80386 works as a fast 8086 with 32-bit
registers and data types
•In real mode, the default operand size is 16 bit but 32- bit operands and
addressing modes may be used with the help of override prefixes.
•The segment size in real mode is 64k, hence the 32-bit effective addressing
must be than 0000FFFFFH. The real mode initializes the 80386 and prepares it
for protected mode.
Memory Addressing in Real Mode: In the real mode, the 80386 can address at
the most 1Mbytes of physical memory using address lines A0-A19.
Paging unit is disabled in real addressing mode, and hence the real addresses
are the same as the physical addresses.
To form a physical memory address, appropriate segment registers contents
(16-bits) are shifted left by four positions and then added to the16-bit offset
address formed using one of the addressing modes, in the same way as in the
80386 real address mode.
The segment in 80386 real mode can be read, write or executed, i.e.no
protection is available.
Any fetch or access past the end of the segment limit generate exception13in
real address mode.
The segments in 80386 real mode may be over lapped or non-overlapped.
The interrupt vector table of 80386 has been allocated 1Kbyte space starting
from 00000H to 003FFH.
80386 Microprocessor
Cores 1 1
Functional Units 6 9
Pipeline stages 3 5
Cache on chip 0 8 KB
Segmentation is the process in which the main memory of the computer is logically divided into
different segments and each segment has its own base address. It is basically used to enhance
the speed of execution of the computer system, so that the processor is able to fetch and
execute the data from the memory easily and fast.
Need for Segmentation –
The Bus Interface Unit (BIU) contains four 16 bit special purpose registers (mentioned below)
called as Segment Registers.
Code segment register (CS): is used for addressing memory location in the code segment
of the memory, where the executable program is stored.
Data segment register (DS): points to the data segment of the memory where the data is
stored.
Extra Segment Register (ES): also refers to a segment in the memory which is another
data segment in the memory.
Stack Segment Register (SS): is used for addressing stack segment of the memory. The
stack segment is that segment of memory which is used to store stack data.
The number of address lines in 8086 is 20, 8086 BIU will send 20bit address, so as to access
one of the 1MB memory locations. The four segment registers actually contain the upper 16 bits
of the starting addresses of the four memory segments of 64 KB each with which the 8086 is
working at that instant of time. A segment is a logical unit of memory that may be up to 64
kilobytes long. Each segment is made up of contiguous memory locations. It is an independent,
separately addressable unit. Starting address will always be changing. It will not be fixed.
Note that the 8086 does not work the whole 1MB memory at any given time. However, it works
only with four 64KB segments within the whole 1MB memory.
Below is the one way of positioning four 64 kilobyte segments within the 1M byte memory space
of an 8086.
Types Of Segmentation –
1. Overlapping Segment – A segment starts at a particular address and its maximum size can
go up to 64kilobytes. But if another segment starts along with this 64kilobytes location of the
first segment, then the two are said to be Overlapping Segment.
2. Non-Overlapped Segment – A segment starts at a particular address and its maximum size
can go up to 64kilobytes. But if another segment starts before this 64kilobytes location of the
first segment, then the two segments are said to be Non-Overlapped Segment.
Rules of Segmentation Segmentation process follows some rules as follows:
The starting address of a segment should be such that it can be evenly divided by 16.
Minimum size of a segment can be 16 bytes and the maximum can be 64 kB.
6. List the salient features of 80386 processor and explain its architectural
diagram briefly.
Salient Features of 80386X
⚫ It supports 8/16/32 bit data operands
⚫ It has 132 pins.
⚫ It has 32-bit internal registers
⚫ It supports 32-bit data bus and 32-bit non-multiplexed address bus
⚫ It supports
⚫ Physical Address of 4GB
⚫ Maximum Segment size of 4GB
⚫ Virtual Address of 64TB (4GB seg. * 16,384 segments = 64TB)
⚫ It operates in 3 different modes
⚫ Real
⚫ Protected
⚫ Virtual.
⚫ MMU provides virtual memory, paging and 4 levels of protection
⚫ Low cost & low power consumption
⚫ Clock Frequency : 20,25 and 33MHz
Only a few pages of the segments, which are required currently for the
execution need to be available in the physical memory. Thus the memory
requirement of the task is substantially reduced, relinquishing the available
memory for other tasks.
Whenever the other pages of task are required for execution, they may be
fetched from the secondary storage.
The previous page which are executed, need not be available in the memory,
and hence the space occupied by them may be relinquished for other tasks.
Thus paging mechanism provides an effective technique to manage the physical
memory for multi tasking systems.
Paging Unit: The paging unit of 80386 uses at wolevel table mechanism to
convert a linear address provided by segmentation unit in to physical addresses.
The paging unit converts the complete map of a task in to pages, each of size
4K.The task is further handled in terms of its page, rather than segments.
The paging unit handles every task in terms of three components namely page
directory, page tables and page itself.
Paging Descriptor Base Register: The control register CR2 is used to store the
32-bit linear address at which the previous page fault was detected.
The CR3 is used as page directory physical base address register, to store the
physical starting address of the page directory.
The lower 12bit of the CR3 are always zero to ensure the page size aligned
directory. A move operation to CR3 automatically loads the page table entry
caches and at ask switch operation, to load CR0 suitably.
Page Directory: This is at the most 4Kbytes in size. Each directory entry is of
4bytes, thus a total of 1024 entries are allowed in a directory.
The upper 10bits of the linear address are used as an index to the
corresponding page directory entry. The page directory entries point to page
tables.
OS
RESER
PAGE TABLE VED U R
PAGE DIRECTORY ENTRY
Page Tables: Each page table is of 4Kbytes in size and many contain a maximum
of 1024 entries. The page table entries contain the starting address of the page
and the statistical information about the page.
The upper 20bit page frame address is combined with the lower 12bit of the
linear address. The address bits A12-A21 are used to select the 1024 page table
entries. The page table can be shared between the tasks.
The Pbit of the above entries indicate, if the entry can be used in address
translation.
If P=1, the entry can be used in address translation, otherwise it cannot be
used.
The Pbit of the currently executed page is always high.
The accessed bit A is set by 80386 before any access to the page. If A=1, the
page is accessed, else un accessed.
The Dbit (Dirtybit) is set before a write operation to the page is carried out. The
D-bit is undefined for page director entries.
The OS reserved bits are defined by the operating system software.
The User/Supervisor (U/S)bit and read/write bit are used to provide protection.
These bits are decoded to provide protection under the 4 level protection
model.
The level 0 is supposed to have the highest privilege, while the level 3 is
supposed to have the least privilege.
This protection provide by the paging unit is transparent to the segmentation
unit
PAGE FRAME OS RESERVED U R
ADDRESS 31….12 00 D A 0 0 - - P
S W
9. Explain the each flag by making use of the flag register format of 80386
microprocessor.