All store their results into a oating point register

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: ding to some very peculiar results. The following example illustrates this property: code/asm/fcomp.c 1 2 3 4 5 6 7 8 9 10 11 12 double recip(int denom) { return 1.0/(double) denom; } void do_nothing() {} /* Just like the name says */ void test1(int denom) { double r1, r2; int t1, t2; 174 13 14 15 16 17 18 19 20 CHAPTER 3. MACHINE-LEVEL REPRESENTATION OF C PROGRAMS r1 = recip(denom); /* Stored in memory */ r2 = recip(denom); /* Stored in register */ t1 = r1 == r2; /* Compares register to memory */ do_nothing(); /* Forces register save to memory */ t2 = r1 == r2; /* Compares memory to memory */ printf("test1 t1: r1 %f %c= r2 %f\n", r1, t1 ? ’=’ : ’!’, r2); printf("test1 t2: r1 %f %c= r2 %f\n", r1, t2 ? ’=’ : ’!’, r2); } code/asm/fcomp.c Variables r1 and r2 are computed by the same function with the same argument. One would expect them to be identical. Furthermmore, both variables t1 and t2 are computing by evaluating the expression r1 == r2, and so we would expect them both to equal 1. There are no apparent...
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