18 stack frames for caller and swap add procedure

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: oc A: Compute 3*x Compute x+4*3*x Goto done 9 10 .L5: addl $10,%edx Case 103 loc B: result += 10, Fall through 11 12 13 .L6: addl $11,%edx jmp .L3 Cases 104, 106 loc C: result += 11 Goto done 14 15 16 .L8: imull %edx,%edx jmp .L3 Default case loc D: result *= result Goto done 17 18 .L9: xorl %edx,%edx Return result loc def: result = 0 19 20 .L3: movl %edx,%eax done: Set result as return value Figure 3.15: Assembly Code for Switch Statement Example in Figure 3.14. 3.6. CONTROL 131 Figure 3.14(a) shows an example of a C switch statement. This example has a number of interesting features, including case labels that do not span a contiguous range (there are no labels for cases 101 and 105), cases with multiple labels (cases 104 and 106), and cases that “fall through” to other cases (case 102), because the code for the case does not end with a break statement. Figure 3.15 shows the assembly code generated when compiling switch_eg. The behavior of this code is shown using an extended form of C as the procedure switch_eg_impl in Figure 3.14(b). We say “extended” because C does not provide the necessary construc...
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