Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Intro to Computer Science I Chapter 1 Introduction to Computation Algorithms, Processors, and Programs.

Similar presentations


Presentation on theme: "1 Intro to Computer Science I Chapter 1 Introduction to Computation Algorithms, Processors, and Programs."— Presentation transcript:

1 1 Intro to Computer Science I Chapter 1 Introduction to Computation Algorithms, Processors, and Programs

2 BGA 2 Algorithm A sequence of unambiguous steps for accomplishing some task or process. In theory an algorithm can have an infinite number of steps but in practice algorithms must have a finite number of steps. Example: calculating requires an infinite number of steps (infinite non-repeating decimal expansion).

3 BGA 3 Finite Algorithm for

4 BGA 4 Processor Any device, calculator, computer, virtual machine, or human being that can process or execute an algorithm. Each type of processor understands a language (e.g., machine language) and algorithms must be expressed in this language in order for the processor to be able to execute them.

5 BGA 5 Memory words, addresses 11100111 00000110 01011101 10010010 01110111 10100000 0001100...000 0001100...001 0001100...010 0001100...011 0001100...100 0001100...101 Memory WordsAddressesMemory words contain data. Each memory word has an address which is used to locate this data. A common size for a word is 8 bits (byte). One or more bytes is required to store each data item (an integer for example) or machine language instruction.

6 BGA 6 Block diagram of a computer Main Memory Secondary Memory Input Devices Output Devices Registers Control Unit ALU

7 BGA 7 Program A representation of an algorithm as a sequence of instructions that can be understood and executed by a processor to complete the task, problem or process described by the algorithm. For a CPU the program is a sequence of machine language instructions stored in memory in binary form

8 BGA 8 Computer Languages Machine language (Lowest level) Assembly language mnemonic form of machine language High level language C, C++, Java Closer to the human level of problem solving

9 BGA 9 An addition problem Pseudo-code i6(assign 6 to i) j7(assign 7 to j) k511(assign 511 to k) sumi + j + k(assign sum to sum)

10 BGA 10 Machine Language (PC) Following string of 112 bits 1010 0001 0000 0000 0000 0000 0000 0011 0000 0110 0000 0000 0000 0010 0000 0011 0000 0110 0000 0000 0000 0100 1010 0011 0000 0000 0000 0110

11 BGA 11 Assembly language (PC) movax,i addax,j addax,k movsum,ax idw6 jdw7 kdw511 sumdw0

12 BGA 12 Java, C++ int i = 6 ; int j = 7 ; int k = 511 ; int sum = i + j + k ;

13 BGA 13 The compilation process High Level Language Program Source Code Machine Language Program Object Code Compiler The compiler translates the high level language source code program into a machine language object code program that can be understood by the computer's CPU.

14 BGA 14 The interpretation process High Level Language Program Source Code Statement The interpreter translates one statement at a time and has it executed by the CPU before returning to translate another statement Interpreter Back for next statement

15 BGA 15 The Java Virtual Machine Java Source Code Bytecode (class file) Java Compiler Bytecode (class file) Java Virtual Machine Real Machine Java Interpreter (a) (b)

16 BGA 16 Java translation example AssemblyBytecodeBytecode Language(hexadecimal)(binary) bipush 610 060001 0000 0000 0110 istore_13C0011 1100 bipush 710 070001 0000 0000 0111 istore_23D0011 1101 sipush 51111 01 FF0001 0001 0000 0001 1111 1111 istore_33E0011 1110 iload_11B0001 1011 iload_21C0001 1100 iadd600110 0000 iload_31D0001 1101 iadd600110 0000 istore 436 040011 0110 0000 0100


Download ppt "1 Intro to Computer Science I Chapter 1 Introduction to Computation Algorithms, Processors, and Programs."

Similar presentations


Ads by Google