Pārlūkot izejas kodu

fixed text to match fig:p1-x86

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

+ 16 - 13
book.tex

@@ -1438,12 +1438,12 @@ Figure~\ref{fig:frame}.  The register \key{rsp} is called the
 the top of the stack. The stack grows downward in memory, so we
 increase the size of the stack by subtracting from the stack pointer.
 In the context of a procedure call, the \emph{return
-  address}\index{return address} is the next instruction after the
-call instruction on the caller side. During a function call, the
-return address is pushed onto the stack.  The register \key{rbp} is
-the \emph{base pointer}\index{base pointer} and is used to access
-variables associated with the current procedure call.  The base
-pointer of the caller is pushed onto the stack after the return
+  address}\index{return address} is the instruction after the call
+instruction on the caller side. The function call inststruction,
+\code{callq}, pushes the return address onto the stack.  The register
+\key{rbp} is the \emph{base pointer}\index{base pointer} and is used
+to access variables associated with the current procedure call.  The
+base pointer of the caller is pushed onto the stack after the return
 address. We number the variables from $1$ to $n$. Variable $1$ is
 stored at address $-8\key{(\%rbp)}$, variable $2$ at
 $-16\key{(\%rbp)}$, etc.
@@ -1489,7 +1489,6 @@ Position & Contents \\ \hline
 \label{fig:frame}
 \end{figure}
 
-
 Getting back to the program in Figure~\ref{fig:p1-x86}, consider how
 control is transfered from the operating system to the \code{main}
 function.  The operating system issues a \code{callq main} instruction
@@ -1514,12 +1513,16 @@ instructions that were generated from the Racket expression \code{(+
   10 32)}.
 
 The four instructions under the label \code{start} carry out the work
-of computing \code{(+ 52 (- 10)))}. The first instruction
-\code{movq \$10, -8(\%rbp)} stores $10$ in variable $1$. The
-instruction \code{negq -8(\%rbp)} changes variable $1$ to $-10$. The
-instruction \code{movq \$52, \%rax} places $52$ in the register \code{rax} and
-finally \code{addq -8(\%rbp), \%rax} adds the contents of variable $1$ to
-\code{rax}, at which point \code{rax} contains $42$.
+of computing \code{(+ 52 (- 10)))}.
+%
+The first instruction \code{movq \$10, -8(\%rbp)} stores $10$ in
+variable $1$.
+%
+The instruction \code{negq -8(\%rbp)} changes variable $1$ to $-10$.
+%
+The following instruction moves the $-10$ from variable $1$ into the
+\code{rax} register.  Finally, \code{addq \$52, \%rax} adds $52$ to
+the value in \code{rax}, updating its contents to $42$.
 
 The three instructions under the label \code{conclusion} are the
 typical \emph{conclusion}\index{conclusion} of a procedure.  The first