Presentation is loading. Please wait.

Presentation is loading. Please wait.

Instruction Sets. Instruction set It is a list of all instructions that a processor can execute. It is a list of all instructions that a processor can.

Similar presentations


Presentation on theme: "Instruction Sets. Instruction set It is a list of all instructions that a processor can execute. It is a list of all instructions that a processor can."— Presentation transcript:

1 Instruction Sets

2 Instruction set It is a list of all instructions that a processor can execute. It is a list of all instructions that a processor can execute. Element of an instruction: Element of an instruction: Operation Code (Op Code) {Determine what will be done} Operation Code (Op Code) {Determine what will be done} Source Operand {Determine which data will be manipulated} Source Operand {Determine which data will be manipulated} Destination Operand {Determine where the data will be stored} Destination Operand {Determine where the data will be stored} Next Instruction {Determine the next instruction to be executed} 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) ) 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. ) 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) Data Operations (Do the operations needed) (example: adding two values, access ALU) Write-back (The result of the operation is written in the registers) Write-back (The result of the operation is written in the registers)

5 Instruction Representation Example of Instructions Example of Instructions ADD, SUB, LOAD, MPY, DIV, STOR ADD, SUB, LOAD, MPY, DIV, STOR Example of Operands Example of Operands ADD A, B ADD A, B LOAD C, X 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 The set of instruction in a computer must be sufficient to allow the user to manage all the information needed Data processing: Data processing: Arithmetic and logic instruction. This instruction is used in the computer registers. Arithmetic and logic instruction. This instruction is used in the computer registers. Data storage Data storage They are memory instructions which allow the movement of data between memory and registers They are memory instructions which allow the movement of data between memory and registers Data movement (I/O) Data movement (I/O) Carries the data from the internal registers to the user. Carries the data from the internal registers to the user. Program flow control: Program flow control: It can use test and branch instructions It can use test and branch instructions

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

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

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

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

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

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

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

14 Pentium Data Types 8 bit Byte 8 bit Byte 16 bit word 16 bit word 32 bit double word 32 bit double word 64 bit quad word 64 bit quad word Addressing is by 8 bit unit Addressing is by 8 bit unit A 32 bit double word is read at addresses divisible by 4 A 32 bit double word is read at addresses divisible by 4

15 Specific Data Types General - arbitrary binary contents General - arbitrary binary contents Integer - single binary value Integer - single binary value Ordinal - unsigned integer Ordinal - unsigned integer Unpacked BCD - One digit per byte Unpacked BCD - One digit per byte Packed BCD - 2 BCD digits per byte Packed BCD - 2 BCD digits per byte Near Pointer - 32 bit offset within segment Near Pointer - 32 bit offset within segment Bit field Bit field Byte String Byte String Floating Point Floating Point

16 Pentium Numeric Data Formats

17 PowerPC Data Types 8 (byte), 16 (halfword), 32 (word) and 64 (doubleword) length data types 8 (byte), 16 (halfword), 32 (word) and 64 (doubleword) length data types Some instructions need operand aligned on 32 bit boundary Some instructions need operand aligned on 32 bit boundary Can be big- or little-endian Can be big- or little-endian Fixed point processor recognises: Fixed point processor recognises: Unsigned byte, unsigned halfword, signed halfword, unsigned word, signed word, unsigned doubleword, byte string (<128 bytes) Unsigned byte, unsigned halfword, signed halfword, unsigned word, signed word, unsigned doubleword, byte string (<128 bytes) Floating point Floating point IEEE 754, Single or double precision 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: Specify: Source (Register, Memory) Source (Register, Memory) Destination (Register, Memory) Destination (Register, Memory) Amount of data Amount of data Examples: mov src, dest Examples: mov src, dest mov dest, src mov dest, src There are different instructions for different movements There are different instructions for different movements Data Move Data Move mov src, dest mov src, dest Data Swap Data Swap xchg src, dest xchg src, dest

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

21 Increment and decrement

22 Arithmetic Complex Operations (SIMD or Single- Instruction Stream Multiple-Data or vector instruction). Complex Operations (SIMD or Single- Instruction Stream Multiple-Data or vector instruction).SIMDvector instructionSIMDvector instruction It performs the same arithmetic operations in multiple pieces of data at the same time. 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. 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 and Arithmetic Shifting Logical shifting are used for unsigned binary numbers. Logical shifting are used for unsigned binary numbers. Arithmetic shifting is used for signed binary numbers Arithmetic shifting is used for signed binary numbers Rotate Operation Rotate Operation It is also known as the circular shifting It is also known as the circular shifting This operation is useful if it is necessary to retain all the existing bits. This operation is useful if it is necessary to retain all the existing bits. It is frequently used in digital cryptography. It is frequently used in digital cryptography.

25 Logical Bitwise operator: Bitwise operator: AND, OR, NOT This operations are faster than arithmetic operations (+,-,*,/) This operations are faster than arithmetic operations (+,-,*,/) Examples: Examples: NOT 0111 = 1000 ( It is used for forming the ones' complement which is used for addition and subtraction) NOT 0111 = 1000 ( It is used for forming the ones' complement which is used for addition and subtraction)ones' complementones' complement 0101 OR 0011 = 0111( It is used as a flag in programming cycles) 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 ) 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 given a bit pattern: 0010 It will be determined whether the third bit is 1, a bitwise AND is applied to it. It will be determined whether the third bit is 1, a bitwise AND is applied to it. 0010 AND 1010 = 0010 0010 AND 1010 = 0010

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

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

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

30 Branch Instructions Conditional Branch Conditional Branch Unconditional Branch Unconditional Branch BRP X BRP X Branch to location X if result is postive Branch to location X if result is postive BRZ X BRZ X Branch to location X if result is zero 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 Self contained program that is incorporated into a larger program Economy and modularity Economy and modularity Call instruction Call instruction Branches from the current location to the procedure Branches from the current location to the procedure Return Instruction Return Instruction Returns from the procedure to the place from which it was called Returns from the procedure to the place from which it was called

33 Procedure Call Insructions

34 Questions 1. Give one example were can be used increment operation? PC<-[PC]+1 2. Mention three examples of bitwise operator? AND, OR, NOT 3. Mention three Instruction types? Data processing, Data storage, Data movement 4. What type of branch instruction is always executed? Unconditional branch 5. 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. 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? 12. What are the existing types of operand? Answer: Addresses, Numbers, characters, logical data. Answer: Addresses, Numbers, characters, logical data. 13. What are the PowerPC data types? 13. What are the PowerPC data types? Answer: 8 (byte), 16 (half-word), 32 (word) and 64 (double- word) length data types Answer: 8 (byte), 16 (half-word), 32 (word) and 64 (double- word) length data types 14 What are the specific data types? 14 What are the specific data types? Answer: General, Integer, Ordinary, Unpacked BCD, Answer: General, Integer, Ordinary, Unpacked BCD, Packed BCD, Near Point, Bit field, Byte String, Floating Point Packed BCD, Near Point, Bit field, Byte String, Floating Point


Download ppt "Instruction Sets. Instruction set It is a list of all instructions that a processor can execute. It is a list of all instructions that a processor can."

Similar presentations


Ads by Google