1 / 36

Instruction Sets

Instruction Sets. Instruction set. It is a list of all instructions that a processor can execute. Element of an instruction: Operation Code (Op Code) {Determine what will be done} Source Operand {Determine which data will be manipulated}

Télécharger la présentation

Instruction Sets

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. Instruction Sets

  2. Instruction set • It is a list of all instructions that a processor can execute. • Element of an instruction: • Operation Code (Op Code) {Determine what will be done} • Source Operand {Determine which data will be manipulated} • Destination Operand {Determine where the data will be stored} • Next Instruction {Determine the next instruction to be executed}

  3. Instruction Cycle State Diagram

  4. Instruction Cycle • Fetch (Instruction is copied from memory to the Instruction Register (IR) ) • Decode (In order to figure out what the instruction should do, it needs to be decoded. ) • Data Operations (Do the operations needed) (example: adding two values, access ALU) • Write-back (The result of the operation is written in the registers)

  5. Instruction Representation • Example of Instructions • ADD, SUB, LOAD, MPY, DIV, STOR • Example of Operands • ADD A, B • LOAD C, X

  6. Instruction Types • The set of instruction in a computer must be sufficient to allow the user to manage all the information needed • Data processing: • Arithmetic and logic instruction. This instruction is used in the computer registers. • Data storage • They are memory instructions which allow the movement of data between memory and registers • Data movement (I/O) • Carries the data from the internal registers to the user. • Program flow control: • It can use test and branch instructions

  7. Number of Address Instruction • Three-address Instruction • Two-address Instruction • One-address Instruction

  8. Three-address Instruction • Operand 1, Operand 2, Result • ADD X,A,B (X = A + B); • May be a forth - next instruction (usually implicit) • Needs very long words to hold everything

  9. Two-address Instruction • Move Y, A Y =A • ADD Y, B Y = Y + B • A MOVE instruction is introduced to do an operation • Reduces length of instruction • Requires some extra work

  10. One address • The second address is Implicit • Usually a register accumulator (AC) • The AC is used to store the results • Common on early machines • It can be possible to process information with Zero- address Instructions. All the address are implicit.

  11. How Many Addresses • More addresses • More complex instructions. More Powerful • More registers • operations are quicker • Fewer instructions per program • Fewer addresses • Less complex instructions. Less Powerful • More instructions per program • Faster fetch/execution of instructions

  12. Design Decisions • Operation • How many ops? • What can they do? • How complex are they? • Data types • Number of CPU registers available. More operations • Instruction formats • Length of op code field • Number of addresses and the addressing modes

  13. Types of Operand • Addresses • Numbers • Integer/floating point • Characters • ASCII etc. • Logical Data • Bits or flags • (Aside: Is there any difference between numbers and characters? Ask a C programmer!)

  14. 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

  15. Specific Data Types • General - arbitrary binary contents • Integer - single binary value • 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

  16. Pentium Numeric Data Formats

  17. PowerPC Data Types • 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

  18. Types of Operation for Instruction Sets 1. Data Transfer 2. Arithmetic 3. Logical 4. Conversion 5. I/O 6. System Control 7. Transfer of Control

  19. Data Transfer • Specify: • Source (Register, Memory) • Destination (Register, Memory) • Amount of data • Examples: mov src, dest mov dest, src • There are different instructions for different movements • Data Move • mov src, dest • Data Swap • xchg src, dest

  20. Arithmetic • Add, Subtract, Multiply, Divide (8- and 16-bit operations are supported directly and can easily be extended) • Signed Integer • Floating point (sine, cosine, square root, etc.) • Others • Increment (a++), ex. PC<-[PC]+1 • Decrement (a--) • Negate (-a)

  21. Increment and decrement

  22. Arithmetic • Complex Operations (SIMD or Single-Instruction Stream Multiple-Data or vector instruction). • It performs the same arithmetic operations in multiple pieces of data at the same time. • SIMD can be used to implement algorithms involved in sound, images and video processing.

  23. Shift and Rotate Operations “S” is a copy of the sign bit Rotate = circular shifting

  24. Logical and Arithmetic Shifting • Logical shifting are used for unsigned binary numbers. • Arithmetic shifting is used for signed binary numbers • Rotate Operation • It is also known as the circular shifting • This operation is useful if it is necessary to retain all the existing bits. • It is frequently used in digital cryptography.

  25. Logical • Bitwise operator: AND, OR, NOT • This operations are faster than arithmetic operations (+,-,*,/) • Examples: • NOT 0111 = 1000 (It is used for forming the ones' complement which is used for addition and subtraction) • 0101 OR 0011 = 0111(It is used as a flag in programming cycles) • 0101 AND 0011 = 0001 (The bitwise AND may be used to perform a bit mask operation and to determine whether a particular bit is 1 or 0 )

  26. Application for Bit Mask Using AND • given a bit pattern: 0010 • It will be determined whether the third bit is 1, a bitwise AND is applied to it. • 0010 AND 1010 = 0010

  27. Conversion & I/O Convert decimal to binary May be specific instructions May be done using data movement instructions (memory mapped) May be done by a separate controller (DMA)

  28. Conversion • Example: Binary to Decimal • 0101 = 4+1=5 • 2^3, 2^2, 2^1, 2^0

  29. System Control and Transfer of Control • Privileged instructions • For operating systems use • Change the sequence of instruction execution • Branch • branch to x if result is zero • Skip • e.g. increment and skip if zero

  30. Branch Instructions • Conditional Branch • Unconditional Branch • BRP X • Branch to location X if result is postive • BRZ X • Branch to location X if result is zero

  31. Branch Instructions

  32. Procedure Call Instructions • Self contained program that is incorporated into a larger program • Economy and modularity • Call instruction • Branches from the current location to the procedure • Return Instruction • Returns from the procedure to the place from which it was called

  33. Procedure Call Insructions

  34. Questions • Give one example were can be used increment operation? PC<-[PC]+1 • Mention three examples of bitwise operator? AND, OR, NOT • Mention three Instruction types? Data processing, Data storage, Data movement • What type of branch instruction is always executed? Unconditional branch • What are the two principal reasons for the use of the procedure call instructions? Economy and Modularity

  35. Questions 6. What is an example of data transfer? mov src, dest 7. What would be the decimal value of 0101? 0101 = 4+1=5 8. When you have one address which register is usually used? accumulator (AC) 9. What is another name for opcode abbreviations? Mnemonics 10. What kind of instructions provide computational capabilities for processing numeric data? Arithmetic Instructions

  36. 11. What are the Pentium data types? • Answer: 8 bit Byte, 16 bit word, 32 bit double word, 64bit quad, 8 bit addressing, 32 bit double word is read and divisible by 4. • 12. What are the existing types of operand? • Answer: Addresses, Numbers, characters, logical data. • 13. What are the PowerPC data types? • Answer: 8 (byte), 16 (half-word), 32 (word) and 64 (double-word) length data types • 14 What are the specific data types? • Answer: General, Integer, Ordinary, Unpacked BCD, • Packed BCD, Near Point, Bit field, Byte String, Floating Point 

More Related