Literature and Other Resources
The course textbook is
Andrew W. Appel,
Modern Compiler Implementation in C,
Cambridge University Press, 1998, ISBN 0-521-58390-X
(reprinted with corrections, 1999; reissued, 2004).
It can be bought in the
for kr. 479.
Errata etc. can be found via the
book home page.
My supplement to the errata,
i.e., additional misprints not yet registered by the authors.
Supplementary literature and material (will be updated as needed)
If you do not already know the C programming language, you are
recommended to purchase the following book:
Brian W. Kernighan, Dennis Ritchie,
The C Programming Language, 2. eds.,
Prentice Hall, 1988.
As an alternative one can use
the WWW-book by Holmes.
Flex - The Fast Lexical Analyzer:
manual, 2.5.37 (pdf),
(IMADA runs version 2.6.0, but the differences are negligible).
A first flex definition file - so you have one you know
should work! To run, carry out the following command line steps
(where your input to the resulting scanner is on the file
./a.out < INPUT
- The YACC-Compatible Parser Generator:
(IMADA runs version 4.1).
Examples of nested scope in
Kim S. Larsen,
Supplementary Notes for DM546,
February 13, 2018.
It comes in two versions. It's the same material, but font size,
and therefore number of pages, differ.
You can print as you always do as regular A4 in 11pt (20 pages)
or just read it electronically.
Alternatively, if you like print, you can get it
as an A5 booklet (25 logical / 14 physical pages / 7 duplex pages).
The latter is in my opinion nicer, but
requires that you can print 2-sided and can staple in the middle
of an A4 page -
- A4 (pdf)
- Print as you normally do.
- A5 booklet (pdf)
- Use acroread, for example, print 2-sided, short-edge binding.
- A5 booklet (ps)
- For direct duplex postscript printing.
- A5 booklet (ps, recto-verso)
- For direct duplex postscript printing on a recto-verso printer.
Manual and the
In case you use other sources for assembler, you may come across the
Intel syntax - here are the primary differences between
Intel and ATT syntax
(the page is for 32 bit, where we use 64 - this just means that
you should read registers such as
and operators such as
GNU Assembler Program Examples:
In first.s, everything has been done "correctly", saving all callee
and caller save registers at any call point. In myfactorial-annotated.s,
this part has been abbreviated to just saving one representative
If you wonder how a particular feature is implemented in assembler,
try writing a simple C program and translates to assember using
gcc -S - here it is done for division as an example:
You can also use godbolt.org to play
around with high-level to assembler compilations.
Try pythontutor.com to see
stack frames in action. You can for instance try it on the factorial program
in C from the course home page. To see the accumulation of the result better,
declare a variable
fac and assign the result
res and then execute
I have done it and you should be able to see the result here on a generated
A complete stack frame layout.
A note on lattices and fixed points.
The simplify-select example from the lecture can be found as
Figure 4 in Register Allocation by Graph Coloring.
Copies of lecture notes have been handed out for the following topics
(there are 4 slides per piece of paper, single-sided):
- Scanner (4 slides)
- Scanner & parser (18 slides)
- Abstract syntax trees (14 slides)
- Symbol tabels & scope (8 slides)
- Call conventions and stack layout (3 slides)
- Register allocation via liveness analyse (19 slides)
- Garbage collection (22 slides)