360 likes | 545 Views
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}
E N D
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}
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)
Instruction Representation • Example of Instructions • ADD, SUB, LOAD, MPY, DIV, STOR • Example of Operands • ADD A, B • LOAD C, X
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
Number of Address Instruction • Three-address Instruction • Two-address Instruction • One-address Instruction
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
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
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.
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
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
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!)
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
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
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
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
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
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)
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.
Shift and Rotate Operations “S” is a copy of the sign bit Rotate = circular shifting
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.
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 )
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
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)
Conversion • Example: Binary to Decimal • 0101 = 4+1=5 • 2^3, 2^2, 2^1, 2^0
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
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
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
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
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
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