This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ssume that register %eax contains the value returned by the recursive call, and that register %ebx contains the value of function parameter n. The returned value (local variable prev_val in the C code) is stored in register %esi (line 14). By using a callee save register, we can be sure that this value will still be available after the second recursive call. Instructions 15 to 17 set up the second recursive call. Again it allocates 12 bytes that are never used, and pushes the value of n-1. Following this call (line 18), the computed result will be in register %eax, and we can assume that the result of the previous call is in register %esi. These are added to give the return value (instruction 19). The completion code restores the registers and deallocates the stack frame. It starts (line 24) by setting the stack frame to the location of the saved value of %ebx. Observe that by computing this stack position relative to the value of %ebp, the computation will be correct regardless of whether or not the terminal condition was reached. 3.8 Array Allocation and Access
View Full Document