This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: IA32: printing FP register variables


> > As long as the relative position of items on the stack didn't change
> > (this var is always 2 from the top), this should be OK.
>
> Well, the reason this problem seems hard to me is exactly because the
> position of items relative to the top of the stack *will* change,
> whenever you execute instructions like FILD, FDIVP, etc.  If they were
> a constant distance, then we could simply assign register numbers to
> ST(0) -- ST(7) in the usual way, and everything would work.

I guess an example would help...

Consider this code where we have doubles a and b allocated to two spots on
the FP stack (excuse the MASM notation... I'm not yet fluent in gas syntax)

fld a_value        ;; a is at bottom_offset(0)
fld b_value        ;; b is at bottom_offset(1)
fld1               ;; temp with no debug info
fadd st2           ;; result of (a + 1)
fstp st1           ;; stored into b, pop the temp

At each instruction, the invariant that a is 0 from the bottom and b is 1
from the bottom holds.  Note, the bottom of the stack can be known by the
debugger via scanning the FPU tag word from the TOP element looking for a FP
register that is empty.  All this info is provided by an FSAVE or FSTENV.

--
Ben Combee, x86/Win32/Novell/Linux CompilerWarrior
http://www.metrowerks.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]