CMSC 104, Lecture 061 Stored Programs A look at how programs are executed.

Slides:



Advertisements
Similar presentations
Chapter 2: Data Manipulation
Advertisements

Computer Architecture and the Fetch-Execute Cycle
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:
Computer Organization and Architecture
Processor System Architecture
The CPU Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches.
Room: E-3-31 Phone: Dr Masri Ayob TK 2123 COMPUTER ORGANISATION & ARCHITECTURE Lecture 5: CPU and Memory.
Processor Technology and Architecture
Chapter 5: Computer Systems Organization Invitation to Computer Science, Java Version, Third Edition.
Data Manipulation Computer System consists of the following parts:
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Computer Processing CSCE 110 J. Michael Moore.
Stored Program Concept: The Hardware View
Chapter 4 Processor Technology and Architecture. Chapter goals Describe CPU instruction and execution cycles Explain how primitive CPU instructions are.
Chapter 2.2 Machine Language.
J. Michael Moore Computer Processing CSCE 110. J. Michael Moore ProcessorInputOutput Memory Storage.
Overview von Neumann Model Components of a Computer Some Computer Organization Models The Computer Bus An Example Organization: The LC-3.
The von Neumann Model – Chapter 4 COMP 2620 Dr. James Money COMP
Computer Structure.
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.
Introduction to Computing Systems from bits & gates to C & beyond The Von Neumann Model Basic components Instruction processing.
Lecture #30 Page 1 ECE 4110– Sequential Logic Design Lecture #30 Agenda 1.von Neumann Stored Program Computer Architecture Announcements 1.N/A.
Week 2.  Understand what the processor is and what it does.  Execute basic LMC programs.  Understand how CPU characteristics affect performance.
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
Chapter 2 Data Manipulation Yonsei University 1 st Semester, 2015 Sanghyun Park.
Computer Science 101 Computer Systems Organization ALU, Control Unit, Instruction Set.
D75P 34 – HNC Computer Architecture
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Information Representation: Machine Instructions.
1.4 Representation of data in computer systems Instructions.
Computer Organization 1 Instruction Fetch and Execute.
CS 1308 Computer Literacy and the Internet. Objectives In this chapter, you will learn about:  The components of a computer system  Putting all the.
Dale & Lewis Chapter 5 Computing components
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
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.
Structure and Role of a Processor
Chapter 2 Data Manipulation © 2007 Pearson Addison-Wesley. All rights reserved.
1 Basic Processor Architecture. 2 Building Blocks of Processor Systems CPU.
Chapter 2 Data Manipulation © 2007 Pearson Addison-Wesley. All rights reserved.
The Processor & its components. The CPU The brain. Performs all major calculations. Controls and manages the operations of other components of the computer.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
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.
Control Unit Lecture 6.
Chapter 4 The Von Neumann Model
Computer Science 210 Computer Organization
Chapter 4 The Von Neumann Model
Computer Architecture
Chapter 4 The Von Neumann Model
The Processor and Machine Language
Chapter 4 The Von Neumann Model
Computer Science 210 Computer Organization
CS149D Elements of Computer Science
CSCE Fall 2013 Prof. Jennifer L. Welch.
The Von Neumann Model Basic components Instruction processing
Chapter 5: Computer Systems Organization
Computer Architecture
The Von Neumann Architecture Odds and Ends
CSCE Fall 2012 Prof. Jennifer L. Welch.
The Stored Program Computer
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.
Chapter 4 The Von Neumann Model
Presentation transcript:

CMSC 104, Lecture 061 Stored Programs A look at how programs are executed

CMSC 104, Lecture 062 The Central Processing Unit l The CPU is the computer’s mechanism for performing operations on data and coordinating the sequence of these operations. l The CPU consists of two main parts oThe Arithmetic Logic Unit - contains circuitry that performs operations oThe Control Unit - contains circuitry that coordinates the machine’s activities

CMSC 104, Lecture 063 Registers l Since the CPU is a separate device from main memory, it needs to have special memory cells to use as a temporary storage place to hold the data it will be working with. These memory cells within the CPU are called registers.

CMSC 104, Lecture 064 Control Unit & ALU jobs l The control unit is responsible for placing the data that’s needed in the registers, telling the ALU which registers are being used, and to turn on the correct circuitry in the ALU for the desired operation. l The ALU uses the data in the indicated registers to do the operation and places the result in the indicated register.

CMSC 104, Lecture 065 CPU - Main Memory Diagram Bus Central Processing Unit Main Memory Arithmetic Logic Unit Control Unit Registers The number of registers varies from machine to machine The number is a multiple of 2, typically 16 or 32.

CMSC 104, Lecture 066 Machine Instructions : Example 1 Add Two Numbers Stored in Memory 1)Get one value and put it in a register. 2)Get the other value and put it in a register. 3)Activate the addition circuitry with the registers used in steps 1 and 2 as inputs and another register designated to hold the result. 4)Store the result in memory. 5)Stop.

CMSC 104, Lecture 067 Machine Instructions Example 2 Division 1)LOAD a register with a value in memory 2)LOAD another register with another value in memory 3)If this second value is zero, jump to step 6. 4)Divide the contents of the first register by the contents of the second register and put the result in the accumulator 5)STORE the contents of the accumulator in memory 6)Stop.

CMSC 104, Lecture Categories of Machine Instructions l Data Transfer - Instructions that move data around (#s 1, 3, & 4 in example 1). oData isn’t really moved, which implies that the original location is left vacant. oData is actually copied from one place to another. The original is undisturbed. l Arithmetic/Logic - Instructions that tell the control unit to request an activity within the ALU (Arithmetic operations or Logical operations)

CMSC 104, Lecture Categories of Machine Instructions (con’t) l Control - Instructions that direct the execution of a program rather than manipulate data. oConditional Branch (Step 3 in example 2) - branch to a different step if a certain condition is true. oUnconditional branches or jumps - Example : Jump to step 25.

CMSC 104, Lecture 0610 The Stored Program l The idea that a program can be stored in main memory is generally credited to John Von Neumann. l In fact, modern computers are said to have Von Neumann architecture. l Many programs can be stored in memory. To execute the program we want its first instruction is fetched from memory.

CMSC 104, Lecture 0611 The Stored Program (con’t) l Remember that whether the program is written in a high-level language, like C, or in assembly language, it is transformed into machine language before the computer can use it. l Machine language is comprised of a series of individual instructions that are coded into 1’s and 0’s.

CMSC 104, Lecture 0612 Machine Language Instructions l Each machine language instruction is made up of two parts oThe opcode - a bit pattern (of 1’s and 0’s) that is a code for an operation, like LOAD, ADD, JUMP or STORE oThe operands - bit patterns that provide more information about the instruction. Example: If the opcode was for LOAD, the the operands would have to say what memory location was to be read and the register to place the value in.

CMSC 104, Lecture 0613 Program Execution l A computer follows a program stored in its memory by getting the instructions from memory and putting a copy of them in the control unit as they are needed. l There are two special purpose registers used for program execution: oInstruction register oProgram counter

CMSC 104, Lecture 0614 Instruction Register & Program Counter l The Instruction Register (IR) contains the instruction that is currently being executed. l The Program Counter (PC) contains the address of the next instruction in memory.

CMSC 104, Lecture 0615 Program Execution l The control unit performs its job by continually repeating what is called the machine cycle l The machine cycle consists of 3 steps: oFetch - gets the next instruction from memory oDecode - decodes the bit pattern in the instruction register oExecute - performs the action requested by the instruction in the instruction register

CMSC 104, Lecture 0616 Program vs Data l Many programs can be stored in the computer’s memory l We can start a program running by putting its starting address in the program counter. l Both data and programs are stored in memory, and remembering that they are both just a collection of 1’s and 0’s, if the address of data is put into the program counter, the machine will attempt to execute data. The likelihood is that it won’t get very far.

CMSC 104, Lecture 0617 Other ALU Operations l Arithmetic Instructions (already mentioned) l Logic Instructions o AND, OR and EXCLUSIVE OR are the logic instructions. oThey all take two operands and produce one result.

CMSC 104, Lecture 0618 Logical Operations l For all logical operations, we consider a 1 to be true and a 0 to be false. l Truth tables can be constructed for each of the logical operations and the contents of these truth tables can be considered the definitions of the operations. l With logical operations, unlike addition, each column’s result is independent of the results of its neighboring columns.

CMSC 104, Lecture 0619 Truth Tables l A truth table is a table of values for an operation. To construct a truth table for an operation, put all possible values of one variable across the top of the table and all possible values of a second variable down the left side of the table. l The upper left corner of the table is divided in two and should give the names of the variables being used.

CMSC 104, Lecture 0620 Truth Table for AND A B

CMSC 104, Lecture 0621 AND l We can see from the truth table for AND that the only way we can get a result of true is if both operands are true. l So A AND B is true if and only if A is true and B is also true.

CMSC 104, Lecture 0622 Truth Table for OR A B 1 1

CMSC 104, Lecture 0623 OR l We can see from the truth table for OR that the only way we can get a result of false is if both operands are false. l So A OR B is true, if A is true and B is also true, or if only A is true, or if only B is true. So either A or B needs to be true or both can be true.