I am given a assembly code which minimizes an infinitely large radian acute angle. But I am confused with how the fpu works. I fairly know about the general registers and other generic opcodes.
I read from a book "The Art of Assembly Language" that fmulp multiplies and stores the result in second operand and then pops st(0). But the following code totally does not seem to follow this rule or else I am confused.
// fHalf = 0.5f
// the previous value required to be computed is already at the fpu stack here
fldpi //loads PI value into st(0)
fxch st(1) // exchange st(1) and st
fmulp st(1), st // What does this do now?
fnstsw, ax // store status register into ax
test ax, 0x400 // test if C2 flag is set (exceeds range or not)
fstp st(1) // pop the PI
The fmulp( st0, sti ) instruction computes sti := sti * st0 and then pops
ST0. This instruction uses the value for STi before popping ST0. The fmul( mem )
instruction requires a 32- or 64-bit memory operand. It converts the specified
memory variable to an 80-bit extended-precision value and then multiplies
ST0 by this value.