Jeremy Siek 4 gadi atpakaļ
vecāks
revīzija
2a6c0d175d
1 mainītis faili ar 34 papildinājumiem un 41 dzēšanām
  1. 34 41
      book.tex

+ 34 - 41
book.tex

@@ -272,10 +272,8 @@ When running on the Microsoft Windows operating system, the GNU C
 compiler follows the Microsoft x64 calling
 convention~\citep{Microsoft:2018aa,Microsoft:2020aa}. So the assembly
 code that we generate will \emph{not} work properly with our runtime
-system on Windows. We include challenge exercises that give some hints
-regarding how to adapt the code generation to the Windows x64
-conventions.
-
+system on Windows. One option to consider for using a Windows computer
+is to run a virtual machine with Linux as the guest operating system.
 
 %\section*{Structure of book}
 % You might want to add short description about each chapter in this book.
@@ -290,22 +288,12 @@ conventions.
 
 \section*{Acknowledgments}
 
-Many people have contributed to the ideas, techniques, organization,
-and teaching of the materials in this book. We especially thank the
-following people.
-
-\begin{itemize}
-\item Bor-Yuh Evan Chang
-\item Kent Dybvig
-\item Daniel P. Friedman
-\item Ronald Garcia
-\item Abdulaziz Ghuloum
-\item Jay McCarthy
-\item Dipanwita Sarkar
-\item Andrew Keep
-\item Oscar Waddell
-\item Michael Wollowski
-\end{itemize}
+Many people have contributed to the ideas, techniques, and
+organization of this book and have taught courses based on it. We
+especially thank John Clements, Bor-Yuh Evan Chang, Kent Dybvig,
+Daniel P. Friedman, Ronald Garcia, Abdulaziz Ghuloum, Andrew Keep, Jay
+McCarthy, Nate Nystrom, Dipanwita Sarkar, Oscar Waddell, and Michael
+Wollowski.
 
 \mbox{}\\
 \noindent Jeremy G. Siek \\
@@ -2626,20 +2614,31 @@ about this approach.
 \index{calling conventions}
 
 As we perform register allocation, we need to be aware of the
-conventions that govern the way in which registers interact with
-function calls, such as calls to the \code{read\_int} function in our
-generated code and even the call that the operating system makes to
-execute our \code{main} function.  The convention for x86 regarding
-how functions share the use of registers is that the caller is
-responsible for freeing up some registers, the \emph{caller-saved
-  registers}, prior to the function call, and the callee is
-responsible for preserving the values of some other registers, the
-\emph{callee-saved registers}.  \index{caller-saved registers}
-\index{callee-saved registers} The caller-saved registers are
+\emph{calling conventions} \index{calling conventions} that govern how
+functions calls are performed in x86. Function calls require
+coordination between the caller and the callee, which is often
+assembly code written by different programmers or generated by
+different compilers. Here we follow the System V calling conventions
+that are used by the \code{gcc} compiler on Linux and
+MacOS~\citep{Bryant:2005aa,Matz:2013aa}.
+%
+Even though $R_1$ does not include programmer-defined functions, our
+generated code will 1) include a \code{main} function that the
+operating system will call to initiate execution, and 2) make calls to
+the \code{read\_int} function in our runtime system.
+
+The calling conventions include rules about how functions share the
+use of registers. In particular, the caller is responsible for freeing
+up some registers prior to the function call for use by the callee.
+These are called the \emph{caller-saved registers}
+\index{caller-saved registers}
+and they are
 \begin{lstlisting}
 rax rcx rdx rsi rdi r8 r9 r10 r11
 \end{lstlisting}
-while the callee-saved registers are
+On the other hand, the callee is responsible for preserving the values
+of the \emph{callee-saved registers}, \index{callee-saved registers}
+which are
 \begin{lstlisting}
 rsp rbp rbx r12 r13 r14 r15
 \end{lstlisting}
@@ -7160,19 +7159,13 @@ the target. However, \code{callq} does not handle
   or
 \item determining how registers are shared by different functions.
 \end{enumerate}
-These issues require coordination between the caller and the callee,
-which is often assembly code written by different programmers or
-generated by different compilers. As a result, people have developed
-\emph{conventions} that govern how functions calls are performed.
-Here we use conventions that are compatible with those of the
-\code{gcc} compiler~\citep{Matz:2013aa}.
 
 Regarding (1) parameter passing, recall that the following six
-registers:
+registers are used to pass arguments to a function, in this order.
 \begin{lstlisting}
 rdi rsi rdx rcx r8 r9
 \end{lstlisting}
-in that order, are used to pass arguments to a function. If there are
+If there are
 more than six arguments, then the convention is to use space on the
 frame of the caller for the rest of the arguments. However, to ease
 the implementation of efficient tail calls
@@ -7184,8 +7177,8 @@ the function.
 
 \index{prelude}\index{conclusion}
 
-Regarding (2) frames \index{frame} and the procedure call stack
-\index{procedure call stack}, recall from Section~\ref{sec:x86} that
+Regarding (2) frames \index{frame} and the procedure call stack,
+\index{procedure call stack} recall from Section~\ref{sec:x86} that
 the stack grows down, with each function call using a chunk of space
 called a frame. The caller sets the stack pointer, register
 \code{rsp}, to the last data item in its frame. The callee must not