1、- 1 - 外文原文 From:J2EE in the Real World Author:Jack Joney Computer Systems A programmers Perspective 深入理解计算机系统 原文: Stack Frame for calling procedure +8 +8 +4 +4 %ebp 0 %ebp 0 Stack Frame for fib_rec -20 -20 %esp -24 -24 %esp -40 After set up Before first recursive call Figure 3.21: Stack Frame for Re
2、cursive Fibonacci Function. State of frame is shown after initial set up (left), and just before the first recursive call (right). For the nonterminal condition, instructions 10 to 12 set up the first recursive call. This involves allocating12 bytes on the stack that are never used, and then pushing
3、 the computed value n-2. At this point, the stack frame will have the form shown on the right side of Figure 3.21. It then makes the recursive call, which will trigger a number n Return Address Saved %ebp Unused Saved %esi Saved %ebx n Return Address Saved %ebp Unused Saved %esi Saved %ebx Unused n-
4、2 - 2 - of calls that allocate stack frames, perform operations on local storage, and so on. As each call returns, it deallocates any stack space and restores any modified callee save registers. Thus, when we return to the current call at line 14 we can assume that register %eax contains the value returned by the recursive call, and that register %ebx contains the value of function