Introduction to Programming Part 2

Slides:



Advertisements
Similar presentations
Basic Computer Vocabulary
Advertisements

What is Hardware? Hardware is the physical parts of the computer system – the parts that you can touch and see. A motherboard, a CPU, a keyboard and a.
The Central Processing Unit: What Goes on Inside the Computer.
 2002 Prentice Hall Hardware Basics: Inside The Box Chapter 2.
ENGR2216 FORTRAN PROGRAMMING FOR ENGINEERS. Chapter 1 The computer CPU MEMORY INPUT/OUTPUT DEVICES DATA REPRESENTATION BINARY SYSTEM OCTAL & HEXADECIMAL.
Main Memory Lecture 2 CSCI 1405, CSCI 1301 Introduction to Computer Science Fall 2009.
Hardware Basics: Inside the Box 2  2001 Prentice Hall2.2 Chapter Outline “There is no invention – only discovery.” Thomas J. Watson, Sr. What Computers.
Chapter 0 Introduction to Computing
Introduction to Computers
1 Introduction to Computers Prof. Sokol Computer and Information Science Brooklyn College.
Computer Applications NCBS Stage 1. The Central Processing UnitSlide 2Computer Applications Stage 1 Course Content and Assessment Practical – 60% (2 Hrs.
Chapter 4 The Central Processing Unit: What goes on Inside the Computer.
Computer Systems CS208. Major Components of a Computer System Processor (CPU) Runs program instructions Main Memory Storage for running programs and current.
MIS 175 Spring Learning Objectives When you finish this chapter, you will: –Recognize major components of an electronic computer. –Understand how.
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510, Section 2.
Abstraction – Number Systems and Data Representation.
Georgia Institute of Technology Introduction to Programming Part 2 Barb Ericson Georgia Institute of Technology May 2006.
The Computer Systems By : Prabir Nandi Computer Instructor KV Lumding.
CPU (CENTRAL PROCESSING UNIT): processor chip (computer’s brain) found on the motherboard.
What is a Computer ? Computers are Electronic Machines that process (performs calculation and manipulation) Data under the control of Set of Instructions.
Chapter Two Hardware Basics: Inside the Box. ©1999 Addison Wesley Longman2.2 Chapter Outline What Computers Do A Bit About Bits The Computer’s Core: CPU.
1 BUSINESS TECHNOLOGY TODAY Chapter Two How ICT Works.
MAC OS – Unit A Page: 10-11, Investigating Data Processing Understanding Memory.
Lesson 2 — How Does A Computer Process Data?
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510.
Introduction to Computers
Introduction to Computers
1 Introduction to Computers Prof. Sokol Computer and Information Science Brooklyn College.
1 Introduction to Computers Lect 1 Won’t tell you much you don’t know. (Misleading– the course gets more conceptual as we create webpages.) Will go into.
Computer Parts. Two Basic Parts Hardware & Software.
Course ILT Basics of information technology Unit objectives Define “information technology” (IT), distinguish between hardware and software, and identify.
Computers Are Your Future Eleventh Edition Chapter 2: Inside the System Unit Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall1.
The Central Processing Unit: What Goes on Inside the Computer
Computer Organization & Assembly Language © by DR. M. Amer.
CSCI-100 Introduction to Computing Hardware Part I.
Introduction to Programming with Java AP Computer Science ASFA.
The Computer System CS 103: Computers and Application Software.
Computer Systems. Bits Computers represent information as patterns of bits A bit (binary digit) is either 0 or 1 –binary  “two states” true and false,
Chapter 2 Turning Data into Something You Can Use
1 Introduction to Computers Prof. Sokol Computer and Information Science Brooklyn College.
COMPUTER SYSTEM A computer system is define as combination of components designed to process data and store files. A computer system consists of four.
 A computer is an electronic device that receives data (input), processes data, stores data, and produces a result (output).  It performs only three.
Information Technology (IT). Information Technology – technology used to create, store, exchange, and use information in its various forms (business data,
The Study of Computer Science Chapter 0
APPENDIX A Hardware and Software Basics
Introduction to Programming with Java
Introduction Computer Hardware Jess 2006
Introduction to Programming Part 2
Topics Introduction Hardware and Software How Computers Store Data
UNIT 9 Computer architecture
Computer Hardware and Software
The Central Processing Unit
Introduction to Computer Architecture
The Study of Computer Science Chapter 0
TexPREP Summer Camp Computer Science
Introduction to Computers
The Study of Computer Science
A451: Computer Systems and Programming
Introduction to Computers
Topics Introduction Hardware and Software How Computers Store Data
Chapter 2: Computer Hardware
Unit One - Computing Fundamentals
The Study of Computer Science
Introduction to Java, and DrJava
Abstraction – Number Systems and Data Representation
Introduction to Java, and DrJava part 1
The Study of Computer Science Chapter 0
Computer components.
Presentation transcript:

Introduction to Programming Part 2 Barb Ericson Georgia Institute of Technology May 2006 Georgia Institute of Technology

Georgia Institute of Technology Learning Goals Understand at a conceptual level Why should you learn to program a computer? What are the parts of a computer? How does a computer execute a program? How are things stored in a computer? How much space do things take? Georgia Institute of Technology

Georgia Institute of Technology Why Learn to Program? The computer is the most amazingly creative device that humans have ever conceived of. If you can imagine it, you can make it “real” on a computer. Computers will continue to have a major impact on modern life Movies, games, business, healthcare, science, education, etc Computers are used to do animation and special effects in movies. Computer gaming is a growing industry. Computers are used throughout the business world. Computers are used to improve healthcare and reduce errors. Computers are used to do simulations and calculations in science. There is a computer on the Mars Rover that controls it. Georgia Institute of Technology

Computers Are Commonplace Computers, or at least processors, are in many common devices See http://electronics.howstuffworks.com/cell-phone7.htm for how cell phones work. Georgia Institute of Technology

Programming is Communicating Alan Perlis, “You think you know when you can learn, are more sure when you can write, even more when you can teach, but certain when you can program.” Georgia Institute of Technology

Georgia Institute of Technology Parts of a Computer User Interface monitor (screen), mouse, keyboard, printer Brain - Central Processing Unit can do math and logic operations Memory - Storage main - RAM secondary – Disks, CD-ROMs, DVDs See http://www.geocities.com/introduction2computers/ and http://www.fayette.k12.il.us/99/Intro2Comp/parts.html See http://www.webopedia.com/TERM/c/computer.html. See http://computer.howstuffworks.com/channel.htm?ch=computer&sub=sub-hardware for information on the hardware of a computer. Georgia Institute of Technology

CPU – Brain of the Computer Arithmetic/Logic Unit (ALU) Does math and logic calculations on numbers in registers Control Unit Reads instructions from memory and decodes and executes them using the ALU 345 Add register A to register B 263 608 Store the value in register C into memory location 320843202 All processing in a computer program happens in the CPU. See http://computer.howstuffworks.com/microprocessor.htm for a nice overview of microprocessors (CPUs). Numbers must be loaded into registers (high-speed storage areas) before they can be processed by the ALU. Georgia Institute of Technology

Fetch, Decode, Execute Cycle The control unit reads (fetches) an instruction from memory The control unit decodes the instruction and sets up the hardware to do the instruction like add the values in the A and B registers and put the result in the C register The instruction is executed The program counter is incremented to read the next instruction The program counter can also be changed to “Jump” to another instruction which means that the value in the program counter is changed See http://computer.howstuffworks.com/microprocessor3.htm for information on how microprocessors work. Georgia Institute of Technology

Play Computer Exercise Have one person be memory Have a set of instructions on index cards Have one person be the control unit Get the top index card from the memory Read each instruction to the class and tell the arithmetic/logic unit what to do When an instruction is finished discard it Have another person be the arithmetic/logic unit. This person should have a calculator and two pieces of paper (for register A and B) Do what the control unit tells you to do Say that we want to solve the problem of calculating the cost of a shirt that was 34.99 and is 40% off and you have a coupon for another 20% off the sale price. First card for the control unit says multiply 34.99 by 0.6 Decode this into telling the ALU to put 34.99 in register A and 0.6 into register B and then multiply them and put the result in register A The second card reads multiply register A by 0.8. Decode this into put 0.8 into register B. Multiply the values in register A and B and store the result in A. Move the result from register A to memory Tell memory to store the value at a location (like 0001). We need to first calculate the first sale price (60% of 34.99). One way to do this is to multiply 34.99 by 0.6. Of course you could have multiplied by 0.40 to get the amount of discount and then subtracted that from the original price. Take the result of the previous operation and multiple it by .8 (to get the additional 20% off). Georgia Institute of Technology

Georgia Institute of Technology Processor Speed Processors (CPUs) have a clock Clock speed is measured in megahertz (MHz) or gigahertz (GHz) Some instructions take just 2-3 clock cycles, some take more When the clock speed increases the computer can execute instructions faster See http://www.webopedia.com/quick_ref/processor.asp for a comparison of processor speeds for several common processors. One megahertz represents one million cycles per second. One gigahertz represents 1 billion cycles per second. Georgia Institute of Technology

Georgia Institute of Technology Memory Computer memory is used to store data The smallest unit of memory is a bit (Binary digIT) A bit can be off (no voltage) or on (has voltage) which we interpret to be 0 or 1 Memory is organized into 8 bit contiguous groups called bytes. A megabyte is 1 million bytes. A gigabyte is 1 billion bytes. See http://computer.howstuffworks.com/bytes1.htm. Georgia Institute of Technology

Georgia Institute of Technology Types of Memory Registers Very high speed temporary storage areas for use in the CPU Used for calculations and comparisons Cache High speed temporary storage for use with the CPU Main Memory – Random-access Memory (RAM) High speed temporary storage Contains programs and data currently being used Often described in Megabytes (MB) Secondary Memory - Disks Contains programs and data not currently being used Often described in Gigabytes (GB) Temporary storage loses the values stored in it after the power is turned off. A megabyte is more than a million bytes. A gigabyte is more than a billion bytes. See http://computer.howstuffworks.com/computer-memory.htm for more information on how memory works. Georgia Institute of Technology

Why are there so many types of memory? The faster memory is the more it costs So we reduce the cost by using small amounts of expensive memory (registers, cache, and RAM) and large amounts of cheaper memory (disks) Why do we need cache? Processors are very fast and need quick access to lots of data Cache provides quick access to data from RAM Georgia Institute of Technology

Georgia Institute of Technology Binary Exercise Challenge the students to count to more than 5 using just the fingers on one hand You have to count up by ones No counting by 10s The fingers can be up or down No in-between states Show the students how to do this using binary numbers. Each finger represents a power of two. Georgia Institute of Technology

How does Memory Represent Values? The different patterns of the on and off bits in a byte determine the value stored Numbers are stored using binary numbers 101 is 1 * 20 + 0 * 21 + 1 * 22 = 1 + 4 = 5 1010 is 0 * 20 + 1 * 21 + 0 * 22 + 1 * 23 = 2 + 8 = 10 Characters are internally represented as numbers Different numbers represent different characters There are several systems for assigning numbers to characters: ASCII, EBCDIC, and Unicode See http://www.webopedia.com/TERM/A/ASCII.html for information about ASCII. Most computers store text in ASCII. ASCII uses 7 or 8 bits to store characters. See http://www.webopedia.com/TERM/E/EBCDIC.html for information on EBCDIC. EBCDIC is used on IBM computers. See http://www.webopedia.com/TERM/U/Unicode.html for information on Unicode which is a 16 bit format that can represent Greek, Chinese and Japanese as well as English characters. Georgia Institute of Technology

Encode and Decode Exercise Use ASCII or UNICODE to write a secret message in decimal and then exchange it with another person See http://www.lookuptables.com/ for the decimal values for characters Georgia Institute of Technology

Encodings Make Computer Powerful Voltages are interpreted as numbers Numbers can be interpreted as characters Characters can be interpreted to be part of a link to Sun’s Java Site <a href=http://java.sun.com>Sun’s Java Site </a> A byte of memory might contain the values “off on off off off off off on” which we assign the binary numbers of “0100 0001” which is the encoding for the letter “a” in ASCII which could be part of a link to Sun’s Java web site. Each layer of encoding is handled by software. a 0100 0001 off on off off off off off on Georgia Institute of Technology

Georgia Institute of Technology Notepad Exercise Open notepad and type a sentence in it Save the file Check the size in bytes by leaving the cursor over the file name Now count the number of letters and spaces Try adding more text to the file and predict how much bigger it will be in bytes Notepad is using 8 bits per character or 1 byte per character to store letters, spaces, and punctuation. Look at the sizes of files on your computer. How many bytes do they have? Georgia Institute of Technology

Georgia Institute of Technology Summary Computers are commonplace and very important to modern life Programming is about communication Computers are made up of parts CPU – calculation and comparisons Memory – temp storage Disk – permanent storage Monitor – Display Keyboard and mouse – User input All data in a computer is stored in bits More data takes more bits Georgia Institute of Technology