AMD amd64 architecture User Manual

Page of 336
x87 Floating-Point Programming
269
24592—Rev. 3.15—November 2009
AMD64 Technology
quotient are calculated, guaranteeing that the remainder returned is less in magnitude than the divisor
in ST(1). If the exponent difference is equal to or greater than 64, only a subset of the integer quotient
bits, numbering between 32 and 63, are calculated and a partial remainder is returned. FPREM can be
repeated on a partial remainder until reduction is complete. It can be used to bring the operands of
transcendental functions into their proper range. FPREM is supported for software written for early
x87 coprocessors. Unlike the FPREM1 instruction, FPREM does not calculate the partial remainder as
specified in IEEE Standard 754.
The FPREM1 instruction works like FPREM, except that the FPREM1 quotient is rounded using
round-to-nearest mode, whereas FPREM truncates the quotient.
Square Root
FSQRT—Floating-Point Square Root
The FSQRT instruction replaces the contents of the top-of-stack, ST(0), with its square root.
6.4.5 Transcendental Functions
The transcendental instructions compute trigonometric functions, inverse trigonometric functions,
logarithmic functions, and exponential functions.
Trigonometric Functions
FSIN—Floating-Point Sine
FCOS—Floating-Point Cosine
FSINCOS—Floating-Point Sine and Cosine
FPTAN—Floating-Point Partial Tangent
FPATAN—Floating-Point Partial Arctangent
The FSIN instruction replaces the contents of ST(0) (in radians) with its sine.
The FCOS instruction replaces the contents of ST(0) (in radians) with its cosine.
The FSINCOS instruction computes both the sine and cosine of the contents of ST(0) (in radians) and
writes the sine to ST(0) and pushes the cosine onto the stack. Frequently, a piece of code that needs to
compute the sine of an argument also needs to compute the cosine of that same argument. In such
cases, use the FSINCOS instruction to compute both functions concurrently, which is faster than using
separate FSIN and FCOS instructions.
The FPTAN instruction replaces the contents of the ST(0) (in radians), with its tangent, in radians, and
pushes the value 1.0 onto the stack.
The FPATAN instruction computes
θ = arctan (Y/X), in which X is located in ST(0) and Y in ST(1).
The result,
θ, is written over Y in ST(1), and the stack is popped.
FSIN, FCOS, FSINCOS, and FPTAN are architecturally restricted in their argument range. Only
arguments with a magnitude of less than 2
63
can be evaluated. If the argument is out of range, the C2