Register names such as eax must be written with an

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: ession x = (a*b)+(-(a*b)+c) as follows. Observe how the instruction fld %st(0) is used to create two copies of a*b on the stack, avoiding the need to save the value in a temporary memory location. 4 1 fldl a %st(0) 4 fchs ¡ ´ ¡ ¡ %st(1) µ %st(0) 2 fmul b ¡ ¡ ¡ %st(0) 5 faddl c ¡ ´ ´ %st(1) µ· %st(0) %st(1) %st(0) 6 3 fld %st(0) fmulp ¡ ´ µ· µ ¡¡ %st(0) 3.14. *FLOATING-POINT CODE Practice Problem 3.27: Diagram the stack contents after each step of the following code: 183 1 fldl b %st(0) %st(1) %st(0) %st(1) %st(0) %st(1) %st(0) %st(1) %st(0) 2 fldl a 3 fmul %st(1),%st 4 fxch 5 fdivrl c 6 fsubrp %st(0) 7 fstp x Give an expression describing this computation. 3.14.6 Using Floating Point in Procedures Floating-point arguments are passed to a calling procedure on the stack, just as are integer arguments. Each parameter of type float requires 4 bytes of stack space, while each parameter of type double requires 8. For functions whose return values are of type float or double, the result i...
View Full Document

Ask a homework question - tutors are online