Browse Source

tweak regarding callee save

Jeremy Siek 9 năm trước cách đây
mục cha
commit
3de092f30d
1 tập tin đã thay đổi với 13 bổ sung10 xóa
  1. 13 10
      book.tex

+ 13 - 10
book.tex

@@ -4662,18 +4662,21 @@ paragraphs. The register \code{rax} is for the return value of the
 function.
 
 Recall from Section~\ref{sec:x86} that the stack is also used for
-local variables and for storing the values of caller-save registers
+local variables and for storing the values of callee-save registers
 (we shall refer to all of these collectively as ``locals''), and that
 at the beginning of a function we move the stack pointer \code{rsp}
-down to make room for them.  To make additional room for passing
-arguments, we shall move the stack pointer even further down. We count
-how many stack arguments are needed for each function call that occurs
-inside the body of the function and find their maximum. Adding this
-number to the number of locals gives us how much the \code{rsp} should
-be moved at the beginning of the function. In preparation for a
-function call, we offset from \code{rsp} to set up the stack
-arguments. We put the first stack argument in \code{0(\%rsp)}, the
-second in \code{8(\%rsp)}, and so on.
+down to make room for them.  We recommend storing the local variables
+first and then the callee-save registers, so that the local variables
+can be accessed using \code{rbp} the same as before the addition of
+functions.  To make additional room for passing arguments, we shall
+move the stack pointer even further down. We count how many stack
+arguments are needed for each function call that occurs inside the
+body of the function and find their maximum. Adding this number to the
+number of locals gives us how much the \code{rsp} should be moved at
+the beginning of the function. In preparation for a function call, we
+offset from \code{rsp} to set up the stack arguments. We put the first
+stack argument in \code{0(\%rsp)}, the second in \code{8(\%rsp)}, and
+so on.
 
 Upon calling the function, the stack arguments are retrieved by the
 callee using the base pointer \code{rbp}. The address \code{16(\%rbp)}