3 ms·
The x87 FPU "stack" is not truly a stack though: it's rather a ring buffer of 8 registers. And you can model it pretty well even without a "head pointer", just
by eddyb 11y ago
The x87 FPU "stack" is not truly a stack though: it's rather a ring buffer of 8 registers.
And you can model it pretty well even without a "head pointer", just with moves between all registers, e.g. push(x) is ST(7) = ST(6), ST(6) = ST(5), ..., ST(1) = ST(0), ST(0) = x.
I've implemented it as such in a lifter from x86 machine code and all the redundant moves just disappear, if the uses of the pseudo-stack are balanced, and you're left with traditional registers.