In this example there is only a single pair the rst

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: s returned on the top of the floating-point register stack in extended-precision format. As an example, consider the following function 1 2 3 4 double funct(double a, float x, double b, int i) { return a*x - b/i; } Arguments a, x, b, and i will be at byte offsets 8, 16, 20, and 28 relative to %ebp, respectively, as diagrammed below: Offset Contents 8 a 16 x 20 b 28 i 184 CHAPTER 3. MACHINE-LEVEL REPRESENTATION OF C PROGRAMS The body of the generated code, and the resulting stack values are as follows: 1 fildl 28(%ebp) %st(0) 2 fdivrl 20(%ebp) %st(0) 3 flds 16(%ebp) Ü %st(1) %st(0) 4 fmull 8(%ebp) ¡Ü ¡Ü %st(1) %st(0) 5 fsubp %st,%st(1) Practice Problem 3.28: %st(0) For a function funct2 with arguments a, x, b, and i (and a different declaration than that of funct, the compiler generates the following code for the function body: 1 2 3 4 5 6 7 8 9 10 11 movl 8(%ebp),%eax fldl 12(%ebp) flds 20(%ebp) movl %eax,-4(%ebp) fildl -4(%ebp) fxch %st(2) faddp %st,%st(1) fdivrp %st,%st(1) fld1 flds 24(%ebp) faddp %st,%st(1) The returned value is of type double. Write C code for funct2. Be sure to correctly d...
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