Advanced Computer Architecture Dr Dawar Khan Assistant Professor
- Slides: 50
Advanced Computer Architecture Dr. Dawar Khan Assistant Professor, Department of IT, University of Haripur
Advanced Computer Architecture Instruction Sets: Characteristics and Functions 29/10/2020
What is an Instruction Set? • The complete collection of instructions that are understood by a CPU • Machine Code • Binary • Usually represented by assembly codes
Elements of an Instruction • Operation code (Op code) —Do this • Source Operand reference —To this • Result Operand reference —Put the answer here • Next Instruction Reference —When you have done that, do this. . . — In computer programming, an operand is a term used to describe any object that is capable of being manipulated. For example, in "1 + 2" the "1" and "2" are the operands and the plus symbol is the operator.
Where are the operands? • • Main memory CPU register I/O device In instruction itself • To specify which register, which memory location, or which I/O device, we’ll need some addressing scheme for each
Instruction Cycle • A instruction cycle(sometimes called fetch decode cycle) • It is basic operational process of computer in which a computer retrieves a program instruction from its memory that determines what actions the instruction dictates and carries out those action
Instruction Cycle
Component of instruction cycle A program counter (PC) is a CPU register in the computer processor which has the address of the next instruction to be executed from memory. MAR either stores the memory address from which data will be fetched to the CPU, or the address to which data will be sent and stored. A memory buffer register (MBR) (also known as memory data register (MDR)) is the register in CPU, that stores the data being transferred CU regulates and integrates the to and from the immediate operations of the computer. access storage. IR holds the instruction currently being executed or decoded. ALU carries out arithmetic and logic operations
Steps of instruction cycle The decoding process allows the CPU to determine what instruction is to be performed so that the CPU can tell how many operands it needs to fetch in order to perform the instruction. The opcode fetched from the memory is decoded for the next steps and moved to the appropriate registers.
If the instruction has an indirect address, the effective address is read from the memory. Steps of instruction Otherwise operands are directly read in casecycle of immediate operand instruction.
Instruction Cycle State Diagram
Instruction Cycle (with Interrupts) - State Diagram Fetch Decode Execute
Instruction Representation • In machine code each instruction has a unique bit pattern • For human consumption (well, programmers anyway) a symbolic representation is used —e. g. ADD, SUB, LOAD • Operands can also be represented in this way —ADD A, B
Simple Instruction Format
Instruction Formats 5. 2 Instruction Formats • A system has 16 registers and 4 K of memory. • We need 4 bits to access one of the registers. We also need 10 bits for a memory address. • If the system is to have 16 -bit instructions, we have two choices for our instructions:
Instruction types Instructions fall into several broad categories that you should be familiar with: • Data movement • Arithmetic Can you think of • Boolean some examples of each of these? • Bit manipulation • I/O • Control transfer • Special purpose
Instruction Types • • Data processing Data storage (main memory) Data movement (I/O) Program flow control
Number of Addresses (a) • 3 addresses —Operand 1, Operand 2, Result —a = b + c; —May be a forth - next instruction (usually implicit) —Not common —Needs very long words to hold everything
Number of Addresses (b) • 2 addresses —One address doubles as operand result —a = a + b —Reduces length of instruction —Requires some extra work – Temporary storage to hold some results
Number of Addresses (c) • 1 address —Implicit second address —Usually a register (accumulator) —Common on early machines
Number of Addresses (d) • 0 (zero) addresses —All addresses implicit —Uses a stack —e. g. push a — push b — add — pop c —c = a + b
Three operand instruction • If we had a three operand instruction, we could specify two source operands and a destination to store the result. • Here is a possible sequence of instructions for our equation: Y = (A-B) / (C + (D * E)) — SUB R 1, A, B — MUL R 2, D, E — ADD R 2, C — DIV R 1, R 2 ; ; Register R 1 R 2 R 1 A-B D*E R 2 + C R 1 / R 2 • The three address format is fairly convenient because we have the flexibility to dictate where the result of computations should go. Note that after this calculation is done, we haven’t changed the contents of any of our original locations A, B, C, D, or E.
Two operand instruction • How can we cut down the number of operands? —Might want to make the instruction shorter • Typical method is to assign a default destination operand to hold the results of the computation —Result always goes into this operand —Overwrites and old data in that location • Let’s say that the default destination is the first operand in the instruction —First operand might be a register, memory, etc.
Two Operand Instructions • Here is a possible sequence of instructions for our equation (say the operands are registers): Y = (A-B) / (C + (D * E)) — SUB A, B — MUL D, E — ADD D, C — DIV A, D ; Register A A-B ; Register D D*E ; Register D D+C ; Register A A / D • Get same end result as before, but we changed the contents of registers A and D • If we had some later processing that wanted to use the original contents of those registers, we must make a copy of them before performing the computation — MOV R 1, A — MOV R 2, D — SUB R 1, B — MUL R 2, E — ADD R 2, C — DIV R 1, R 2 ; ; ; Copy A to register R 1 Copy D to register R 2 Register R 1 -B Register R 2*E Register R 2+C Register R 1 / R 2 • Now the original registers for A-E remain the same as before, but at the cost of some extra instructions to save the results.
One Operand Instructions • Can use the same idea to get rid of the second operand, leaving only one operand • The second operand is left implicit; e. g. could assume that the second operand will always be in a register such as the Accumulator: Y = (A-B) / (C + (D * E)) — LDA — MUL — ADD — STO — LDA — SUB — DIV D E C R 1 A B R 1 ; ; ; ; Load ACC with D Acc * E Acc + C Store Acc to R 1 Acc A-B Acc / R 1 • Many early computers relied heavily on one-address based instructions, as it makes the CPU much simpler to design. As you can see, it does become somewhat more unwieldy to program.
Two Operand Instructions • Here is a possible sequence of instructions for our equation (say the operands are registers): Y = (A-B) / (C + (D * E)) — SUB A, B — MUL D, E — ADD D, C — DIV A, D ; Register A A-B ; Register D D*E ; Register D D+C ; Register A A / D • Get same end result as before, but we changed the contents of registers A and D • If we had some later processing that wanted to use the original contents of those registers, we must make a copy of them before performing the computation — MOV R 1, A — MOV R 2, D — SUB R 1, B — MUL R 2, E — ADD R 2, C — DIV R 1, R 2 ; ; ; Copy A to register R 1 Copy D to register R 2 Register R 1 -B Register R 2*E Register R 2+C Register R 1 / R 2 • Now the original registers for A-E remain the same as before, but at the cost of some extra instructions to save the results.
One Operand Instructions • Can use the same idea to get rid of the second operand, leaving only one operand • The second operand is left implicit; e. g. could assume that the second operand will always be in a register such as the Accumulator: Y = (A-B) / (C + (D * E)) — LDA — MUL — ADD — STO — LDA — SUB — DIV D E C R 1 A B R 1 ; ; ; ; Load ACC with D Acc * E Acc + C Store Acc to R 1 Acc A-B Acc / R 1 • Many early computers relied heavily on one-address based instructions, as it makes the CPU much simpler to design. As you can see, it does become somewhat more unwieldy to program.
Zero Operand Instructions • In some cases we can have zero operand instructions • Uses the Stack — Section of memory where we can add and remove items in LIFO order — Last In, First Out — Envision a stack of trays in a cafeteria; the last tray placed on the stack is the first one someone takes out — The stack in the computer behaves the same way, but with data values – PUSH A – POP A result in A – ADD back on ; Places A on top of stack ; Removes value on top of stack and puts ; Pops top two values off stack, pushes result
Stack-Based Instructions Y = (A-B) / (C + (D * E)) —Instruction —PUSH B —PUSH A —SUB —PUSH E —PUSH D —MUL —PUSH C —ADD —DIV Stack Contents (top to left) ; B, A ; (A-B), E, D ; (A-B), (E*D), C ; (A-B), (E*D+C) ; (A-B) / (E*D+C)
How many operands is best? • More operands —More complex (powerful? ) instructions —Fewer instructions per program • More registers —Inter-register operations are quicker • Fewer operands —Less complex (powerful? ) instructions —More instructions per program —Faster fetch/execution of instructions
Operand VS variable • Is there any difference between a variable and an operand? • An expression may have following parts —Operands —Operators —Special symbols (also known as operators) e. g. x=a+b; • Here x, a, and b are operands • + and = are operators
Operand VS Variable a. Operands may be constants • b. Operands Is theremay anybedifference variables between a variable may andbean operand? c. Operands more complex expressions • An expression may have following parts —Operands —Operators —Special symbols (also known as operators) e. g. x=a+b; • Here x, a, and b are operands • + and = are operators • when a variable are used in an operation it can be called an operand.
Operand VS Variable • 2) Operators • Operators are the special kinds of symbols (or function like words (sizeof)) that are used to perform any specific task like mathematical and logical. • For example, there is an expression to add two integer numbers (10+20), here 10 and 20 are the operands and being added through the special symbol + (plus), thus plus (+) is an operator here. Another example, there is a logical expression (age>=18), here we are going to check whether age is greater than or equal to 18 or not, thus greater than or equal to (>=) is the combination of two special symbols > and =, it is also an operator in C/C++ and other programming languages too.
Operand VS Variable (3) Special Symbols: • In any programming language, an expression may have other special symbols too, that are not used to perform any mathematical or logical operations but they are also an important part of an expression. • For example, there is an expression x= (a+b); here, ; (semicolon) and brackets are Special symbols also called special operators, semicolon (; ) is using to terminate the expression and brackets are using to put the expression in an unit.
Design Tradeoff Decisions • Operation repertoire —How many ops? —What can they do? —How complex are they? • Data types —What types of data should ops perform on? • Registers —Number of registers, what ops on what registers? • Addressing — Mode by which an address is specified (more on this later)
Design Decisions (2) • Registers —Number of CPU registers available —Which operations can be performed on which registers? • Addressing modes (later…) • RISC v CISC
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!)
Types of Operation • • Data Transfer Arithmetic Logical Conversion I/O System Control Transfer of Control
Data Transfer • Specify —Source —Destination —Amount of data • May be different instructions for different movements —e. g. IBM 370 • Or one instruction and different addresses —e. g. VAX
Arithmetic • • Add, Subtract, Multiply, Divide Signed Integer Floating point ? May include —Increment (a++) —Decrement (a--) —Negate (-a)
Logical • Bitwise operations • AND, OR, NOT
Conversion • E. g. Binary to Decimal
Conversion • E. g. Binary to Decimal
Transfer of Control • Branch —e. g. branch to x if result is zero • Skip —e. g. increment and skip if zero —ISZ Register 1 —Branch xxxx —ADD A • Subroutine call —c. f. interrupt call
Conversion • E. g. Binary to Decimal
- Anuj dawar
- Promotion from assistant to associate professor
- Cuhk assistant professor salary
- Professor mushtaq khan
- Ec 6009
- Bus architecture in computer architecture
- Architecture and organization difference
- Design of a basic computer
- Assistant computer control
- Advanced topics in computer science
- Advanced computer graphics
- Advanced computer forensics
- Fastbloc se
- Abc in software architecture
- Call and return architecture
- Modular architecture vs integrated architecture
- Modular and integral architecture
- Computer organization and architecture 10th solution
- Intel pentium
- Vlab iit kharagpur
- Introduction to computer organization and architecture
- Timing and control in computer architecture
- Evolution and interpretation of computer architecture
- Programmed i/o in computer architecture
- Floating point division algorithm in computer architecture
- Wipro
- Static interconnection network in computer architecture
- Smt in computer architecture
- Mips not pseudo instruction
- Collision vector in pipelining
- Instruction format in computer architecture
- Nano programming in computer architecture
- A microprogram sequencer
- Memory system design in computer architecture
- Dram memory mapping
- Linear pipeline processors
- Computer architecture definition
- Parallel processing architecture
- Number system in computer architecture
- Computer architecture definition
- Stack isa example
- What are the input devices
- Branch prediction in computer architecture
- Computer architecture patterson
- Multiple instruction single data
- What is guard bit in computer architecture
- Bus interconnection in computer architecture
- Basic mips implementation in computer architecture
- Explain virtual memory in computer architecture
- Computer architecture definition
- Dynamic interconnection network in computer architecture