Advanced Processor
Advanced Processor
Advanced Processor
1. Features of 80386
The 80386 microprocessor is an enhanced version of the 80286 microprocessor
Memory-management unit is enhanced to provide memory paging.
The 80386 also includes 32-bit extended registers and a 32-bit address and data bus. These
extended registers include EAX, EBX, ECX, EDX, EBP, ESP, EDI, ESI, EIP and EFLAGS.
The 80386 has a physical memory size of 4GBytes that can be addressed as a virtual
memory with up to 64TBytes.
The 80386 is operated in the pipelined mode, it sends the address of the next instruction
or memory data to the memory system prior to completing the execution of the current
instruction
This allows the memory system to begin fetching the next instruction or data before the
current is completed. This increases access time.
The instruction set of the 80386 is enhanced to include instructions that address the 32-
bit extended register set.
The 80386 memory manager is similar to the 80286, except the physical addresses
generated by the MMU are 32 bits wide instead of 24-bits.
The concept of paging is introduced in 80386
80386 support three operating modes:
1) Real Mode (default)
2) Protected Virtual Address Mode (PVAM)
3) Virtual Mode
The memory management section of 80386 supports virtual memory, paging and four
levels of protection.
The 80386 includes special hardware for task switching.
2. 80386 Architecture
The internal architecture of the 80386 includes six functional units that operate in
parallel. The parallel operation is called as pipeline processing.
Fetching, decoding execution, memory management, and bus access for several
instructions are performed simultaneously.
The six functional units of the 80386 are
1) Bus Interface Unit
2) Code Pre-fetch Unit
3) Instruction Decoder Unit
4) Execution Unit
5) Segmentation Unit
6) Paging Unit
Figure: 80386 Architecture
The Bus Interface Unit connects the 80386 with memory and I/O. Based on internal
requests for fetching instructions and transferring data from the code pre-fetch unit, the
80386 generates the address, data and control signals for the current bus cycles.
The code pre-fetch unit pre-fetches instructions when the bus interface unit is not
executing the bus cycles. It then stores them in a 16-byte instruction queue for decoding
by the instruction decode unit.
The instruction decode unit translates instructions from the pre-fetch queue into micro-
codes. The decoded instructions are then stored in an instruction queue (FIFO) for
processing by the execution unit.
The execution unit processes the instructions from the instruction queue. It contains a
control unit, a data unit and a protection test unit.
The control unit contains microcode and parallel hardware for fast multiply, divide and
effective address calculation. The unit includes a 32-bit ALU, 8 general purpose
registers and a 64-bit barrel shifter for performing multiple bit shifts in one clock. The
data unit carries out data operations requested by the control unit.
The protection test unit checks for segmentation violations under the control of
microcode.
The segmentation unit calculates and translates the logical address into linear addresses
at the request of the execution unit.
The translated linear address is sent to the paging unit. Upon enabling the paging
mechanism, the 80386 translates these linear addresses into physical addresses.
If paging is not enabled, the physical address is identical to the linear address and no
translation is necessary.
3. Register organization of 80386
The Register organization of 80386 is as follows:
LDTR (Local Descriptor Table Register) and TR (Task Register) can be loaded with
instructions which take a 16-bit segment selector as an operand.
45-46 DPL (Descriptor Indicates privilege level associated with memory space. 0 - most
privileged 3 – least privileged
Privilege level)
47 Present If set 0 , indicates that the address range that is specified by the
descriptor is temporarily not present.
53 X Reserved by Intel
The Above figure is the format of the code/data descriptor; one descriptor is 64-bit long.
As we can see, a descriptor actually includes a 32-bit base address and a 20-bit limit and
some attributes, the 32-bit base address indicate where the segment starts, and the 20-bit
limit indicates the length of the segment.
However, a problem comes up, 20-bit limit can only represent 2^20 = 1MB memory, to access
a 4GB memory space, descriptor uses G bit to indicate whether the limit use 4K or 1 byte for
one unit, that means if G bit is set then we get 2^20*4K = 4GB memory, if it is unset then we
only use a memory space under 1MB.
P-bit: Present bit, if logic1 indicates that the entry can be used in address translation. If
P = 0, the entry cannot be used for translation. When P = 0, the remaining bits of the
entry can be used to indicate the location of the page on the disk memory system.
Difference between page directory and page table entry:
The main difference is that the page directory entry contains the physical address of a page
table, while the page table entry contains the physical address of a 4K-bytephysical page of
memory.
The other difference is the D (dirty bit), which has no function in thepage directory entry,
but indicates that a page has been written to in a page table entry.
8.5. Page Translation Mechanism in 80386
A page frame is a 4K-byte unit of contiguous addresses of physical memory. Pages begin on
byte boundaries and are fixed in size.
A linear address refers indirectly to a physical address by specifying a page table, a page
within that table, and an offset within that page
BIU:
BIU generates address, data and control signals for a bus cycle it is supported with an
additional parity detection/generation for memory reads and writes.
During memory write operation, the 486 generates even parity bit for each byte outputs
these bits.
These bits will be stored in a separate parity memory bank.
During read operation, stored parity bits will be read from the parity memory.
80486 checks the parities of data bytes read and compare them with the DP0 – DP3
signals and generates parity check error, if it occurs.
It pre-fetches the instruction bytes in advance and holds them in a 32–byte code queue.
Instruction Decoder :
Decodes the instructions in the queue and passes the control and protection test unit.
Execution Unit:
Executes the instruction with the help of Barrel Shifter, ALU and Register bank.
Segmentation Unit and Paging Unit :
They are part of MMU(which manages virtual memory of system). Helpful in generation of
Physical Address.
Work same as they work in 80386.
Cache Unit:
8KB cache
Additional high speed cache memory provides a way of improving overall system
performance.
It contains the recently used instructions, data or both.
The main aim is that the microprocessor unit access code and data in the cache most of
time, instead from the main memory.
EFLAG Register
The extended flag register EFLAG is illustrated in the figure below:-
The only new flag bit is the AC alignment check, used to indicate that the
microprocessor has accessed a word at an odd address or a double word boundary.
Special Features:
1) 8086 is a pipelined processor
2) 8086 is two staged pipelined architecture:
Fetch Stage: It pre-fetch up to 6 bytes of instruction and store them in the queue.
Execute stage: Executes the instruction
3) 8086 can operate in 2 modes
Minimum mode: A system with only one processor i.e.8086
Maximum mode: A system with multiple processors.
e.g. 8086 + math co-
processor(8087), 8086+ I/O
processor (8089), Multiple 8086
processors
4) 8086 uses memory bank
In 8086 entire data is not stored in single sequential memory of 1MB.
The memory is divided into two banks of 512KB each.
I. Lower Bank/ Even Bank: Stores the data types at even locations (0,2,4…)
II. Higher Bank/ Odd Bank: Stores the data types at odd locations (1,3,5…)
5) 8086 uses memory segmentation
Segmentation means dividing memory into logical components.
In 8086 memory is divided into 16 segments of capacity 216 bytes each and used
as code, stack, data and extra segment
2. 8086 ARCHITECTURE
In 8086 CPU is divided into two independent functional parts BIU and EU.
Dividing the work between these two units’ speeds up the processing.
Instruction queue
- It holds the instruction bytes of the next instruction to be executed by EU
Segment Registers
- Four 16-bit register that provides powerful memory management mechanism
- ES (extra segment), CS (code segment), SS (stack segment) , DS (data segment).
- The size of each register is 64kb.
Instruction pointer (IP)
- Register that holds 16-bit address or offset of next code byte within code segment
Address Generation and bus control
- Generation of 20-bit physical
2) EU (Execution Unit)
Components of EU
3. 8086 REGISTERS
The 8086 microprocessor has a total of fourteen registers that are accessible to the
programmer as follows:-
AX: - Accumulator register consists of two 8-bit registers AL and AH, which can be
combined together and used as a 16-bit register AX.
BX: -Base register consists of two 8-bit registers BL and BH, which can be combined
together and used as a 16-bit register BX.
BX register usually contains a data pointer used for based, based indexed or
register indirect addressing.
CX:-Count Register consists of two 8-bit registers CL and CH, which can be combined
together and used as a 16-bit register CX.
Count register can be used in Loop, shift/rotate instructions and as a counter in
string manipulation.
DX: - Data register can be used together with AX register to execute MUL and DIV
instruction.
Code Segment (CS): The CS register is used for addressing a memory location in the
Code Segment of the memory, where the executable program is stored.
Data Segment (DS): The DS contains most data used by program. Data are accessed in
the Data Segment by an offset address or the content of other register that holds the offset
address.
Stack Segment (SS): SS defined the area of memory used for the stack.
Extra Segment (ES): ES is additional data segment that is used by some of the string to
hold the destination data
3. Pointer Registers
The pointers IP, BP, SP usually contain offsets within the code, data and stack segments
respectively.
Stack Pointer (SP): SP is a 16-bit register pointing to program stack in stack segment.
Base Pointer (BP): BP is a 16-bit register pointing to data in stack segment. BP register
is usually used for based, based indexed or register indirect addressing.
4. Index registers
Source Index (SI): SI is a 16-bit register used for indexed, based indexed and register
indirect addressing, as well as a source data addresses in string manipulation instructions.
Destination Index (DI): DI is a 16-bit register. DI is used for indexed, based indexed
and register indirect addressing, as well as a destination data addresses in string
manipulation instructions.
5. Flag Registers
The 16-bit flag register of 8086 contains 9 active flags (six conditional & 3 control flags),
other 7 flags are undefined.
Status Flags: It indicates certain condition that arises during the execution. They are
controlled by the processor.
Control Flags: It controls certain operations of the processor. They are deliberately
set/reset by the user.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
U U U U OF DF IF TF SF ZF U AF U PF U CF
CONTROL FLAGS
Control flags are set or reset deliberately to control the operations of the execution unit.
STATUS FLAG
This flag indicates an overflow condition for unsigned integer arithmetic. It is also used in
multiple-precision arithmetic.
This flag is used to indicate the parity of result. If lower order 8-bits of the result contains
even number of 1’s, the Parity Flag is set and for odd number of 1’s, the Parity Flag is reset.
In sign magnitude format the sign of number is indicated by MSB bit. If the result of
operation is negative, sign flag is set.
It occurs when signed numbers are added or subtracted. OF=1 indicates that the result
has exceeded the capacity of machine.
4. Addressing Mode
There are 12 addressing modes in 8086 as follows:-
1) Immediate Mode
If a source operand is part of the instruction instead of the contents of a register or
memory location, it represents what is called the immediate operand.
In other word it is constant data contained in an instruction
If source operand is the part of instruction rather than register or memory, then referred
as immediate addressing mode.
Operand = address field
E.g. MOV AL, 05H; instruction copies immediate number 05H to AL register
Immediate data may be 8-bits or 16-bits in length
Instruction
Advantage:
Limitation:
Advantage:
Limitation:
Advantage:
+ 0 0 3 0 ( direct address)
---------------------
3 0 6 3 0 (physical address)
4) Register Indirect Addressing
In this addressing mode effective address of memory is calculated from base register
(BX) or index register (SI, DI), specified in the instruction. Then it is added to the
segment register to generate physical address.
Equation: Physical Address PA ={starting address of Segment Register } + { [BX] or index
register }
E.g. MOV [DI], BX; value of BX is moved to the memory location specified in DI
MOV [BX], AX ; value of AX is moved to the memory location specified in BX
Advantage:
When memory is accessed PA is computed from BX and DS, when the stack is accessed PA is
computed from BP and SS.
Equation:
PA ={starting address of Segment Register } + { [BX] or [BP] }+ (8 or 16 bit)
displacement
Example: MOV AL, TEMP [BX]; segment register address+ BX+ offset
MOV AL, TEMP [BP]; segment register address+ BP+ offset
Assume DS=3060, BX=0050 and displacement=08
+ 0 0 5 0 H(base register)
+ 0 8 H(offset)
----------------------------------------
3 0 6 5 8 H(physical address)
+ 0 0 5 0 H (Source Index)
+ 0 8 H (offset)
----------------------------------------
3 0 6 5 8 H (physical address)
segment register)
+ 3 0 0 0 H (base register)
+ 0 4 0 0 H (Source Index)
+ 0 8 H (offset)
----------------------------------------
5 3 4 0 8 H (physical address)
[40300] = 38
[DI] = 03
- If CY=O, then PC is loaded with current PC contents plus 8 bit signed value of START,
otherwise the next instruction is executed.
- Displacement is calculated on the basis of next location to be executed.
5. SEGMENTATION IN 8086
In Segmentation, the total memory size is divided into segments of various sizes.
Segment is just an area in memory.
The process of dividing memory into segments of various sizes is called Segmentation.
Memory is huge collection of bytes. In order to organize these bytes in an efficient
manner Segmentation is used.
= 1MB/64KB
= 1024KB/64KB
= 16 segments.
Segment Registers are used to hold the upper 16-bit of the starting address for each of
the segment.
The 16-bit of the starting address is the starting address of the segment from where the
BIU is currently fetching instruction code bytes.
The BIU always inserts zeros for the LSB of the 20-bit address for a segment. Because the
segment registers cannot store 20 bits, they only store the upper 16 bits.
The 20-bit address of a byte is called its Physical Address (PA).
Offset is the displacement of the memory location from the starting location of the
segment.
The value of Data Segment Register (DS) is 2222 H.
To convert this 16-bit address into 20-bit, the BIU appends 0H to the LSBs of the base
address.
After appending, the starting address of the Data Segment becomes 22220H.
If the data at any location has an address specified as: 2222H: 0016 H where the number
0016 H is an offset.
To calculate the effective address of the memory, BIU uses the following formula:
Physical Address = Starting Address of Segment + Offset
To find the starting address of the segment, BIU appends the contents of Segment Register
with 0H and then, it adds offset to it.
EA = 2 2 2 2 0 H
+0016H
----------------
22236H
Unit 02 – Advanced Microprocessor
1. 80286
The 80286 was designed for multi-user systems with multitasking applications, including
communications and real-time process control.
It had 134,000 transistors and consisted of four independent units: address unit, bus unit,
instruction unit and execution unit.
These were organized into a pipeline, significantly increasing performance.
It was produced in a 68-pin package including PLCC (Plastic Leaded Chip Carrier), LCC
(Leadless chip carrier) and PGA (Pin Grid Array) packages.
The Intel 80286 had a 24-bit address bus and was able to address up to 16 MB of RAM,
compared to 1 MB for its predecessor. However cost and initial rarity of software using the
memory above 1 MB meant that 80286 computers were rarely shipped with more than one
megabyte of RAM.
80286 Architecture contains 4 separate processing units.
(1) Bus Unit (BU)
(2) Instruction Unit (IU)
(3) Address Unit (AU)
(4) Execution Unit (EU)
The 80286 CPU contains almost the same set of registers, as in 8086, namely
(1) Eight 16-bit general purpose registers (AX, BX, CX, DX)
(2) Four 16-bit segment registers (CS, SS, DS, ES)
(3) Status and control registers (SP, BP, SI, DI)
(4) Instruction Pointer (IP)
(5) Two 16-bit register - FLAGS, MSW
(6) Two 16-bit register - LDTR and TR
(7) Two 48-bit register -GDTR and IDTR
1) PE - Protection Enable
The PE bit is set to enable the Protected Mode. If PE is reset, the processor operates
again in Real Mode.
2) MP - Monitor Processor Extension
The MP bit is used in conjunction with the TS bit to determine if the WAIT opcode will
generate a Coprocessor Not Available fault when TS=1. When both MP = 1 and TS = 1,
the WAIT opcode generates a trap. Otherwise, the WAIT opcode does not generate a
trap. Note that TS is automatically set whenever a task switch operation is performed.
3) EM - Processor Extension Emulator
The EMulate coprocessor bit is set to cause all coprocessor opcodes to generate a
Coprocessor Not Available fault. It is reset to allow coprocessor opcodes to be executed
on an actual Intel387 DX coprocessor. Note that the WAIT opcode is not affected by the
EM bit setting.
4) TS – Task Switch
TS is automatically set whenever a task switch operation is performed.
The 80286 is the first member of the family of advanced microprocessors with memory
management and protection abilities.
The 80286 CPU, with its 24-bit address bus is able to address 16 Mbytes of physical
memory. Various versions of 80286 are available that runs on 12.5 MHz, 10 MHz and 8
MHz clock frequencies.
80286 is upwardly compatible with 8086 in terms of instruction set.
80286 have two operating modes namely real address mode and virtual address mode.
In real address mode, the 80286 can address up to 1Mb of physical memory address like
8086.
In virtual address mode, it can address up to 16 Mb of physical memory address space and
1 GB of virtual memory address space.
The instruction set of 80286 includes the instructions of 8086 and 80186.
80286 have some extra instructions to support operating system and memory
management.
In protected virtual address mode, it is source code compatible with 8086.
The performance of 80286 is five times faster than the standard 8086.
The virtual address space of a microprocessor may be many times larger than the actual
physical address space.
This is desirable as a microprocessor is supposed to store large programs and data which
cannot be accommodated in the physical memory space.
Usually programs and data are stored in a secondary storage such as a hard disk.
The hard disk is in the virtual or logical address space but not in the physical address
space.
Faster memory such as RAM is used as the physical memory (Primary Storage).
When a microprocessor is to execute a program, it checks whether the program is
available in the physical memory (RAM).
If the program is not available in the physical memory, it is brought from the secondary
memory to the physical memory for execution.
If available space is inadequate in the physical memory, some less important or unused
program can be swapped back to the secondary memory to create space.
80286 is the first processor to support the concepts of virtual memory and memory
management.
The concept of Virtual Memory is implemented using Physical memory that the CPU
can directly access and secondary memory that is used as storage for data and program,
which are stored in secondary memory initially.
The complete virtual memory is mapped on to the 16Mbyte physical memory.
If a program larger than 16Mbyte is stored on the hard disk and is to be executed, if it is
fetched in terms of data or program segments of less than 16Mbyte in size into the program
memory by swapping sequentially as per sequence of execution.
The 80286 is able to address 1 GB (230 bytes) of virtual memory.
80286 uses the 16-bit content of a segment register as a selector to address a descriptor
stored in the physical memory.
The descriptor is a block of contiguous memory locations containing information of a
segment, like segment base address, segment limit, segment type, privilege level, segment
availability in physical memory descriptor type and segment.
Hardware reset is the only way to come out of protected mode
6. Privilege level
Each task assigned a privilege level, which indicates the priority or privilege of that task.
It can only change by transferring the control, using gate descriptors, to a new segment.
A task executing at level 0, the most privileged level, can access the entire data segment
defined in GDT and LDT of the task.
A task executing at level 3, the least privileged level, will have the most limited access to
data and other descriptors.
The use of rings allows for system software to restrict tasks from accessing data.
In most environments, the operating system and some device drivers run in ring 0 and
applications run in ring 3.
7. DESCRIPTOR TABLE
GDT, LDT, IDT and TSS are all data structures specified by Intel architecture in memory
management module.
Descriptor is an identifier of a program segment or page.
GDT
GDT, Global Descriptor Table, is used to define the characteristics of the various
memory areas used during program execution, including the base address, the size and
access privileges like execute ability and write ability.
These memory areas are called segments in Intel terminology. Segment is a term for
memory management in Intel architecture, which is also used collaboratively with paging
mechanism.
LDT
LDT, Local Descriptor Table, acts similar to GDT, which also saves segments descriptor.
The LDT is the sibling of the Global Descriptor Table (GDT) and defines up to 8192
memory segments accessible to programs.
The descriptor describes the location, length, and access rights of the segment of memory.
The selector, located in the segment register, selects one of descriptors from one of two
tables of descriptors.
Fig. 8 : Protected Mode Addressing with Descriptor Table
1. Features of 80386
The 80386 microprocessor is an enhanced version of the 80286 microprocessor
Memory-management unit is enhanced to provide memory paging.
The 80386 also includes 32-bit extended registers and a 32-bit address and data bus. These
extended registers include EAX, EBX, ECX, EDX, EBP, ESP, EDI, ESI, EIP and EFLAGS.
The 80386 has a physical memory size of 4GBytes that can be addressed as a virtual
memory with up to 64TBytes.
The 80386 is operated in the pipelined mode, it sends the address of the next instruction
or memory data to the memory system prior to completing the execution of the current
instruction
This allows the memory system to begin fetching the next instruction or data before the
current is completed. This increases access time.
The instruction set of the 80386 is enhanced to include instructions that address the 32-
bit extended register set.
The 80386 memory manager is similar to the 80286, except the physical addresses
generated by the MMU are 32 bits wide instead of 24-bits.
The concept of paging is introduced in 80386
80386 support three operating modes:
1) Real Mode (default)
2) Protected Virtual Address Mode (PVAM)
3) Virtual Mode
The memory management section of 80386 supports virtual memory, paging and four
levels of protection.
The 80386 includes special hardware for task switching.
2. 80386 Architecture
The internal architecture of the 80386 includes six functional units that operate in
parallel. The parallel operation is called as pipeline processing.
Fetching, decoding execution, memory management, and bus access for several
instructions are performed simultaneously.
The six functional units of the 80386 are
1) Bus Interface Unit
2) Code Pre-fetch Unit
3) Instruction Decoder Unit
4) Execution Unit
5) Segmentation Unit
6) Paging Unit
GDTR (Global Descriptor Table Register) and IDTR (Interrupt Descriptor Table
Register) be loaded with instructions which get a 6 byte data item from memory
LDTR (Local Descriptor Table Register) and TR (Task Register) can be loaded with
instructions which take a 16-bit segment selector as an operand.
45-46 DPL (Descriptor Indicates privilege level associated with memory space. 0 - most
privileged 3 – least privileged
Privilege level)
47 Present If set 0 , indicates that the address range that is specified by the
descriptor is temporarily not present.
53 X Reserved by Intel
The Above figure is the format of the code/data descriptor; one descriptor is 64-bit long.
As we can see, a descriptor actually includes a 32-bit base address and a 20-bit limit and
some attributes, the 32-bit base address indicate where the segment starts, and the 20-bit
limit indicates the length of the segment.
However, a problem comes up, 20-bit limit can only represent 2^20 = 1MB memory, to access
a 4GB memory space, descriptor uses G bit to indicate whether the limit use 4K or 1 byte for
one unit, that means if G bit is set then we get 2^20*4K = 4GB memory, if it is unset then we
only use a memory space under 1MB.
P-bit: Present bit, if logic1 indicates that the entry can be used in address translation. If
P = 0, the entry cannot be used for translation. When P = 0, the remaining bits of the
entry can be used to indicate the location of the page on the disk memory system.
Difference between page directory and page table entry:
The main difference is that the page directory entry contains the physical address of a page
table, while the page table entry contains the physical address of a 4K-bytephysical page of
memory.
The other difference is the D (dirty bit), which has no function in thepage directory entry,
but indicates that a page has been written to in a page table entry.
8.5. Page Translation Mechanism in 80386
A page frame is a 4K-byte unit of contiguous addresses of physical memory. Pages begin on
byte boundaries and are fixed in size.
A linear address refers indirectly to a physical address by specifying a page table, a page
within that table, and an offset within that page
BIU:
BIU generates address, data and control signals for a bus cycle it is supported with an
additional parity detection/generation for memory reads and writes.
During memory write operation, the 486 generates even parity bit for each byte outputs
these bits.
These bits will be stored in a separate parity memory bank.
During read operation, stored parity bits will be read from the parity memory.
80486 checks the parities of data bytes read and compare them with the DP0 – DP3
signals and generates parity check error, if it occurs.
It pre-fetches the instruction bytes in advance and holds them in a 32–byte code queue.
Instruction Decoder :
Decodes the instructions in the queue and passes the control and protection test unit.
Execution Unit:
Executes the instruction with the help of Barrel Shifter, ALU and Register bank.
Segmentation Unit and Paging Unit :
They are part of MMU(which manages virtual memory of system). Helpful in generation of
Physical Address.
Work same as they work in 80386.
Cache Unit:
8KB cache
Additional high speed cache memory provides a way of improving overall system
performance.
It contains the recently used instructions, data or both.
The main aim is that the microprocessor unit access code and data in the cache most of
time, instead from the main memory.
EFLAG Register
The extended flag register EFLAG is illustrated in the figure below:-
The only new flag bit is the AC alignment check, used to indicate that the
microprocessor has accessed a word at an odd address or a double word boundary.