Literature
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 university bookstore for kr. 489.
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)
-
You are supposed to be familiar with the C programming language,
but if you are not, the C-part of
cppreference.com
is a convenient reference for a programmer, skilled in some other language.If you would like a more tutorial-like book, there are many alternatives you can purchase, or you can try the following free option by Holmes.
-
GNU Make:
manual
(IMADA runs version 4.1).
-
Flex - The Fast Lexical Analyzer:
project repository,
releases,
manual, 2.6.4,
manual, 2.6.0 (pdf)
(IMADA runs version 2.6.4, but the differences between 2.6.4 and 2.6.0 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
INPUT
):flex first.l
gcc lex.yy.c
./a.out < INPUT
-
Bison
- The YACC-Compatible Parser Generator:
manual
(IMADA runs version 3.0.4, but the differences are negligible).
-
GNU Make:
manual
(IMADA runs version 4.1).
-
Examples of nested scope in
C
and Python.
-
Kim S. Larsen,
Supplementary Notes for DM546,
February 11, 2019
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 prefer printed material, 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.
- Tiny Expressions.
-
GNU Assembler
Manual and the
X86 Wiki.
-
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 uses the 32 bit notation in the register examples, where we use 64
- you can just think of registers such as
eax
asrax
and operators such asmovl
asmovq
) when you check for the real differences. -
GNU Assembler Program Examples:
first.s,
testglobalvar.s,
myfactorial-annotated.s.
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
every time.
-
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: div.c, div.s. -
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
res
infac
and assign the result tores
and then executereturn res
. I have done it and you should be able to see the result here on a generated permanent link. -
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.