Jeremy Siek пре 9 година
родитељ
комит
e3ef73f596
1 измењених фајлова са 16 додато и 15 уклоњено
  1. 16 15
      book.tex

+ 16 - 15
book.tex

@@ -3139,27 +3139,28 @@ functions; instead we use a combination of registers and stack
 locations for passing arguments, following the conventions used by
 locations for passing arguments, following the conventions used by
 \code{gcc} as described by \cite{Matz:2013aa}. Up to six arguments may
 \code{gcc} as described by \cite{Matz:2013aa}. Up to six arguments may
 be passed in registers, using the registers \code{rdi}, \code{rsi},
 be passed in registers, using the registers \code{rdi}, \code{rsi},
-\code{rdx}, \code{rcx}, \code{r8}, and \code{r9}. If there are more
-than six arguments, then the rest must be placed on the stack, which
-we call \emph{stack arguments}, which we discuss in the following
-paragraphs. Continuing on the topic of registers, each function may
-need to use all the registers for storing local variables, frame base
-pointers, etc. so when we make a function call, we need to figure out
-how the two functions can share the same register set without getting
-in each others way. The convention for x86-64 is that the caller is
-responsible freeing up some registers, the \emph{caller save
-  registers}, prior to the function call, and the callee is
-responsible for saving and restoring some other registers, the
-\emph{callee save registers}, before and after using them. The
-caller save registers are 
+\code{rdx}, \code{rcx}, \code{r8}, and \code{r9}, in that order.  If
+there are more than six arguments, then the rest must be placed on the
+stack, which we call \emph{stack arguments}, which we discuss in later
+paragraphs. The register \code{rax} is for the return value of the
+function.
+
+Each function may need to use all the registers for storing local
+variables, frame base pointers, etc. so when we make a function call,
+we need to figure out how the two functions can share the same
+register set without getting in each others way. The convention for
+x86-64 is that the caller is responsible freeing up some registers,
+the \emph{caller save registers}, prior to the function call, and the
+callee is responsible for saving and restoring some other registers,
+the \emph{callee save registers}, before and after using them. The
+caller save registers are
 \begin{lstlisting}
 \begin{lstlisting}
 rdx rcx rsi rdi r8 r9 r10 r11
 rdx rcx rsi rdi r8 r9 r10 r11
 \end{lstlisting}
 \end{lstlisting}
 while the callee save registers are 
 while the callee save registers are 
 \begin{lstlisting}
 \begin{lstlisting}
-rbx r12 r13 r14 r15
+rsp rbp rbx r12 r13 r14 r15
 \end{lstlisting}
 \end{lstlisting}
-UNDER CONSTRUCTION
 
 
 Recall from Section~\ref{sec:x86-64} that the stack is also used for
 Recall from Section~\ref{sec:x86-64} that the stack is also used for
 local variables, and that at the beginning of a function we move the
 local variables, and that at the beginning of a function we move the