Variable x is initially at offset 8 relative to

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: } 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 first execution of body-statement. A direct translation into a form using goto’s...
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