L4 leal edxedx2eax leal edxeax4edx jmp l3 case

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: ontrol flow of the assembly code. The stack set-up and completion portions of the assembly code have been omitted 3.6. CONTROL 119 That is, the compiler generates separate blocks of code for then-statement and else-statement. It inserts conditional and unconditional branches to make sure the correct block is executed. Practice Problem 3.9: When given the following C code: code/asm/simple-if.c 1 2 3 4 5 void cond(int a, int *p) { if (p && a > 0) *p += a; } code/asm/simple-if.c GCC generates the following assembly code. movl 8(%ebp),%edx movl 12(%ebp),%eax testl %eax,%eax je .L3 testl %edx,%edx jle .L3 addl %edx,(%eax) .L3: 1 2 3 4 5 6 7 8 A. Write a goto version in C that performs the same computation and mimics the control flow of the assembly code, in the style shown in Figure 3.11(b). You might find it helpful to first annotate the assembly code as we have done in our examples. B. Explain why the assembly code contains two conditional branches, even though the C code has only one if statement. 3.6.5...
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