|
@@ -130,10 +130,10 @@ Dedicated to PL group at Indiana University.
|
|
|
The $S_0$ language includes integers, operations on integers,
|
|
|
(arithmetic and input), and local variable definitions. This language
|
|
|
is rich enough to exhibit several compilation techniques but simple
|
|
|
-enough so that we can reasonably hope to implement the compilation to
|
|
|
-x86-64 assembly in two weeks of hard work. The instructor solution
|
|
|
+enough so that it is reasonable to implement the compilation to
|
|
|
+x86-64 assembly in two weeks of part-time work. The instructor solution
|
|
|
for the $S_0$ compiler consists of 6 recursive functions and a few
|
|
|
-small helper functions that together span 256 lines of code.
|
|
|
+helper functions that together span 256 lines of code.
|
|
|
|
|
|
The syntax of the $S_0$ language is defined by the following grammar.
|
|
|
\[
|
|
@@ -159,13 +159,17 @@ Given user input of 2, the following expression evaluates to $5$.
|
|
|
(+ \; (\key{read}) \; 3) \Longrightarrow 5
|
|
|
\]
|
|
|
Given user input of 2 then 3, the following expression may evaluate to
|
|
|
-either $1$ or $-1$ depending on the whims of the Scheme
|
|
|
-implementation.
|
|
|
+either $1$ or $-1$ depending on whether the implementation (an interpreter
|
|
|
+or compiler) decides to evaluate the \texttt{read} on the left before
|
|
|
+the \texttt{read} on the right, or vice versa.
|
|
|
\[
|
|
|
(+ \; (\key{read}) \; (-\; (\key{read})))
|
|
|
\Longrightarrow
|
|
|
1 \text{ or } -1
|
|
|
\]
|
|
|
+We include the \texttt{read} operation in $S_0$ to demonstrate that
|
|
|
+order of evaluation sometimes makes a difference and also to prevent
|
|
|
+the use of an interpreter to trivially implement the compiler for $S_0$.
|
|
|
|
|
|
\section{x86-64 Assembly}
|
|
|
|