Introduction to computer: executes instructions. Overview Topics discussed in this webnote: –Structure and operation of the CPU –Program flow –Types of.

Slides:



Advertisements
Similar presentations
Chapter 2: Data Manipulation
Advertisements

The CPU The Central Presentation Unit What is the CPU?
Machine cycle.
Computer Architecture and the Fetch-Execute Cycle
Dr. Rabie A. Ramadan Al-Azhar University Lecture 3
Chapter 2 Data Manipulation Dr. Farzana Rahman Assistant Professor Department of Computer Science James Madison University 1 Some sldes are adapted from.
ARITHMETIC LOGIC SHIFT UNIT
 Suppose for a moment that you were asked to perform a task and were given the following list of instructions to perform:
The CPU Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches.
Computer Systems. Computer System Components Computer Networks.
Execution of an instruction
Chapter 5: Computer Systems Organization Invitation to Computer Science, Java Version, Third Edition.
Chapter 4 Processor Technology and Architecture. Chapter goals Describe CPU instruction and execution cycles Explain how primitive CPU instructions are.
Basic Computer Organization, CPU L1 Prof. Sin-Min Lee Department of Computer Science.
1 Sec (2.3) Program Execution. 2 In the CPU we have CU and ALU, in CU there are two special purpose registers: 1. Instruction Register 2. Program Counter.
 Central Processing Unit(CPU) Central Processing Unit(CPU)  Components of the CPU Components of the CPU  Actions Performed by CPU Actions Performed.
CPU Structure and Instruction Execution Timothy C. Rice Jr., MIT.
What’s on the Motherboard? The two main parts of the CPU are the control unit and the arithmetic logic unit. The control unit retrieves instructions from.
Inside The CPU. Buses There are 3 Types of Buses There are 3 Types of Buses Address bus Address bus –between CPU and Main Memory –Carries address of where.
Lecture 13 - Introduction to the Central Processing Unit (CPU)
Computer Science 210 Computer Organization The Instruction Execution Cycle.
Basic Operational Concepts of a Computer
Lecture 3. Diff b/w RAM and Registers Registers are used to hold data immediately applicable to the operation at hand Registers are used to hold data.
CS 1308 Computer Literacy and the Internet Computer Systems Organization.
Chapter 5: Computer Systems Organization Invitation to Computer Science, Java Version, Third Edition.
Computer Systems Organization CS 1428 Foundations of Computer Science.
Presented by: Sergio Ospina Qing Gao. Contents ♦ 12.1 Processor Organization ♦ 12.2 Register Organization ♦ 12.3 Instruction Cycle ♦ 12.4 Instruction.
Stack Stack Pointer A stack is a means of storing data that works on a ‘Last in first out’ (LIFO) basis. It reverses the order that data arrives and is.
Introduction to Computing Systems from bits & gates to C & beyond The Von Neumann Model Basic components Instruction processing.
Week 2.  Understand what the processor is and what it does.  Execute basic LMC programs.  Understand how CPU characteristics affect performance.
CPU Design. Introduction – The CPU must perform three main tasks: Communication with memory – Fetching Instructions – Fetching and storing data Interpretation.
Von Neumann Machine Objectives: Explain Von Neumann architecture:  Memory –Organization –Decoding memory addresses, MAR & MDR  ALU and Control Unit –Executing.
Model Computer CPU Arithmetic Logic Unit Control Unit Memory Unit
Execution of an instruction
Module : Algorithmic state machines. Machine language Machine language is built up from discrete statements or instructions. On the processing architecture,
1 Purpose of This Chapter In this chapter we introduce a basic computer and show how its operation can be specified with register transfer statements.
Computer Science 101 Computer Systems Organization ALU, Control Unit, Instruction Set.
D75P 34 – HNC Computer Architecture
Computer Architecture 2 nd year (computer and Information Sc.)
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Information Representation: Machine Instructions.
COMPILERS CLASS 22/7,23/7. Introduction Compiler: A Compiler is a program that can read a program in one language (Source) and translate it into an equivalent.
CS 1308 Computer Literacy and the Internet. Objectives In this chapter, you will learn about:  The components of a computer system  Putting all the.
System Unit Working of CPU. The CPU CPU The CPU CPU stands for central processing unit. it is brain of computer It is most important component of the.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Overview von Neumann Architecture Computer component Computer function
Question What technology differentiates the different stages a computer had gone through from generation 1 to present?
Simple ALU How to perform this C language integer operation in the computer C=A+B; ? The arithmetic/logic unit (ALU) of a processor performs integer arithmetic.
CMSC 104, Lecture 061 Stored Programs A look at how programs are executed.
Chapter 5: Computer Systems Organization Invitation to Computer Science,
1 3 Computing System Fundamentals 3.2 Computer Architecture.
CPUz 4 n00bz.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Chapter 20 Computer Operations Computer Studies Today Chapter 20.
Types of Micro-operation  Transfer data between registers  Transfer data from register to external  Transfer data from external to register  Perform.
The Processor The Main Components Arithmetic/Logic Unit (ALU) Control Unit System Clock Registers.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Lecture 13 - Introduction to the Central Processing Unit (CPU)
The Processor and Machine Language
Functional Units.
The Von Neumann Model Basic components Instruction processing
Chapter 5: Computer Systems Organization
Sequencing, Selection, and Loops in Machine Language
Fundamental Concepts Processor fetches one instruction at a time and perform the operation specified. Instructions are fetched from successive memory locations.
Central Processing Unit
GCSE OCR 1 The CPU Computer Science J276 Unit 1
A Top-Level View Of Computer Function And Interconnection
Information Representation: Machine Instructions
Objectives Describe common CPU components and their function: ALU Arithmetic Logic Unit), CU (Control Unit), Cache Explain the function of the CPU as.
Sec (2.3) Program Execution.
Presentation transcript:

Introduction to computer: executes instructions

Overview Topics discussed in this webnote: –Structure and operation of the CPU –Program flow –Types of instructions that a computer can execute

Overview Topics discussed in this webnote: –Structure and operation of the CPU –Program flow –Types of instructions that a computer can execute

Structure of a CPU

Components of a CPU General purpose registers: Arithmetic and Logic Unit (ALU): – Register is a synonym for memory in computer science – A general purpose register is a memory cell – Each general purpose register has a unique name – It is used to store (and recall) intermediate result of complex computations – Is a complex electrical circuit that can perform Mathematical (+, -, ×, /) and logical operations (, ≥, and, or) – The output (result) of the computation (obtained by the ALU) is often stored in a general purpose register

Structure of a CPU (cont.) Instruction register (IR): Program counter (PC): Contains the current instruction being executed by the CPU The CPU will perform the operation indicated by the instruction code contained in the instruction register The program counter is a register (memory cell) ! This register contains the address (location in memory) of the next instruction after the CPU finishes executing the current instruction in the instruction register The value in the program counter will be increased after the CPU finishes executing one instruction

Structure of a CPU (cont.) Processor status register (PSR): This register contains the various information about the CPU Among the information contained in the PSR is: When the CPU compares 2 numbers a and b, the outcome of the comparison is stored in the PSR The outcome of a compare operation will allow the CPU to determine the following fact between a and b: The result of a comparison operation equal not equal less than less than or equal greater than greater than or equal

Operation of a CPU The CPU performs the following sequence of operations repeatedly: 1.After executing an instruction, the CPU obtains ("fetches") the (next) instruction at the address (location) given in the program counter 2.The fetched instruction is stored in the instruction register in the CPU and the program counter is increased to point to the next instruction in the memory 3.The fetched instruction (stored in the instruction register) is the executed (the CPU will do the operation indicated by the instruction code in the instruction register)

Operation of a CPU (cont.) Example: Supposed the CPU has just finished executing the instruction (instruction code 0) in the instruction register: (Instruction code 0 in the instruction register means "add" and it has just been executed)

Operation of a CPU (cont.) The following figures illustrates the CPU's execution cycle (that goes on indefinitely): The CPU will cause the memory to retrieve (recall) the value stored at memory address (location) 1 1. The CPU first sends a request to retrieve (recall) the data stored at memory location given by the program counter (PC) (in the figure, the value of the PC = 1):

Operation of a CPU (cont.) In response, the RAM memory sends the value stored in memory location 1 (= the number 4) to the CPU which stores it in the instruction register (IR): 2. In response, the RAM memory sends the value stored in memory location 1 (= the number 4) to the CPU which stores it in the instruction register (IR): This number (4) will be interpreted as a code for a computer instruction. The old instruction code (0) will be over-written by the new instruction code

3. The program counter is then increased: Notice that the CPU is now ready to fetch the next instruction when the current instruction (stored in the instruction register) is processed. Operation of a CPU (cont.)

4. The CPU will now execute the instruction in the program counter (instruction code = 4) When the CPU is finished, it will repeat these steps again (and again, until you turn the computer off)...

Pointers: pointing to a location in memory Pointer: A pointer is "something" that points to somewhere Examples: 3 pointers to different directions

In Computer Science, a pointer always points to a location in memory Examples: Pointers: pointing to a location in memory (cont.) Pointer to memory location 1Pointer to memory location 4

Pointers: pointing to a location in memory (cont.) The computer does not have "pointing finger" that point to some location in memory The pointer is represented in the computer by the value of the address (location) of the memory where the pointer is pointing at

Pointers: pointing to a location in memory (cont.) Examples: Pointer to memory location 1Pointer to memory location 4 Storing the value 1 in some register/memory cell will remember the memory location 1 The value 1 in the register/memory cell is effectively pointing to the memory location 1 Storing the value 4 in some register/memory cell will remember the memory location 4 The value 4 in the register/memory cell is effectively pointing to the memory location 4

Example of a pointer: the program counter (PC) The program counter (PC) is in fact a pointer Example When the program counter (PC) contains the value 1: the program counter (PC) is in fact pointing to the memory location 1:

Overview Logical (functional) view of a computer Program flow Types of instructions that a computer can execute

Program flow Definition: program flow Default program flow: Program flow = the sequence of instructions from the program executed by the CPU After executing a non-branching (or non-jumping) instruction at memory location n, then next instruction that is executed is the instruction at memory location n+1

Program flow (cont.) Example: All of the instructions in the figure are non-branching Therefore, the sequence of instructions executed by the CPU starting at memory location 0 is: 1. 0 ("add") 2. 4 ("compare") 3. 1 ("subtract") 4. And so on (in sequence)

Branching: changing the program flow Branch instruction: A branch instruction can alter (change) the default program flow When the CPU executes a branch x instruction, the next instruction that will be executed by the CPU is the instruction at memory location x

Branching: changing the program flow (cont.) Example: Notice there is a branch to location 4 instruction in the example. Therefore, the sequence of instructions executed by the CPU starting at memory location 0 is: 1. 0 ("add") ("branch to location 4") ("negate" --- this is the instruction at memory location 4) 4. 0 ("add") 5. And so on (in sequence again)

Overview Logical (functional) view of a computer Program flow Types of instructions that a computer can execute

The types of instructions that a computer can execute The computer is a computing (reckoning) machine All existing computers (actually the CPU) execute the following 3 types of instructions: Arithmetic and logic operations The result of an arithmetic and logic operation is often stored in a general purpose register + − × / AND OR NOT

The types of instructions that a computer can execute (cont.) Memory transfer operations Transfer the content from some specific memory location to a specific register (memory cell) in the CPU. and vice versa (transfer the content from some specific register (memory cell) in the CPU to some specific memory location).

The types of instructions that a computer can execute (cont.) Branch operations A branch instruction will cause the CPU to branch (jump) to the specified location in memory After the jump has occurred, the CPU will continue to execute the instructions in sequence, until another branch/jump instruction is encountered There are 2 kinds of branch operations: 1.A unconditional branch instruction will always cause the CPU to jump to the target location 2.A conditional branch instruction will only cause the CPU to jump to the target location when the specified condition is met