Can someone please explain exactly what this is and how it is caused?

Can it be caused by successive/excessive fstp commands?

many thanks
Posted on 2001-10-20 13:47:57 by Unregistered
A stack overflow happens when you reach the limit and then go beyond it.
Ex: when you PUSH something, your StackPointer decrases... when it reaches Zero and you PUSH again, SP will turn into 0xFFFD again, because:

0 - 2 = maximum - 2
the maximum of any 16 bit register is 0xFFFF
so FFFF - 2 = 0xFFFD

On the FPU a stack overflow happens when you push 8 times (FLD) and the push again a vlue into the stack (FLD)
But the FPU stack does not work like a normal stack or register. It does not use a pointer, but it does something like a shift.

FPU Stack
|--|--|--|--|--|--|--|--|
St0.....................St7

When you push 7F
|7F|--|--|--|--|--|--|--|
St0......................St7

Then you push 6A
|6A|7F|--|--|--|--|--|--|
St0........................St7

Now you push more stuff
|1C|3E|E2|17|44|7A|6A|7F|
St0.................................St7

When you push one more value (FF) into the stack then it will overflow and overwrite the last stack position
|FF|1C|3E|E2|17|44|7A|6A|
St0................................St7

As you can see, the last position (st7) was overwritten by the one in St6. That's what happen when the FPU stack overflows.
Posted on 2001-10-21 03:31:37 by eeprom
Can it be caused by successive/excessive fstp commands?

Hey!!! I really don't know what happen if you fstp witouht having any value in the stack!!
I would like to know it :)
Posted on 2001-10-21 03:35:11 by eeprom
I believe excessive pops from the FPU do cause an underflow.
Posted on 2001-10-21 07:18:56 by Eóin
I tried ten successive fstp st(0)s without putting anything on the fp stack and no problem, ditto following that with 10 successive flds.
Posted on 2001-10-21 13:34:33 by iankay
The program doesn't necessarly crash, but if you look at the values that are poped off you'll see a bizarre number.
Posted on 2001-10-21 14:07:36 by Eóin
iankay, the CPU has to set-up to throw exceptions for these events by setting bits in the FPU control register. If those bits aren't set then nothing happens. Well, besides getting values that might not be what is intended.
Posted on 2001-10-21 14:42:24 by bitRAKE