The parent executes only the printf in line 9 printf2

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: d the testb instruction to perform the AND operation. Problem 3.11 Solution: [Pg. 125] This is another chance to practice deciphering loop code. The C compiler has done some interesting optimizations. A. The register usage can be determined by looking at how the arguments get fetched, and how registers are initialized. Register Usage Register Variable Initially %eax a a %ebx b b %ecx i 0 %edx result a B. The test-expr occurs on line 5 of the C code and on line 10 and the jump condition of line 11 in the assembly code. The body-statement occurs on lines 6 through 8 of the C code and on lines 7 to 9 of the assembly code. The compiler has detected that the initial test of the while loop will always be true, since i is initialized to 0, which is clearly less than 256. C. The annotated code is as follows 1 2 3 4 5 movl 8(%ebp),%eax movl 12(%ebp),%ebx xorl %ecx,%ecx movl %eax,%edx .p2align 4,,7 Put a in %eax Put b in %ebx i=0 result = a a in %eax, b in %ebx, i in %ecx, result in %edx B.3. MACHINE LEVEL REPRESENTATION OF C PROGRAMS 6 7 8 9 10 11 12 705 .L5: addl %eax,%edx subl %ebx,%eax addl %ebx,%ecx cmpl $255,%ecx j...
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