1 / 64

William Stallings Computer Organization and Architecture 6 th Edition

William Stallings Computer Organization and Architecture 6 th Edition. Chapter 10 Instruction Sets: Characteristics and Functions. What is an instruction set?. The complete collection of instructions that are understood by a CPU Machine Code Binary Usually represented by assembly codes.

kata
Download Presentation

William Stallings Computer Organization and Architecture 6 th Edition

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. William Stallings Computer Organization and Architecture6th Edition Chapter 10 Instruction Sets: Characteristics and Functions

  2. What is an instruction set? • The complete collection of instructions that are understood by a CPU • Machine Code • Binary • Usually represented by assembly codes

  3. Elements of an Instruction • Operation code (Op code) • Specifies the operation to be performed. • Source Operand reference • Input operands for the operation. • Result Operand reference • Put the answer here • Next Instruction Reference • Tell the CPU where to fetch the next instruction after the execution of this instruction is complete.

  4. Elements of an Instruction (cont.) • Source and Result operands can be in one of three areas: • Main memory (or virtual memory or cache) • CPU register • I/O device

  5. Instruction Cycle State Diagram

  6. Instruction Representation • In machine code each instruction has a unique bit pattern • For human consumption (well, programmers anyway) a symbolic representation is used • e.g. ADD, SUB, LOAD • Operands can also be represented in this way • ADD A,B

  7. Simple Instruction Format

  8. Instruction Types • Data processing • Arithmetic and logic instructions • Data storage (main memory) • Memory instruction • Data movement (I/O) • I/O instruction are need to transfer programs and data into memory and the results of computations back out to the user. • Program flow control • Test and branch instruction • Test instructions are used to test the value of a data word or the status of a computation. • Branch instructions are used to branch a different set of instructions depending on the decision made.

  9. Number of Addresses (a) • 3 addresses • Operand 1, Operand 2, Result • a = b + c; • May be a forth - next instruction (usually implicit) • Not common • Needs very long words to hold everything

  10. Number of Addresses (b) • 2 addresses • One address doubles as operand and result • a = a + b • Reduces length of instruction • Requires some extra work • Temporary storage to hold some results

  11. Number of Addresses (c) • 1 address • Implicit second address • Usually a register (accumulator) • Common on early machines

  12. Number of Addresses (d) • 0 (zero) addresses • All addresses implicit • Uses a stack • e.g. push a • push b • add • pop c • c = a + b

  13. Utilization of instruction address

  14. Example: Y=(A-B)/(C+D*E) • Three-address instruction • SUB Y, A, B (Y=A-B)MPY T, D, E (T=D*E)ADD T, T, C (T=T+C)DIV Y, Y, T (Y=Y/T) • Two-address instruction • MOVE Y, A (Y=A)SUB Y, B (Y=Y-B)MOVE T, D (T=D)MPY T, E (T=T*E)ADD T, C (T=T+C)DIV Y, T (Y=Y/T)

  15. Example: Y=(A-B)/(C+D*E) • One-address instruction • LOAD D (AC=D)MPY E (AC=AC*E)ADD C (AC=AC+C)STOR Y (Y=AC)LOAD A (AC=A)SUB B (AC=AC-B)DIV Y (AC=AC/Y)STOR Y (Y=AC)

  16. 精選範例

  17. 精選範例- 解答

  18. How Many Addresses • More addresses • More complex instructions • More registers • Inter-register operations are quicker • Fewer instructions per program • Fewer addresses • Less complex instructions • More instructions per program • Faster fetch/execution of instructions

  19. Design Decisions (1) • Operation repertoire • How many ops? • What can they do? • How complex are they? • Data types • The various types of data upon which operations are performed. • Instruction formats • Length of op code field • Number of addresses

  20. Design Decisions (2) • Registers • Number of CPU registers available • Which operations can be performed on which registers? • Addressing modes (later…) • The mode or modes by which the address of an operand is specified. • RISC v CISC

  21. Types of Operand • Machine instruction operate on data, the most important categories of data are • Addresses • Numbers • Integer/floating point • Characters • ASCII etc. • Logical Data • Bits or flags

  22. Types of Operand (cont.) • Address • Addresses are a form of data. • Addresses can be considered to be unsigned integers • Numbers • There is a limit to the magnitude of numbers representable on a machine. • In the FP numbers, a limit to their precision. • Three types of numerical data are common in computer • Integer or fixed point • Floating point • Decimal • Binary/decimal converter

  23. Types of Operand (cont.) • Characters • A number of codes have been devised by which characters are represented by a sequence of bits • International Reference Alphabet (IRA) • American Standard Code for Information Interchange (ASCII) • 7 bit, 128 different characters, including some control characters. • IRA-encoded characters • 8 bit • The last bit is parity bit • Extended Binary Coded Decimal Interchange Code (EBCDIC) • Used on IBM S/390 machines • 8 bit

  24. Types of Operand (cont.) • Logical Data • To consider an n-bit unit as consisting of n 1-bit items of data • Each item having the value 0 or 1 • The same data are treated sometimes as logical and other times as numerical or text. • The “type” of a unit of data is determined by the operation being performed on it • It is almost always the case with machine language.

  25. Pentium Data Types • 8 bit Byte • 16 bit word • 32 bit double word • 64 bit quad word • Addressing is by 8 bit unit • A 32 bit double word is read at addresses divisible by 4 • Little-endian style • The least significant byte is stored in the lowest address.

  26. Specific Data Types • General - arbitrary binary contents • Integer - signed binary value (2s complement) • Ordinal - unsigned integer • Unpacked BCD - One digit per byte • Packed BCD - 2 BCD digits per byte • Near Pointer - 32 bit offset within segment • Bit field • Byte String • Floating Point – IEEE 754 standard

  27. Pentium Floating Point Data Types

  28. PowerPC Data Types • The PowerPC can deal with data type of • 8 (byte), 16 (halfword), 32 (word) and 64 (doubleword) length data types • Some instructions need operand aligned on 32 bit boundary • Can be big- or little-endian • Fixed point processor recognises: • Unsigned byte, unsigned halfword, signed halfword, unsigned word, signed word, unsigned doubleword, byte string (<128 bytes) • Floating point • IEEE 754 • Single or double precision

  29. Types of Operation • Data Transfer • Arithmetic • Logical • Conversion • I/O • System Control • Transfer of Control

  30. Common Instruction Set Operation

  31. Common Instruction Set Operation (cont.)

  32. Common Instruction Set Operation (cont.)

  33. Common Instruction Set Operation (cont.)

  34. CPU actions for various types of operations

  35. Data Transfer • The data transfer instruction must specify the followings: • Source • Destination • Amount of data • The mode of addressing for each operand • May be different instructions for different movements • e.g. IBM 370 • Or one instruction and different addresses • e.g. VAX

  36. Example of IBM S/390 Data Transfer Operations

  37. Data Transfer (cont.) • CPU actions • If both source and destination are register, the CPU transfer data from one register to another. • If one or both operands are in memory, the CPU must perform some or all of the following actions • Calculate the memory address • If the address refers to virtual memory, translate from virtual to actual memory address. • Determine whether the addressed item is in cache • If not, issue a command to the memory module.

  38. Arithmetic • Most machine provide the basic arithmetic • Add, Subtract, Multiply, Divide • These are always provided for signed integer (fixed-point) numbers. • They are often provide floating point and packed decimal numbers. • Other possible operations include • Absolute • Negate • Increment • Decrement

  39. Logical • Bitwise operations • AND, OR, NOT • The AND operation can be used as a mask that selects certain bits in a word and zeros out the remaining bits • Logical shift • The bits of a word are shifted left or right • On one end, the bit shifted out is lost. • On the other end, a o is shifted in,

  40. Logical: Shift and Rotate Operations

  41. Logical (cont.) • Arithmetic shift • The arithmetic shift operation treats the data as a signed integer and does the sign bit. • A right arithmetic shift corresponds to a division by 2 • A left arithmetic shift corresponds to a multiplication by 2 • Rotate • Preserve all of the bits being operated on.

  42. Logical (cont.) • Conversion • That change the format or operate on the format of data • E.g. Binary to Decimal

  43. Input/Output • A variety of approaches • Isolated programmed I/O, memory-mapped programmed I/O, DMA, and I/O processor • May be specific instructions (Isolated) • May be done using data movement instructions (memory mapped) • May be done by a separate controller (DMA)

  44. Systems Control • System control • Can be executed only while the CPU is in a certain privileged state or is executing a program in a special privileged area of memory. • CPU needs to be in specific state • Ring 0 on 80386+ • Kernel mode • For operating systems use

  45. Transfer of Control • Branch • Jump instruction, has as one of its operands, the address of the next instruction to be executed. • Conditional branch • e.g. branch to x if result is zero • User-visible register • Most machine provide a 1-bit or multiple-bit condition code • Skip • Includes an implied address, the address of the next instruction plus one instruction-length • e.g. increment and skip if zero (ISZ) • ISZ Register1

  46. Transfer of Control (cont.) • Procedure Call instruction • The reasons for the use of procedures are economy and modularity. • A procedure allows the same piece of code to be used many times. • The procedure mechanism involves two basic instructions • Call instruction • Return instruction • A procedure can be called from more than one location • A procedure call can appear in a procedure (nesting of procedures to an arbitrary depth) • Each procedure call is matched by a return in the called program

  47. Transfer of Control (cont.) • There are three common places for storing the return address • Register • Start of called procedure • Top of stack • Reentrant procedure • A reentrant procedure is one in which it is possible to have several calls open to it at the same time • Eg. Recursive procedure

  48. Branch Instruction

  49. Nested Procedure Calls

  50. Use of Stack

More Related