80386 Microprocessor Pdf



80386 Microprocessor Pdf
Unit
2
THE 80386 AND 80486 MICROPROCESSOR
-80386 Microprocessors -Special 80386 Registers -80386 Memory Management -Moving to Protected Mode -Virtual 8086 Mode -The Memory Paging Mechanism -80486 Microprocessor -80386 Addressing Modes -Instruction Set
Introduction to the 80386 The 80386 is an advanced 32-bit microprocessor optimized for multitasking operating systems and designed for applications needing very high performance. The 32-bit registers and data paths support 32-bit addresses and data types. The processor can address up to four gigabytes of physical memory and 64 terabytes (2^(46) bytes) of virtual memory. The onchip memory- management facilities include address translation registers, advanced multitasking hardware, a protection mechanism, and paged virtual memory. Special debugging registers provide data and code breakpoints even in ROM-based software. Two versions of 80386 are commonly available: 1) 80386DX 2)80386SX
80386DX 32 bit address bus 16 bit data bus Packaged in 132 pin ceramic package Address 4GB of memory
80386SX 24 bit address bus 32bit data bus 100 pin flat pin grid array(PGA) 16 MB of memory
80386SX was developed after the DX for application that didn’t require the full 32-bit bus version.It is found in many PCs use the same basic mother board design as the 80286.Most application less than the 16MB of memory ,so the SX is popular and less costly version of the 80386 microprocessor.  The 80386 cpu supports 16k no:of segments and thus total virtual memory space is 4GB *16 k=64 tera bytes  Memory management section supports  Virtual memory  Paging  4 levels of protection  20-33 MHz frequency
Architecture of 80386 The Internal Architecture of 80386 is divided into 3 sections. • Central processing unit(CPU) • Memory management unit(MMU) • Bus interface unit(BIU) • Central processing unit is further divided into Execution unit(EU) and Instruction unit(IU) • Execution unit has 8 General purpose and 8 Special purpose registers which are either used for handling data or calculating offset addresses.
•The Instruction unit decodes the opcode bytes received from the 16-byte instruction code queue and arranges them in a 3- instruction decoded instruction queue. •After decoding them pass it to the control section for deriving the necessary control signals. The barrel shifter increases the speed of all shift and rotate operations.
• The multiply / divide logic implements the bit-shift-rotate algorithms to complete the operations in minimum time. •Even 32- bit multiplications can be executed within one microsecond by the multiply / divide logic. •The Memory management unit consists of  Segmentation unit and  Paging unit.  •Segmentation unit allows the use of two address components, viz. segment and offset for relocability and sharing of code and data. •Segmentation unit allows segments of size 4Gbytes at max. •The Paging unit organizes the physical memory in terms of pages of 4kbytes size each. •Paging unit 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. The Segmentation unit provides a 4 level protection mechanism for protecting and isolating the system code and data from those of the application program. •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. •The Bus control unit has a prioritizer to resolve the priority of the various bus requests.This controls the access of the bus. The address driver drives the bus enable and address signal A0 – A31. The pipeline and dynamic bus sizing unit handle the related control signals. •The data buffers interface the internal data bus with the system bus.
Register Organisation: •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. • 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.
• 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. •Also, it is not automatically cleared after the successful execution of JMP, CALL and INT instruction causing a task switch. These instruction are used to set the RF to the value specified by the memory data available at the stack. •Segment Descriptor Registers: This registers are not available for programmers, rather they are internally used to store the descriptor information, like attributes, limit and base addresses of segments. •The six segment registers have corresponding six 73 bit descriptor registers. Each of them contains 32 bit base address, 32 bit base limit and 9 bit attributes. These are automatically loaded when the corresponding segments are loaded with selectors. •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. •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, viz. global descriptor table (GDT),interrupt descriptor table (IDT), local descriptor table (LDT) and task state segment descriptor (TSS). •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 breakpoint addresses, while DR6 and DR7 respectively hold breakpoint status and breakpoint control information. •Two more test register are provided by 80386 for page caching namely test control and test status register.
ADDRESSING MODES: The 80386 supports overall eleven 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. •The different scaled modes are as follows. •Scaled Indexed Mode: Contents of the an index register are multiplied by a scale factor that may be added further to get the operand offset. •Based Scaled Indexed Mode: Contents of the an index register are multiplied by a scale factor and then added to base register to obtain the offset. •Based Scaled Indexed Mode with Displacement: The Contents of the an index register are multiplied by a scaling factor and the result is added to a base register and a displacement to get the offset of an operand.
Real Address Mode of 80386 •After reset, the 80386 starts from memory location FFFFFFF0H under the real address mode. In the real mode, 80386 works as a fast 8086 with 32-bit registers and data types. •In real mode, the default operand size is 16 bit but 32- bit operands and addressing modes may be used with the help of override prefixes. •The segment size in real mode is 64k, hence the 32-bit effective addressing must be less than 0000FFFFFH. The real mode initializes the 80386 and prepares it for protected mode.
•Memory Addressing in Real Mode: In the real mode, the 80386 can address at the most1Mbytes of physical memory using address lines A0-A19. •Paging unit is disabled in real addressing mode, and hence the real addresses are the same as the physical addresses. •To form a 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. •Any fetch or access past the end of the segment limit generate exception 13 in real address mode. •The segments in 80386 real mode may be overlapped or non-overlapped. •The interrupt vector table of 80386 has been allocated 1Kbyte space starting from 00000H to 003FFH.
Protected Mode of 80386: •All the capabilities of 80386 are available for utilization in its protected mode of operation. •The 80386 in protected mode support all the software written for 80286 and 8086 to be executed under the control of memory management and protection abilities of 80386. •The protected mode allows the use of additional instruction, addressing modes and capabilities of 80386.
ADDRESSING IN PROTECTED MODE: In this mode, the contents of segment registers are used as selectors to address descriptors which contain the segment limit, base address and access rights byte of the segment. •The effective address (offset) is added with segment base address to calculate linear address. This linear address is further used as physical address, if the paging unit is disabled, otherwise the paging unit converts the linear address into physical address. •The paging unit is a memory management unit enabled only in protected mode. The paging mechanism allows handling of large segments of memory in terms of pages of 4Kbyte size. •The paging unit operates under the control of segmentation unit. The paging unit if enabled converts linear addresses into physical address, in protected mode.
Segmentation: •Descriptor tables: These descriptor tables and registers are manipulated by the operating system to ensure the correct operation of the processor, and hence the correct execution of the program. •Three types of the 80386 descriptor tables are listed as follows: •GLOBAL DESCRIPTOR TABLE ( GDT ) •LOCAL DESCRIPTOR TABLE ( LDT )
•INTERRUPT DESCRIPTOR TABLE ( IDT ) •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). •The DPL field specifies the descriptor privilege level. •The D bit specifies the code segment operation size. If D=1, the segment is a 32bit operand segment, else, it is a 16-bit operand segment. •The P bit (present) signifies whether the segment is present in the physical memory or not. If P=1, the segment is present in the physical memory. •The G (granularity) bit indicates whether the segment is page addressable. The zero bit must remain zero for compatibility with future process. •The AVL (available) field specifies whether the descriptor is for user or for operating system.
•The 80386 has five types of descriptors listed as follows:
1.Code or Data Segment Descriptors. 2.System Descriptors. 3.Local descriptors. 4.TSS (Task State Segment) Descriptors. 5.GATE Descriptors. •The 80386 provides a four level protection mechanism exactly in the same way as the 80286 does.
Paging: •Paging
Operation: Paging is one of the memory management techniques used for virtual memory multitasking operating system. •The segmentation scheme may divide the physical memory into a variable size segments but the paging divides the memory into a fixed size pages. •The segments are supposed to be the logical segments of the program, but the pages do not have any logical relation with the program. •The pages are just fixed size portions of the program module or data. •The advantage of paging scheme is that the complete segment of a task need not be in the physical memory at any time. •Only a few pages of the segments, which are required currently for the execution need to be available in the physical memory. Thus the memory requirement of the task is substantially reduced, relinquishing the available memory for other tasks. •Whenever the other pages of task are required for execution, they may be fetched from the secondary storage.
•The previous page which are executed, need not be available in the memory, and hence the space occupied by them may be relinquished for other tasks. •Thus paging mechanism provides an effective technique to manage the physical memory for multitasking systems.
•Paging Unit: The paging unit of 80386 uses a two level table mechanism to convert a linear address provided by segmentation unit into physical addresses. The paging unit converts the complete map of a task into pages, each of size 4K. The task is further handled in terms of its page, rather than segments. The paging unit handles every task in terms of three components namely page directory, page tables and page itself.
•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.
•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. •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.
•The D bit ( Dirty bit) is set before a write operation to the page is carried out. The D-bit is undefined for page director entries. •The OS reserved bits are defined by the operating system software. •The User / Supervisor (U/S) bit and read/write bit are used to provide protection. These bits are decoded to provide protection under the 4 level protection model. •The level 0 is supposed to have the highest privilege, while the level 3 is supposed to have the least privilege. •This protection provide by the paging unit is transparent to the segmentation unit.
Virtual 8086 Mode
•In its protected mode of operation, 80386DX provides a virtual 8086 operating environment to execute the 8086 programs. •The real mode can also used to execute the 8086 programs along with the capabilities of 80386, like protection and a few additional instructions. •Once the 80386 enters the protected mode from the real mode, it cannot return back to the real mode without a reset operation. •Thus, the virtual 8086 mode of operation of 80386, offers an advantage of executing 8086 programs while in protected mode. •The address forming mechanism in virtual 8086 mode is exactly identical with that of 8086 real mode. •In virtual mode, 8086 can address 1Mbytes of physical memory that may be anywhere in the 4Gbytes address space of the protected mode of 80386. •Like 80386 real mode, the addresses in virtual 8086 mode lie within 1Mbytes of memory. •In virtual mode, the paging mechanism and protection capabilities are available at the service of the programmers. •The 80386 supports multiprogramming, hence more than one programmer may be use the CPU at a time.
INTRODUCTION TO 80486 The Intel 80486 (or i486) was a microprocessor produced by Intel and the first tightly pipelined x86 design. Introduced in 1989, it was also the first x86 chip to se more than a million transistors, due to a large on-chip cache and an integrated floating point unit. It represents a fourth generation of binary compatible CPUs since the original 8086 of 1978, and it was the second 32-bit x86 design after the 80386.  A 50 MHz 80486 executed around 40 million instructions per second on average and was able to reach 50 MIPS peak.  The instruction set of the i486 is very similar to its predecessor, the Intel 80386, with the addition of only a few extra instructions, such as CMPXCHG which executes the compare-and-swap atomic operation and the XADD which executes the fetch-and-add atomic operation returning the original value, unlike the ADD instruction that only returned some flags.  the architecture of the i486 is a vast improvement over the 80386.  It has an on-chip unified instruction and data cache, an on-chip floating-point unit (FPU), except in the SX and SL models, and an enhanced bus interface unit.  Simple instructions (such as ALU reg, reg) execute in one clock cycle  A 16-MHz 486 therefore has a performance similar to a 33-MHz 386 (or 286), and the older design has to reach 50 MHz to be comparable with a 25-MHz 486 part.
Differences between the 386 and 486 •

• •
An 8 KB on-chip SRAM cache stores the most recently used instructions and data (16 KB and/or write-back on some later models). The 386 had no such internal cache but supported a slower off-chip cache. Tightly coupled pipelining allows the 486 to complete a simple instruction like ALU reg,reg or ALU reg,im every clock cycle. The 386 needed two clock cycles for this. Integrated FPU (disabled or absent in SX models) with a dedicated local bus gives faster floating point calculations compared to the i386+i387 combination. Improved MMU performance.
The 486 has a 32-bit data bus and a 32-bit address bus. Just like the 80386, the 32-bit address bus of the 80486 enabled up to 4 Gigabyte of memory to be directly addressed using a flat memory model with 32-bit linear addresses in protected mode.
.
Internal Architecture of the 80486
Pin description of 80486
BUS CYCLE IDENTIFICATION
The architecture is more identical to 80386.A math co-processor and a one level cache is added in addition with the 80386 architecture
 The purpose of the Register is to hold temporary results, and control the execution of the program. General-purpose registers in Pentium are EAX, ECX, EDX, EBX, ESP, EBP,ESI, or EDI.  The 32-bit registers are named with prefix E, EAX, etc, and the least 16 bits 0-15 of these registers can be accessed with names such as AX, SI Similarly the lower eight bits (0-7) can be accessed with names such as AL & BL. The higher eight bits (8-15) with names such as AH & BH.  The instruction pointer EAP known as program counter(PC) in 8-bit microprocessor, is a 32bit register to handle 32-bit memory addresses, and the lower 16 bit segment IP is used for 16-bi memory address.  The flag register is a 32-bit register  The I/O Privilege uses two bits in protected mode to determine which I/O instructions can be used, and the nested task is used to show a link between two tasks.  The processor also includes control registers and system address registers , debug and test registers for system and debugging operations.
The internal programming model is given below
The flag register of 80486
KEY TERM A Architecture 3 Architecture of the 8048617 ADDRESSING MODES7 B BUS CYCLE IDENTIFICATION19 E Execution unit 3 F Flag Register6 P Protected Mode9 Paging12 R Register Organisation4 Real Address Mode8 S Segmentation10 V Virtual 8086 Mode14
KEYTERM QUIZ 1.How many stages are available in pipelining of 80386? 2.the clock frequecncy of 80386 is . 3.The flags used to select between virtual and protected mode is 4.what is the size of memory the 80386 can access. 5.80486 has a internal ROM of 4K .Say Yes/No 6.The physical address is bits. 7.the addressing mode of MOV EAX,[EBX+12345689] is 8.The address and data bus of all x86 are same. say true or false 9.Which processor has the cache organization a)8086 b)80286 c)80386 d)80486 10.The real mode in X86 will work in the memory address range of only.
OBJECTIVE QUESTIONS
M bytes
TYPE
1. The term PSW Program Status word refers a) Accumulator & Flag register b) H and L register c) Accumulator & Instruction register d) B and C register 2. A —— is used to isolate a bit, it does this because that ANI sets all other bits to Zero a) subroutine b) flag c) label d) mask 3. Interaction between a CPU and a peripheral device that takes place during and imput output operation is known as a) handshaking b) flagging c) relocating d) sub?routine 4. Addressing in which the instructions contains the address of the data to the operated on is known as
a) immediate addressing b) implied addressing c) register addressing d) direct addressing
5. Resart is a special type of CALL in which a) the address is programmed but not built into the hardware b) the address is programmed built into the hardware c) the address is not programmed but built into the hardware d) None of the above 6. The maximum addressable memory space of 80386 is a) 64G b) 16 G c) 8G d) 4G
7.The stack is a specialized temporary ?? access memory during ?. and ?? instructions a) random, store, load b) random, push, load c) sequential, store, pop d) sequential, push, pop 8. The No. of control lines in 80386 are ——9. The length of EAX ? register is ——- bits 10. The length of program counter is ——– bits 11. The length of stack pointer is ——– bits 12. The length of status word is ——- bits 13. The No. of CONTROL flags are ——14. What is the purpose of using ALE signal high ? a) To latch low order address from bus to separate A0 ? A7 b) To latch data Do ? D 7 from bus go separate data bus c) To disable data bus latch 15. What is the purpose of READY signal? a) It is used to indicate to user that microprocessor is working and ready to use b) It is used to provide for proper WAIT states when microprocessor is communicating with slow peripheral device. c) It is used to provide for proper showing down of fast peripheral devices so as to communicate at micro processors speed.
16. What is the addressing mode used in instruction MOV BL, CL? a) Direct b) Indirect c) Indexed d) Immediate
17. The maximum number of Io devices can be interfaced with 80386 in the Io mapped Io technique are 18. Shadow Address will exist in a) absolute decoding b) linear decoding c) partical decoding d) none of the above 19. The Instructions used for data transfer in Io mapped IO are a) IN, OUT b) IN, LDA add c) STA add d) None of the above 20. Number of Address lines in 80486 is a) 16 b)32 c) 34 d) 128
REVIEW QUESTIONS 2 MARKS 1. Differentiate between 80386 and 80486. 2. Classify the different groups of 80386 instruction set with example. 3. Differentiate between unidirectional buffer and bi-directional buffer.
4. What is the need for ALE signal in 8085 microprocessor? 5. Give the operation of the foll instructions:(a) DAA (b) DEC. 6. State the functions for ALE and TRAP pins . 7. Make note on the real mode operation of 80386. 8. What is a MPU? 9. What do you mean by multiplexing the bus? 10. List out the two modes of operation of x86 family. 11. What is a program counter? 12. What is an instruction? 13. What is PSW? Draw 14. Define - Interrupt. 15. What are the addressing modes for 80386 microprocessor? 16. make note of the protected mode of 80386? 17. Define stack. 18. Specify how a program counter is useful in program execution.
19. How the data and address lines are demultiplexed? 20. Show the bit positions of various flags in 80386 flag register? 21. List the various signals of 80486. 22. What are the instruction pipelining stages in 80386 and 80486 23. What are the similarity and difference between subtract and compare instructions? 24. List the type of signals that have to be applied to generate an hardware interrupts. 25. Write a subroutine to clear the flag register and accumulator using 80386? 26. Draw a simple diagram for the flags of 80486? 27. List out the similarities between CALL_RET and PUSH_POP instructions. 28. List interrupts of 80386 29. Define: (a) Instruction Cycle (b) M/c cycle (c) T-state. 30. Explain the execution of the instruction PUSHAH. 31. What are the different memory mapping schemes? Give any one advantage and disadvantage for each
BIG QUESTIONS 1. a. Draw the block diagram of 80386 mp and explain? (18 b. Write an assembly language program to add two 2-digits BCD Number? (4) 2. a. Explain the instruction set of 80386? (10) b. Write notes on control flags .
3. a. Explain the architecture of Intel 80486 the help of a block diagram? (10 b. Explain the similarities diff b/w 80386 and 80486?
4. a. With neat block diagram explain the BIU unit of 80386? (8) b. List out the maskable and non maskable interrupts available in 80386? (4)
5.(a)Specify the contents of the registers and the flag status as the following instructions are executed.(4) i. MOV AX, 00 ii. MOV EBX,[02F8] iii. MOV ECX, EBX vi. HLT (b)Write instructions to load the hexadecimal number 65H in register CX and 92H in accumulator A.(8) 6. (a)Why the lower order address bus is multiplexed with data bus? How they will be de-multiplexed? (6) (b) Differentiate between maskable and non-maskable interrupts.(6) 7. a)Write an assembly language program using minimum number of instructions to add the 32 bit no. in EBX, EDX & ECX. Store the result in MEMORY. (6) b) Explain the similarities diff b/w subtract and compare instructions in 8085? (6) 8. (a)Explain in detail the following instructions:- (i) ADD (ii) RAL (iii) SHR (iv) CMP (b) Define & explain the term addressing modes. 9. (a)Draw the pin diagram and explain the control signals present in 80386
10. Explain with examples the arithmetic instruction .(12) 11. Explain with examples the data transfer instruction .(12) 12. Explain with examples the control instruction .(12) 13. Explain with examples the logical instruction of 80386.(12) 14.What are the addressing modes present in 80386 .explain with example.(12)

Microprocessor 80386 Mcq Pdf

IntelPdf

Intel 80386 Microprocessor Pdf

They reduce the use of processor’s external bus when the same locations are accessed multiple times. Q. Tqit. 1(v) With the neat diagram, describe the selector fields in 80386 microprocessor 4 Ans.: Diagram 1 mark and Explanation 3 marks A protected-mode segment register holds a 16-bit segment selector (see the figure below). Gloom download for mac. From the bitsavers.org collection, a scanned-in computer-related document.intel:: 80386:: 231746-001 Introduction to the 80386 Apr86.