386 dynamically allocated arrays c only supports

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ved %ebp Unused -20 -24 Saved %esi Saved %ebx Unused %esp After set up -40 n-2 Before first recursive call • • • +8 +4 %ebp 0 n Return Address Saved %ebp Unused -20 %esp -24 Saved %esi Saved %ebx Stack Frame for calling procedure Stack Frame for fib_rec Figure 3.21: Stack Frame for Recursive 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 allocating 12 bytes on the stack that are never used, and then pushing 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 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 a...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online