80386-32-Bit Processor
80386-32-Bit Processor
Next page
• The Paging unit :
– organizes the physical memory in terms of pages of 4kbytes
size each.
– works under the control of the segmentation unit, i.e. each
segment is further divided into pages.
– The virtual memory is also organizes in terms of segments
and pages by the memory management unit.
– Paging unit converts linear addresses into physical
addresses.
• The control and attribute PLA checks the privileges at the page
level. Each of the pages maintains the paging information of
the task. The limit and attribute PLA checks segment limits
and attributes at segment level to avoid invalid accesses to
code and data in the memory segments.
Bus interface unit
AX EAX
BX EBX
CX ECX
DX EDX
SI ESI
DI EDI
BP EBP
SP ESP
CS CODE SEGMENT
SS STACK SEGMENT
DS
ES DATA SEGMENT
FS
GS
INSTRUCTION POINTER AND FLAG REGISTER
31 16 15 0
IP EIP
FLAGS EFLAGS
Register Organization
• The 80386 has eight 32 - bit general purpose registers which
may be used as either 8 bit or 16 bit registers.
• A 32 - bit register known as an extended register, is
represented by the register name with prefix E.
• Example : A 32 bit register corresponding to AX is EAX,
similarly BX is EBX etc.
• The 16 bit registers BP, SP, SI and DI in 8086 are now
available with their extended size of 32 bit and are names as
EBP,ESP,ESI and EDI.
• AX represents the lower 16 bit of the 32 bit register EAX.
• Upper 16-bits are neither use nor changed.
• BP, SP, SI, DI represents the lower 16 bit of their 32 bit
counterparts, and can be used as independent 16 bit registers.
• The six segment registers available in 80386 are
– CS, SS, DS, ES, FS and GS.
• The CS and SS are the code and the stack segment registers
respectively,
• while DS, ES, FS, GS are 4 data segment registers.
• A 16 bit instruction pointer IP is available along with 32 bit
counterpart EIP.
• Flag Register of 80386:
– The Flag register of 80386 is a 32 bit register.
– Out of the 32 bits, Intel has reserved bits D18 to D31, D5
and D3, while D1 is always set at 1.
– Two extra new flags are added to the 80286 flag to derive
the flag register of 80386. They are VM and RF flags.
Next page
FLAGS
31 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
F
L
A
G RESERVED FOR VM RF 0 NT IOPL OF DF IF TF SF ZF 0 AF 0 PF 1 CF
S INTEL
Next page
• System Address Registers: Four special registers are defined to
refer to the descriptor tables supported by 80386.
• The 80386 supports four types of descriptor table:
– global descriptor table Register (GDTR),
– interrupt descriptor table Register(IDTR),
– local descriptor table Register(LDTR) and
– task state segment descriptor Register (TSSR).
GDTR
There can be at most 8K local and 8K global descriptor per task total=16K(214)
Each selector can address a segment of size 64K
Thus total virtual memory is 64K*16K =(230)= 1GB for 80286
4GB segment size in 80386
What will be maximum virtual memory for 80386?
LDTR
Unlike 6 bytes of GDTR contains base address and
limits
LDTR contains only 16-bit selector number that points
to an LDT descriptors in GDT
Whenever the selector is loaded in to LDTR the
corresponding descriptor is read from GDT ad loadled
in to LDT invisible or cache register
The 32- bit base address in LDTR identifies the starting
address of LDT in physical memory and 16-bit limit
determines the size of LDT
Every time new selector is is loaded into LDTR,a local
descriptors table descriptor is cached and new LDT is
activated
Interrupt Descriptor Table
IDT is used to store interrupt gates and trap gates, task
gates
IDT has 24-bit base address and 16-bit limit register in
the CPU (in 80286)
32-bit base address in 80386
LIDT instruction is used to Load Interrupt Descriptor
table.
IDT able to handle up to 256 interrupt
So that total number of descriptor=256
Each descriptor is of 8 bytes
So, maximum number of location required for
IDT=256*8=2048 = 2K
09/15/14 28
• Control Registers: The 80386 has three 32 bit control registers
CR0, CR2 and CR3 to hold global machine status independent
of the executed task. Load and store instructions are available
to access these registers.
• Lower 16-bits in CR0 is present in the 80286 called as MSW
• Debug and Test Registers: Intel has provide a set of 8 debug
registers for hardware debugging. Out of these eight registers
DR0 to DR7, two registers DR4 and DR5 are Intel reserved.
• The initial four registers DR0 to DR3 store four program
controllable breakpoints addresses, while DR6 and DR7
respectively hold break point status and break-point
control information.
• Two more test register are provided by 80386 for page
caching namely test control and test status register.
Real Address Mode of 80386
OFFSET
19 0
SEGMENT
SELECTOR 0000
MAX LIMIT FIXED
AT 64 K IN REAL
MODE
c
c
+ MEMORY OPERAND SELECTED
c 64 K
SEGMENT
BYTES
c c
SEGMENT BASE
SELECTOR OFFSET
SELECTOR OFFSET
47 / 31 31 / 15 0
SEGMENT LIMIT
ACCESS RIGHT
c
c
LIMIT
c
c
BASE ADDRESS
+ MEMORY OPERAND
UP TO SELECTED
c 4 GB
SEGMENT DESCRIPTOR SEGMENT
c
SEGMENT BASE ADDRESS
Next page
Segmentation
Next page
• DESCRIPTORS: The 80386 descriptors have a 20-bit
segment limit and 32-bit segment address. The descriptor of
80386 are 8-byte quantities access right or attribute bits along
with the base and limit of the segments.
• Descriptor Attribute Bits: The A (accessed) attributed bit
indicates whether the segment has been accessed by the CPU
or not.
• The TYPE field decides the descriptor type and hence the
segment type.
• The S bit decides whether it is a system descriptor (S=0) or
code/data segment descriptor ( S=1).
Next page
Paging
Next page
• 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 12 bit 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 a task switch operation,
to load CR0 suitably.
Next page
• Page Directory : This is at the most 4Kbytes in size. Each
directory entry is of 4 bytes, thus a total of 1024 entries are
allowed in a directory.
• The upper 10 bits of the linear address are used as an index to
the corresponding page directory entry. The page directory
entries point to page tables.
• 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.
Next page
PAGE TABLE ADDRESS OS R
U
31 ….12 0 0 D A 0 0 - - P
RESERVED S W
READ / WRITE
0 0 NONE
READ / WRITE
1 1 READ - WRITE
Next page
• The upper 20 bit page frame address is combined with the
lower 12 bit 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 P bit 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 P bit 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 unaccessed.
Next page
INSIDE 80386 IN THE MEMORY
31 22 12 0
10 10 +
12
0 31 0
31
CR 31 DIRECTORY 0
0
CR 1 +
+
CR
2
PAGE TABLE
CR DBA
3
CONTROL
REGISTERS
386
PAGE N DX CPU OS
MEMORY
TASK 2
MEMORY
8086OS
TASK 1
EMPTY MEMORY
TASK 1
PAGE N
MEMORY
PAGE
1
AVAILABLE
8086OS
`
TASK 1
PAGE EMPTY MEMORY
DIRECTORY
ROOT TASK1 PAGE 8086 OS
TABLE
VIRTUAL MODE MEMORY
8086 TASK PAGE DIRECTORY TASK
1
000000000 H