Lesson Objectives Aims Key Words Compiler, interpreter, assembler

Slides:



Advertisements
Similar presentations
An Overview Of Virtual Machine Architectures Ross Rosemark.
Advertisements

GCSE Computing Lesson 5.
compilers and interpreters
8. Code Generation. Generate executable code for a target machine that is a faithful representation of the semantics of the source code Depends not only.
Reference Book: Modern Compiler Design by Grune, Bal, Jacobs and Langendoen Wiley 2000.
Compiled by Benjamin Muganzi 3.2 Functions and Purposes of Translators Computing 9691 Paper 3 1.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
High-level Languages.
1 Text Reference: Warford. 2 Computer Architecture: The design of those aspects of a computer which are visible to the programmer. Architecture Organization.
FOUNDATION IN INFORMATION TECHNOLOGY (CS-T-101) TOPIC : INFORMATION SYSTEM – SOFTWARE.
 Computer Languages Computer Languages  Machine Language Machine Language  Assembly Language Assembly Language  High Level Language High Level Language.
Computer Systems – Machine & Assembly code. Objectives Machine Code Assembly Language Op-code Operand Instruction Set.
Processor Fundamentals Assembly Language. Learning Objectives Show understanding of the relationship between assembly language and machine code, including.
Representation of Data Binary Representation of Instructions teachwithict.weebly.com.
Representation of Data - Instructions Start of the lesson: Open this PowerPoint from the A451 page – Representation of Data/ Instructions How confident.
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Programming Languages
F453 Module 8: Low Level Languages 8.1: Use of Computer Architecture.
Introduction to computer software. Programming the computer Program, is a sequence of instructions, written to perform a specified task on a computer.
A Single Intermediate Language That Supports Multiple Implemtntation of Exceptions Delvin Defoe Washington University in Saint Louis Department of Computer.
Chapter 1. Introduction.
Computer Basics.
Computer Systems Nat 5 Computing Science
Computer Applications in Business
COS341 Project 3 (2017): Executable Code for SPL
Why don’t programmers have to program in machine code?
Lecture 1b- Introduction
Component 1.6.
GCSE COMPUTER SCIENCE Computers 1.5 Assembly Language.
High or Low Level Programming Language? Justify your decision.
Chapter 1 Introduction.
Component 1.6.
Introduction to programming
Computational Thinking, Problem-solving and Programming: General Principals IB Computer Science.
Programming languages
Programming Language Hierarchy, Phases of a Java Program
Lesson Objectives Aims Key Words
F453 Computing Questions and Answers
Compiler Construction (CS-636)
Computer Systems Nat 5 Computing Science
Chapter 1 Introduction.
课程名 编译原理 Compiling Techniques
A451 Theory – 7 Programming 7A, B - Algorithms.
Chapter 3 Machine Language and Assembly Language.
Chapter 3 Machine Language and Assembly Language.
Teaching Computing to GCSE
CSCI/CMPE 3334 Systems Programming
TRANSLATORS AND IDEs Key Revision Points.
Teaching Computing to GCSE
Translators & Facilities of Languages
Programming Languages
High Level Programming Languages
CSc 453 Interpreters & Interpretation
Lesson Objectives Aims Understand how machine code is generated
CS105 Introduction to Computer Concepts Intro to programming
Programming Languages
Processor Fundamentals
Introduction to Computer Programming
Mastering Memory Modes
ICT Programming Lesson 1:
Mastering Translators and Compilers
CSC 253 Lecture 2.
Nat 4/5 Computing Science Translator Programs
Chapter 6 Programming the basic computer
Lecture 11 How assembler works
1.3.7 High- and low-level languages and their translators
Programming language translators
CSc 453 Interpreters & Interpretation
Presentation transcript:

Lesson Objectives Aims Key Words Compiler, interpreter, assembler To understand the differences between the three main types of translator: compiler, interpreter and assembler. Key Words Compiler, interpreter, assembler

Compilation Source Code (High Level) Compiler Executable (low level) Code runs on target system

Compile once – run many Works only on target system Self contained code (except system calls) Protects intellectual property (unless decompiled/reverse engineered/open source)

To port code: Must be re-compiled for another target Likely need to re-write (libraries, system calls etc) Code can be cross platform but: Executable will still only run on one system Redundant code

Interpreter Interpreter targeted at specific system Source Code Interpreter targeted at specific system Code runs on target system

Interpreters No executable produced - it translates each line of code into machine code, line by line. This means it can be platform independent code (the interpreter has to handle all the differences in system architecture) Machine code produced while the interpreter is running is not saved – code is re-generated every time it is run Used in some common languages including BASIC, Lisp, Prolog, Python, JavaScript. Code cannot be executed without an interpreter installed on the target system.

Advantages Disadvantages Source code is write once – run anywhere (on any computer with an interpreter.) You can easily inspect the contents of variables as the program is running. You can test code more efficiently as well as being able to test single lines of code. Code can be run on many different types of computers and OSs, such as Macs, PC, UNIX and LINUX. Disadvantages You must have an interpreter running on the computer in order to be able to run the program. An interpreter must be created for each individual computer architecture you want code to run on As source code must be compiled each time, interpreted programs can sometimes run slowly. You have to rely on the interpreter for machine-level optimisations rather than programming them yourself. Developers can view the source code, which means that they could use your intellectual property to develop their own software.

Virtual Machines There is a spanner in the works There are languages that are both compiled and interpreted Java. Why? Why do they do it?!

It’s another take on the interpreted idea. The compiler turns code into “byte code” which is an intermediary between source code and fully compiled code Funnily enough this code is called “intermediate code” The interpreter is then called a “virtual machine”

VM Method Source Code Compiler VM Code written in a given language Turns source into intermediate code This is not code that any real machine can run VM Understands the “generic” intermediate code instruction set Provides sandboxed environment Interprets intermediate code to generate machine code

Why? Compile on ANY platform Run on ANY platform (with the VM) Faster than pure interpreted languages

Assembler Assembly Language Source Code Assembler (Op Codes) Translator (binary) Executable (code runs on target)

An assembler is one step up from coding purely in machine code (0’s and 1’s (think MIT’s ALTAIR (one for the geeks))) Assembly language uses mnemonics to represent cpu instruction codes Each translates to a hexadecimal token and then a binary op code

Assembler matches directly to op codes Whereas a high level language will turn single instructions in to many different op codes (and depending on compiler, different methods to solve the same problem) Turning assembly code in to an executable is often called “assembling” rather than compiling

Nearly all machine code instructions are in two parts: Opcode Data The op code is the instruction, the data is, er, the data!

Each binary opcode is usually unique to a processor X86, X64, PPC, ARM etc may share instructions but not op codes This explains a LOT about why code for one system won’t work on another!

Assemblers make life a lot easier by providing: mnemonics Assemblers make life a lot easier by providing: Mnemonics ADD SUB MOV JMP Labels Automatic calculation of memory addresses for jumps and loops

And this used to be done by hand… Compiling Even though assembly is 1-1 instruction mapping it still takes work to compile a program First all labels are allocated memory addresses and a symbol table created Then the code is compiled, linked to the symbol table And this used to be done by hand…

Review/Success Criteria You should know: The difference between assembly, interpreters and compilers How software is turned from source code to executable