|
@@ -26,7 +26,7 @@
|
|
|
|
|
|
\def\racketEd{0}
|
|
|
\def\pythonEd{1}
|
|
|
-\def\edition{0}
|
|
|
+\def\edition{1}
|
|
|
|
|
|
% material that is specific to the Racket edition of the book
|
|
|
\newcommand{\racket}[1]{{\if\edition\racketEd{#1}\fi}}
|
|
@@ -3898,7 +3898,7 @@ programs.
|
|
|
The \code{patch\_instructions} pass compiles from \LangXVar{} to
|
|
|
\LangXInt{} by making sure that each instruction adheres to the
|
|
|
restriction that at most one argument of an instruction may be a
|
|
|
-memory reference.
|
|
|
+memory reference.
|
|
|
|
|
|
We return to the following example.\\
|
|
|
\begin{minipage}{0.5\textwidth}
|
|
@@ -3945,6 +3945,12 @@ from \key{rax} to the destination location, as follows.
|
|
|
movq %rax, -16(%rbp)
|
|
|
\end{lstlisting}
|
|
|
|
|
|
+There is a similar corner case that also needs to be dealt with. If
|
|
|
+one argument is an immediate integer larger than $2^{16}$ and the
|
|
|
+other is a memory reference, then the instruction is invalid. One can
|
|
|
+fix this, for example, by first moving the immediate integer into
|
|
|
+\key{rax} and then using \key{rax} in place of the integer.
|
|
|
+
|
|
|
\begin{exercise}
|
|
|
\normalfont\normalsize Implement the \key{patch\_instructions} pass in
|
|
|
\racket{\code{compiler.rkt}}\python{\code{compiler.py}}.
|