Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS149D Elements of Computer Science

Similar presentations


Presentation on theme: "CS149D Elements of Computer Science"— Presentation transcript:

1 CS149D Elements of Computer Science
Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture 6: 9/12/2002 Lecture 6: 9/12/2002 CS149D Fall 2002

2 Outline Chapter 2 Data Manipulation Central Processing Unit
Machine Instructions Stored-Program Concept Program Execution Lecture 6: 9/12/2002 CS149D Fall 2002

3 Central Processing Unit1/2
CPU Consists of 2 parts: Arithmetic Logic Unit (ALU) & Control Unit Contains registers for temporary storage of information General-purpose registers Temporary holding places for data manipulated by CPU Special-purpose registers To perform an operation on data stored in main memory Control unit transfers data from memory into registers Inform ALU which registers hold data Activate appropriate circuitry within ALU to perform the desired operation Tell ALU which register should receive the results Lecture 6: 9/12/2002 CS149D Fall 2002

4 Central Processing Unit2/2
Memory Facilities available Registers (on CPU, hold operation operands) Cache (high speed memory faster than main memory) Often on CPU Exploit principle of locality Simply keep contents of most recently accessed memory locations Main memory Secondary memory (mass storage) Lecture 6: 9/12/2002 CS149D Fall 2002

5 CPU/Memory Interface Main Memory CPU bus Example of adding 2 values
Read data by supplying memory cell address Write data by supplying memory cell address Example of adding 2 values Get first value from memory and place in a register R1 Get second value from memory and place in another register R2 Activate addition circuitry with R1 and R2 as inputs and R3 to hold results Store contents of R3 (result) in memory Stop Lecture 6: 9/12/2002 CS149D Fall 2002

6 Machine Instructions1/2
Data transfer Movement of data from one location to another LOAD fill a register with contents of a memory cell STORE transfer contents of a register to a memory cell Arithmetic/Logic Arithmetic operations Logic operations AND, OR, XOR SHIFT, ROTATE Control direct execution of program JUMP direct control unit to execute an instruction other than the next one Unconditional Skip to step 5 Conditional If resulting value is 0, then skip to step 5 Lecture 6: 9/12/2002 CS149D Fall 2002

7 Machine Instructions2/2
Example for a conditional JUMP Division 1- LOAD a register R1 with a value from memory 2- LOAD register R2 with another value from memory 3- If contents of R2 is zero, JUMP to step 6 4- Divide contents of R1 by contents of R2, result stored in R3 5- STORE the content of R3 in memory 6- STOP Lecture 6: 9/12/2002 CS149D Fall 2002

8 Stored-Program Concept
Program (instructions) stored in memory instead of being built into the control unit as part of the machine A machine recognizes a bit pattern as representing a specific instruction Instruction consists of two parts Op-code (operation code) & operand(s) field(s) STORE operands would be Register containing data to be stored Address of memory cell to receive data Lecture 6: 9/12/2002 CS149D Fall 2002

9 A Sample Machine Architecture
CPU ALU register Program Counter Instruction Register 1 F Main Memory 00 01 02 FF 256 memory cells with a capacity of 8 bits each 16 general-purpose registers 2 special-purpose registers Bus Program Counter address of next instruction to be executed Instruction Register hold instruction being executed Lecture 6: 9/12/2002 CS149D Fall 2002

10 A Sample Machine Architecture
Instruction Format Instruction consists of 4 hex digits (2 bytes) Op-code Operand Fields LOAD register 3 with contents of the memory cell at address 4716 Textual representation might be “LOAD R3,47” B25816 JUMP to instruction at address 5816 if contents of register 2 is the same as register 0 Lecture 6: 9/12/2002 CS149D Fall 2002

11 Program Execution JUMP Instruction B25816 2. Decode 1.Fetch 3. Execute
Decode bit pattern in instruction register 1.Fetch Retrieve next instruction from memory (as per program counter) and then increment program counter 3. Execute Perform action requested by instruction in instruction register Machine cycle Lecture 6: 9/12/2002 CS149D Fall 2002


Download ppt "CS149D Elements of Computer Science"

Similar presentations


Ads by Google