Remember that the disassembly listing shows the value

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: e with simple control flow. It also gives you a chance to examine the implementation of logical operations. A. 1 2 3 4 5 6 7 8 9 code/asm/simple-if.c void cond(int a, int *p) { if (p == 0) goto done; if (a <= 0) goto done; *p += a; done: } code/asm/simple-if.c B. The first conditional branch is part of the implementation of the || expression. If the test for p being nonnull fails, the code will skip the test of a > 0. Problem 3.10 Solution: [Pg. 120] The code generated when compiling loops can be tricky to analyze, because the compiler can perform many different optimizations on loop code, and because it can be difficult to match program variables with registers. We start practicing this skill with a fairly simple loop. A. The register usage can be determined by simply looking at how the arguments get fetched. Register Usage Register Variable Initially %esi x x %ebx y y %ecx n n B. The body-statement portion consists of lines 4 to 6 in the C code and lines 6 to 8 in the assembly code. The test-expr portion is...
View Full Document

Ask a homework question - tutors are online