|
@@ -1628,16 +1628,17 @@ $\Rightarrow$
|
|
The \key{read} operation does not have a direct counterpart in x86-64
|
|
The \key{read} operation does not have a direct counterpart in x86-64
|
|
assembly, so we have instead implemented this functionality in the C
|
|
assembly, so we have instead implemented this functionality in the C
|
|
language, with the function \code{read\_int} in the file
|
|
language, with the function \code{read\_int} in the file
|
|
-\code{runtime.c}. In general, we have refer to all of the
|
|
|
|
-functionality in this file as the \emph{runtime system}, or simply
|
|
|
|
-\emph{runtime} for short. When compiling your generated x86-64
|
|
|
|
-assembly code, you will need to compile \code{runtime.c} and link it
|
|
|
|
-in. For our purposes of code generation, all you need to do is
|
|
|
|
|
|
+\code{runtime.c}. In general, we refer to all of the functionality in
|
|
|
|
+this file as the \emph{runtime system}, or simply the \emph{runtime}
|
|
|
|
+for short. When compiling your generated x86-64 assembly code, you
|
|
|
|
+will need to compile \code{runtime.c} to \code{runtime.o} (an ``object
|
|
|
|
+file'', using \code{gcc} option \code{-c}) and link it into the final
|
|
|
|
+executable. For our purposes of code generation, all you need to do is
|
|
translate an assignment of \key{read} to some variable $\itm{lhs}$
|
|
translate an assignment of \key{read} to some variable $\itm{lhs}$
|
|
-(for left-hand side) into call to the \code{read\_int} function
|
|
|
|
-followed by a move from \code{rax} into the left-hand side. Also,
|
|
|
|
-recall that the return value of a function is typically placed in the
|
|
|
|
-\code{rax} register. \\
|
|
|
|
|
|
+(for left-hand side) into a call to the \code{read\_int} function
|
|
|
|
+followed by a move from \code{rax} to the left-hand side. The move
|
|
|
|
+from \code{rax} is needed because the return value from
|
|
|
|
+\code{read\_int} goes into \code{rax}, as is the case in general. \\
|
|
\begin{tabular}{lll}
|
|
\begin{tabular}{lll}
|
|
\begin{minipage}{0.4\textwidth}
|
|
\begin{minipage}{0.4\textwidth}
|
|
\begin{lstlisting}
|
|
\begin{lstlisting}
|