Intel Assembler. Project administration. Non-standard project. Project administration: Repository
|
|
|
- Ruby Quinn
- 10 years ago
- Views:
Transcription
1 Lecture 14 Project, Assembler and Exam Source code Compiler phases and program representations Frontend Lexical analysis (scanning) Backend Immediate code generation Today Project Emma Söderberg Revised by Emma Söderberg on March 5, Based on slides by Görel Hedin and Lennart Andersson. Syntactic analysis (parsing) Semantic analysis Analysis Tokens AST Attributed AST Optimization Machine code generation Synthesis Intermediate code Intermediate code Machine code Intel assembler Exam Repetition Beyond.. EDA180: Compiler Construction F14-1 EDA180: Compiler Construction F14-2 Standard project Course Project Build a compiler for your language In teams of 2 persons. Prerequisites: Approved assignments Assignment supervisor may grant postponement Design a small procedural language: integer and boolean types variables, constants, expressions, statements,... block structure with nested procedures parameters, return values, recursion name analysis type analysis intermediate code generation assembly code generation EDA180: Compiler Construction F14-3 EDA180: Compiler Construction F14-4
2 Non-standard project Project administration Design a language of your choice. Must be accepted by project supervisor in advance. Should be approximately the same size as the standard project. Typical requirements: non-trivial grammar non-trivial name analysis significant semantic computations translation to some intermediate code translation to native code Estimated work load: 40 hours (20-80) Administration Report your project group to your assignment supervisor. Your assignment supervisor will be your project supervisor. Book a meeting with your supervisor. Three tasks: Design, Front end, Back end. Three deadlines: March 24, April 22, and May 6. (also on the course webpage) Project supervisors: Niklas Fors, [email protected]. Jesper Öqvist, [email protected]. EDA180: Compiler Construction F14-5 EDA180: Compiler Construction F14-6 Project administration: Repository Git (recommended): Private repository don t assist plagiarism. View the section on Cooperation or Plagiarism on the department web page. Note that this excludes GitHub. BitBucket: Private Git repositories Academic license Used by your supervisor Set up your own and give access to your supervisor. Subversion: We can set up a repository for you. Intel Assembler Generate assembler from ICode Tools: as, ld, gcc EDA180: Compiler Construction F14-7 EDA180: Compiler Construction F14-8
3 Intel 386/486/Pentium processor architecture Register structure Structure of the EAX register (bits): General-purpose registers: EAX, EBX, ECX, EDX, ESI, EDI ESP stack pointer EBP base pointer Instruction pointer: EIP Segment registers: ECS, EDS, EES, ESS Flags register: EFLAGS 32 bits used to store results of comparisons AH AL AX EAX AL,AH 8-bit registers. AX a 16-bit register. EAX extended AX to 32 bits. EBX, ECX, and EDX have the same structure. EDA180: Compiler Construction F14-9 EDA180: Compiler Construction F14-10 Program example Memory.data # allocating memory n:.long 234 # the number length:.long 0 # the result ten:.long 10 # the divisor.text # instructions.global _start # make _start globally known _start: movl $0, %ebx # use ebx as counter movl n, %eax # copy number to eax nextdigit: movl $0, %edx # prepare for long division idivl ten # divide combined edx:eax by 10 # quotient to eax addl $1, %ebx # add 1 to counter cmpl $0, %eax # compare eax to 0 jg nextdigit # jump if eax>0 movl %ebx, length # copy counter to memory Memory size: Every byte (b, 8 bits) has an address, 0, 1,... word (w, 16 bits) long (l, 32 bits) In the project: All variables reside on the stack. Memory for the stack is allocated by ld (default 2Mb). You will not need a.data segment! Variables may have predetermined locations in memory and be referred to by name. EDA180: Compiler Construction F14-11 EDA180: Compiler Construction F14-12
4 Useful operand forms Operand Refers to $1448 constant 1448 (base 10) nextdigit label address %eax value in eax (%ebp) value at address contained in ebp 4(%ebp) value at 4 bytes after address in ebp (%ebp,%eax,4) value at ebp+4*eax The last three forms refer to values in main memory. Useful instructions Instruction Operands Effect movl rmc32, rm32 rm32 rmc32 addl rmc32, rm32 rm32 rm32+rmc32 subl rmc32, rm32 rm32 rm32-rmc32 negl rm32 rm32 -rm32 idivl rm32 eax edx:eax/rm32 edx remainder notl rm32 rm32! rm32, bitwise, false = 0 andl rmc32, rm32 rm32 rm32 & rmc32, bitwise orl rmc32, rm32 rm32 rm32 rmc32, bitwise cmpl rmc32 1, rmc32 2 compare by computing rmc32 2 -rmc32 1 leal m32, r32 r32 address denoted by m32 Operand types: r register, m memory, c constant An instruction can have at most one memory (m) operand. EDA180: Compiler Construction F14-13 EDA180: Compiler Construction F14-14 Conditional and jump instructions The result of comparisons (compl) end up in the EFLAGS register and may be used by succeeding instructions. Condition codes (cc) set by the compl instruction: l le e ne g ge < = > Jumps may be conditional: jmp dest je dest jg dest jcc dest jump unconditionally jump if equal jump if greater jump if cc (conditional code) Other conditional instructions: setcc rm8 rm8 = cc? 1 : 0 cmovcc rm32, r32 r32 = rm32 if cc Stack instructions Instruction Operand Effect pushl rmc32 push value in rmc32 popl rm32 pop to rm32 Example: pushl %ebx Stack before: Stack after: value towards address 0 ebx value value EDA180: Compiler Construction F14-15 EDA180: Compiler Construction F14-16
5 Procedure calls C compiler conventions Instruction Operands Effect call c32 push return address and jump ret pop return address and jump int c32 interrupt to kernel Example: p: call p ret # will push address of next instruction # will pop address and jump Arguments are pushed on the stack in reverse order in the caller s activation record. Caller pops arguments after return. Callee must restore EBX, ESI, EDI, ESP, and EBP before returning. EAX is used for return values. EDA180: Compiler Construction F14-17 EDA180: Compiler Construction F14-18 Debugging assembler The ddd debugger (gdb): Step through program The Exam Inspect memory Inspect registers EDA180: Compiler Construction F14-19 EDA180: Compiler Construction F14-20
6 The exam Old exams Regular exam: Wednesday March 13, 8-13, Sparta:D. Next exam: Friday August 30, 8-13, Victoriastadion 1A. One week advance registration is required for the August exam. Allowed material at the exam: Manual page on JastAdd syntax. ICode reference. Dictionary between English and your native language. Bonus points from the seminar exercises: Are counted at both the above examination dates, but not next year. Prerequisites for writing the exam: Approved assignments. Assignment supervisor may grant postponement. See the course web site, but note that... from 2008 a slightly different intermediate code is used. in 2003 and earlier, a slightly different JastAdd notation was used. Now, walk-through of the exam from EDA180: Compiler Construction F14-21 EDA180: Compiler Construction F14-22 Exam: Problem 1 Lexical analysis Exam: Problem 2 Parsing According to the Java Language Specification, an identifier is an unlimited-length sequence of Java letters and Java digits, the first of which must be a Java letter. Assume that a Java letter is one of a z, A Z, and that a Java digit is one of 0 9. According to the Java code conventions a class identifier should start with a capital letter, a method name should start with a small letter, and all letters should be capital in a constant name. a. Specify regular expressions for class and method identifiers according to the Java code conventions. You may use [a-z], but not more complex ranges like [a-za-z], as a regular expression denoting the language of all strings with one character from the specified range. b. An identifier cannot have the same spelling as the null literal. Construct a DFA recognizing class and method identifiers according to the Java code conventions and the literal null with distinct final states. A qualified identifier in Java adheres to the grammar qualifiedid qualifiedid. qualifiedid qualifiedid ID where ID is an identifier token. a. This grammar is ambiguous. Provide a string that has two different parse trees and draw the trees. b. Construct an equivalent grammar on canonical form that is unambiguous. c. Consider the language of all strings generated by the first grammar followed by a $ token. Construct a canonical LL(1) grammar for this language and present the LL(1) table. d. Specify an equivalent EBNF grammar for the first grammar that is not recursive and requires just 1 token lookahead. EDA180: Compiler Construction F14-23 EDA180: Compiler Construction F14-24
7 Exam: Problem 3 Semantic analysis Consider the following fragment of an abstract grammar. ProcedureDecl ::= Type <ID> Parameters Stmt; abstract Stmt; Assignment: Stmt ::= <ID> Expr; IfStmt: Stmt ::= Expr Then:Stmt Else:Stmt; Return: Stmt ::= Expr; StmtList: Stmt ::= Stmt*; a. Every execution path through the procedure block must terminate with a return statement. Construct a.jadd file with a method that checks this. Note that the following concrete program should not generate an error message. integer fac(integer n) { if (n==0) { return 1; else { return n*fac(n-1); Exam: Problem 3 Semantic analysis b. Assume that there is a traversing visitor: class TraversingVisitor implements Visitor {... Object visit(ifstmt node, Object data) { node.getexpr().accept(this, data); node.getthen().accept(this, data); node.getelse().accept(this, data); return null;... Construct a subclass of this class that provides a method static int numberofreturns(proceduredecl node) that will return the number of return statements in the node argument. EDA180: Compiler Construction F14-25 EDA180: Compiler Construction F14-26 Exam: Problem 4 Code generation and run-time system Exam: Problem 4 Code generation and run-time system You are going to generate intermediate code for the printr procedure in void main() { int n; void printr(int k); { if (k >= 0) { printr(k-1); print(k); n = read(); printr(n); a. Introduce a Print instruction in ICode that can be used for the print statement in the example. You should specify the abstract and the context-free grammars. b. What code should be generated for printr? Assume the same activation record layout as in the lectures, i.e. header, local variables, and temporaries, and that arguments are pushed on the stack by the caller. You must not replace the recursive calls by iteration. You must use a labeling scheme that would avoid name clashes in more complex examples. c. Draw a diagram showing the stack of activation records just before k=0 is printed for the case that n=2. You should indicate where the dynamic and static links point and the values of variables, parameters, and temporaries. The static links should be correct even if they are not used in this example. EDA180: Compiler Construction F14-27 EDA180: Compiler Construction F14-28
8 F14: Machine code generation Repetition F14-F01 Overall knowledge about: Machine architecture with CPU, registers, and memory. EDA180: Compiler Construction F14-29 EDA180: Compiler Construction F14-30 F13: Optimization F12: Memory Management SSA form (Static Single Assignment) A powerful representation for optimization. Typical optimizations at the intermediate code level: Dominance analysis. Copy propagation. Constant propagation.... Typical optimizations at the machine code level: Register allocation. Instruction scheduling (to take advantage of pipelining). Overall knowledge: The difference between manual and automatic memory management. Terminology: fragmentation, memory leak, dangling pointer, compaction, root pointer,... Main ideas in the main algorithms: reference counting, mark-sweep, copying, generation-based, conservative, incremental,... Main benefits and drawbacks of the different algorithms. You don t have to: Memorize the details of the algorithms. EDA180: Compiler Construction F14-31 EDA180: Compiler Construction F14-32
9 F11: Intermediate Code F10: Run-time systems What different kinds of intermediate code are there? Why temporary variables are needed and how they are handled. Advantages of using intermediate code. Difference between intermediate code and machine code. Difference between a virtual machine and a real machine. Translate a program to ICode. How to implement code generation based on the AST. You don t have to: Memorize the details of ICode you may use the ICode reference on the exam. Terminology: activation record, stack, stack pointer, frame pointer, static link, dynamic link, return address, object, heap, heap pointer,... How procedure calls work, with parameter and return value transmission. How object creation works. How local and non-local variables in procedures are accessed. How different kinds of variables are accessed in an OO language. What v-tables are and how they are used in OO languages for method calls. Draw the execution state at a given point in a given program. EDA180: Compiler Construction F14-33 EDA180: Compiler Construction F14-34 F9: Attribute grammars F8: Name and type analysis You should understand: General idea. What is the difference between inherited and synthesized attributes? You should be able to: Compute values for synthesized and inherited attribute for a given attribute grammar. Make name analysis using synthesized and inherited attributes. Terminology: name analysis, type analysis, scope, block, homogeneous blocks, declaration-before-use, bindings, symbol table,... Different kinds of scope rules. The difference between IdDecls and IdUses. How to implement name analysis based on the AST. Typical kinds of errors that can occur during compilation, and what different compiler phases they are identified in. EDA180: Compiler Construction F14-35 EDA180: Compiler Construction F14-36
10 F7: LR parsing F6: AST computations, AOP, The visitor pattern You should understand: The principles for how an LR parser works, LR items. Why LR is more powerful than LL. Typical kinds of unambiguous grammars that can be handled by an LR parser but not by an LL parser. Shift and reduce actions. What is meant by a Shift/Reduce or Reduce/Reduce conflict? The Visitor pattern and how to use it. Intertype declarations (static Aspect-oriented programming) and how to use them. The benefits and drawbacks of these techniques, compared to each other and compared to writing tangled code. Implement various computations using Visitors and Intertype declarations, e.g., unparsing, metrics, interpretation, name analysis, type checking, computation of information needed for code generation,... EDA180: Compiler Construction F14-37 EDA180: Compiler Construction F14-38 F5: Nullable, First and Follow,... Abstract syntax trees F5: Nullable, First and Follow,... Abstract syntax trees The principles for how an LL parser works. Intuitive definitions: nullable, FIRST, FOLLOW. Construct the nullable, FIRST, and FOLLOW tables for any CFG. Construct the LL(1) table for a CFG. decide if a grammar is LL(1) or not. The difference between a parse tree and an abstract syntax tree. The difference between a CFG and an abstract grammar. How to design an object-oriented abstract grammar with good names. Write down an abstract grammar using the JastAdd notation. How to build ASTs using semantic actions. How to build the AST when an LL parser is used. You don t have to: Memorize the API for generated JastAdd classes you may use the JastAdd manual page on the exam. Memorize the JJTree way for building ASTs. EDA180: Compiler Construction F14-39 EDA180: Compiler Construction F14-40
11 F4: LL Parsing F4: LL Parsing The different names for LL parsing. How to implement an LL parser by hand using recursive procedures. Typical kinds of grammars that an LL(1) parser cannot accept. Given a CFG with some of these typical problems, construct an equivalent CFG that is LL(1). What is the difference between local lookahead and global lookahead? What the dangling else problem is and how to handle it in an LL parser generator. Why it is sometimes useful to extend a CFG by an EOF-rule, and how to do it. What is meant by ambiguous and unambiguous grammars. Given an ambiguous grammar for expressions, construct an equivalent unambiguous grammar (given associativity and precedence rules). Typical kinds of unambiguous grammars that cannot be handled by an LL(1) parser. When could such grammars be LL(k)? Construct equivalent grammars that are LL(1). EDA180: Compiler Construction F14-41 EDA180: Compiler Construction F14-42 F3: Context-free grammars and Parsing How to design a clear and simple CFG for a language (disregarding ambiguities, non-ll-ness, etc.). Terminology: terminals, nonterminals, productions, start symbol. The formal definition of a CFG, G = (N, T, P, S), and what it means. The different notation forms for CFGs. Given a grammar on EBNF form, how to construct an equivalent grammar on canonical form, and vice versa. What is meant by (leftmost/rightmost) derivation. Show that a string belongs to a given language REs. Typical notation for regular expressions. The difference between REs and CFGs. F2: Regular expressions and Scanning Typical kinds of tokens and non-tokens. How to define typical tokens and non-tokens using regular expressions. What typical ambiguities may occur for a set of token definitions? How can such ambiguities be resolved? What a finite automaton (FA) is. The difference between a deterministic and nondeterministic FA. How to translate an NFA to a DFA. How to implement a scanner based on FAs, including handling ambiguities between regular expressions. EDA180: Compiler Construction F14-43 EDA180: Compiler Construction F14-44
12 F1: Introduction The typical phases in a compiler. The typical representations of a program inside a compiler. The separation into analysis and synthesis. The separation into front end and back end. Typical applications of compiler construction techniques (in addition to the typical source-to-machine code compiler). Beyond.. Examples of compiler-related research: Development of programming editors textual and graphical. Evaluation of reference attributes incremental/parallel. Optimizing compilers for multiprocessors.... Examples of compiler-related Master s thesis projects: Extend the Java language Java 7, Lambda expressions... Develop IDE for the Modelica Language (Modelon/Ideon) Optimize the JModelica compiler (Modelon/Ideon)... Let us now if you are interested in a Master s thesis or PhD thesis project! EDA180: Compiler Construction F14-45 EDA180: Compiler Construction F14-46
Introduction. Compiler Design CSE 504. Overview. Programming problems are easier to solve in high-level languages
Introduction Compiler esign CSE 504 1 Overview 2 3 Phases of Translation ast modifled: Mon Jan 28 2013 at 17:19:57 EST Version: 1.5 23:45:54 2013/01/28 Compiled at 11:48 on 2015/01/28 Compiler esign Introduction
Assembly Language: Function Calls" Jennifer Rexford!
Assembly Language: Function Calls" Jennifer Rexford! 1 Goals of this Lecture" Function call problems:! Calling and returning! Passing parameters! Storing local variables! Handling registers without interference!
CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 20: Stack Frames 7 March 08
CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 20: Stack Frames 7 March 08 CS 412/413 Spring 2008 Introduction to Compilers 1 Where We Are Source code if (b == 0) a = b; Low-level IR code
How to make the computer understand? Lecture 15: Putting it all together. Example (Output assembly code) Example (input program) Anatomy of a Computer
How to make the computer understand? Fall 2005 Lecture 15: Putting it all together From parsing to code generation Write a program using a programming language Microprocessors talk in assembly language
Compiler Construction
Compiler Construction Regular expressions Scanning Görel Hedin Reviderad 2013 01 23.a 2013 Compiler Construction 2013 F02-1 Compiler overview source code lexical analysis tokens intermediate code generation
CSCI 3136 Principles of Programming Languages
CSCI 3136 Principles of Programming Languages Faculty of Computer Science Dalhousie University Winter 2013 CSCI 3136 Principles of Programming Languages Faculty of Computer Science Dalhousie University
Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) [email protected] http://www.mzahran.com
CSCI-UA.0201-003 Computer Systems Organization Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) [email protected] http://www.mzahran.com Some slides adapted (and slightly modified)
CS61: Systems Programing and Machine Organization
CS61: Systems Programing and Machine Organization Fall 2009 Section Notes for Week 2 (September 14 th - 18 th ) Topics to be covered: I. Binary Basics II. Signed Numbers III. Architecture Overview IV.
Instruction Set Architecture
CS:APP Chapter 4 Computer Architecture Instruction Set Architecture Randal E. Bryant adapted by Jason Fritts http://csapp.cs.cmu.edu CS:APP2e Hardware Architecture - using Y86 ISA For learning aspects
COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing
COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing The scanner (or lexical analyzer) of a compiler processes the source program, recognizing
Language Processing Systems
Language Processing Systems Evaluation Active sheets 10 % Exercise reports 30 % Midterm Exam 20 % Final Exam 40 % Contact Send e-mail to [email protected] Course materials at www.u-aizu.ac.jp/~hamada/education.html
Scanning and parsing. Topics. Announcements Pick a partner by Monday Makeup lecture will be on Monday August 29th at 3pm
Scanning and Parsing Announcements Pick a partner by Monday Makeup lecture will be on Monday August 29th at 3pm Today Outline of planned topics for course Overall structure of a compiler Lexical analysis
Machine-Level Programming II: Arithmetic & Control
Mellon Machine-Level Programming II: Arithmetic & Control 15-213 / 18-213: Introduction to Computer Systems 6 th Lecture, Jan 29, 2015 Instructors: Seth Copen Goldstein, Franz Franchetti, Greg Kesden 1
CS:APP Chapter 4 Computer Architecture Instruction Set Architecture. CS:APP2e
CS:APP Chapter 4 Computer Architecture Instruction Set Architecture CS:APP2e Instruction Set Architecture Assembly Language View Processor state Registers, memory, Instructions addl, pushl, ret, How instructions
If-Then-Else Problem (a motivating example for LR grammars)
If-Then-Else Problem (a motivating example for LR grammars) If x then y else z If a then if b then c else d this is analogous to a bracket notation when left brackets >= right brackets: [ [ ] ([ i ] j,
Programming Languages
Programming Languages In the beginning To use a computer, you needed to know how to program it. Today People no longer need to know how to program in order to use the computer. To see how this was accomplished,
X86-64 Architecture Guide
X86-64 Architecture Guide For the code-generation project, we shall expose you to a simplified version of the x86-64 platform. Example Consider the following Decaf program: class Program { int foo(int
Glossary of Object Oriented Terms
Appendix E Glossary of Object Oriented Terms abstract class: A class primarily intended to define an instance, but can not be instantiated without additional methods. abstract data type: An abstraction
Compilers. Introduction to Compilers. Lecture 1. Spring term. Mick O Donnell: [email protected] Alfonso Ortega: alfonso.ortega@uam.
Compilers Spring term Mick O Donnell: [email protected] Alfonso Ortega: [email protected] Lecture 1 to Compilers 1 Topic 1: What is a Compiler? 3 What is a Compiler? A compiler is a computer
C Compiler Targeting the Java Virtual Machine
C Compiler Targeting the Java Virtual Machine Jack Pien Senior Honors Thesis (Advisor: Javed A. Aslam) Dartmouth College Computer Science Technical Report PCS-TR98-334 May 30, 1998 Abstract One of the
Compiler Construction
Compiler Construction Lecture 1 - An Overview 2003 Robert M. Siegfried All rights reserved A few basic definitions Translate - v, a.to turn into one s own language or another. b. to transform or turn from
Semester Review. CSC 301, Fall 2015
Semester Review CSC 301, Fall 2015 Programming Language Classes There are many different programming language classes, but four classes or paradigms stand out:! Imperative Languages! assignment and iteration!
Return-oriented programming without returns
Faculty of Computer Science Institute for System Architecture, Operating Systems Group Return-oriented programming without urns S. Checkoway, L. Davi, A. Dmitrienko, A. Sadeghi, H. Shacham, M. Winandy
Machine Programming II: Instruc8ons
Machine Programming II: Instrucons Move instrucons, registers, and operands Complete addressing mode, address computaon (leal) Arithmec operaons (including some x6 6 instrucons) Condion codes Control,
A Tiny Guide to Programming in 32-bit x86 Assembly Language
CS308, Spring 1999 A Tiny Guide to Programming in 32-bit x86 Assembly Language by Adam Ferrari, [email protected] (with changes by Alan Batson, [email protected] and Mike Lack, [email protected])
Lecture 27 C and Assembly
Ananda Gunawardena Lecture 27 C and Assembly This is a quick introduction to working with x86 assembly. Some of the instructions and register names must be check for latest commands and register names.
Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)
Semantic Analysis Scoping (Readings 7.1,7.4,7.6) Static Dynamic Parameter passing methods (7.5) Building symbol tables (7.6) How to use them to find multiply-declared and undeclared variables Type checking
Advanced compiler construction. General course information. Teacher & assistant. Course goals. Evaluation. Grading scheme. Michel Schinz 2007 03 16
Advanced compiler construction Michel Schinz 2007 03 16 General course information Teacher & assistant Course goals Teacher: Michel Schinz [email protected] Assistant: Iulian Dragos INR 321, 368 64
Lecture 9. Semantic Analysis Scoping and Symbol Table
Lecture 9. Semantic Analysis Scoping and Symbol Table Wei Le 2015.10 Outline Semantic analysis Scoping The Role of Symbol Table Implementing a Symbol Table Semantic Analysis Parser builds abstract syntax
Design Patterns in Parsing
Abstract Axel T. Schreiner Department of Computer Science Rochester Institute of Technology 102 Lomb Memorial Drive Rochester NY 14623-5608 USA [email protected] Design Patterns in Parsing James E. Heliotis
Programming Language Pragmatics
Programming Language Pragmatics THIRD EDITION Michael L. Scott Department of Computer Science University of Rochester ^ШШШШШ AMSTERDAM BOSTON HEIDELBERG LONDON, '-*i» ЩЛ< ^ ' m H NEW YORK «OXFORD «PARIS»SAN
Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, 2014. School of Informatics University of Edinburgh [email protected].
Pushdown automata Informatics 2A: Lecture 9 Alex Simpson School of Informatics University of Edinburgh [email protected] 3 October, 2014 1 / 17 Recap of lecture 8 Context-free languages are defined by context-free
Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.
Code Generation I Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.7 Stack Machines A simple evaluation model No variables
Syntaktická analýza. Ján Šturc. Zima 208
Syntaktická analýza Ján Šturc Zima 208 Position of a Parser in the Compiler Model 2 The parser The task of the parser is to check syntax The syntax-directed translation stage in the compiler s front-end
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 7 Scanner Parser Project Wednesday, September 7 DUE: Wednesday, September 21 This
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Scanner-Parser Project Thursday, Feb 7 DUE: Wednesday, Feb 20, 9:00 pm This project
Computer Programming. Course Details An Introduction to Computational Tools. Prof. Mauro Gaspari: [email protected]
Computer Programming Course Details An Introduction to Computational Tools Prof. Mauro Gaspari: [email protected] Road map for today The skills that we would like you to acquire: to think like a computer
Context free grammars and predictive parsing
Context free grammars and predictive parsing Programming Language Concepts and Implementation Fall 2012, Lecture 6 Context free grammars Next week: LR parsing Describing programming language syntax Ambiguities
Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C
Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection
Static vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer
Lecture 10: Static Semantics Overview 1 Lexical analysis Produces tokens Detects & eliminates illegal tokens Parsing Produces trees Detects & eliminates ill-formed parse trees Static semantic analysis
1/20/2016 INTRODUCTION
INTRODUCTION 1 Programming languages have common concepts that are seen in all languages This course will discuss and illustrate these common concepts: Syntax Names Types Semantics Memory Management We
Semantic Analysis: Types and Type Checking
Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors
An Introduction to Assembly Programming with the ARM 32-bit Processor Family
An Introduction to Assembly Programming with the ARM 32-bit Processor Family G. Agosta Politecnico di Milano December 3, 2011 Contents 1 Introduction 1 1.1 Prerequisites............................. 2
CS143 Handout 08 Summer 2008 July 02, 2007 Bottom-Up Parsing
CS143 Handout 08 Summer 2008 July 02, 2007 Bottom-Up Parsing Handout written by Maggie Johnson and revised by Julie Zelenski. Bottom-up parsing As the name suggests, bottom-up parsing works in the opposite
Lecture Outline. Stack machines The MIPS assembly language. Code Generation (I)
Lecture Outline Code Generation (I) Stack machines The MIPS assembl language Adapted from Lectures b Profs. Ale Aiken and George Necula (UCB) A simple source language Stack- machine implementation of the
Hacking Techniques & Intrusion Detection. Ali Al-Shemery arabnix [at] gmail
Hacking Techniques & Intrusion Detection Ali Al-Shemery arabnix [at] gmail All materials is licensed under a Creative Commons Share Alike license http://creativecommonsorg/licenses/by-sa/30/ # whoami Ali
language 1 (source) compiler language 2 (target) Figure 1: Compiling a program
CS 2112 Lecture 27 Interpreters, compilers, and the Java Virtual Machine 1 May 2012 Lecturer: Andrew Myers 1 Interpreters vs. compilers There are two strategies for obtaining runnable code from a program
Compiler I: Syntax Analysis Human Thought
Course map Compiler I: Syntax Analysis Human Thought Abstract design Chapters 9, 12 H.L. Language & Operating Sys. Compiler Chapters 10-11 Virtual Machine Software hierarchy Translator Chapters 7-8 Assembly
1 The Java Virtual Machine
1 The Java Virtual Machine About the Spec Format This document describes the Java virtual machine and the instruction set. In this introduction, each component of the machine is briefly described. This
CHAPTER 6 TASK MANAGEMENT
CHAPTER 6 TASK MANAGEMENT This chapter describes the IA-32 architecture s task management facilities. These facilities are only available when the processor is running in protected mode. 6.1. TASK MANAGEMENT
Off-by-One exploitation tutorial
Off-by-One exploitation tutorial By Saif El-Sherei www.elsherei.com Introduction: I decided to get a bit more into Linux exploitation, so I thought it would be nice if I document this as a good friend
l C-Programming l A real computer language l Data Representation l Everything goes down to bits and bytes l Machine representation Language
198:211 Computer Architecture Topics: Processor Design Where are we now? C-Programming A real computer language Data Representation Everything goes down to bits and bytes Machine representation Language
Textual Modeling Languages
Textual Modeling Languages Slides 4-31 and 38-40 of this lecture are reused from the Model Engineering course at TU Vienna with the kind permission of Prof. Gerti Kappel (head of the Business Informatics
Compiler and Language Processing Tools
Compiler and Language Processing Tools Summer Term 2011 Prof. Dr. Arnd Poetzsch-Heffter Software Technology Group TU Kaiserslautern Prof. Dr. Arnd Poetzsch-Heffter Compilers 1 Outline 1. Language Processing
Intel 8086 architecture
Intel 8086 architecture Today we ll take a look at Intel s 8086, which is one of the oldest and yet most prevalent processor architectures around. We ll make many comparisons between the MIPS and 8086
Stack Allocation. Run-Time Data Structures. Static Structures
Run-Time Data Structures Stack Allocation Static Structures For static structures, a fixed address is used throughout execution. This is the oldest and simplest memory organization. In current compilers,
KITES TECHNOLOGY COURSE MODULE (C, C++, DS)
KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php [email protected] [email protected] Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL
2) Write in detail the issues in the design of code generator.
COMPUTER SCIENCE AND ENGINEERING VI SEM CSE Principles of Compiler Design Unit-IV Question and answers UNIT IV CODE GENERATION 9 Issues in the design of code generator The target machine Runtime Storage
Programming Languages
Programming Languages Programming languages bridge the gap between people and machines; for that matter, they also bridge the gap among people who would like to share algorithms in a way that immediately
COMPUTER SCIENCE. 1. Computer Fundamentals and Applications
COMPUTER SCIENCE 1. Computer Fundamentals and Applications (i)generation of Computers, PC Family of Computers, Different I/O devices;introduction to Operating System, Overview of different Operating Systems,
Technical paper review. Program visualization and explanation for novice C programmers by Matthew Heinsen Egan and Chris McDonald.
Technical paper review Program visualization and explanation for novice C programmers by Matthew Heinsen Egan and Chris McDonald Garvit Pahal Indian Institute of Technology, Kanpur October 28, 2014 Garvit
Faculty of Engineering Student Number:
Philadelphia University Student Name: Faculty of Engineering Student Number: Dept. of Computer Engineering Final Exam, First Semester: 2012/2013 Course Title: Microprocessors Date: 17/01//2013 Course No:
Sources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
Software Engineering and Service Design: courses in ITMO University
Software Engineering and Service Design: courses in ITMO University Igor Buzhinsky [email protected] Computer Technologies Department Department of Computer Science and Information Systems December
CA4003 - Compiler Construction
CA4003 - Compiler Construction David Sinclair Overview This module will cover the compilation process, reading and parsing a structured language, storing it in an appropriate data structure, analysing
64-Bit NASM Notes. Invoking 64-Bit NASM
64-Bit NASM Notes The transition from 32- to 64-bit architectures is no joke, as anyone who has wrestled with 32/64 bit incompatibilities will attest We note here some key differences between 32- and 64-bit
Computer Organization and Architecture
Computer Organization and Architecture Chapter 11 Instruction Sets: Addressing Modes and Formats Instruction Set Design One goal of instruction set design is to minimize instruction length Another goal
Departamento de Investigación. LaST: Language Study Tool. Nº 143 Edgard Lindner y Enrique Molinari Coordinación: Graciela Matich
Departamento de Investigación LaST: Language Study Tool Nº 143 Edgard Lindner y Enrique Molinari Coordinación: Graciela Matich Noviembre 2005 Para citar este documento: Lindner, Edgard; Enrique Molinari,
Approximating Context-Free Grammars for Parsing and Verification
Approximating Context-Free Grammars for Parsing and Verification Sylvain Schmitz LORIA, INRIA Nancy - Grand Est October 18, 2007 datatype a option = NONE SOME of a fun filter pred l = let fun filterp (x::r,
Programming and Software Development CTAG Alignments
Programming and Software Development CTAG Alignments This document contains information about four Career-Technical Articulation Numbers (CTANs) for Programming and Software Development Career-Technical
Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA) * Instruction set architecture of a machine fills the semantic gap between the user and the machine. * ISA serves as the starting point for the design of a new machine
Organization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.
Organization of Programming Languages CS320/520N Razvan C. Bunescu School of Electrical Engineering and Computer Science [email protected] Names, Bindings, and Scopes A name is a symbolic identifier used
University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. CSC467 Compilers and Interpreters Fall Semester, 2005
University of Toronto Department of Electrical and Computer Engineering Midterm Examination CSC467 Compilers and Interpreters Fall Semester, 2005 Time and date: TBA Location: TBA Print your name and ID
Fundamentals of Java Programming
Fundamentals of Java Programming This document is exclusive property of Cisco Systems, Inc. Permission is granted to print and copy this document for non-commercial distribution and exclusive use by instructors
Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.
Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java
02 B The Java Virtual Machine
02 B The Java Virtual Machine CS1102S: Data Structures and Algorithms Martin Henz January 22, 2010 Generated on Friday 22 nd January, 2010, 09:46 CS1102S: Data Structures and Algorithms 02 B The Java Virtual
Lumousoft Visual Programming Language and its IDE
Lumousoft Visual Programming Language and its IDE Xianliang Lu Lumousoft Inc. Waterloo Ontario Canada Abstract - This paper presents a new high-level graphical programming language and its IDE (Integration
Objects for lexical analysis
Rochester Institute of Technology RIT Scholar Works Articles 2002 Objects for lexical analysis Bernd Kuhl Axel-Tobias Schreiner Follow this and additional works at: http://scholarworks.rit.edu/article
03 - Lexical Analysis
03 - Lexical Analysis First, let s see a simplified overview of the compilation process: source code file (sequence of char) Step 2: parsing (syntax analysis) arse Tree Step 1: scanning (lexical analysis)
Where we are CS 4120 Introduction to Compilers Abstract Assembly Instruction selection mov e1 , e2 jmp e cmp e1 , e2 [jne je jgt ] l push e1 call e
0/5/03 Where we are CS 0 Introduction to Compilers Ross Tate Cornell University Lecture 8: Instruction Selection Intermediate code synta-directed translation reordering with traces Canonical intermediate
The previous chapter provided a definition of the semantics of a programming
Chapter 7 TRANSLATIONAL SEMANTICS The previous chapter provided a definition of the semantics of a programming language in terms of the programming language itself. The primary example was based on a Lisp
Automating Mimicry Attacks Using Static Binary Analysis
Automating Mimicry Attacks Using Static Binary Analysis Christopher Kruegel and Engin Kirda Technical University Vienna [email protected], [email protected] Darren Mutz, William Robertson,
Programming from the Ground Up
Programming from the Ground Up Jonathan Bartlett Edited by Dominick Bruno, Jr. Programming from the Ground Up by Jonathan Bartlett Edited by Dominick Bruno, Jr. Copyright 2003 by Jonathan Bartlett Permission
Division of Mathematical Sciences
Division of Mathematical Sciences Chair: Mohammad Ladan, Ph.D. The Division of Mathematical Sciences at Haigazian University includes Computer Science and Mathematics. The Bachelor of Science (B.S.) degree
Lexical analysis FORMAL LANGUAGES AND COMPILERS. Floriano Scioscia. Formal Languages and Compilers A.Y. 2015/2016
Master s Degree Course in Computer Engineering Formal Languages FORMAL LANGUAGES AND COMPILERS Lexical analysis Floriano Scioscia 1 Introductive terminological distinction Lexical string or lexeme = meaningful
Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters
Interpreters and virtual machines Michel Schinz 2007 03 23 Interpreters Interpreters Why interpreters? An interpreter is a program that executes another program, represented as some kind of data-structure.
2010-2011 Assessment for Master s Degree Program Fall 2010 - Spring 2011 Computer Science Dept. Texas A&M University - Commerce
2010-2011 Assessment for Master s Degree Program Fall 2010 - Spring 2011 Computer Science Dept. Texas A&M University - Commerce Program Objective #1 (PO1):Students will be able to demonstrate a broad knowledge
Applying Clang Static Analyzer to Linux Kernel
Applying Clang Static Analyzer to Linux Kernel 2012/6/7 FUJITSU COMPUTER TECHNOLOGIES LIMITED Hiroo MATSUMOTO 管 理 番 号 1154ka1 Copyright 2012 FUJITSU COMPUTER TECHNOLOGIES LIMITED Abstract Now there are
Using Eclipse CDT/PTP for Static Analysis
PTP User-Developer Workshop Sept 18-20, 2012 Using Eclipse CDT/PTP for Static Analysis Beth R. Tibbitts IBM STG [email protected] "This material is based upon work supported by the Defense Advanced Research
A Java-based environment for teaching programming language concepts æ
A Java-based environment for teaching programming language concepts æ Manfred Hauswirth, Mehdi Jazayeri, and Alexander Winzer Distributed Systems Group Technical University of Vienna Argentinierstraße
Static Analysis. Find the Bug! 15-654: Analysis of Software Artifacts. Jonathan Aldrich. disable interrupts. ERROR: returning with interrupts disabled
Static Analysis 15-654: Analysis of Software Artifacts Jonathan Aldrich 1 Find the Bug! Source: Engler et al., Checking System Rules Using System-Specific, Programmer-Written Compiler Extensions, OSDI
Organization of DSLE part. Overview of DSLE. Model driven software engineering. Engineering. Tooling. Topics:
Organization of DSLE part Domain Specific Language Engineering Tooling Eclipse plus EMF Xtext, Xtend, Xpand, QVTo and ATL Prof.dr. Mark van den Brand GLT 2010/11 Topics: Meta-modeling Model transformations
CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions
CSC45 AUTOMATA 2. Finite Automata: Examples and Definitions Finite Automata: Examples and Definitions A finite automaton is a simple type of computer. Itsoutputislimitedto yes to or no. It has very primitive
Artificial Intelligence. Class: 3 rd
Artificial Intelligence Class: 3 rd Teaching scheme: 4 hours lecture credits: Course description: This subject covers the fundamentals of Artificial Intelligence including programming in logic, knowledge
Systems Design & Programming Data Movement Instructions. Intel Assembly
Intel Assembly Data Movement Instruction: mov (covered already) push, pop lea (mov and offset) lds, les, lfs, lgs, lss movs, lods, stos ins, outs xchg, xlat lahf, sahf (not covered) in, out movsx, movzx
1 Introduction. 2 An Interpreter. 2.1 Handling Source Code
1 Introduction The purpose of this assignment is to write an interpreter for a small subset of the Lisp programming language. The interpreter should be able to perform simple arithmetic and comparisons
Chapter 7D The Java Virtual Machine
This sub chapter discusses another architecture, that of the JVM (Java Virtual Machine). In general, a VM (Virtual Machine) is a hypothetical machine (implemented in either hardware or software) that directly
Software Fingerprinting for Automated Malicious Code Analysis
Software Fingerprinting for Automated Malicious Code Analysis Philippe Charland Mission Critical Cyber Security Section October 25, 2012 Terms of Release: This document is approved for release to Defence
