How does a computer works Hyoungshick Kim Department of Computer Science and Engineering College of Information and Communication Engineering Sungkyunkwan.

Slides:



Advertisements
Similar presentations
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Advertisements

Lecture 1: Overview of Computers & Programming
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
The Analytical Engine Module 6 Program Translation.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition by Tony Gaddis, Judy Walters,
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
CS102 Introduction to Computer Programming
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Why Program? Computer – programmable machine designed to follow instructions Program – instructions in computer memory to make it do something Programmer.
Chapter Introduction to Computers and Programming 1.
Introduction to Programming Dr Masitah Ghazali Programming Techniques I SCJ1013.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
1 Lecture 2 : Computer System and Programming. Computer? a programmable machine that  Receives input  Stores and manipulates data  Provides output.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Topics Introduction Hardware and Software How Computers Store Data
Computer Hardware and Software Chapter 1. Overview Brief History of Computers Hardware of a Computer Binary and Hexadecimal Numbers Compiling vs. Interpreting.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
MAC OS – Unit A Page: 10-11, Investigating Data Processing Understanding Memory.
Lecture 2 “Structure of computer” Informatics. Computer is  general purpose device that can be programmed to carry out a set of arithmetic or logical.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 1 Introduction to Computers and Programming.
Robert Crawford, MBA West Middle School.  Explain how the binary system is used by computers.  Describe how software is written and translated  Summarize.
1 Lecture 2 : Computer System and Programming. Computer? a programmable machine that  Receives input  Stores and manipulates data  Provides output.
What is Programming? A program is a list of instructions that is executed by a computer to accomplish a particular task. Creating those instructions is.
CS 127 Introduction to Computer Science. What is a computer?  “A machine that stores and manipulates information under the control of a changeable program”
CS 1428 Foundations of Computer Science I. Two Main Components  Hardware  Physical media that uses electrical current to process instructions.  Software.
Lecture 2 Programming life cycle. computer piano analogy Piano + player - computer hardware Musical score/notes - software or program Composer - programmer.
Ch 1 - Introduction to Computers and Programming Hardware Terminology Main Memory Auxiliary Memory Drives Writing Algorithms Using Pseudocode Programming.
1. COMPUTERS AND PROGRAMS Rocky K. C. Chang September 6, 2015 (Adapted from John Zelle’s slides)
Representation of Data - Instructions Start of the lesson: Open this PowerPoint from the A451 page – Representation of Data/ Instructions How confident.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
The purpose of a CPU is to process data Custom written software is created for a user to meet exact purpose Off the shelf software is developed by a software.
Information Technology (IT). Information Technology – technology used to create, store, exchange, and use information in its various forms (business data,
Chapter 1: Introduction to Computers and Programming
Topic 2: Hardware and Software
Java Programming: From the Ground Up
BASIC PROGRAMMING C SCP1103 (02)
Engineering Problem Solving With C An Object Based Approach
Topics Introduction Hardware and Software How Computers Store Data
CSCI-235 Micro-Computer Applications
BASIC PROGRAMMING C SCP1103 (02)
Overview of Computers and Programming Chapter 1
Chapter 1: Introduction to Computers and Programming
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
DDC 1023 – Programming Technique
Introduction
Computer System and Programming
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Chapter 1: Introduction to Computers and Programming
CS190/295 Programming in Python for Life Sciences: Lecture 1
Topics Introduction Hardware and Software How Computers Store Data
Topics Introduction Hardware and Software How Computers Store Data
Introduction to computers
The Study of Computer Science
Introduction to Computer Systems
Lecture 8 Programming Paradigm & Languages. Programming Languages The process of telling the computer what to do Also known as coding.
Computers, Programs, and Programming Languages
ICS103 Programming in C 1: Overview of Computers And Programming
Programming Logic and Design Eighth Edition
Chapter 1: Introduction to Computers and Programming
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

How does a computer works Hyoungshick Kim Department of Computer Science and Engineering College of Information and Communication Engineering Sungkyunkwan University Computer Programming for Engineers (2016 Spring)

Objectives In this course, you will learn about What computer is How a computer works

What is computer? (Discussion time)

Arduino Computer

Computer Computer = Hardware + Software Like piano and music “Hardware” refers to the physical parts of the computer (cf. “software” refers to the code that runs on the computer)

Computer Hardware

CPU CPU - Central Processing Unit The brains of the computers Performs simple operations e.g. Add two numbers Computer can run 2 billion operations per second Run button... code "runs" on the CPU

RAM RAM - Memory, Random Access Memory Temporary, working storage bytes RAM is "volatile", not "persistent",.. gone when power goes out

Persistent Storage Persistent storage  "Non volatile".. preserved when not powered Hard drive - stores bytes as a magnetic pattern on a spinning disk Flash drive - stores bytes as electrons in a chip  SD card, flash chips built into a phone or tablet Not to be confused with "Adobe Flash", a proprietary media format

Software Code that runs on the hardware CPU implements "machine code" instructions Each machine code instruction is extremely simple e.g. add 2 numbers e.g. compare 2 numbers

Machine Code A CPU understands a low level "machine code" language The language of the machine code is hardwired into the design of the CPU hardware Each family of compatible CPUs (e.g. the very popular Intel x86 family) has its own, idiosyncratic machine code which is not compatible with the machine code of other CPU families

What is a Program? What is Running? "Program" e.g. Firefox, millions of simple machine code instructions Machine code is particular to the type of CPU: Intel, ARM, etc. CPU runs a "fetch/execute cycle" fetch one instruction in sequence execute (run) that instruction, e.g. do the addition fetch the next instruction, and so on "loop" instruction: jump back 10 instructions Loops are implemented this way "if" instruction: skip ahead if a certain condition is true If statements are implemented this way

Running a Program How can we run a program (e.g. Firefox.exe)? Firefox.exe is just a file consisting of the bytes of millions of instructions (with about 4 bytes) 0. When we double click a program execution file …

Running Instructions The CPU runs instructions using a "fetch-execute" cycle: the CPU gets the first instruction in the sequence, executes it, then fetches the next instruction and executes it, and so on.

Syntax, Semantics and Program Translation It is extremely rare to write machine code by hand We write code in a more "high level" computer language with features that are more useful and powerful than the simple operations found in machine code Programming languages (called “artificial languages”) are languages just as “natural languages” such as English and Chinese. Syntax and Semantics are important concepts that apply to all languages. 15

Syntax The syntax of a language is a set of characters and the acceptable sequences (arrangements) of those characters. English, for example, includes the letters of the alphabet, punctuation, and properly spelled words and sentences. The following is a syntactically correct sentence in English, “what time is it now?” The following, however, is not syntactically correct, “what tyme is it now?” The sequence of letters “tyme” is not a word in the English language.

Semantics The semantics of a language is the meaning associated with each syntactically correct sequence of characters. Consider the following sentence: “A silent noise drinks stones.” This sentence is syntactically correct, but has no meaning. Thus, it is semantically incorrect. Every language has its own syntax and semantics.

Syntax Errors vs. Semantic Errors Program debugging is the process of finding and correcting errors (“bugs”) in a computer program. Syntax errors are caused by invalid syntax. (for example, entering prnt instead of print). Since a translator (compiler or interpreter) can detect syntax errors (e.g. prnt), translators terminate and indicate where the error occurred.

In contrast, semantic errors are errors in program logic. Such errors cannot be automatically detected, because translators cannot understand the original intention. For example, if a program computes the average of five numbers ; ( ) / 4 The divisor should be 5 and not 4, but translators do not understand what a programmer is meant to do. => It is up to the programmer to detect such errors. Program debugging is not a trivial task, and consumes much of the time of program developments.

Program Translation A central processing unit (CPU) is designed to interpret and execute a specific set of instructions represented in binary form (i.e., 1s and 0s) called machine code. Only machine code can be executed by a CPU. 20

Compiler "Compiler" looks at the source code Compiler translates the source code into a large number of machine code instructions e.g. Firefox -- written in C++ Compiler takes in Firefox C++ source code, produces Firefox.exe The end user does not need to the source code or the compiler. Distribute the program.exe file in working form Does not work backwards -- having the.exe, you cannot recover the source code (well)

Visual Representation of Compiler The Compiler for the C++ language, (1) reads that C++ code and (2) translates and expands it to a larger sequence of the machine code instructions to implement the sequence of actions specified by the C++ code

Interpreter Interpreter is a program which "runs" other code e.g. web browsers includes a Javascript interpreter Browser "runs" bits of Javascript code in a web page, such as ours Interpreter looks at one line at a time The interpreter then does that action, in the moment Then proceeds to the next line

Interpreter vs Compiler The compiler translates source code to equivalent machine code The interpreter does the code, looking at each line and doing it See an example: // Javascript code a = 1; b = a + 2; Interpreter looks at a = 1;, does it Interpreter looks at b = a + 2;, does it

Interpreter vs Compiler Discuss their pros and cons

Questions?