1 / 29

Chapter 2 The Microprocessor and its Architecture

Chapter 2 The Microprocessor and its Architecture. Instructor : Dr. Yu Youling. Outline . Internal Microprocessor Architecture Real Model Memory Addressing. The CPU. The Central Processing Unit (CPU) is a fundamental component of a PC system (No CPU  No Computer)

amalia
Download Presentation

Chapter 2 The Microprocessor and its Architecture

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 2The Microprocessor and its Architecture Instructor:Dr. Yu Youling

  2. Outline • Internal Microprocessor Architecture • Real Model Memory Addressing

  3. The CPU • The Central Processing Unit (CPU) is a fundamental component of a PC system (No CPU No Computer) • Basically it is a complex microprocessor whose main task is to process data stored in an external memory (RAM) according to instructions also stored within that external memory • Additionally, however, CPUs also generally contain some special fast internal storage memory, called registers

  4. The CPU Components • Basic Components • Registers & Flags • Arithmetic Logic Units • Shifters / Rotators • Address Decoding Modules • Advanced Components • Math. Co-processors • Data & Program Pipelines • Caches • Micro-code instruction decoders. • Multimedia Extension Processors. (MMX) • Etc.

  5. Registers • Registers can be used by a programmer/user like a ‘scratch pad’ to carry out calculations or other tasks performed within the CPU • All of the 8086 family of CPUs have 14, 16-bit registers that are commonly used and are at the disposal of the user • Starting with the 80386, Intel also added a new set of 32-bit registers and instructions to the CPU • For this course, however, we are only going to focus on what Intel refer to as the Real Mode operationof the CPU

  6. Real Mode Memory Addressing • The special mode called Real Mode switches any 8086 family CPU into an 8086 compatibility mode (even Pentium IVs have this mode implemented) • In this mode the user is allowed access only to 14 basic 16-bit registers, 1Mb of RAM and 64 Kb of I/O space • Once this area has been mastered, the basic skills and knowledge required to master the more advanced CPUs like the 80386, 80486, Pentiums, Pentium IIs with MMX, etc. will have been developed

  7. 1MB RAM • In real mode, 8086 family CPUs are able to access a total of 1 MB of RAM • Conceptually this can be thought of as a contiguous block from 00000h  FFFFFh • In practice, however, this memory is segmented into 64Kb blocks, i.e. blocks from 0000h FFFFh • This was done to maintain compatibility with Intel’s early 8085 processors, which had only 16 address lines providing access to 64 Kb of memory (216 = 64K)

  8. General Purpose Registers

  9. General Purpose Registers • General Purpose Register • for arithmetic calculations, temporary data storage, data transfer, etc • EAX: Accumulator: Referenced as EAX, AX, AL or AH. • The most commonly used register • Used by string instructions (STOSB, STOSW, etc.) to hold the data being transferred • Used by I/O instructions (IN, OUT) to hold the data being transferred • Used by multiply (MUL) and divide (DIV) to contain the data before the instruction and the result after • Used by string instructions and BIOS to hold the ASCII and ATTRIBUTE values when writing to the screen in text mode

  10. General Purpose Registers • General Purpose Register • EBX: Base Index: • Used by several addressing mode instructions to hold the base of a block of data to be manipulated. • A block usually contains some related data, e.g. a message to print in ASCII • ECX: Count: • Used by instructions such as REP and LOOP as a counter, e.g if CX = 10 then the LOOP instruction will loop 10 times decreasing CX until it reaches zero • Also used by the Shift (SHR, SHL) and Rotate (ROR, ROL) instructions to indicate how many bits to shift or rotate

  11. General Purpose Registers • General Purpose Register • EDX: Data: • Used by I/O (IN, OUT) instructions to hold the address of the port being accessed • Used by the Multiply (MUL) and Divide (DIV) instructions to hold the result of 32-bit data manipulations • Also used by BIOS to set up cursor positions

  12. General Purpose Registers • ESP: Stack Pointer: • Used by the stack, call and return instructions. • EBP: Base Pointer: • Holds the base pointer for memory data transfers. • EDI: Destination Index: • Holds the base destination pointer for string instructions. • ESI: Source Index: • Holds the base source pointer for string instructions.

  13. General Purpose Registers • EIP: Instruction Pointer: • register that points to the next instruction to be executed in the RAM • If a 2 byte instruction is currently being executed at 0100, then IP = 0102 • IP has a range from 0000 (0000 decimal) to FFFF (65535 decimal) • This means that the CPU can only access up to 64K bytes of instructions using the IP register alone • Always works in conjunction with the CS register to generate a physical address

  14. General Purpose Registers • EIP: Instruction Pointer: • Certain program instructions may alter it in order to cause execution of a different section of code • Jump instructions alter IP to point to a new instruction to jump to next • Call instructions also alter IP to indicate a new location to start executing from, but the current value of IP is saved to allow a return to the current next instruction • Interrupts alter this register, setting it to point to the location of the relevant ISR code

  15. Special Purpose Registers • EFLAGS: • Store the state of various conditions in the microprocessor. • The rightmost 5 flag bits and overflow change after many of the arithmetic and logic instructions execute. Data transfer and program control instructions never change the flags.

  16. Flag bits • C (Carry): • Holds the carry out after addition or the borrow after subtraction. • Also indicates error conditions. • P (Parity): • 0 for odd number of bits (奇数) and 1 for even(偶数). • Obsolete feature of the 80x86. • A (Auxiliary Carry): • Highly specialized flag used by DAA and DAS instructions after BCD addition or subtraction.

  17. Flag bits • Z (Zero): • 1 if the result of an arithmetic or logic instruction is 0. • S (Sign): • 1 if the sign of the result of an arithmetic or logic instruction is negative. • T (Trap): • Trap enable. The microprocessor interrupts the flow of instructions on conditions indicated by the debug and control registers.

  18. Flag bits • I (Interrupt): • Controls the operation of the INTR (Interrupt request) pin. If 1, interrupts are enabled. Set by STI and CLI instructions. • D (Direction): • Selects with increment or decrement mode for the DI and/or SI registers during string instructions. If 1, registers are automatically decremented. Set by STD and CLD instructions. • O (Overflow): • Set for addition and subtraction instructions.

  19. Flag bits • 80286 and up: • IOPL (I/O privilege level): • It holds the privilege level at which your code must be running in order to execute any I/O-related instructions. 00 is the highest. • NT (Nested Task): • Set when one system task has invoked another through a CALL instruction in protected mode.

  20. Flag bits • 80386 and up: • RF (Resume): • Used in debugging. • VM (Virtual Mode): • When 0, the CPU can operate in Protected mode, Virtual 8086 mode or Real mode. • When set, the CPU is converted to a high speed 8086. This bit has enormous impact.

  21. Flag bits • 80486SX and up: • AC (Alignment Check): • Specialized instruction for the 80486SX. • Pentium and up: • VIF (Virtual Interrupt Flag): • Copy of the interrupt flag bit. • VIP (Virtual Interrupt Pending): • Provides information about a virtual mode interrupt. • ID (Identification): • Supports the CPUID instruction, which provides version number and manufacturer information about the microprocessor.

  22. Segment Registers • CS (Code Segment): • In real mode, this specifies the start of a 64KB memory segment. • In protected mode, it selects a descriptor. • The code segment is limited to 64KB in the 8086-80286 and 4 GB in the 386 and above. • DS (Data Segment): • Similar to the CS except this segment holds data. • ES (Extra Segment): • Data segment used by some string instructions to hold destination data. • SS (Stack Segment): • Similar to the CS except this segment holds the stack. • ESP and EBP hold offsets into this segment. • FS and GS: 80386 and up. • Allows two additional memory segments to be defined.

  23. Real Mode Memory Addressing • Used because IP is only 16-bits long whereas the total addressable RAM space is 220 = 1M = 216+4 in size • The actual physical address in RAM is calculated as (SEGMENT * 16) + IP, i.e. Segment & Offset • e.g. if CS = 07A0 and IP = 0100 then the physical address = 07A00 + 0100 = 07B00 • Note • More than one segment pointer combination can point to the same physical address • e.g. 07B00 = 07A0:0100 or 07B0:0000

  24. Real Mode Memory Addressing • Only mode available to the 8086 and 8088. • Allow the processor to address only the first 1MB of memory. • DOS requires real mode. • Segments and Offsets: • Effective address = Segment address + an offset.

  25. Real Mode Memory Addressing • Segments and Offsets: • Syntax is usually given as seg_addr:offset, e.g. 1000:F000 in the previous example to specify 1F000H. • Default Segment and Offset Registers • Implicit combinations of segment registers and offsets are defined for memory references. • For example, the code segment (CS) is always used with the instruction pointer (IP for real mode or EIP for protected mode). • CS:EIP • SS:ESP, SS:EBP • DS:EAX, DS:EBX, DS:ECX, DS:EDX, DS:EDI, DS:ESI, DS:8-bit_literal, DS:32-bit_literal • ES:EDI • FS and GS have no default. • It is illegal to place an offset larger than FFFF into the 80386 32-bit registers operating in Real Mode.

  26. Real Mode Memory Addressing • Segments and Offsets: • Segments can overlap, as shown below for the CS and DS. • Segmented addressing allows relocation of data and code. • OS can assign the segment addresses at run time.

  27. Relocation • Segment and offset addressing allows for easy and efficient relocation of code and data. • To relocate code or data only the segment number needs to be changed. For example, if an instruction appears at offset address 0002 the segment address does not matter because if it changes so does the effective address of the instruction.

  28. Homework • 第一部分 • 8,10,13,14,20 • 第二部分(任选一,中文,500字) • 通过互联网,查询并简要写出保护模式的工作原理 • 通过互联网,查询并简要写出分页机制的工作原理

More Related