Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 1 Introduction. Components of a Computer CPU (central processing unit) Executing instructions –Carrying out arithmetic and logical operations.

Similar presentations


Presentation on theme: "Chapter 1 Introduction. Components of a Computer CPU (central processing unit) Executing instructions –Carrying out arithmetic and logical operations."— Presentation transcript:

1 Chapter 1 Introduction

2 Components of a Computer CPU (central processing unit) Executing instructions –Carrying out arithmetic and logical operations (+, -, *, /, and, or, …) –Coordinating: Accessing memory (read, write), handling exceptions (divided by zero), …

3 Components of a Computer (cont.) Memory Storing and retrieving (writing and reading) information (instructions and data). RAM (random-access memory) –volatile Secondary storage –Hard disk, CD, USB –Non-volatile

4 Information in Memory Binary, 100110100010… A string of 0s and 1s can mean different things –A number (integer, floating-point) –An instruction (addition, load, store) In RISC, every piece of information (number or instruction) is 32 bits long.

5 Numbers in Memory Binary Converting decimal to binary –Integers 100 = 1*2^6 + 1*2^5 + 0*2^4 + 0*2^3 + 1*2^2 + 0*2^1 + 0*2^0 100 10 = 1100100 2

6 Converting decimal to binary –Fractions 2^0 2^(-1) 2^(-2) 2^(-3) 2^(-4) 2^(-5) 2^(-6) … 2* 0.1 0.2 0.4 0.8 1.6 1.2 0.4 … 0 0 0 0 1 1 0 … 1*10^(-1) = 1*2(-4) + 1*2^(-5) + 0*2^(-6) + … 1*10^(-1) = 1.10011001100…*2^(-4) 0.1 10 = 0.000110011001100… 2

7 Converting binary to decimal Integers 1100100 2 = 2^6 + 2^5 + 2^2 = 64 + 32 + 4 = 100 10 Fractions 1.10011 2 = 2^0 + 2^(-1) + 2^(-4) + 2^(-5) = 1 + 1/2 + 1/16 + 1/32 = 1.59375 10

8 Components of a Computer (cont.) I/O (input/output) devices –Keyboard, mouse –Monitor Communication links –Bus –Network

9 Algorithms Method for solving a problem using a computer Unambiguous (well-defined and precise) Executable (can be carried out) Finite (does not run on forever) An algorithm is language independent.

10 Program Implementation of an algorithm in a language (Java), so a computer can understand. Stored in a file (source file) extension to identify the language (hw1.java).

11 From Program to Machine Code Compiler: Translates a program (high-level language) into machine language (low- level). –Machine architecture dependent (Intel, sparc). –End result: Executable file (binary). Often object files are linked together to produce an executable.

12 From Program to Machine Code Interpreter –Translate a program into an intermediate language, independent of machine architecture. –Run an intermediate language program by an interpreter that implements the intermediate language on that machine. JVM (Java virtual machine) executes an intermediate language program on the underlying machine.

13 Program Errors Computers (hardware) are very rigid, cannot tolerate slightest errors: Missing “;” Misplaced spaces Upper case in place of lower case …

14 Programming Disciplines Design, design, design. Think logically, structure your program carefully, know exactly what each step is supposed to do, anticipate future changes. Your program is to be read and modified by others.

15 Programming Disciplines Consistent style –Comments –Indentations –Line breaks –Blank lines –Positions of “{“ and “}” Programming is a craftsmanship, requires skills and art.


Download ppt "Chapter 1 Introduction. Components of a Computer CPU (central processing unit) Executing instructions –Carrying out arithmetic and logical operations."

Similar presentations


Ads by Google