Unit-I: - 80386 Introduction
Unit-I: - 80386 Introduction
Unit-I: - 80386 Introduction
80386 introduction
Sr.
No.
Topic
No of
Lectures
8086
80386
Multitasking is possible.
protection is available in
80386.
Paging is available.
FEATURES OF 80386:
Two versions of 80386 are commonly available:
1) 80386DX
2)80386SX
80386DX
80386SX
1) 32 bit address bus
address bus 32bit data bus
16 bit data bus
2) Packaged in 132 pin ceramic
flat
pin grid array(PGA)
package
3) Address 4GB of memory
1) 24 bit
2) 100 pin
3) 16 MB of
6
Features of 80386
The Intel 386 DX Microprocessor is an entry-level 32-bit
microprocessor designed for single-user applications and operating
systems such as MS-DOS and Windows.
It has 132-pins.
It contains more than 200 instructions.
It is designed using high-speed CHMOS IV technology.
The processor addresses up to 4GB (Gigabyte) of Physical memory.
It has 64TB (Terabyte) of Virtual memory.
Maximum size of each segment is 4(GB) Gigabyte.
It has eight 32-bit general purpose registers.
Its Object Code Compatible with All 8086 Family Microprocessors.
It is operate with a minimum frequency of 16MHz.
It can handle 8/16/32-bit data types.
Features of 80386
Architecture of 80386
All members of 8086 family employ parallel
processing.
The Internal Architecture of 80386 is divided into
6 functional units:
1) Bus interface unit
2) Pre-fetch unit
3) Decode unit
4) Execution unit
5) Segment unit
6) Page unit
The execution unit and the instruction unit when
combined is
known as the central processing unit.
The segment unit and the paging unit when
combined is
9
10
Data Unit:
Data unit is responsible for performing different operations
on data. For that it is divided its work into three units:
Barrel Shifter Adder Unit.
Multiply/Divide Unit.
Register file.
Architecture of 80386
The architecture of 80386DX consist three functional units:
A] Central Processing Unit.
B] Memory Management Unit.
C] Bus Interface Unit.
Instruction Decoder:
Instruction decoder decodes the instruction opcode bytes received from 16-byte
instruction queue into 3-decoded instruction for immediate use by the execution unit.
Execution Unit:
Execution unit reads instruction from instruction queue and execute it. For executing
an instruction it has three subunits:
Data unit
Control unit
Test protection unit
Execution Unit
13
Control Unit:
Control unit directs all of the processor operations for which
it extracts instruction from memory, then decodes &
executes by generating timing and control signals. Control
unit has two sub units:
Control ROM
Decode and sequencing
Control ROM:
It is an intermediate level to execute computer program
instructions. Micro programs were organized as a
sequence of microinstruction and stored in special control
memory. It manages the translation of instruction of
micro- instruction.
Decode and Sequencing:
It manages scheduling of the micro- instruction between the
various execution units and deals with results coming
Paging Unit:
The paging unit translates the linear address space into physical address
space. Each segment is divided into one or more 4k byte pages.
Adder:
In adder the selectors linear base address is added to the offset to from the
physical address.
Page cache:
A cache is a small amount of memory which operates more quickly than
main memory. Data is moved from main memory to the cache so that it
can be accessed faster. Page cache tool allows the user to limit the
amount of page cache used by applications. Each page cache is of 4kb.
Control and attributes PLA:
Control and attribute PLA checks the privileges at the page level. Each of
the pages maintains the paging information of the task.
Bus Interface
Unit
17
Register Set
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
named as EBP, ESP, ESI and EDI.
AX represents the lower 16 bit of the 32 bit register
EAX.
18
A) Instruction Pointer:
The instruction pointer is a 32-bit register named EIP.
EIP holds the offset of the next instruction to be
executed.
The offset is always relative to the base of the code
segment (CS).
The lower 16 bits (bits 0 to 15) of EIP contain the 16bit instruction pointer named IP, which is used for 16bit addressing.
B) Flags Register
80386DX has a 32-bit Flags Register named EFLAGS.
The defined bits and bit fields within EFLAGS are shown in Figure
on next slide,
It is used to control certain operations of 80386DX and to indicate
the status of the 80386 DX.
It contains information about the result of the recent arithmetic or
logical operation
the state of the processor
the state of the current task
The lower 16 bits (bit 0 to 15) of EFLAGS contain the 16-bit flag
register named FLAGS, which is most useful when executing 8086
and 80286 code.
Eflags Register
New Registers
Four categories (13 new reg.)
3
6
2
2
control registers
debug registers
test registers
segment registers
Control Registers
The 80386 DX has three control registers of 32 bits, CR0,
CR2 and CR3, to hold machine state of a global nature
(not specific to an individual task).
CR1 has been left undefined by Intel & should not be
used. Generate exception 6 (invalid opcode)
These registers hold machine state that affects all tasks in
the system. To access the Control Registers, load and
store instructions are defined.
CR0: Machine Control Register (includes 80386
Machine Status Word)
CR0, shown in Figure below, contains 6 defined bits for
control and status purposes.
The low-order 16 bits of CR0 are also known as the
Machine Status Word, MSW, for compatibility with 80286
Protected Mode.
Control Register 0
Debug Registers :
The six programmer accessible debug registers provide on-chip support for
debugging.
Debug Registers DR0 to DR3 are used to specify the four linear
breakpoints. Compares with processors address generation logic on every
instruction & if match found, an exception 1 (debug fault) is generated.
The Debug Status Register DR6 displays the current state of the
breakpoints. Never cleared by the processor.
DR4 and DR5 are reserved by Intel which do not defined.
The Debug Control Register DR7 is used to set the breakpoints. Control the
operation of the four linear address breakpoints.
Test Registers
Test registers are used to control the testing of the RAM/CAM (Content
Addressable Memories) in the Translation Look aside Buffer portion of the
80386DX.
TR6 is the command test register.
TR7 is the data register which contains the data of the Translation Look
aside buffer test.
Debug registers
Debug Registers
Segment Registers
There are six 16-bit registers name as CS, DS, ES, SS, FS, GS.
In real mode they contain the base address of a segment:
CS base address of the code segment
SS base address of the stack segment
DS base address of the data segment
ES, FS, GS base address of other data segments
CS and SS are initialized automatically by the operating system at
the moment of the program start.
The other segment registers are set by program instructions.
In protected mode the value in the register is an index into a table
of segment descriptors.
Each descriptor register holds a 32-bit segment base address, a
32-bit segment limit, and the other necessary segment attributes.
They are initialized automatically by the operating system.
The selector contains three fields. The lowest two bits (RPL) i.e.
Requestor Privilege level. The next bit is TL i.e. Table Indicator,
determines which table of descriptors defines the segment.
Segment Registers
MOD
->
R/M
00
01
10
For 16 bit
10
For 32 bit
11
000
[BX]+[SI]
[BX]+[SI]
+d8
[BX]+[SI]
+d16
DS:[EAX]
+d32
AL
AX
001
[BX]+[DI]
[BX]+[DI]
+d8
[BX]+[DI]
+d16
DS:[ECX]
+d32
Cl
CX
010
[BP]+[SI]
[BP]+[SI]
+d8
[BP]+[SI]
+d16
DS:[EDX]
+d32
Dl
DX
011
[BP]+[DI]
[BP]+[DI]
+d8
[BP]+[DI]
+d16
DS:[EBX]
+d32
Bl
BX
100
[SI]
[SI]+d8
[SI] +d16
Uses scaled AH
index byte
SP
101
[DI]
[DI]+d8
[DI] +d16
SS:[EBP]
+d32
CH
BP
DS:[ESI]
+d32
001XX110
DS:[EDI]
DH
SI
BH
DI
110
111
42
44
Status Flags:
CF (CARRY FLAG):It is set by arthmetic
instruction that generate either a carry
and borrow.
PF (PARITY FLAG): IT is set when
generated output has even no of 1s.
AF (Auxiliary CARRY FLAG): It is set when
there is a carry or borrow after a nibble.
ZF (ZERO FLAG): Zero flag is set to 1 ,if
the result of an operation is zero.
SF(SIGN FLAG): Sign flag is set to 1 when
output of operation is negative.
45
SYSTEM FLAGS:
VM ( Virtual Mode Flag): If this flag is set, the 80386
enters the virtual 8086 mode within the protection mode.
This is to be set only when the 80386 is in protected mode.
In this mode, if any privileged instruction is executed an
exception 13 is generated. This bit can be set using IRET
instruction or any task switch operation only in the
protected mode.
RF- (Resume Flag): This flag is used with the debug register
breakpoints. It is checked at the starting of every
instruction cycle and if it is set, any debug fault is ignored
during the instruction cycle. The RF is automatically reset
after successful execution of every instruction, except for
IRET and POPF instructions
47
48
50
53
80386 Architecture
54
Addressing modes:
The 80386 supports overall addressing modes to facilitate
efficient execution of higher level language programs.
In case of all those modes, the 80386 can now have 32-bit
immediate or 32- bit register operands or displacements.
The 80386 has a family of scaled modes.
In case of scaled modes, any of the index register values
can be multiplied by a valid scale factor to obtain the
displacement.
The valid scale factor are 1, 2, 4 and 8.
.
55
Maeng Lect01-57
58
Memory
I/O
59
AX
AH
AL
Memory Addressing in
Real Mode
To form a PH
Physical memory address, appropriate
segment registers contents (16-bits) are
shifted left by four positions and then
added to the 16-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.
62
63
64
x86 Instruction
Format
65
Instruction format:
An instruction format defines the layout of the bits of
an instruction.
It includes the opcode
Zero or more operands
Addressing mode for each operand
The bit allocation can be determined by the
following factors:
Number of addressing modes
Number of operands
Number of CPU registers
Number of register sets
Address range
Address granularity(address can refer
byte,word or double word)
66
67
Instruction prefixes:
It is divided into 4 subfields
Instruction prefixes
Segment override
Operand size override
Address size override
68
Instruction prefixes:
The instruction prefix if present consists of either LOCK
prefix or one of the repeat prefixes. The LOCK prefix is used
to ensure the exclusive use of shared memory in
multiprocessor environment
The repeat prefix specify repeated operation of string.
Segment override
the segment override specifies which segment register an
instruction should use rather than default segment register.
Operand size override:
Specifies which operand size an instruction should use
69
6 bits
D=0 from
D=1 To
W=0 byte
W=1 word/ double
word
MOD R/M:
MOD- The MOD field specifies whether one of the operand is
in memory or both operands are register.
REG/operand- The REG field identifies one of the register or it
can form the part of opcode.
R/M- If MOD field specifies register to register transfer then
R/M identifies the register else it specifies how the effective
address of the memory operand is to be calculated.
70
Instruction Set
New instructions introduced by
80186/80188 and 80286.
PUSH immediate data
Push all and pop all (PUSHA and
POPA)
Multiply immediate data
Shift and rotate by immediate
count
String I/O
ENTER and LEAVE
BOUND
71
SIB:
Used to specify certain addressing modes such as
scaled,index and based. Scale(2 bits) specifies
scaling factor, Index(3 bits)specify index register,
base(3 bits) specify base register.
Displacement:
This field specifies an 8,16 or 32 bit displacement if
specified by the addressing mode.
Immediate:
This field provides the value of an 8,16, or 32 bit
operand.
72
New instructions
by 80386.
introduced
End of Unit-I
74