Presentation is loading. Please wait.

Presentation is loading. Please wait.

GROUP #4 CHAPTER 10 JOEL FRAGA JAIME J.OCON DEISY HERNANDEZ.

Similar presentations


Presentation on theme: "GROUP #4 CHAPTER 10 JOEL FRAGA JAIME J.OCON DEISY HERNANDEZ."— Presentation transcript:

1 GROUP #4 CHAPTER 10 JOEL FRAGA JAIME J.OCON DEISY HERNANDEZ

2 What is an Instruction Set? Also called a command set, the basic set of commands, or instructions, that a microprocessor understands Also called a command set, the basic set of commands, or instructions, that a microprocessor understandsinstructions Machine Code Machine Code Binary Binary Usually represented by assembly codes Usually represented by assembly codes

3 Elements of an Instruction Operation code: Specifies the operation to be performed (e.g.. ADD, I/O). The operation is specified by a binary code, known as the operation code, or opcode. Operation code: Specifies the operation to be performed (e.g.. ADD, I/O). The operation is specified by a binary code, known as the operation code, or opcode. Source operand reference: The operation may involve one or more source operands, that is, operands that are inputs for the operation. Source operand reference: The operation may involve one or more source operands, that is, operands that are inputs for the operation. Result operand reference: The operation may produce a result. Result operand reference: The operation may produce a result. Next instruction reference: This tells the CPU where to fetch the next instruction after the execution of this instruction is complete. Next instruction reference: This tells the CPU where to fetch the next instruction after the execution of this instruction is complete.

4 Instruction Cycle State Diagram

5 Instruction Cycle State Diagram steps. Instruction address calculation (iac): Determine the address of the next instruction to be executed. Usually, this involves adding a fixed number to the address of the previous instruction. For example, if each instruction is 16 bits long and memory is organized into 16-bit words, then add 1 to the previous address. If, instead, memory is organized as individually addressable 8-bit bytes, then add 2 to the previous address. Instruction address calculation (iac): Determine the address of the next instruction to be executed. Usually, this involves adding a fixed number to the address of the previous instruction. For example, if each instruction is 16 bits long and memory is organized into 16-bit words, then add 1 to the previous address. If, instead, memory is organized as individually addressable 8-bit bytes, then add 2 to the previous address. Instruction fetch (if): Read instruction from its memory location into the processor. Instruction fetch (if): Read instruction from its memory location into the processor. Instruction operation decoding (iod): Analyze instruction to determine type of operation to he performed and operand(s) to be used. Instruction operation decoding (iod): Analyze instruction to determine type of operation to he performed and operand(s) to be used. Operand address calculation (oac): If the operation involves reference to an operand in memory or available via I/O. then determine the address of the operand. Operand address calculation (oac): If the operation involves reference to an operand in memory or available via I/O. then determine the address of the operand. Operand fetch (of): Fetch the operand from memory or read it in from I/O, Operand fetch (of): Fetch the operand from memory or read it in from I/O, Data operation (do): Perform the operation indicated in the instruction. Data operation (do): Perform the operation indicated in the instruction. Operand store (os): Write the result into memory or out to I/O Operand store (os): Write the result into memory or out to I/O

6 Instruction Types Data processing: Arithmetic and logic instructions Data processing: Arithmetic and logic instructions Data storage: Memory instructions Data storage: Memory instructions Data movement: I/O instructions Data movement: I/O instructions Control: Test and branch instructions Control: Test and branch instructions

7 Simple Instruction Format

8 Number of Addresses (a) 3 addresses 3 addresses Operand 1, Operand 2, Result Operand 1, Operand 2, Result a = b + c; a = b + c; Three-address instruction formats are not common, because they require a relatively long instruction format to hold the three address references Three-address instruction formats are not common, because they require a relatively long instruction format to hold the three address references

9 Number of Addresses (b) 2 addresses 2 addresses One address doubles as operand and result One address doubles as operand and result a = a + b a = a + b The two-address formal reduces the space requirement but also introduces some awkwardness. To avoid altering the value of an operand, a MOVE instruction is used to move one of the values to a result or temporary location before performing the operation. The two-address formal reduces the space requirement but also introduces some awkwardness. To avoid altering the value of an operand, a MOVE instruction is used to move one of the values to a result or temporary location before performing the operation.

10 Number of Addresses (c) 1 address 1 address a second address must be implicit. This was common in earlier machines, with the implied address being a CPU register known as the accumulator. or AC. The accumulator contains one of the operands and is used to store the result. a second address must be implicit. This was common in earlier machines, with the implied address being a CPU register known as the accumulator. or AC. The accumulator contains one of the operands and is used to store the result.

11 Number of Addresses (d) 0 (zero) addresses 0 (zero) addresses Zero-address instructions are applicable to a special memory organization, called a Stack. A stack is a last-in-first-out set of locations. Zero-address instructions are applicable to a special memory organization, called a Stack. A stack is a last-in-first-out set of locations. c = a + b c = a + b

12 How Many Addresses Fewer addresses: Fewer addresses: Fewer addresses per instruction result in more primitive instructions, which requires a less complex CPU. Fewer addresses per instruction result in more primitive instructions, which requires a less complex CPU. It also results in instructions of shorter length. On the other hand, programs contain more total instructions, which in general results in longer execution times and longer, more complex programs It also results in instructions of shorter length. On the other hand, programs contain more total instructions, which in general results in longer execution times and longer, more complex programs Multiple-address instructions: Multiple-address instructions: With multiple-address instructions, it is common to have multiple general-purpose registers. This allows some operations to be performed solely on registers. With multiple-address instructions, it is common to have multiple general-purpose registers. This allows some operations to be performed solely on registers. Because register references are faster than memory references, this speeds up execution. Because register references are faster than memory references, this speeds up execution.

13 Number of Address One of the ways of describing the processor architecture is by the number of addresses contained in each instruction. One of the ways of describing the processor architecture is by the number of addresses contained in each instruction. The number of address can be from zero to four addresses, depending on the number of operations required. The number of address can be from zero to four addresses, depending on the number of operations required. Number of Addresses Symbolic Representation Interpretation 3 OP A, B, C A  B OP C A  B OP C 2 OP A, B A  A OP B A  A OP B 1 OP A AC  AC OP A AC  AC OP A 0OP T  (T-1) OP T T  (T-1) OP T

14 Instruction Sets Design Instruction sets is the most interesting and analyzed aspect of a computer design. Instruction sets is the most interesting and analyzed aspect of a computer design. The Instruction sets define the functions performed by the CPU and has significant effect on the implementation of the CPU. The Instruction sets define the functions performed by the CPU and has significant effect on the implementation of the CPU. The design of Instruction Sets is complex because it affects many aspects of the computer The design of Instruction Sets is complex because it affects many aspects of the computer The Instruction Sets are the programmer's means of controlling the CPU. The Instruction Sets are the programmer's means of controlling the CPU.

15 Instruction Sets Design The most fundamental Instructions Sets design issues are: The most fundamental Instructions Sets design issues are: OPERATION REPERTOIRE: OPERATION REPERTOIRE: How many and which operations to provide, and how complex the operations should be. How many and which operations to provide, and how complex the operations should be. DATA TYPES: DATA TYPES: The various types of data upon which operations are performed. The various types of data upon which operations are performed. INSTRUCTION FORMATS: INSTRUCTION FORMATS: Instruction length, number of addresses, size of various fields. Instruction length, number of addresses, size of various fields. REGISTERS: REGISTERS: Number of CPU registers that can be referenced by instructions, and their sizes. Number of CPU registers that can be referenced by instructions, and their sizes. ADDRESSING: ADDRESSING: The mode or modes by which the address of an operant is specified. The mode or modes by which the address of an operant is specified.

16 Types of Operands Operands are the part of a machine instruction that reference data or device. Operands are the part of a machine instruction that reference data or device. In the general instruction: ADD B to A In the general instruction: ADD B to A A and B are the Operands ADD is the Operation code

17 Types of Operands The most important or general categories Operand data references are described as follows: The most important or general categories Operand data references are described as follows: ADDRESSES: They are a form of data that is used for calculations in a instruction to determine the main or virtual memory address. ADDRESSES: They are a form of data that is used for calculations in a instruction to determine the main or virtual memory address. NUMBERS: Numeric data types act as counters and other functions that require nonnumeric data processing. NUMBERS: Numeric data types act as counters and other functions that require nonnumeric data processing. Three types of numerical data common on computers: Three types of numerical data common on computers: Integers or fixed point Integers or fixed point Floating points Floating points decimal decimal

18 Types of Operands CHARACTERS: A unique 7 bit data representation of characters used by computers. The most commonly used characters codes is the IRA (International Reference Alphabet) or the ASCII Code (American Standard Code for Information Interchange) CHARACTERS: A unique 7 bit data representation of characters used by computers. The most commonly used characters codes is the IRA (International Reference Alphabet) or the ASCII Code (American Standard Code for Information Interchange) LOGICAL DATA: Is a n-bit unit of a word or other addressable selected for data information. The selected unit consist of a 1-bit items of data. It can be used for storing an array of a Boolean or binary information in which each item can only take the values of 1 (true) and 0 (false). LOGICAL DATA: Is a n-bit unit of a word or other addressable selected for data information. The selected unit consist of a 1-bit items of data. It can be used for storing an array of a Boolean or binary information in which each item can only take the values of 1 (true) and 0 (false).

19 Pentium Data Types The Pentium Processors is capable of dealing with data types of 8 (byte), 16 (word), 32(doubleword), and 64 (quadword) bits in lenghts. The Pentium Processors is capable of dealing with data types of 8 (byte), 16 (word), 32(doubleword), and 64 (quadword) bits in lenghts. The byte, word, doubleword, and quadword are refered to as general data types. The byte, word, doubleword, and quadword are refered to as general data types. The pentium processor also support an impressive array of specific data types that are recognized and operated on by particular instructions. The pentium processor also support an impressive array of specific data types that are recognized and operated on by particular instructions.

20 Pentium Data Types Pentium Data types: Pentium Data types: General: Byte word(16 bits), doubleworld(32 bits), and quadword(64 bits) locations with arbitrary binary contents. General: Byte word(16 bits), doubleworld(32 bits), and quadword(64 bits) locations with arbitrary binary contents. Intergers: A signed binary value contained in a byte, word, or doubleword, using two complement representation. Intergers: A signed binary value contained in a byte, word, or doubleword, using two complement representation. Ordinal: An unsigned integer contained in a byte, word, or doubleword. Ordinal: An unsigned integer contained in a byte, word, or doubleword. Umpacked Binary Code: A representation of a BCD digit in the range 0 through 9, with one digit in each byte. Umpacked Binary Code: A representation of a BCD digit in the range 0 through 9, with one digit in each byte. Packed Binary Code: Packed byte representation of two BCD digits, value range 0 to 99. Packed Binary Code: Packed byte representation of two BCD digits, value range 0 to 99. Near Pointer: A 32 bit effective address that represent the offset within a segment. Used for all pointers in a nonsegmented memory and for references within segment in a segmented memory. Near Pointer: A 32 bit effective address that represent the offset within a segment. Used for all pointers in a nonsegmented memory and for references within segment in a segmented memory. Bit Field: A continuous sequence of bits in which the position of each bit is considered as an independent unit. Bit Field: A continuous sequence of bits in which the position of each bit is considered as an independent unit. Byte String: A continuous sequence of bytes, words, or doublewords, containing form zero to 32 bytes. Byte String: A continuous sequence of bytes, words, or doublewords, containing form zero to 32 bytes. Floating Point: A set of data types that are used by the floating point unit and operated on by floating point instructions Floating Point: A set of data types that are used by the floating point unit and operated on by floating point instructions

21 Pentium Data Types Pentium Numeric Data Format:

22 Power PC Data Types The Power PC can support data types of 8 (byte), 16 (halfword), 32 (word) and 64 (doubleword) bits in length. The Power PC can support data types of 8 (byte), 16 (halfword), 32 (word) and 64 (doubleword) bits in length. The byte, halfword, word, and doubleword are general data types. The byte, halfword, word, and doubleword are general data types. The Power Pc can use either little endian or big endian style. That is, the last significant byte is stored in the lowest or highest address. The Power Pc can use either little endian or big endian style. That is, the last significant byte is stored in the lowest or highest address.

23 Power PC Data Types The Power PC Processor support the following data: The Power PC Processor support the following data: UNSIGNED BYTE: Can be used for logical or interger arithmetic operations. It is loaded from the memory into a general register by zero extending on the left to the full register size. UNSIGNED BYTE: Can be used for logical or interger arithmetic operations. It is loaded from the memory into a general register by zero extending on the left to the full register size. UNSIGNED HALFWORD: Used for 16 bit quantities of unsigned byte. UNSIGNED HALFWORD: Used for 16 bit quantities of unsigned byte. SIGNED HALFWORD: Used for arithmetic operations. It is loaded into the memory by sign extending on the left to full register size. SIGNED HALFWORD: Used for arithmetic operations. It is loaded into the memory by sign extending on the left to full register size. UNSIGNED WORD: Used for logical operations and as an address pointer. UNSIGNED WORD: Used for logical operations and as an address pointer. SIGNED WORD: Used for arithmetic operations. SIGNED WORD: Used for arithmetic operations. UNSIGNED DOUBLEWORD: Used as an address pointer. UNSIGNED DOUBLEWORD: Used as an address pointer. BYTE STRING: Byte string extending from zero to 128 bytes in length. BYTE STRING: Byte string extending from zero to 128 bytes in length.

24 Types of Operations The number of opcodes varies widely from machine to machine. The number of opcodes varies widely from machine to machine. The same general types of operations are found on all machines. The same general types of operations are found on all machines. General Types of Operations: General Types of Operations: Data Transfer Data Transfer Arithmetic Arithmetic Logical Logical Conversion Conversion I/O I/O System Control System Control Transfer of Control Transfer of Control

25 Types of Operations DATA TRANSFER: DATA TRANSFER: It is the most fundamental type of machine instruction. It is the most fundamental type of machine instruction. The Data Transfer Instructions must specify the following: The Data Transfer Instructions must specify the following: Specify the location of the source and destination of the operands. Specify the location of the source and destination of the operands. Indicate the length of data to be transferred. Indicate the length of data to be transferred. Specify the mode of the of the addressing for each operand. Specify the mode of the of the addressing for each operand.

26 Types of Operations ARITHMETIC: ARITHMETIC: Provides the basic operations for addition, multiplication, and division. Provides the basic operations for addition, multiplication, and division. Other possible arithmetic operations include a variety of single operands instructions: Other possible arithmetic operations include a variety of single operands instructions: ABSOLUTELY: Takes the absolute value of the operand. ABSOLUTELY: Takes the absolute value of the operand. NEGATE: Negates the operand. (-a) NEGATE: Negates the operand. (-a) INCREMENT: Add 1 to the operand. (a++) INCREMENT: Add 1 to the operand. (a++) DECREMENT: Subtract 1 from the operand. (a--) DECREMENT: Subtract 1 from the operand. (a--)

27 Types of Operations LOGICAL: LOGICAL: Logical operations provides a means of manipulating individual bits of a word or other addressable units. Often call “Bit Twiddling”. Logical operations provides a means of manipulating individual bits of a word or other addressable units. Often call “Bit Twiddling”. The logical data manipulation is based upon Boolean operations or binary data as shown in the following table: The logical data manipulation is based upon Boolean operations or binary data as shown in the following table: PQ NOT P P AND Q P OR Q P XOR Q P = Q 0010001 0110110 1000110 1101101

28 Types of Operations In addition to Logical operations, most machines provides a variety of shifting and rotating functions, the most common ones are illustrated: In addition to Logical operations, most machines provides a variety of shifting and rotating functions, the most common ones are illustrated: The logical right shift moves the bits of words The logical right shift moves the bits of words to the right. The last bit of data is lost. The Logical left shift moves the bits of words The Logical left shift moves the bits of words to the left. The last bit of data is lost. The arithmetic right shift treats the data The arithmetic right shift treats the data assigned integers. The sign bit is replicated into the bit position to its right. The arithmetic left shift treats the data The arithmetic left shift treats the data assigned integers. The sign bit is replicated into the bit position to its left. The rotate or cyclic changes the format or The rotate or cyclic changes the format or operate on the format of data. Converting from decimal to binary.

29 Types of Operations Example of Shifting and Rotating Operations: Example of Shifting and Rotating Operations: INPUTOPERATIONRESULT 10100110 LOGICAL RIGHT SHIFT (3 Bits) 00010100 10100110 Logical left shift (3 Bits) 00110000 10100110 Arithmetic right shift (3 Bits) 11110100 10100110 Arithmetic left shift (3 Bits) 10110000 10100110 Right Rotate (3 Bits) 11010100 10100110 Left rotate (3 Bits) 00110101

30 Types of Operations CONVERSIONS: CONVERSIONS: Conversion instructions are those that change the format or operate on the format of data. Conversion instructions are those that change the format or operate on the format of data. An example is to convert from decimal to binary. An example is to convert from decimal to binary.

31 Instructions to transfer data between an Input/Output and the CPU or memory. It can be done by: Specific Instructions (I/O commands): A transfer in which only one byte or word of information is moved by a given computer command (i.e. Control, Test, Read, Write) A terminal is an example of a device that is normally capable of only this type of transfer. Specific Instructions (I/O commands): A transfer in which only one byte or word of information is moved by a given computer command (i.e. Control, Test, Read, Write) A terminal is an example of a device that is normally capable of only this type of transfer. Using data movement instructions (memory mapped). A computer that uses memory-mapped I/O, accesses hardware by reading and writing to specific memory locations, using the same assembler language instructions that computer would normally use to access memory. Using data movement instructions (memory mapped). A computer that uses memory-mapped I/O, accesses hardware by reading and writing to specific memory locations, using the same assembler language instructions that computer would normally use to access memory. By a separate controller (DMA module: Direct Memory access). It is capable of mimicking the processor and takes over control of the system from the processor. DMA module in effects steals a bus cycle. A disk is an example of a device that uses DMA. By a separate controller (DMA module: Direct Memory access). It is capable of mimicking the processor and takes over control of the system from the processor. DMA module in effects steals a bus cycle. A disk is an example of a device that uses DMA.

32 Systems Control Instructions: control some basic element of the system or processor state. Most simple version of privilege states: Two states, “user” and “administrator” states. Some processors have more than two privilege states, allowing different levels of freedom to increasingly trusted operations. Most simple version of privilege states: Two states, “user” and “administrator” states. Some processors have more than two privilege states, allowing different levels of freedom to increasingly trusted operations. Privileged Instructions: Typically are reserved for the use of the operating system as a form of protection. Privileged Instructions: Typically are reserved for the use of the operating system as a form of protection. CPU needs to be in specific state CPU needs to be in specific state Ring 0: Is the level with the most privileges and interacts with the physical hardware such as the CPU and memory. Ring 0: Is the level with the most privileges and interacts with the physical hardware such as the CPU and memory. Kernel mode (Supervisor or administrator mode): A program in supervisor mode is trusted never to fail. A failure may cause the whole computer system to crash. Kernel mode (Supervisor or administrator mode): A program in supervisor mode is trusted never to fail. A failure may cause the whole computer system to crash.

33 Example of privilege ring usage in a typical operating system.

34 Transfer of Control Instructions Branch Instruction: Also called a jump instruction. Has as one of its operands the address of the next instruction to be executed. e.g. go to x if result is zero. (conditional Branch) e.g. go to x if result is zero. (conditional Branch) If a branch is always taken is an unconditional branch. If a branch is always taken is an unconditional branch.  Skip Instruction: implies that one instruction be skipped; thus, the implied address equals the address of the next instruction plus one instruction length. e.g. increment and skip if zero e.g. increment and skip if zero ADD A ADD A Branch xxxx Branch xxxx  Subroutine call: these type of instructions typically modified the program code, modifying the address of a branch at a standard location so that it behaved like an explicit return instruction. e.g. interrupt call e.g. interrupt call

35 Branch Instruction

36 Nested Procedure Calls

37 Use of Stack: is an ordered set of elements, only one of which can be accessed at a time. Items may only be added or deleted from the top of the stack.

38 Byte Order In computing, endianness is the byte (and sometimes bit) ordering used to represent some kind of data. Typical cases are the order in which integer values are stored as bytes in computer memory (relative to a given memory addressing scheme) and the transmission order over a network or other medium. When specifically talking about bytes, endianness is also referred to simply as byte order. In computing, endianness is the byte (and sometimes bit) ordering used to represent some kind of data. Typical cases are the order in which integer values are stored as bytes in computer memory (relative to a given memory addressing scheme) and the transmission order over a network or other medium. When specifically talking about bytes, endianness is also referred to simply as byte order.

39 Byte Order (example) 12345678 can be stored in 4x8bit locations as follows ; AddressValue (1)Value(2) AddressValue (1)Value(2) 1841278 1841278 1853456 1853456 1865634 1865634 1867812 1867812 Big endian Little endian Big endian Little endian i.e. read top down or bottom up? i.e. read top down or bottom up?

40 Review Questions? 1. What is an Instruction Set? 2. Explain each steps of the instruction set cycle? 3. How many general data types does processor support? 4. How many general data type the power PC processor support? 5. What are the types of general operations found on majority of computers? 6. How are instruction types categorize? 7. What is the maximum number of addresses one might need in an instruction? 8. Which ways you can transfer data between I/O and the CPU? 9. What is the importance of the Kernel mode? 10. Explain the concept of Byte Order?


Download ppt "GROUP #4 CHAPTER 10 JOEL FRAGA JAIME J.OCON DEISY HERNANDEZ."

Similar presentations


Ads by Google