Assembly: How does fld st(0) duplicates the top stack value in the following code?

There’s a good guide to x87 FPU by Raymond Filiatreault. Chapter 1 explains how the FPU register stack works. Yes, fld st(0) pushes a copy of the top of the stack. The Intel insn ref manual explicitly mentions this special-case use of fld st(n) I believe you’re right that fstp does pop after the fild. The first fild / fstp pair converts a global int (at L1000F140) to a … Read more

How to move ST(0) to EAX?

There is no real reason why you should. Remember that EAX is only a 32-bit register, while all the FPU registers are 80 bits in width, because the FPU does calculations on 80-bit floats by default. Therefore, moving data from the FPU register to a general purpose register will cause data loss. If you really want to … Read more