Unlike the CPU registers where you can overwrite values by MOVing other values in them, you cannot load values in the FPU registers unless they are "tagged" as FREE.

Therefore, if all 8 FPU registers are in use, trying to load some other value will be impossible and will raise an exception. Managing the content of these registers is often the tricky part of using the FPU. Transfering values to temporary storage may become necessary in some cases to free registers to perform other intermediate operations.

The reference number of these registers is relative to the last one loaded (top of the stack) which is referred as st(0). If you use Windbg and have a window showing the FPU registers, you may notice that the value in the top register may transfer to the "bottom" registers when you pop it. Although that bottom register may seem to have a value, it would have been tagged as FREE, and therefore available for further use.

When using a debugger, you can check the loading condition of the registers by looking at the TAG word. There are 2 bits for each register. The two most significant bits are for st(0) and so on. The meaning of those bits are as follows:
00 = register contains valid number.
01 = register contains a value of 0
10 = register contains a special value (NAN, infinity, ...)
11 = register is empty (i.e. FREE)

Posted on 2003-03-14 00:07:58 by Raymond
10 = register contains a special value (NAN, infinity, ...) :grin:

Ya, you definitely can not load more than 8 values into the FPU without poping out the stack to make more room. The FPU is very limited. You sent out the wrong impressing when you said all you were doing is one FLD into the FPU, and your program was in its initial stages (this would have been an ez one to spot had this been known).

However I bet you'll never forget this lesson ;)
Posted on 2003-03-14 00:43:48 by NaN