Understanding Compilation: From High-Level Source Code to Machine Code, Slides of Compiler Construction

An introduction to compilers and the compilation process. It explains what compilers are, their role in translating high-level source code into low-level machine code, and the differences between human-readable source code and machine code. It also covers the challenges of ensuring correct translation and the complexity of the compilation process.

Typology: Slides

2011/2012

Uploaded on 11/03/2012

ekavia
ekavia 🇮🇳

4.3

(58)

241 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Compiler
Construction
Lecture 1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Understanding Compilation: From High-Level Source Code to Machine Code and more Slides Compiler Construction in PDF only on Docsity!

Compiler

Construction

Lecture 1

10

What are Compilers

 Translate information from one representation to another

 Usually information = program

12

In This Course

We will study typical compilation:

 from programs written in high- level languages to low-level object code and machine code

13

Typical Compilation

High-level source code

Compiler

Low-level machine code

15

Source Code

 Optimized for human readability

 Matches human notions of grammar

 Uses named constructs such as variables and procedures

16

Assembly Code

. globl _expr _expr: pushl %ebp movl %esp,%ebp subl $24,%esp movl 8(%ebp),%eax movl %eax,%edx leal0(,%edx,4),%eax movl %eax,%edx imull 8(%ebp),%edx movl 8(%ebp),%eax incl %eax

imull %eax,%edx movl 8(%ebp),%eax incl %eax imull %eax,%edx movl %edx,-4(%ebp) movl -4(%ebp),%edx movl %edx,%eax jmp L .align 4 L2: leave ret

18

How to Translate

Correctness: the generated machine code must execute precisely the same computation as the source code

19

How to Translate

 Is there a unique translation? No!

 Is there an algorithm for an “ideal translation”? No!