Introduction to Programming Instructor: Yong Tang Brookhaven National Laboratory Working on accelerator control 631-344-7022 (BNL Phone #)

Slides:



Advertisements
Similar presentations
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and.
Advertisements

ENGR2216 FORTRAN PROGRAMMING FOR ENGINEERS. Chapter 1 The computer CPU MEMORY INPUT/OUTPUT DEVICES DATA REPRESENTATION BINARY SYSTEM OCTAL & HEXADECIMAL.
 The central processing unit (CPU) interprets and executes instructions.  The “brains” of the computer.  The speed of the processor is how fast it.
The Binary Machine Modern high-level programming languages are designed to make programming easier. On the other end, the low level, all modern digital.
Data Representation Computer Organization &
Data Representation COE 205
Introduction to Computers and Programming. Some definitions Algorithm: –A procedure for solving a problem –A sequence of discrete steps that defines such.
Comp 1001 Introduction to Information Technology & Computer Architecture Wednesday 12-1Dr. Joe Carthy
Binary and Hexadecimal Numbers
Assembly Language for Intel-Based Computers, 4th Edition
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
1 Introduction Chapter 1 n What is Assembly Language? n Data Representation.
Chapter 1-C,D Computers and Digital Basics.
Binary and Decimal Numbers
Introduction to Information Technology
IT-101 Section 001 Lecture #4 Introduction to Information Technology.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#1) By Dr. Syed Noman.
Codes and number systems Introduction to Computer Yung-Yu Chuang with slides by Nisan & Schocken ( ) and Harris & Harris (DDCA)
Representing Information in Binary (Continued)
Communications Technology 2104 Mercedes Lahey. Bit 1. bit=From a shortening of the words “binary digit” 2. the basic unit of information for computers.
Assembly Language for Intel-Based Computers, 5th Edition
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
CS1430: Programming in C++ Section 2 Instructor: Qi Yang 213 Ullrich
Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and copy this slide show for your personal use, or for.
Computers Organization & Assembly Language
Some material taken from Assembly Language for x86 Processors by Kip Irvine © Pearson Education, 2010 Slides revised 2/2/2014 by Patrick Kelley.
Computer Systems Chapter 1 Pages Hardware-physical pieces Key hardware components in a computer system: The physical parts. – Central processing.
CSU0014 Assembly Languages Homepage: Textbook: Kip R. Irvine, Assembly Language for Intel-Based Computers,
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
Assembly Language for x86 Processors 7th Edition
MAC OS – Unit A Page: 10-11, Investigating Data Processing Understanding Memory.
An Introduction to Computers August 12, 2008 Mrs. C. Furman.
Chapter 1: Basic Concepts
Slide 1 Wednesday, October 07, 2015 Low Level Machine.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
Assembly Language for x86 Processors 7 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and copy this.
CPU Internal memory I/O interface circuit System bus
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
Computer Science Theory & Introduction Week 1 Lecture Material – F'13 Revision Doug Hogan Penn State University CMPSC 201 – C++ Programming for Engineers.
General Computer Stuff Hardware: physical parts of a computer: CPU, drives, etc. Software: Programs and Data A computer needs both to be useful.
Data Representation (in computer system). Data Representation How do computers represent data? b The computers are digital Recognize.
1 CS1430: Programming in C++ Section 2 Instructor: Qi Yang 213 Ullrich
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive.
Computer Organization and Assembly Languages 2007/11/10
COMP1070/2002/lec1/H.Melikian COMP1070 Lecture #2 Computers and Computer Languages Some terminology What is Software? Operating Systems.
 Computers are 2-state devices › Pulse – No pulse › On – Off  Represented by › 1 – 0  BINARY.
Binary a. express numbers in binary, binary-coded decimal (BCD), octal and hexadecimal;
Suffolk County Community College Mathematics and Computer Science Ammerman Campus CST 121Spring 2013 Section 151CRN: Computer Organization And System.
1 Chapter 1: Introduction Appendix A: Binary and Hexadecimal Tutorial Assembly Language for Intel-Based Computers, 3rd edition Kip R. Irvine.
 Human language : commonly used to express feeling and understand what other people expression.  Computer language : are a languages by which a user.
1 Chapter 1: Basic Concepts Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine 9/6/2003.
CSC235 Computer Organization & Assembly Language
Lec 3: Data Representation
Assembly Language for x86 Processors 6th Edition
Assembly Language (CSW 353)
3.1 Denary, Binary and Hexadecimal Number Systems
Data Representation Binary Numbers Binary Addition
Microprocessor and Assembly Language
Information Support and Services
Assembly Language for x86 Processors 6th Edition
Introduction to Computer Programming
Data Representation Numbers
Binary and Hexadecimal Numbers
Information Representation
Computer Organization and Assembly Language
All assignments and information is posted on web site
Binary System.
Information Technology Department
Presentation transcript:

Introduction to Programming Instructor: Yong Tang Brookhaven National Laboratory Working on accelerator control (BNL Phone #)

2 Text Book: Learning Processing by Daniel Shiffman Publisher: Morgan Kaufmann Introduction to Programming

3 Do we need to buy the text book? It is recommended that you buy the book. However, you can survive without it. Introduction to Programming

4 Supply: USB drives to save files and transfer data. Very cheap when they are on sale. About $1 per GB, or even less. Every one should have one or two. Introduction to Computing

5 Course Web Pages: www2.sunysuffolk.edu/tangy  Outline  Announcements  Slides  Projects  Data files for projects and exercises  Answers to some exercises Introduction to Programming

6 Attendance Policy  Attending classes is very important  Firm but flexible policy  If you can not attend a class, call or  Absences Grades Introduction to Computing

7 Grading Policy  Specified in the outline  In general, if one attends the classes, finishes lab work, exams and projects, one can pass the course  Pay attention to the attendance policy  Do not worry about grades, to learn something is more important Introduction to Computing

8 Objective  Learning computer programming. Please notice that the language processing is only a tool.  One should be able to write medium-size and relatively complex programs. Introduction to Programming

9 What are programs?  A program is a sequence of instructions written in computer languages to guide computers to perform tasks.  A computer follows the instructions exactly and precisely. --- an important observation of computer programming. Introduction to Programming

10 An example  To calculate the average of two numbers Input: get the two numbers Processing: calculate their average Output: display the result Introduction to Programming

11 Programming Languages  Programming Language analogy: Each computer has a native machine language (language L0) that runs directly on its hardware A more human-friendly language is usually constructed above machine language, called Language L1 Introduction to Programming

12 Programming Languages  Programming Language analogy: Each computer has a native machine language (language L0) that runs directly on its hardware A more human-friendly language is usually constructed above machine language, called Language L1 Introduction to Programming

13 Programming Languages  Programming Language analogy (Cont.) Programs written in L1 can run two different ways: Interpretation – L0 program interprets and executes L1 instructions one by one Translation – L1 program is completely translated into an L0 program, which then runs on the computer hardware Introduction to Programming

14 Programming languages  First generation: machine language: Consists of 0’s and 1’s The only language understood by computers Fast and efficient Very hard to program, read and understand. Used in the old times. Introduction to Programming

15 Programming languages  Second generation: assembly language: English words are used in a very cryptic way Needs an assembler to convert it to machine language Relatively fast and efficient Still hard to program, read and understand; but is doable. The core parts of OS’s are usually coded in assembly language Different hardware (CPUs) has different assemblers Introduction to Programming

16 Programming languages  Third generation: high level language: C, C++, Java, C#,VB, Fortran,… English-like language Developing programs by writing source code Source code (compiler or interpreter)  assembly language (assembler)  machine language Still fast and efficient for most tasks Relatively easy to program, read and understand Portable to almost all platforms. Introduction to Programming

Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Translating Languages English: Display the sum of A times B plus C. C++: cout << (A * B + C); Assembly Language: mov eax,A mul B add eax,C call WriteIn t Intel Machine Language: A F E

Specific Machine Levels

19 Compiler and Interpreter  Compiler converts the whole program from source code to machine code, generates an executable program. Source files  object files (.obj) A linker links all the object files and library functions  an executable program (.exe)  Interpreter converts the source code one line/block at a time and execute it. Advantage: easy to develop and debug the program Disadvantage: slow Introduction to Programming

20 Write a fast program  The slowest part of a program is I/O: Reduce I/O times as much as possible Use buffers to do I/O  A fast computer make a program running fast:  Fast CPU (32-bit vs. 64-bit)  Big memory (32-bit machine can access only 3.7 Gb)  Good video card if you like to play fast games Introduction to Programming

Units of Memory and Storage  Computer understands 0 and 1 only: on/off state, N/S pole, 0/5 volts…  1 (“on”) and 0 (“off”) are referred to as bits.  Eight bits is a byte. Two bytes represent a unique character (Unicode)

Units of Memory and Storage  Kilobyte (KB) = one thousand (1024) bytes  Megabyte (MB) = one million (1024 KB) bytes  Gigabyte (GB) = one billion bytes  Terabyte (TB) = one trillion bytes

Data Representations  Everything is a number in the computer memory or on storages Numbers  numbers Characters  numbers by ASCII Grey  numbers (0-255) Color  three numbers (R/G/B)

Data Representations  Every English character is represented by an ASCII number.  ASCII codes are defined by ANSI.  Two bytes for a character (Unicode)

Data Representations  Decimal number: base ,1,2,…,9  Binary number: base ,1  Octal number: base ,1,2,…7  Hexadecimal number: base ,1,2,…9,A,B,C,D,E,F

Binary Numbers  Digits are 1 and 0 1 = true 0 = false  MSB – most significant bit  LSB – least significant bit  Bit numbering

Binary Numbers  Each digit (bit) is either 1 or 0  Each bit represents a power of 2: Every binary number is a sum of powers of 2

Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Translating Binary to Decimal Weighted positional notation shows how to calculate the decimal value of each binary bit: dec = (D n-1  2 n-1 )  (D n-2  2 n-2 ) ...  (D 1  2 1 )  (D 0  2 0 ) D = binary digit binary = decimal 9: (1  2 3 ) + (1  2 0 ) = 9

Binary Addition  Starting with the LSB, add each pair of digits, include the carry if present.

Integer Storage Sizes What is the largest unsigned integer that may be stored in 20 bits? Standard sizes:

Hexadecimal Integers Binary values are represented in hexadecimal.

Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Translating Binary to Hexadecimal Each hexadecimal digit corresponds to 4 binary bits. Example: Translate the binary integer to hexadecimal:

Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Converting Hexadecimal to Decimal  Multiply each digit by its corresponding power of 16: dec = (D 3  16 3 ) + (D 2  16 2 ) + (D 1  16 1 ) + (D 0  16 0 )  Hex 1234 equals (1  16 3 ) + (2  16 2 ) + (3  16 1 ) + (4  16 0 ), or decimal 4,660.  Hex 3BA4 equals (3  16 3 ) + (11 * 16 2 ) + (10  16 1 ) + (4  16 0 ), or decimal 15,268.

Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Character Storage  Character sets Standard ASCII(0 – 127) Extended ASCII (0 – 255) ANSI (0 – 255) Unicode (0 – 65,535)