Even though its value is passed to the peer threads

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: and types and sizes in floating-point code. code/asm/fpfunct2-ans.c 1 2 3 4 double funct2(int a, double x, float b, float i) { return a/(x+b) - (i+1); } code/asm/fpfunct2-ans.c Problem 3.29 Solution: [Pg. 186] Insert the following code between lines 4 and 5: 1 cmpb $1,%ah Test if comparison outcome is < Problem 3.30 Solution: [Pg. 191] code/asm/asmprobs-ans.c B.4. PROCESSOR ARCHITECTURE 1 2 3 4 5 6 7 8 715 int ok_smul(int x, int y, int *dest) { long long prod = (long long) x * y; int trunc = (int) prod; *dest = trunc; return (trunc == prod); } code/asm/asmprobs-ans.c B.4 Processor Architecture B.5 Optimizing Program Performance Problem 5.1 Solution: [Pg. 205] This problem illustrates some of the subtle effects of memory aliasing. As the commented code below shows, the effect will be to set the value at xp to zero. 1 2 3 *xp = *xp + *xp; /* 2x */ *xp = *xp - *xp; /* 2x-2x = 0 */ *xp = *xp - *xp; /* 0-0 = 0 */ This example illustrates that our intuition about program behavior can often be wrong. We naturally think of the case where...
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