This preview shows page 1. Sign up to view the full content.
Unformatted text preview: } while ((n > 0) & (y < n)); /* Note use of bitwise ’&’ */ return x; } generates the following assembly code:
Initially x, y, and n are at offsets 8, 12, and 16 from %ebp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 GCC movl 8(%ebp),%esi movl 12(%ebp),%ebx movl 16(%ebp),%ecx .p2align 4,,7 Inserted to optimize cache performance .L6: imull %ecx,%ebx addl %ecx,%esi decl %ecx testl %ecx,%ecx setg %al cmpl %ecx,%ebx setl %dl andl %edx,%eax testb $1,%al jne .L6 A. Make a table of register usage, similar to the one shown in Figure 3.12(b). B. Identify test-expr and body-statement in the C code, and the corresponding lines in the assembly code. C. Add annotations to the assembly code describing the operation of the program, similar to those shown in Figure 3.12(b). While Loops The general form of a while statement is as follows: while (test-expr) body-statement It differs from do-while in that test-expr is evaluated and the loop is potentially terminated before the ﬁrst execution of body-statement. A direct translation into a form using goto’s...
View Full Document
- Spring '10
- The American