Академический Документы
Профессиональный Документы
Культура Документы
Maeng Lect01-2
PCI BUS
ISA BUS
Maeng Lect01-4
O O O O O I O I O O I I I I I O O O O
Maeng Lect01-5
Maeng Lect01-6
Memory
I/O
All signal lines are TTL compatible. Fan-out are two low power Shottkey(LS) TTLs. SA0 through SA19: System Address Bus:(I/O)
to address memory and I/O devices; 16MB of memory with LA17 through LA23 input when CPUHLDA is high and MASTER* is low; output at all other times SA bus driven by CPU when CPUHLDA is low; SA bus driven by 8237 DMA controller when CPUHLDA is high latched with an internally generated ALE signal Maeng Lect01-7
386DX Microprocessor
Internal Architecture
Maeng Lect01-9
Maeng Lect01-10
Maeng Lect01-11
Maeng Lect01-12
contains offset addresses (16-bit in real mode: 64 KB) ESP(extended stack pointer) and EBP(extended base pointer) combined with the contents of the SS register to produce physical memory address TOS (top of stack) : SS:SP BP : an offset relative to the SS register
Maeng Lect01-13
Maeng Lect01-14
Local Data
Destination String
Maeng Lect01-15
Example
1 2 3 4
1 2 3 4
0
0 0 2 2
Logical Address
0 0 2
1 2 3 6
Physical Address
Maeng Lect01-16
Maeng Lect01-17
18
80386
Protected Mode System control Instruction set Basic + Extended+ 80386 specific Instruction Set
Real Mode
Maeng Lect01-19
21
Instruction Encoding
General Instruction Format
TTTTTTTT 7 0 TTTTTTTT 7 0 mod TTT r/m 7 6 5 32 0 ss index base 76 5 3 2 0 d32| 16 | 8 | none data32 |16 |8 | none
s-i-b byte
address displacement
immediate data
Maeng Lect01-22
Maeng Lect01-23
Maeng Lect01-24
Control Transfer
Stack Frame Instructions: ENTER and LEAVE to allocate and deallocate a data area called a stack frame ENTER : make a stack frame
ENTER imm16,0; Make procedure stack frame ENTER imm16,1; Make stack frame for procedure parameter ENTER imm16,imm8: Make stack frame for procedure parameter first operand : the number of bytes to be allocated on the stack for local data storage second operand: lexical nesting level of the routine
Maeng Lect01-25
Control Transfer
Procedure A Data for Proc. C (16 bytes) BP for Proc. C BP for Proc. B BP for Proc. A BP for Proc. B Ret addr for proc. B Data for Proc. B (12 bytes) BP for Proc. B BP for Proc. A BP for Proc. A Ret addr for proc. A Data for Proc. A (32 bytes) BP when executing Procedure A BP for Proc. A Old BP Stack frame for B Enter 32, 1 Stack frame for C Leave Ret Leave Ret Leave Ret Procedure B Enter 12, 2 Procedure C
Enter 16, 3
Maeng Lect01-26
String Handling
Loop and Loop-handling Instructions
LOOP, LOOPE/Z, LOOPNE/NZ: CX must be preloaded with a count
Maeng Lect01-27
28
GDTR : global descriptor table LDTR : local descriptor table IDTR : interrupt descriptor table TR : task register EIP : 32 bits in length EFLAGS CR0, CR1, CR2, CR3 DR0-DR7(Debug registers) TR6-TR7(Test registers)
MSW
DR0 DR1 DR2 DR3 DR4 DR5 DR6 DR7 TR6 TR7
Maeng Lect01-29
Segment Descriptors
Descriptor:
the element by which the on-chip memory manager hardware manages the segmentation of the 80386DXs 64T-byte virtual memory address space. One descriptor exists for each segment of memory in virtual address space. 8 bytes long and contains three kinds of information Limit Base Access Rights Types of segment descriptors system segment descriptor(s=0), non-system segment descriptor(s=1)(code and data)
Maeng Lect01-30
Segment Descriptors
32
24
23
16
15
AVL
BASE 31..24
G X 0
LIMIT 19..16
DPL
TYPE
BASE 23..16
SEGMENT BASE 15 .. 0
SEGMENT LIMIT 15 .. 0
Maeng Lect01-31
8191
47
BASE
16 15 LIMIT
1 0
Maeng Lect01-32
255
1 0
Maeng Lect01-33
GDTR 31
15
GDT
LIMIT
BASE
15 LDTR selector
LDT0
LDTn
Maeng Lect01-34
Control Registers
31 23 Page Directory Base Register Page Fault Linear Address RESERVED
P G
15
RESERVED
CR0
MP: math present EM: emulate R: extension type TS: task switched
MSW : CR0
the lower 5 bits of CR0 are system-control flags PE: protected-mode enable bit At reset, PE is cleared.(real mode) Set PE to 1 to enter protected mode Once in protected mode, 386 cannot be switched back to real mode under SW control
Maeng Lect01-35
RPL
1-0
TI=0 use global descriptor table (GDT) TI=1 use local descriptor table (LDT)
15-3
Example: CS: 1007H, GDT base 00100000H, LDT base 00120000H (CS) = 0001 0000 0000 0111 : RPL = 3, TI =1, Index = 0001 0000 0000 0 Address of the segment descriptor = 00120000H + 1000H = 00121000H
Maeng Lect01-36
32
31 offset
INDEX
= 16K) unique segments of memory, each of which has a maximum size of 4G bytes Total virtual address space = 246 , 64 TB
214(16,384
T I
RPL
Maeng Lect01-37
PAGING DISABLED PG? PAGING ENABLED 31 LINEAR ADDRESS DIR PAGE OFFSET 0
PAGE TRANSLATION
PHYSICAL ADDRESS
Maeng Lect01-38
OFFSET
Selector SEGMENT TRANSLATION (DS) Data Segment Operand Offset(EBX)
LOGICAL ADDRESS
PAGING DISABLED PG? PAGING ENABLED 31 LINEAR ADDRESS DIR PAGE OFFSET 0
PAGE TRANSLATION
Segment Descriptor
LDT
PHYSICAL ADDRESS
Maeng Lect01-39
Transparently Loaded by MPU Programmer accessible Selectors CS DS SS ES FS GS 63 52 51 20 19 0 64-bit Segment Descriptor Cache Registers
Access Rights
Base Address
Limit
Maeng Lect01-40