Jeremy Siek 6 anni fa
parent
commit
57cbd32280
1 ha cambiato i file con 15 aggiunte e 14 eliminazioni
  1. 15 14
      book.tex

+ 15 - 14
book.tex

@@ -1235,9 +1235,9 @@ main:
 	negq	-8(%rbp)
 	movq	$52, %rax
 	addq	-8(%rbp), %rax
-
 	movq	%rax, %rdi
 	callq	print_int
+        
 	addq	$16, %rsp
 	movq    $0, %rax
 	popq	%rbp
@@ -1283,19 +1283,20 @@ places $52$ in the register \key{rax} and \key{addq -8(\%rbp), \%rax}
 adds the contents of variable $1$ to \key{rax}, at which point
 \key{rax} contains $42$.
 
-The last six instructions are the typical \emph{conclusion} of a
-procedure. The first two print the final result of the program. The
-latter three are necessary to get the state of the machine back to
-where it was before the current procedure was called.  The \key{addq
-  \$16, \%rsp} instruction moves the stack pointer back to point at
-the old base pointer. The amount added here needs to match the amount
-that was subtracted in the prelude of the procedure. The \key{movq
-  \$0, \%rax} instruction ensures that the returned exit code is 0.
-Then \key{popq \%rbp} returns the old base pointer to \key{rbp} and
-adds $8$ to the stack pointer.  The \key{retq} instruction jumps back
-to the procedure that called this one and adds 8 to the stack pointer,
-returning the stack pointer to where it was prior to the procedure
-call.
+The next two instructions print the final result of the program.
+
+The last four instructions are the typical \emph{conclusion} of a
+procedure.  The first three are necessary to get the state of the
+machine back to where it was before the current procedure was called.
+The \key{addq \$16, \%rsp} instruction moves the stack pointer back to
+point at the old base pointer. The amount added here needs to match
+the amount that was subtracted in the prelude of the procedure. The
+\key{movq \$0, \%rax} instruction ensures that the returned exit code
+is 0.  Then \key{popq \%rbp} returns the old base pointer to \key{rbp}
+and adds $8$ to the stack pointer.  The \key{retq} instruction jumps
+back to the procedure that called this one and adds 8 to the stack
+pointer, returning the stack pointer to where it was prior to the
+procedure call.
 
 The compiler will need a convenient representation for manipulating
 x86 programs, so we define an abstract syntax for x86 in