Digital Computer Systems Lecture 4
Digital Computer Systems Lecture 4
Why HLL?
Shield programmers from detailed
machine-level specifications (hence
higher productivity)
Portability
Easy to upgrade (e.g. CC++->C#)
Main Characteristics
Usually translated by compilers
Global
local
Control Structures
What distinguishes a computer from a
calculator
Used for making decisions and loops
Subroutines
Why do we need them?
Economy: decrease program size
Modularity: facilitate the programming
Different Paradigms
Imperative/Procedural (e.g. C)
a list of operations to do in order
Compiler
Anatomy of a Compiler
Lexical analysis
Syntactic analysis
Semantic analysis
Code generation (high/intermediate
level)
Optimization
Code generation (object file or machine
code)
10
11
12
13
Example
14
Example
15
Example
16
Example: IR (intermediate
representation)
17
Example: IR optimization
IR
Optimized IR
18
19
20