Lecture 1 Second Course
Lecture 1 Second Course
Lecture 1 Second Course
3rd class
Computer Architecture / Course 2
1
2016\2017 ﻣﯾﺳﺎء ﻋﺑد ﻋﻠﻲ ﺧﺿراﻟدﺑﺎس.د.م.أ ﻗﺳم ﻋﻠوم اﻟﺣﺎﺳوب/اﻟﺟﺎﻣﻌﺔ اﻟﺗﻛﻧوﻟوﺟﯾﺔ
Lecture One
Protected Mode Software Architecture of the 80386DX
1- Introduction:
It can be dealing with large size in protected mode is 230 equal 1 Gag byte and 4
Gag byte equal 32 line addressing.
In real mode can be dealing with large size is 220 equal 1 mega byte. In virtual
address can be dealing with large size is 64Tira byte equal 264.
• Paging address = offset + Selector ==== protected mode.
• Physical address = offset + base ==== real mode.
2- Registers in protected Mode 80386DX:
In protected mode find five new registers addition to register in real mode.
a- Global Descriptor Table Register (GDTR).
b- Interrupt Descriptor Table Register (IDTR).
c- Local Descriptor Table Register (LDTR).
d- Control Register (CR).
e- Task Register (TR).
• Furthermore, the functions of a few registers have been extended. For example,
the instruction pointer, which is now called EIP; more bits of the flag register
(EFLAGS) are active; and all four control register, CR0 through CR3 are
functional, as shown in Figure (31).
2
2016\2017 أ.م.د.ﻣﯾﺳﺎء ﻋﺑد ﻋﻠﻲ ﺧﺿراﻟدﺑﺎس اﻟﺟﺎﻣﻌﺔ اﻟﺗﻛﻧوﻟوﺟﯾﺔ/ﻗﺳم ﻋﻠوم اﻟﺣﺎﺳوب
3
2016\2017 ﻣﯾﺳﺎء ﻋﺑد ﻋﻠﻲ ﺧﺿراﻟدﺑﺎس.د.م.أ ﻗﺳم ﻋﻠوم اﻟﺣﺎﺳوب/اﻟﺟﺎﻣﻌﺔ اﻟﺗﻛﻧوﻟوﺟﯾﺔ
a- Global Descriptor Table Register (GDTR): the contents of the global descriptor
table register defines a table in the 80386DX physical address space called the
global descriptor table (GDT). This global descriptor table is one important
element of the 80386DX memory management system.
GDTR is a 48-bit register that is located inside the 80386DX . the lower 2 bytes
of this register, which are identified as LIMIT specify the size in bytes of the
GDT. The value of LIMIT is 1 less than the actual size of the table. If LIMIT
equal 00FFH the table is 256 bytes in the length.
The upper 4 bytes of the GDTR, which are labeled BASE in locate the beginning
of GDT in physical memory. This 32-bit base address allows the table to be
position anywhere in the 80386 DX linear address space. And each descriptor is
8bytes long. If global descriptor table is increased to its maximum size 65.536
bytes, it can hold up to 8192 descriptors.
For example 1:
If the limit and base in the global descriptor table register are 0FFFH and
00100000H respectively, what is the beginning address of the descriptor table, size
of the table in bytes and the ending address of the table?
Solution:
The starting address of the global descriptor table in physical memory is given
base. Therefore,
GDTSTART = 00100000H
The limit is the offset to the end of the table. This gives
GDTEND = 00100000H + 0FFFH = 00100FFFH
Finally, The table is equal to the decimal value of the LIMIT plus 1.
GDTSIZE = FFFH + 1H = 4096 bytes
4
2016\2017 ﻣﯾﺳﺎء ﻋﺑد ﻋﻠﻲ ﺧﺿراﻟدﺑﺎس.د.م.أ ﻗﺳم ﻋﻠوم اﻟﺣﺎﺳوب/اﻟﺟﺎﻣﻌﺔ اﻟﺗﻛﻧوﻟوﺟﯾﺔ
For example 2:
How many descriptor can be stored in the global descriptor table defined in
example 1?
Solution:
Each descriptor takes up 8 bytes: therefore, a 4096-byte table can hold
4096/8 = 512 descriptors
b- Interrupt Descriptor Table Register (IDTR): this register like global descriptor
table, the interrupt descriptor table register (IDTR) define a table in physical
memory. This table contains what are called interrupt descriptors, not segment
descriptors. For this reason, it is known as the interrupt descriptor table (IDT).
The IDTR is 48 bits in length. Again, the lower two bytes of the register
(LIMIT) define the table size. That is, the size of the table equals LIMIT + 1
bytes. The 2 bytes define the size, the IDT can be also be up to 256.536 bytes
exceptions. The upper 4 bytes of IDTR (BASE) identify the starting address of
IDT in physical memory, as shown in Figure(32).
5
2016\2017 ﻣﯾﺳﺎء ﻋﺑد ﻋﻠﻲ ﺧﺿراﻟدﺑﺎس.د.م.أ ﻗﺳم ﻋﻠوم اﻟﺣﺎﺳوب/اﻟﺟﺎﻣﻌﺔ اﻟﺗﻛﻧوﻟوﺟﯾﺔ
For Example 1:
What is the maximum value that should be assigned to LIMIT in the IDTR?
Solution:
The maximum number of interrupt descriptors that can be used in an 80386DX
microcomputer system is 256. Therefore, the maximum table size in byte is
IDTSIZE = 8 × 256 = 2048 bytes
For Example 2:
What is the address range of the last descriptor in the interrupt descriptor table
defined by base address 00011000H and limit 01FFH?
Solution:
From the values of the base and limit, it find the that table is located in the address
range define by
IDTSTART = 00011000H
And
IDTEND = IDTSTART + 01FF
IDTEND = 00011000H + 01FF
IDTEND = 000111FF
The last descriptor in this table takes up the 8 bytes of memory from address
000111F8H through 000111FFH.
c-Local Descriptor Table Register:
The local descriptor table register (LDTR) is also part of the 80386DX memory
management support mechanism. Each task can have access to its own private
descriptor table in addition to the global descriptor table. This private table is
called local descriptor table (LDT), and defines a local memory address space for
use by the task.
The LDT holds segments descriptor that provide access to code and data in
segments of memory that are reserved for the current task. The protected mode-
mode software system may contain many local descriptor tables. For reason we
6
2016\2017 ﻣﯾﺳﺎء ﻋﺑد ﻋﻠﻲ ﺧﺿراﻟدﺑﺎس.د.م.أ ﻗﺳم ﻋﻠوم اﻟﺣﺎﺳوب/اﻟﺟﺎﻣﻌﺔ اﻟﺗﻛﻧوﻟوﺟﯾﺔ
have identified LDT0 through LDTN. The contents of the LDT is 16- bits does
not directly define the local descriptor table. Instead, it holds a selector that points
to an LDT descriptor in the GDT, as shown in Figure (33).
Figure 33. The task with global and local descriptor tables.
7
2016\2017 ﻣﯾﺳﺎء ﻋﺑد ﻋﻠﻲ ﺧﺿراﻟدﺑﺎس.د.م.أ ﻗﺳم ﻋﻠوم اﻟﺣﺎﺳوب/اﻟﺟﺎﻣﻌﺔ اﻟﺗﻛﻧوﻟوﺟﯾﺔ
d-Control Register:
The protected model includes the four system-control registers, identified as CR0
through CR3, as shown in Figure (34).
8
2016\2017 ﻣﯾﺳﺎء ﻋﺑد ﻋﻠﻲ ﺧﺿراﻟدﺑﺎس.د.م.أ ﻗﺳم ﻋﻠوم اﻟﺣﺎﺳوب/اﻟﺟﺎﻣﻌﺔ اﻟﺗﻛﻧوﻟوﺟﯾﺔ
EM = Emulate Math.
EM= 1 is the software emulate to perform numeric operation. The MP is 1
EM = 0 is the software emulate not to perform numeric operation. The MP is 0
R= Extension Type.
R =1 is complement 80387 to 80386.
R= 0 is complement 80287 to 80286.
TS = Task Switch, automatically gets set (1) whenever the 80386DX switches
from on task to another it can be clear by software. In the other hand,
TS = 0 in the same task.
TS =1 transfer in the other task.
PG = Paging
PG = 0 is not paging the address is physical address in memory.
PG = 1 is paging the address is paging address in memory.
CR1 = Reserved.
CR2 = Page Fault Linear Address.
CR3 = Page Directory Base Register (PDBR).
e-Task Register:
The Task register is a key element in the protected mode task switching
mechanism of the 80386DX microprocessor. This register holds a 16-bit index value
called a selector the initial selector must be loaded into TR under software control.
This starts the initial task after this is done, the selector is changed automatically
whenever the 80386DX executes an instruction that perform a task switch.
3- Virtual Address and Virtual Address Space:
The protected mode memory management unit (MMU) employ memory pointer
that are 48 bits in length and consists of two parts, the selector and offset. This 48 bits
memory pointer is called virtual address is used by program to specify the memory
locations of instructions or data. As shown in Figure (35), the selector is 16 bits in length
and the offset is 32 bits in long.
9
2016\2017 ﻣﯾﺳﺎء ﻋﺑد ﻋﻠﻲ ﺧﺿراﻟدﺑﺎس.د.م.أ ﻗﺳم ﻋﻠوم اﻟﺣﺎﺳوب/اﻟﺟﺎﻣﻌﺔ اﻟﺗﻛﻧوﻟوﺟﯾﺔ
Virtual address
Selector Offset
47 32 31 0
10
2016\2017 ﻣﯾﺳﺎء ﻋﺑد ﻋﻠﻲ ﺧﺿراﻟدﺑﺎس.د.م.أ ﻗﺳم ﻋﻠوم اﻟﺣﺎﺳوب/اﻟﺟﺎﻣﻌﺔ اﻟﺗﻛﻧوﻟوﺟﯾﺔ
.
.
. Local address space
.
. 32 Tira bytes
.
Local Segment 1
Local Segment 0
Virtual address space
64 Tira bytes
Global Segment 8191
.
. Global address space
.
32 Tira bytes
.
.
.
Global Segment 1
Global Segment 0
Figure 37. The protected mode memory management and address space.
11
2016\2017 ﻣﯾﺳﺎء ﻋﺑد ﻋﻠﻲ ﺧﺿراﻟدﺑﺎس.د.م.أ ﻗﺳم ﻋﻠوم اﻟﺣﺎﺳوب/اﻟﺟﺎﻣﻌﺔ اﻟﺗﻛﻧوﻟوﺟﯾﺔ
5-
6- Segment Descriptor:
Each descriptor is consist of 8 byte task switching, called task state selector, as
shown in Figure (38).
12
2016\2017 ﻣﯾﺳﺎء ﻋﺑد ﻋﻠﻲ ﺧﺿراﻟدﺑﺎس.د.م.أ ﻗﺳم ﻋﻠوم اﻟﺣﺎﺳوب/اﻟﺟﺎﻣﻌﺔ اﻟﺗﻛﻧوﻟوﺟﯾﺔ
• Multi Tasking: Multi Tasking: is the more operation existence in the same time,
the process in 80386DX is divided the time to treatment many operation, as
shown in Figure (39).
13
2016\2017 ﻣﯾﺳﺎء ﻋﺑد ﻋﻠﻲ ﺧﺿراﻟدﺑﺎس.د.م.أ ﻗﺳم ﻋﻠوم اﻟﺣﺎﺳوب/اﻟﺟﺎﻣﻌﺔ اﻟﺗﻛﻧوﻟوﺟﯾﺔ
FFFFFFFFH
FFFFFFFFH
FFFFFFFFH
4GB
00000002 H
00000001 H
00000000 H
14
2016\2017 ﻣﯾﺳﺎء ﻋﺑد ﻋﻠﻲ ﺧﺿراﻟدﺑﺎس.د.م.أ ﻗﺳم ﻋﻠوم اﻟﺣﺎﺳوب/اﻟﺟﺎﻣﻌﺔ اﻟﺗﻛﻧوﻟوﺟﯾﺔ
In protected mode the 32-bit address bus the 80386DX results in a 4GB byte
physical memory address space. Each word is 32-bit or 4-byte.
15
2016\2017 ﻣﯾﺳﺎء ﻋﺑد ﻋﻠﻲ ﺧﺿراﻟدﺑﺎس.د.م.أ ﻗﺳم ﻋﻠوم اﻟﺣﺎﺳوب/اﻟﺟﺎﻣﻌﺔ اﻟﺗﻛﻧوﻟوﺟﯾﺔ
16