0 évaluation0% ont trouvé ce document utile (0 vote)
22 vues32 pages
The document discusses instruction sets and instruction cycles. It defines an instruction set as the complete set of instructions understood by a CPU and describes its main components like operation codes, source/destination operands. It covers addressing modes like immediate, direct, indirect, and register modes. Instruction types include data movement, arithmetic, logical, branch, and control instructions. The instruction cycle is described as a sequence of fetch, decode, execute, and write-back phases where each instruction is processed in turn.
The document discusses instruction sets and instruction cycles. It defines an instruction set as the complete set of instructions understood by a CPU and describes its main components like operation codes, source/destination operands. It covers addressing modes like immediate, direct, indirect, and register modes. Instruction types include data movement, arithmetic, logical, branch, and control instructions. The instruction cycle is described as a sequence of fetch, decode, execute, and write-back phases where each instruction is processed in turn.
The document discusses instruction sets and instruction cycles. It defines an instruction set as the complete set of instructions understood by a CPU and describes its main components like operation codes, source/destination operands. It covers addressing modes like immediate, direct, indirect, and register modes. Instruction types include data movement, arithmetic, logical, branch, and control instructions. The instruction cycle is described as a sequence of fetch, decode, execute, and write-back phases where each instruction is processed in turn.
Contents • Instruction set • Elements of Instruction • Instruction set design Issues • Addressing modes • Types of Instructions • Instruction Cycle
COA March 2017 2
Instruction set • The complete collection of instructions that are understood by a CPU • The instruction set is also the machine description that a hardware designer must understand to design a correct implementation of the computer • Serves as an interface between software and hardware. • Machine language: binary representation of operations and (addresses of) arguments • Assembly language: mnemonic representation OP A,B,C (meaning A <- OP(B,C))
COA March 2017 3
Elements of Instruction • Operation code (opcode)-mnemonic code • Source operand reference • Destination operand reference • Next instruction reference
COA March 2017 4
Example of simple Instruction format using two addresses
COA March 2017 5
Instruction Set Design Issues • Where are operands stored? • How many explicit operands are there? • How is the operand location specified? • What type & size of operands are supported? • What operations are supported? • Number of CPU registers available • Which operations can be performed on which registers
COA March 2017 6
Importance of Registers – Registers are much faster than memory (even cache) • Register values are available immediately • When memory isn’t ready, processor must wait (“stall”) – Registers are convenient for variable storage • More compact code since small fields specify registers compared to memory addresses – Two types of registers – General purpose & specific purpose
COA March 2017 7
Addressing modes • Addressing modes are method of referencing the operands • The most common addressing techniques are – Immediate – Direct – Indirect – Register – Register indirect
COA March 2017 8
Immediate Addressing mode • Operand is part of instruction • Operand = address field • Example • ADD 5 • No memory reference to fetch data • Fast
COA March 2017 9
Direct Addressing • Address field contains address of operand • Effective address (EA) = address field (A) • e.g., ADD A – Look in memory at address A for operand • Single memory reference to access data
COA March 2017 10
COA March 2017 11 Indirect Addressing • Look in A, find address [A] and look there for operand • E.g. ADD [A] • Multiple memory accesses to find operand • Hence, slower
COA March 2017 12
COA March 2017 13 Register Addressing • Operand is held in register named in address field • Very small address field needed – Shorter instructions • No memory access • Very fast execution • Availability of Multiple registers helps performance
COA March 2017 14
COA March 2017 15 Register indirect addressing • Operand is in memory cell pointed to by contents of register R • One fewer memory access than indirect addressing
COA March 2017 16
COA March 2017 17 Instruction Types • Data movement instructions • Arithmetic instructions • Logical instructions • Branch instructions • Control instructions
COA March 2017 18
Data Transfer/movement • Data transfer Instructions include: Store, load, exchange, move, clear, set, push, pop • Specifies: source and destination • Example • LDA 2000H; load the data in memory location 2000H to accumulator • MOV R1,R2; move the data in register R2 to Register R1
COA March 2017 19
Input/output Instructions • Example • IN 02H; transfer the data at port 02H to Ac. • OUT 02H; transfer the data in Ac. through 02H
COA March 2017 20
Arithmetic • Arithmetic instructions include Add, Subtract, Multiply, Divide • May also include – Absolute (|a|) – Increment (a++) – Decrement (a--) – Negate (-a) • Example: ADD A,B....A=A+B
COA March 2017 21
Logical • Bitwise operations/instructions: AND, OR, NOT, XOR, TEST, CMP, SET • Example: AND A, B; A=A AND B • Shifting and rotating functions – arithmetic right shift: division – arithmetic left shift: multiplication
COA March 2017 22
Branch instructions
– Alter the normal flow of control from executing the next
instruction in sequence – Br Loc, Brz Loc2 ---unconditional or conditional branches
COA March 2017 23
Control instruction • No operation (NOP) or stop execution (HLT)
COA March 2017 24
Example: write an assembly code for Y=(A-B)/[(C+(D*E))] Implicit second address, usually a register (accumulator, AC) LOAD D MUL E ADD C STOR Y LOAD A SUB B DIV Y STOR Y COA March 2017 25 Using two addresses
One address doubles as operand and result
– Reduces length of instruction MOV Y,A SUB Y,B MOV T,D MUL T,E ADD T,C DIV Y,T
COA March 2017 26
Instruction Cycle • A program in the memory consists of a sequence of instructions • Program is executed in the computer by going through a cycle for each instruction • Each instruction cycle in turn is subdivided in to a sequence of sub cycles or phases
COA March 2017 27
Instruction Cycle…
COA March 2017 28
Fetch and Decode • Program counter, PC is loaded with the address of the first instruction in the program • Sequence counter SC is cleared to 0, providing a decoded timing signal T0 • After each clock pulse, SC is incremented by one so that timing signals go through a sequence T0, T1, T2
COA March 2017 29
micro operations for fetch & decode phases
COA March 2017 30
Instruction cycle… • Decode IR[12-14] -identify type of instruction • Decoder out put D7 is equal to 1 when the operation code is 111 • If D7=1 register reference instruction; otherwise memory reference Instruction
Chapter 02 Computer Organization and Design, Fifth Edition: The Hardware/Software Interface (The Morgan Kaufmann Series in Computer Architecture and Design) 5th Edition