Data Manipulation, part two Introduction to computer, 2 nd semester, 2010/2011 Mr.Nael Aburas Faculty of Information.

Slides:



Advertisements
Similar presentations
Chapter 2: Data Manipulation
Advertisements

Machine 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:
2.3) Example of program execution 1. instruction  B25 8 Op-code B means to change the value of the program counter if the contents of the indicated register.
Processor System Architecture
Computer Architecture and Data Manipulation Chapter 3.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Computer Science: An Overview Tenth Edition by J. Glenn Brookshear Chapter.
Computer Systems. Computer System Components Computer Networks.
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.
Chapter 9_2 Following Instructions: Principles of Computer Operation.
Chapter 2.2 Machine Language.
Operating system Part three Introduction to computer, 2nd semester, 2010/2011 Mr.Nael Aburas Faculty of Information.
Dale & Lewis Chapter 5 Computing components. Let’s design a computer Generic CPU with registers −Program counter (PC) – 5 bits (size of addresses) −Instruction.
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.
J. Michael Moore Computer Processing CSCE 110. J. Michael Moore ProcessorInputOutput Memory Storage.
Introduction to computer: executes instructions. Overview Topics discussed in this webnote: –Structure and operation of the CPU –Program flow –Types of.
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.
1 Programming in Machine Language SCSC 311 Spring 2011.
Computer Systems Organization CS 1428 Foundations of Computer Science.
Data manipulation, Part one Introduction to computer, 2nd semester, 2010/2011 Mr.Nael Aburas Faculty of Information.
Assembly Language A Brief Introduction. Unit Learning Goals CPU architecture. Basic Assembler Commands High level Programming  Assembler  Machine Language.
Islamic University Of Gaza, Nael Aburas Data Storage Introduction to computer, 2nd semester, 2010/2011 Mr.Nael Aburas
CS 111 – Sept. 15 Chapter 2 – Manipulating data by performing instructions “What is going on in the CPU?” Commitment: –Please read through section 2.3.
Chapter 2 Data Manipulation Yonsei University 1 st Semester, 2015 Sanghyun Park.
Important Concepts  Parts of the CPU  Arithmetic/Logic Unit  Control Unit  Registers  Program Counter  Instruction Register  Fetch/Decode/Execute.
Chapter 2 Data Manipulation © 2007 Pearson Addison-Wesley. All rights reserved.
Computer Science 101 Computer Systems Organization ALU, Control Unit, Instruction Set.
Chapter 2 Data Manipulation. © 2005 Pearson Addison-Wesley. All rights reserved 2-2 Chapter 2: Data Manipulation 2.1 Computer Architecture 2.2 Machine.
CMSC 150 PROGRAM EXECUTION CS 150: Wed 1 Feb 2012.
Lecture 7: 9/17/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Data Manipulation Brookshear, J.G. (2012) Computer Science: an Overview.
Chapter 2 Data Manipulation © 2007 Pearson Addison-Wesley. All rights reserved.
Dale & Lewis Chapter 5 Computing components
Chapter 2 Data Manipulation © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 2: Data Manipulation
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.
1 Sec (2.4) Arithmetic / logic instruction:. 2 Logical operations: Ex: XOR OR AND
Chapter 2 Data Manipulation © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 2 Data Manipulation © 2007 Pearson Addison-Wesley. All rights reserved.
27 October 2015 Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
© 2015 Pearson Education Limited 2015 Quiz in last 15 minutes Midterm 1 is next Sunday Assignment 1 due today at 4pm Assignment 2 will be up today; due.
Programming in Machine Language
Microcomputer Programming
The fetch-execute cycle
The Processor and Machine Language
Functional Units.
CS149D Elements of Computer Science
CSCE Fall 2013 Prof. Jennifer L. Welch.
The Von Neumann Model Basic components Instruction processing
MARIE: An Introduction to a Simple Computer
Chapter 2: Data Manipulation
CSCE Fall 2012 Prof. Jennifer L. Welch.
Chapter 2: Data Manipulation
Program Execution.
Objectives Describe common CPU components and their function: ALU Arithmetic Logic Unit), CU (Control Unit), Cache Explain the function of the CPU as.
Chapter 2: Data Manipulation
CS 111 – Sept. 16 Machine language examples Instruction execution
COMPUTER ARCHITECTURE
Sec (2.3) Program Execution.
Presentation transcript:

Data Manipulation, part two Introduction to computer, 2 nd semester, 2010/2011 Mr.Nael Aburas Faculty of Information Technology Islamic University of Gaza 1Islamic University Of Gaza, Nael Aburas

Program execution A computer follows a program stored in its memory by copying the instructions from a memory into the CPU as needed. To understand how the overall execution process takes place, it is necessary to consider two of the special purpose registers within the CPU: ◦ Instruction register ◦ Program counter 2Islamic University Of Gaza, Nael Aburas

Program execution  Instruction register contains the instruction that is currently being executed (current instruction)  Program counter contains the address of the next instruction to be executed. (next instruction) 3Islamic University Of Gaza, Nael Aburas

Machine cycle For every instruction, a processor repeats a set of basic operations, which comprise a machine cycle ◦ Fetch ◦ Decode ◦ execute 4Islamic University Of Gaza, Nael Aburas

The machine cycle 2-5 Islamic University Of Gaza, Nael Aburas

Fetch ◦ The CPU requests the main memory to provide it with the instruction that is stored at the address indicated by the program counter. ◦ The CPU places the instruction received form memory in its instruction register and then increments the program counter. ◦ The program counter will be ready for the next fetch. 6Islamic University Of Gaza, Nael Aburas

Decode & Execute Decode  Breaking the operand filed into its proper components based on the instruction's op- code.  The CPU then executes the instruction by activating the appropriate circuitry to perform the requested task.  Once the instruction in the instruction register has been executed, the CPU again begins the machine cycle with the fetch step 7Islamic University Of Gaza, Nael Aburas

Machine cycle  Sometimes Special case is the execution of a JUMP instruction. Example, figure 2.9, which means “JUMP to the instruction at address 58 if the contents of register 2 is the same as that of register 0.  If they contain different bit patterns, the execute step terminates and the next machine cycle begins.  If equal, the machine places the value 58 in its program counter during the execute step, then, then next fetch step finds 58 in the program counter, so the instruction at that address will be the next instruction to be fetched and executed. 8Islamic University Of Gaza, Nael Aburas

Figure 2.9 Decoding the instruction B Islamic University Of Gaza, Nael Aburas

Example of program execution The example that will be described bellow is about adding two values and store the result. First we need to store the program somewhere in the memory. Suppose that the program is stored in addresses, starting at address A0 (hexadecimal). We can cause the machine to execute it by placing the address (A0) of the first instruction in the program counter and starting the machine (Figure 2.10) 10Islamic University Of Gaza, Nael Aburas

Figure 2.10 The program from Figure 2.7 stored in main memory ready for execution 2-11 Islamic University Of Gaza, Nael Aburas

Example of program execution The CPU begins the fetch step by extracting the instruction stored in main memory at location A0 and plain it in the instruction register (Figure 2.11a). Notice that in the machine, instruction are 16 bits long. Thus the entire instruction to be fetched occupies the memory cells at both address A0 and A1, the CPU is designed to take this into account. 12Islamic University Of Gaza, Nael Aburas

Example of program execution The CPU then adds two to the program counter so that this register contains the address of the next instruction (Figure 2.11b). Next, the CPU decode “analyzes” the instruction in its instruction register and concludes that it is to load register 5 with the contents of the memory cell at address 6C. This load is performed during the execution step of the machine cycle, and then the CPU begins the next cycle. And so on. 13Islamic University Of Gaza, Nael Aburas

Figure 2.11 Performing the fetch step of the machine cycle 2-14 Islamic University Of Gaza, Nael Aburas

Figure 2.11 Performing the fetch step of the machine cycle (cont’d) 15Islamic University Of Gaza, Nael Aburas

Exercise 1 Suppose that the memory cells from address 00 to 05 in the machine described in appendix C contain the (hexadecimal) bit patterns given in the following table If we start the machine with its program counter containing 00, what bit pattern is in the memory cell whose address is hexadecimal 17 when the machine halts? Addresscontents C Islamic University Of Gaza, Nael Aburas

Exercise 2 Suppose that the memory cells from address B0 to B8 in the machine described in appendix C contain the (hexadecimal) bit patterns given in the following table If the program counter starts at B0, what bit pattern is in register number 3 after the first instruction has been executed? What bit pattern is in memory cell B8 when the halt instruction is executed? 17Islamic University Of Gaza, Nael Aburas

Exercise 2, (Cont’d) Addresscontents B013 B1B8 B2A3 B302 B433 B5B8 B6C0 B700 B80F 18Islamic University Of Gaza, Nael Aburas

Arithmetic/logic instructions As mentioned before, the arithmetic/logic group of instructions consists of instructions requesting arithmetic, logic, and shift operations 19Islamic University Of Gaza, Nael Aburas

Logic operations  We introduced the logic AND, OR, XOR in chapter1. these operations can be extended to operations that combine two strings of bits to produce a single output string.  Example: AND 20Islamic University Of Gaza, Nael Aburas

Logic operations One of the major uses of the AND operation is for placing 0s in one part of the bit pattern. For example: is the first operand of the AND operation. Without knowing the content of the second operand, we still can conclude that the four most significant bits of the result will be 0s, and the four least significant bits will be copy of that part of the second operand AND 21Islamic University Of Gaza, Nael Aburas

Logic operations This use of AND is an example of masking Mask: determine which part of the other operand will effect the result Example: the mask can be used to with the AND operation to force a 0 in the third bit from the high-order end of byte. The mask can be used with OR operation to force a 1 in that position. (OR is used for placing 1 in somewhere in the byte.), ( the OR operation can be used to duplicate a part of string while putting 1s in the no duplicated position “other part”) 22Islamic University Of Gaza, Nael Aburas

Logic operations A major use for XOR operation is in forming the complement of the byte. For example, the relation between the second operand and the result as following: XOR 23Islamic University Of Gaza, Nael Aburas

Exercise 3 Suppose you want to isolate the middle four bits of a byte by placing 0s in the other four bit without disturbing the middle four bits. What mask must you use together with what operation? 24Islamic University Of Gaza, Nael Aburas

Exercise 3, Answer The mask is , with the AND operation 25Islamic University Of Gaza, Nael Aburas

Exercise 4 Using the machine language of appendix C, write a program that places a 1 in the most significant bit of the memory cell whose address is A7without modifying the remaining bits in the cell. 26Islamic University Of Gaza, Nael Aburas

Exercise 4, Answer 12A7 (load register 2 with the content of memory cell A7) 2380 (load register 3 with the value 80) 7023 (OR register2 and 3 leaving the result in register 0) 30A7 (STORE contents of register 0 n memory cell A7) C000 (Halt) 27Islamic University Of Gaza, Nael Aburas

Rotation and shift operation The operations Rotation and sift provide a means for moving bits within a register These operations are classified by the direction of motion (right or left). 28Islamic University Of Gaza, Nael Aburas

Figure 2.12 Rotating the bit pattern 65 (hexadecimal) one bit to the right 29Islamic University Of Gaza, Nael Aburas

Rotation and shift operation Another technique is to discard the bit that falls of and always fill the hole with 0, the term logical shift is used to refer to this technique. 30Islamic University Of Gaza, Nael Aburas