10 |
10 |
11 |
11 |
12 |
12 |
13 |
13 |
14 \begin{document} |
14 \begin{document} |
15 \fnote{\copyright{} Christian Urban, King's College London, 2017, 2018, 2019, 2020} |
15 \fnote{\copyright{} Christian Urban, King's College London, 2017, 2018, 2019, 2020, 2023} |
16 |
16 |
17 \section*{Handout 7 (Compilation)} |
17 \section*{Handout 7 (Compilation)} |
18 |
18 |
19 The purpose of a compiler is to transform a program a human can read and |
19 The purpose of a compiler is to transform a program a human can read and |
20 write into code the machine can run as fast as possible. The fastest |
20 write into code the machine can run as fast as possible. The fastest |
51 \end{center} |
51 \end{center} |
52 |
52 |
53 \noindent |
53 \noindent |
54 The input will be WHILE-programs; the output will be assembly files |
54 The input will be WHILE-programs; the output will be assembly files |
55 (with the file extension .j). Assembly files essentially contain |
55 (with the file extension .j). Assembly files essentially contain |
56 human-readable low-level code, meaning they are not just bits and bytes, |
56 human-readable low-level code, meaning they are not just bits and |
57 but rather something you can read and understand---with a bit of |
57 bytes, but rather something you can read and understand---with a bit |
58 practice of course. An \emph{assembler} will then translate the assembly |
58 of practice of course. An \emph{assembler} will then translate the |
59 files into unreadable class- or binary-files the JVM or CPU can run. |
59 assembly files into unreadable class- or binary-files the JVM or CPU |
60 Unfortunately, the Java ecosystem does not come with an assembler which |
60 can run. Unfortunately, the Java ecosystem does not come with an |
61 would be handy for our compiler-endeavour (unlike Microsoft's Common |
61 assembler which would be handy for our compiler-endeavour (unlike |
62 Language Infrastructure for the .Net platform which has an assembler |
62 Microsoft's Common Language Infrastructure for the .Net platform which |
63 out-of-the-box). As a substitute we shall use the 3rd-party programs |
63 has an assembler out-of-the-box). As a substitute we shall use the |
64 Jasmin and Krakatau |
64 3rd-party programs Jasmin or Krakatau (Jasmin is the preferred |
|
65 option---a \texttt{jasmin.jar}-file is available on KEATS): |
65 |
66 |
66 \begin{itemize} |
67 \begin{itemize} |
67 \item \url{http://jasmin.sourceforge.net} |
68 \item \url{http://jasmin.sourceforge.net} |
68 \item \url{https://github.com/Storyyeller/Krakatau} |
69 \item \url{https://github.com/Storyyeller/Krakatau} |
69 \end{itemize} |
70 \end{itemize} |