From 3c65a9e64c84e223cb622ce228ad670e48d2b0bf Mon Sep 17 00:00:00 2001 From: "Jeremy G. Siek" Date: Sat, 28 Sep 2024 14:44:31 -0400 Subject: [PATCH] fix output of select instructions in chapter 2 example --- book.tex | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/book.tex b/book.tex index 575a1d1..6ce38e2 100644 --- a/book.tex +++ b/book.tex @@ -3958,9 +3958,11 @@ \section{Assign Homes} \end{minipage}\\ % The output of \code{select\_instructions} is shown next, on the left, -and the output of \code{assign\_homes} is on the right. In this -example, we assign variable \code{a} to stack location -\code{-8(\%rbp)} and variable \code{b} to location \code{-16(\%rbp)}. +and the output of \code{assign\_homes} is on the right. +In this example, we assign variable \code{a} to stack location + \code{-8(\%rbp)} and variable \code{b} to location \code{-16(\%rbp)}. + +{\if\edition\racketEd \begin{transformation} \begin{lstlisting}[basicstyle=\ttfamily\footnotesize] movq $42, a @@ -3975,6 +3977,24 @@ \section{Assign Homes} movq -16(%rbp), %rax \end{lstlisting} \end{transformation} +\fi} +{\if\edition\pythonEd +\begin{transformation} +\begin{lstlisting}[basicstyle=\ttfamily\footnotesize] +movq $42, a +movq a, b +movq b, %rdi +callq print_int +\end{lstlisting} +\compilesto +\begin{lstlisting}[basicstyle=\ttfamily\footnotesize] +movq $42, -8(%rbp) +movq -8(%rbp), -16(%rbp) +movq -16(%rbp), %rdi +callq print_int +\end{lstlisting} +\end{transformation} +\fi} \racket{ The \code{assign\_homes} pass should replace all variables