6. Program Translation CS100: The World of Computing John Dougherty Haverford College.

Slides:



Advertisements
Similar presentations
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Advertisements

 Suppose for a moment that you were asked to perform a task and were given the following list of instructions to perform:
CSI 3125, Preliminaries, page 1 Programming languages and the process of programming –Programming means more than coding. –Why study programming languages?
CS105 INTRODUCTION TO COMPUTER CONCEPTS INTRO TO PROGRAMMING Instructor: Cuong (Charlie) Pham.
The Binary Machine Modern high-level programming languages are designed to make programming easier. On the other end, the low level, all modern digital.
PLLab, NTHU Cs2403 Programming Languages Implementation Issues Cs2403 Programming Language Spring 2005 Kun-Yuan Hsieh.
The Analytical Engine Module 6 Program Translation.
Computer Concepts 5th Edition Parsons/Oja Page 546 CHAPTER 11 Software Engineering Section A PARSONS/OJA Computer Programming.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Compiler Design Lexical Analysis Syntactical Analysis Semantic Analysis Optimization Code Generation.
Chapter 8 High-Level Programming Languages Nell Dale John Lewis.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
Introduction and Syntax. Course objectives Discuss features of programming languages. Discuss how the features are implemented in a simple computer architecture.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
1 Programming Languages Examples: C, Java, HTML, Haskell, Prolog, SAS Also known as formal languages Completely described and rigidly governed by formal.
1 CS101 Introduction to Computing Lecture 19 Programming Languages.
CS 331, Principles of Programming Languages Introduction.
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Building Applications.
Programming Languages Lecture 12. What is Programming?  The process of telling the computer what to do  Also known as coding.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.
Introduction to Programming Language CS105 Programming Language First-generation: Machine language Second-generation: Assembly language Third-generation:
1 Software Development Topic 2 Software Development Languages and Environments.
High-Level Programming Languages: C++
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
COP4020 Programming Languages
Programming Language Rico Yu. Levels of Programming Languages 1.Low level languages 2.High level languages.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
CS101 Introduction to Computing Lecture Programming Languages.
Computer Systems Organization CS 1428 Foundations of Computer Science.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 2.
Chapter 1 Introduction to Computers and C++ Programming Goals: To introduce the fundamental hardware and software components of a computer system To introduce.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
CS 1308 Computer Literacy and The Internet Software.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 1- 1 October 20, October 20, 2015October 20, 2015October 20,
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
Chapter 6 Programming Languages (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
1 Programming Languages Fundamentals Cao Hoaøng Truï Khoa Coâng Ngheä Thoâng Tin Ñaïi Hoïc Baùch Khoa TP. HCM.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
PROGRAMMING LANGUAGES
1 Text Reference: Warford. 2 Computer Architecture: The design of those aspects of a computer which are visible to the programmer. Architecture Organization.
Overview of Previous Lesson(s) Over View  A program must be translated into a form in which it can be executed by a computer.  The software systems.
Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.
Programming Languages
Instructions. Portability In addition to making hardware backward compatible, we have also made software portable. In describing software, “portable”
CS 331, Principles of Programming Languages Chapter 1.
Assembly Language Friday, Week 5 Monday, Week 6. Assembly Language  Set of mnemonic names for the instructions in a particular computer's machine language.
FOUNDATION IN INFORMATION TECHNOLOGY (CS-T-101) TOPIC : INFORMATION SYSTEM – SOFTWARE.
Introduction 1 (Read Chap. 1) What is Programming? For some given problem: design a solution for it -- identify, organize & store the problem's data --
Chapter 4 Software. Chapter 4: Software Generations of Languages Each computer is wired to perform certain operations in response to an instruction. An.
Introduction to programming Carl Smith National Certificate Year 2 – Unit 4.
Programming Languages
Programming and Languages Dept. of Computer and Information Science IUPUI.
Programming Language Concepts (CIS 635) Elsa L Gunter 4303 GITC NJIT,
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Software Engineering Algorithms, Compilers, & Lifecycle.
Programming Languages Salihu Ibrahim Dasuki (PhD) CSC102 INTRODUCTION TO COMPUTER SCIENCE.
a medium allowing humans and computers to communicate an abstraction of the real world a notation for expressing algorithms the set of all syntactically.
Introduction to computer software. Programming the computer Program, is a sequence of instructions, written to perform a specified task on a computer.
Component 1.6.
Operating System Interface between a user and the computer hardware
Introduction to Programming
Developing Applications
CS105 Introduction to Computer Concepts Intro to programming
High Level Programming Languages
CS105 Introduction to Computer Concepts Intro to programming
Presentation transcript:

6. Program Translation CS100: The World of Computing John Dougherty Haverford College

Overview  The Problem  The “Source” – high-level code  The Target – low-level (machine) code  Types of translation  The translation algorithm/process  PIPPIN

The Problem  People communication in ambiguous, high- level languages, using experience, context, and can ask for clarity interactively e.g., Thoreau threw through the tunnel.  Machines have no “sense” of context or experience, and need unambiguous instructions

The Source  High-level programming languages close to natural language (but not quite) Alice, Javascript, C++, Java, C#  Known as Source code  Each instructions implies many lower-level instructions (as we’ll see …)

The Target  Low-level instructions that are clear and simple – typically fixed in size, with a command and some reference to data Opcode Operand  Known as … Machine code || binary code || executable

Program Translation  From High- to Low-Level  Recall “divide and conquer” in programming Input  Process  Output … then details of Process, then details of …  Typically many low-level operations per high-level instruction  From source code to machine/binary code  Two ways to translate …

Interpretation  Works with the source always  Translates and executes “on the fly”  Like a language translator at the UN  Easier to debug  Executes slower

Compilation  Works with executable  Translates the entire program from source to machine code once  Executes the machine code as many times as needed  Recompile often during development  Executes substantially faster  Most software is distributed (except open source)  Hides algorithm

Phases of Translation  Scanning – breaking text sequence into tokens (i.e., meaningful chunks) “ while ”, “ = ”, “ For all together ”  Parsing – organizing the tokens to discover the meaning of the program  Code Generation – writing the sequence of machine level operations Opcodes, operands

Language Levels  High-level: one-to-many relation to machine language (e.g., z = x + y is 4 PIPPIN ops)  Assembly language: one-to-one (roughly) relation to machine language (PIPPIN)  Low-level: machine, or binary, language of 0s and 1s

Arithmetic Instructions  To demonstrate this process, we’ll look at standard arithmetic expressions and statements in a high-level language  Expressions have a pattern, or (recursively- defined) form Var = exp Where exp = value | exp + exp | exp – exp | … (demonstration of Rosetta)Rosetta

PIPPIN instruction layout opcodeoperand Each box contains a byte

Sample PIPPIN Opcodes LOD (load from X) STO (store to X) HLT (halt execution) ADD (acc = acc + X)

Example PIPPIN program ; PIPPIN code for Z = X + Y [1]LOD X; acc <= X [2]ADD Y; acc <= acc + Y [3]STO Z; acc => Z [4]HLT; halt ;other examples AE pp

Programming Paradigms  Imperative: procedures as abstractions, details of how to do a task (e.g., FORTRAN, Pascal)  Functional: mathematical approach of input- process-return value – functions can be composed of other functions (including themselves), and can be evaluated (e.g., LISP)  Declarative: describe the information, but not the way it is processed (e.g., Prolog)  Object-Oriented: interacting objects (e.g., Java, C++, C#, Smalltalk, Javascript, Alice)