ECE 103 Engineering Programming Chapter 5 Programming Languages Herbert G. Mayer, PSU CS Status 6/19/2015 Initial content copied verbatim from ECE 103.

Slides:



Advertisements
Similar presentations
Overview of Programming and Problem Solving ROBERT REAVES.
Advertisements

EEE226 MICROPROCESSORBY DR. ZAINI ABDUL HALIM School of Electrical & Electronic Engineering USM.
CS 161 Introduction to Programming and Problem Solving Chapter 6 Programming Development Environment Herbert G. Mayer, PSU Status 10/20/2014.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1.
Introduction to Computers and Programming - Class 1 1 Introduction to Computers and Programming Professor Avi Rosenfeld.
Chapter 1: An Overview of Computers and Programming Languages J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program.
Chapter Chapter Goals Describe the layers of a computer system Describe the concept of abstraction and its relationship to computing Describe.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
The Analytical Engine Module 6 Program Translation.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Computing Components 01/26/11. Announcements & Reminders Programs 1 due Friday, 9/2/11 What is my late policy? Proxy Codes for Labs  You should be able.
Introduction to Computers and Programming. Some definitions Algorithm: –A procedure for solving a problem –A sequence of discrete steps that defines such.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
1 Introduction to computers Overview l · Grading Policy »Cheating Rules (serious concern) »Examinations and Fixation of Timings »Quizzes »Homework Assignments.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
CIS 260 Computer Programming I in C Prof. Timothy Arndt.
Chapter 17 Microprocessor Fundamentals William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper.
The CPU The Central Presentation Unit Language Levels Fetch execute cycle Processor speed.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#1) By Dr. Syed Noman.
 2000 Prentice Hall, Inc. All rights reserved. 1 Introduction to Computers and C Programming Outline Introduction What Is a Computer? Computer Organization.
Chapter 1 The Big Picture Chapter Goals Describe the layers of a computer system Describe the concept of abstraction and its relationship to computing.
CS102 Introduction to Computer Programming
Chapter 01 Nell Dale & John Lewis.
Tools make jobs easier to do -A computer is a tool used by many professions A computer can do many different jobs because they are programmable - Machine.
CMPT 300: Operating Systems
1 Lecture 2 : Computer System and Programming. Computer? a programmable machine that  Receives input  Stores and manipulates data  Provides output.
An Introduction Chapter Chapter 1 Introduction2 Computer Systems  Programmable machines  Hardware + Software (program) HardwareProgram.
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
CS 1 •This is Computer Science 1. •Who is Professor Adams?
CISC105 General Computer Science Class 1 – 6/5/2006.
An Introduction to Computers August 12, 2008 Mrs. C. Furman.
Chapter 1 The Big Picture.
Computer Systems Organization CS 1428 Foundations of Computer Science.
1 Overview of Programming and Problem Solving Chapter 1.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Introduction Lecture 01.
Visual C++ Programming: Concepts and Projects
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
1 Lecture 2 : Computer System and Programming. Computer? a programmable machine that  Receives input  Stores and manipulates data  Provides output.
Computer Organization & Assembly Language © by DR. M. Amer.
Computing Systems & Programming ECE Fundamental Concepts Chapter 1 Engineering Problem Solving.
Beginning Snapshots Chapter 0. C++ An Introduction to Computing, 3rd ed. 2 Objectives Give an overview of computer science Show its breadth Provide context.
Programming in C++ Dale/Weems/Headington Chapter 1 Overview of Programming and Problem Solving.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
A.Abhari CPS1251 Topic 1: Introduction to Computers Computer Hardware Computer components Connecting Computers Computer Software Operating System (OS)
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,
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 2 Computer Organization.
CS 125 Lecture 2 Martin van Bommel. Hardware vs Software Hardware - physical components you can see and touch –e.g. processor, keyboard, disk drive Software.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
Chapter 1 An Overview of Computers and Programming Languages.
The Big Picture. My Story  Wrote great programs  Didn’t understand how they worked.
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Introduction to Computers and Computing.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Computer Operation. Binary Codes CPU operates in binary codes Representation of values in binary codes Instructions to CPU in binary codes Addresses in.
Hello world !!! ASCII representation of hello.c.
ECE 101 Exploring Electrical Engineering Chapter 9 Programming Development Environment Herbert G. Mayer, PSU Status 3/1/2016.
1 Chapter 1 Background Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Week 6 Dr. Muhammad Ayaz Intro. to Assembly Language.
1 The user’s view  A user is a person employing the computer to do useful work  Examples of useful work include spreadsheets word processing developing.
Java Programming: From the Ground Up
ECE 103 Engineering Programming Chapter 5 Programming Languages
Chapter 1: An Overview of Computers and Programming Languages
CSCI-235 Micro-Computer Applications
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
Introduction to Programming
Computer System and Programming
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
Computer Science I CSC 135.
Introduction to Computer Programming
A Level Computer Science Topic 5: Computer Architecture and Assembly
Presentation transcript:

ECE 103 Engineering Programming Chapter 5 Programming Languages Herbert G. Mayer, PSU CS Status 6/19/2015 Initial content copied verbatim from ECE 103 material developed by Professor Phillip PSU ECE

Syllabus What’s This Blue Code? Introduction Computer Architecture Overview Machine Language Assembly Language High-Level Language C Programming Language

2 What’s This? // Assume non-negative args. Should be ”unsigned” int fact( int arg ) { // fact if ( arg <= 1 ) { // fact(0) = fact(1) = 1 return 1; }else{ return fact( arg – 1 ) * arg; } //end if } //end fact int main( /* no params */ ) { // main printf( ”Factorial %d = %d\n”, 10, fact( 10 ) ); return 0; } //end main

3 Introduction What is a program?  Software that runs on an standard computer Word processor, database engine, web browser, video game, graphics package, simulator, etc.  Where else are programs found? Embedded – Microwave oven, engine controller, media player, thermostat, pacemaker, toy, etc. Electromechanical – Early computers (e.g. ENIAC) Mechanical – Jacquard loom (1801), Babbage analytical engine (1837) Biological – Instinctive and learned behaviors

4 What do programs do?  Perform “useful” computation or IO  Process information Input  Program  Output  Programs may require input (but not always) numeric or text input, sensor values, etc.  Programs may generate output (but not always) text, graphics, actions such as triggering devices

5 How are programs created? 1. Develop an algorithm for the solution in your head 2. Write a program via a computer file; textual Programming languages provide syntax for implementing algorithms on a computer Traditional approaches:  Machine language  Assembly language  High-level languages, generally machine- independent

6 Classic Computer Architecture Overview Simplified computer model: Main Memory (RAM, ROM) Auxiliary Storage (e.g., disk drives) Input (e.g., keyboard, mouse) Output (e.g., monitor, printer) Processor (CPU)

7 The processor executes the program's instructions. Registers (fast memory) Memory Interface Instruction Decoder To main memory The ALU (Arithmetic Logic Unit) performs basic arithmetic, logic, and comparison operations. ALU

8 Program instructions and data are stored in computer memory (e.g., RAM or sometimes ROM) Each memory location is assigned a unique address. Address : Stored Value v0v0 v1v1 v2v2 v3v3 : v 253 v 254 v 255

9 Example: Vintage CPU (1975) MOS 6502 Single core 8-bit data Memory  64 KB main  Registers: Accumulator (A) Index (X, Y) Processor Status (P) Stack Pointer (S) Program Counter (PC) Speed: 1 to 2 MHz Process: 8  m # of transistors: ~3500 Die Shot Pin-out

10 Example: Modern CPU (2013) Intel i Haswell Four cores 64-bit data Memory  4x256 KB L2 cache  8 MB L3 cache  32 GB main (3.2x10 7 KB)  Registers: 8 32-bit bit Integrated GPU Speed: 3.4 GHz (3400 MHz) Process: 22 nm (0.022  m) # of transistors: ~1.4 billion Die Shot Package

11 Machine Language Machine language (ML) is a set of very low-level instructions that directs a computer processor to perform specific elementary operations  Not to be confused with the programming language ML! Each CPU family has its own, unique ML Some families (Intel x86) have long life Deep expertise needed to write ML programs

12 How does a computer run ML programs? A machine language program consists of processor instructions and data that are stored in memory Example: 6502 CPU (start address = $600) e.g., A9 represents the CPU’s “Load Accumulator” instruction Address (hex) Stored Instruction or Data binaryhex A A D

13 The CPU’s program counter contains the address of the next instruction to execute Processor cycle:  Retrieve an instruction from memory  Decode the instruction  Act on the instruction  Increment the program counter Example: Visual CPU Simulator –

14 Assembly Language ML coding is tedious and error-prone, so more advanced languages were developed Assembly language programs (AL) use mnemonics (symbolic names and keywords) instead of binary digits AL programs are easier to write, understand, and modify than ML programs; but still tedious

15 Example: AL version of previous ML code 600: A9 5ALDA #$5A; Load accumulator with number 602: 18CLC; Clear carry flag 603: 69 20ADC #$20; Add $20 to accumulator w/carry 605: 8D 00 10STA $1000; Store accumulator at $1000 An assembler translates an assembly program to machine language Assembly language still requires a high level of programmer expertise Example: Easy 6502 –

16 High-Level Languages A high-level language (HLL) uses a more natural language approach to keywords and syntax A single HLL statement may be equivalent to many machine or assembly instructions Abstract algorithms are easier to implement in HLL It is easier to write, maintain, modify, and port programs using a high-level language; result: Higher productivity

17 Example: HLL version of previous ML code m = 0x5A + 0x20; /* Add hex $5A and $20 */ A compiler or interpreter translates a high-level program to machine code Many HLLs (several hundred) exist:  FORTRAN, COBOL, Lisp, BASIC, …  Pascal, C, C++, C#, Java, Python, … An HLL increases programmer productivity (again)!

18 The C Programming Language C was developed by Dennis Ritchie in the early 1970s for use on UNIX systems at Bell Labs C is a somewhat “high-level” language, because it supports structured programming practices C also is “low-level”, as it permits access to underlying computer hardware C is an international standard (ISO) C and the newer C++ are widely used in engineering, scientific, and business disciplines:  Efficient, good performance, portable

19 C Language Evolution 1969 to 1973 – C (Bell Labs initial development) 1978 – K&R C (Kernighan and Ritchie) 1989 – C89 (ANSI) 1990 – C90 (ISO) 1995 – C90 Normative Amendment 1 → "C95" 1999 – C99 (ISO) 2011 – C11 (ISO) ANSI C89 and ISO C90 are the same standard.