Instruction Sets

Post on 25-Feb-2016

57 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

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} - PowerPoint PPT Presentation

Transcript

Instruction SetsInstruction Sets

Instruction setInstruction set

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

Element of an instruction:Element of an instruction: Operation Code (Op Code) {Determine what will Operation Code (Op Code) {Determine what will

be done}be done} Source Operand {Determine which data will be Source Operand {Determine which data will be

manipulated}manipulated} Destination Operand {Determine where the Destination Operand {Determine where the

data will be stored}data will be stored} Next Instruction {Determine the next instruction Next Instruction {Determine the next instruction

to be executed} to be executed}

Instruction Cycle State Instruction Cycle State DiagramDiagram

Instruction CycleInstruction Cycle Fetch (Instruction is copied from memory Fetch (Instruction is copied from memory

to the Instruction Register (IR) )to the Instruction Register (IR) ) Decode (In order to figure out what the Decode (In order to figure out what the

instruction should do, it needs to be instruction should do, it needs to be decoded. )decoded. )

Data Operations (Do the operations Data Operations (Do the operations needed) (example: adding two values, needed) (example: adding two values, access ALU)access ALU)

Write-back (The result of the operation is Write-back (The result of the operation is written in the registers) written in the registers)

Instruction Instruction RepresentationRepresentation

Example of InstructionsExample of Instructions ADD, SUB, LOAD, MPY, DIV, STORADD, SUB, LOAD, MPY, DIV, STOR

Example of OperandsExample of Operands ADD A, BADD A, B LOAD C, XLOAD C, X

Instruction TypesInstruction Types The set of instruction in a computer must be The set of instruction in a computer must be

sufficient to allow the user to manage all the sufficient to allow the user to manage all the information neededinformation needed

Data processing:Data processing: Arithmetic and logic instruction. This instruction is used Arithmetic and logic instruction. This instruction is used

in the computer registers. in the computer registers. Data storage Data storage

They are memory instructions which allow the They are memory instructions which allow the movement of data between memory and registersmovement 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 instructionsIt can use test and branch instructions

Number of Address Number of Address InstructionInstruction

Three-address InstructionThree-address Instruction Two-address InstructionTwo-address Instruction One-address InstructionOne-address Instruction

Three-address Three-address InstructionInstruction

Operand 1, Operand 2, ResultOperand 1, Operand 2, Result ADD X,A,B (X = A + B);ADD X,A,B (X = A + B); May be a forth - next instruction May be a forth - next instruction

(usually implicit)(usually implicit) Needs very long words to hold Needs very long words to hold

everythingeverything

Two-address InstructionTwo-address Instruction Move Y, AMove Y, A Y =AY =A ADD Y, BADD Y, B Y = Y + BY = Y + B

A MOVE instruction is introduced to do A MOVE instruction is introduced to do an operation an operation

Reduces length of instructionReduces length of instruction Requires some extra workRequires some extra work

One addressOne 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 resultsThe AC is used to store the results Common on early machinesCommon on early machines

It can be possible to process It can be possible to process information with Zero- address information with Zero- address Instructions. All the address are Instructions. All the address are implicit.implicit.

How Many AddressesHow Many Addresses More addressesMore addresses

More complex instructions. More More complex instructions. More PowerfulPowerful

More registersMore registers operations are quickeroperations are quicker

Fewer instructions per programFewer instructions per program Fewer addressesFewer addresses

Less complex instructions. Less PowerfulLess complex instructions. Less Powerful More instructions per programMore instructions per program Faster fetch/execution of instructionsFaster fetch/execution of instructions

Design DecisionsDesign Decisions OperationOperation

How many ops?How many ops? What can they do?What can they do? How complex are they?How complex are they?

Data typesData types Number of CPU registers available. More Number of CPU registers available. More

operationsoperations Instruction formatsInstruction formats

Length of op code fieldLength of op code field Number of addresses and the addressing modesNumber of addresses and the addressing modes

Types of OperandTypes of Operand AddressesAddresses NumbersNumbers

Integer/floating pointInteger/floating point CharactersCharacters

ASCII etc.ASCII etc. Logical DataLogical Data

Bits or flagsBits or flags (Aside: Is there any difference between numbers (Aside: Is there any difference between numbers

and characters? Ask a C programmer!)and characters? Ask a C programmer!)

Pentium Data TypesPentium Data Types 8 bit Byte8 bit Byte 16 bit word16 bit word 32 bit double word32 bit double word 64 bit quad word64 bit quad word Addressing is by 8 bit unitAddressing is by 8 bit unit A 32 bit double word is read at A 32 bit double word is read at

addresses divisible by 4addresses divisible by 4

Specific Data TypesSpecific Data Types General - arbitrary binary contentsGeneral - arbitrary binary contents Integer - single binary valueInteger - single binary value Ordinal - unsigned integerOrdinal - unsigned integer Unpacked BCD - One digit per byteUnpacked BCD - One digit per byte Packed BCD - 2 BCD digits per bytePacked BCD - 2 BCD digits per byte Near Pointer - 32 bit offset within segmentNear Pointer - 32 bit offset within segment Bit fieldBit field Byte StringByte String Floating PointFloating Point

Pentium Numeric Data Pentium Numeric Data FormatsFormats

PowerPC Data TypesPowerPC Data Types 8 (byte), 16 (halfword), 32 (word) and 64 8 (byte), 16 (halfword), 32 (word) and 64

(doubleword) length data types(doubleword) length data types Some instructions need operand aligned on Some instructions need operand aligned on

32 bit boundary32 bit boundary Can be big- or little-endianCan be big- or little-endian Fixed point processor recognises:Fixed point processor recognises:

Unsigned byte, unsigned halfword, signed Unsigned byte, unsigned halfword, signed halfword, unsigned word, signed word, halfword, unsigned word, signed word, unsigned doubleword, byte string (<128 bytes)unsigned doubleword, byte string (<128 bytes)

Floating pointFloating point IEEE 754, Single or double precisionIEEE 754, Single or double precision

Types of Operation for Types of Operation for Instruction SetsInstruction Sets

1. Data Transfer1. Data Transfer2. Arithmetic2. Arithmetic3. Logical3. Logical4. Conversion4. Conversion5. I/O5. I/O6. System Control6. System Control7. Transfer of Control7. Transfer of Control

Data TransferData Transfer Specify:Specify:

Source (Register, Memory)Source (Register, Memory) Destination (Register, Memory)Destination (Register, Memory) Amount of dataAmount of data Examples: Examples: movmov src, dest src, dest movmov dest, src dest, src

There are different instructions for different There are different instructions for different movementsmovements Data MoveData Move

movmov src, dest src, dest Data SwapData Swap

xchgxchg src, dest src, dest

ArithmeticArithmetic Add, Subtract, Multiply, DivideAdd, Subtract, Multiply, Divide

(8- and 16-bit operations are supported (8- and 16-bit operations are supported directly and can easily be extended)directly and can easily be extended)

Signed IntegerSigned Integer Floating point (Floating point (sinesine, , cosinecosine, , square rootsquare root, ,

etc.)etc.) OthersOthers

Increment (a++), ex. PC<-[PC]+1 Increment (a++), ex. PC<-[PC]+1 Decrement (a--)Decrement (a--) Negate (-a)Negate (-a)

Increment and Increment and decrementdecrement

ArithmeticArithmetic Complex Operations (Complex Operations (SIMDSIMD or Single- or Single-

Instruction Stream Multiple-Data or Instruction Stream Multiple-Data or vector instructionvector instruction).).

It performs the same arithmetic It performs the same arithmetic operations in multiple pieces of data operations in multiple pieces of data at the same time.at the same time.

SIMD can be used to implement SIMD can be used to implement algorithms involved in sound, images algorithms involved in sound, images and video processing.and video processing.

Shift and Rotate Shift and Rotate OperationsOperations

“S” is a copy of the sign bit

Rotate = circular shiftingRotate = circular shifting

Logical and Arithmetic ShiftingLogical and Arithmetic Shifting Logical shifting are used for unsigned binary Logical shifting are used for unsigned binary

numbers.numbers. Arithmetic shifting is used for signed binary Arithmetic shifting is used for signed binary

numbersnumbers

Rotate OperationRotate Operation It is also known as the circular shiftingIt is also known as the circular shifting This operation is useful if it is necessary to retain This operation is useful if it is necessary to retain

all the existing bits. all the existing bits. It is frequently used in digital cryptography.It is frequently used in digital cryptography.

LogicalLogical Bitwise operator:Bitwise operator:

AND, OR, NOTAND, OR, NOT This operations are faster than arithmetic This operations are faster than arithmetic

operations (+,-,*,/)operations (+,-,*,/) Examples:Examples:

NOT 0111 = 1000 (NOT 0111 = 1000 (It is used for forming the It is used for forming the ones' complementones' complement which is used for addition and subtraction) which is used for addition and subtraction)

0101 OR 0011 = 0111(0101 OR 0011 = 0111(It is used as a flag in programming It is used as a flag in programming cycles)cycles)

0101 AND 0011 = 0001 (0101 AND 0011 = 0001 (The bitwise AND may be used to The bitwise AND may be used to perform a perform a bit maskbit mask operation and operation and to determine whether a particular to determine whether a particular bit is 1 or 0bit is 1 or 0 ) )

Application for Bit Mask Application for Bit Mask Using ANDUsing AND

given a bit pattern: 0010given a bit pattern: 0010 It will be determined whether the It will be determined whether the

third bit is 1, a bitwise AND is third bit is 1, a bitwise AND is applied to it.applied to it.

0010 AND 1010 = 0010 0010 AND 1010 = 0010

Conversion & I/OConversion & I/O Convert decimal to binaryConvert decimal to binary May be specific instructionsMay be specific instructions May be done using data movement May be done using data movement

instructions (memory mapped)instructions (memory mapped) May be done by a separate May be done by a separate

controller (DMA)controller (DMA)

ConversionConversion Example: Binary to DecimalExample: Binary to Decimal 0101 = 4+1=50101 = 4+1=5 2^3, 2^2, 2^1, 2^02^3, 2^2, 2^1, 2^0

System Control and System Control and Transfer of ControlTransfer of Control

Privileged instructionsPrivileged instructions For operating systems useFor operating systems use Change the sequence of instruction Change the sequence of instruction

executionexecution BranchBranch

branch to x if result is zerobranch to x if result is zero SkipSkip

e.g. increment and skip if zeroe.g. increment and skip if zero

Branch InstructionsBranch Instructions Conditional BranchConditional Branch Unconditional BranchUnconditional Branch BRP XBRP X

Branch to location X if result is postiveBranch to location X if result is postive BRZ XBRZ X

Branch to location X if result is zeroBranch to location X if result is zero

Branch InstructionsBranch Instructions

Procedure Call Procedure Call InstructionsInstructions

Self contained program that is Self contained program that is incorporated into a larger programincorporated into a larger program Economy and modularityEconomy and modularity

Call instructionCall instruction Branches from the current location to the Branches from the current location to the

procedureprocedure Return InstructionReturn Instruction

Returns from the procedure to the place Returns from the procedure to the place from which it was calledfrom which it was called

Procedure Call Procedure Call InsructionsInsructions

QuestionsQuestions1.1. Give one example were can be used Give one example were can be used

increment operation? increment operation? PC<-[PC]+1PC<-[PC]+1

2.2. Mention three examples of bitwise operator?Mention three examples of bitwise operator?AND, OR, NOTAND, OR, NOT

3.3. Mention three Instruction types?Mention three Instruction types?Data processing, Data storage, Data movementData processing, Data storage, Data movement

4.4. What type of branch instruction is always What type of branch instruction is always executed? Unconditional branchexecuted? Unconditional branch

5.5. What are the two principal reasons for the What are the two principal reasons for the use of the procedure call instructions? use of the procedure call instructions? Economy and ModularityEconomy and Modularity

QuestionsQuestions6. What is an example of data transfer?6. What is an example of data transfer?

movmov src, dest src, dest 7. What would be the decimal value of 0101?7. What would be the decimal value of 0101?

0101 = 4+1=50101 = 4+1=5

8. When you have one address which register is 8. When you have one address which register is usually used?usually used?

accumulator (AC)accumulator (AC)9. What is another name for opcode abbreviations? 9. What is another name for opcode abbreviations?

MnemonicsMnemonics10. What kind of instructions provide 10. What kind of instructions provide

computational capabilities for processing computational capabilities for processing numeric data? Arithmetic Instructionsnumeric data? Arithmetic Instructions

11. What are the Pentium data types? 11. What are the Pentium data types? Answer: 8 bit Byte, 16 bit word, 32 bit double word, Answer: 8 bit Byte, 16 bit word, 32 bit double word,

64bit quad, 8 bit addressing, 32 bit double word is read 64bit quad, 8 bit addressing, 32 bit double word is read and divisible by 4.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 Answer: 8 (byte), 16 (half-word), 32 (word) and 64

(double-word) length data types(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 Packed BCD, Near Point, Bit field, Byte String, Floating

Point Point 

top related