Author Topic: tag word  (Read 16652 times)

mene mene tekel

  • Guest
tag word
« on: December 30, 2008, 12:14:25 AM »
Hi,

I'm struggeling around with my FPU tag word (FTW) which doesn't work as expected.
Roughly, I'm doing following:
...
finit
fld1 ;Only st0 is valid, all others are empty!
...
fsave memory ;1st surprise: FTW = FCFF, should be FFFC because st0 is valid?
...
frstor memory ;Restored correctly as far I can see in my debugger
...
fdecstp
...
fsave memory ;2nd surprise: FTW = FCFF, again, should be FFF3 because st1 is valid, now?
...
frstor memory
...
fdecstp
...
I always come up with FTW = FCFF!

When I debug the program with OllyDbg the debugger masters the stuff, so it shows 1st only st0 being valid, then 2nd only st1 being valid etc. but unfornunately doesn't shows me the original FTW it derives it's knowledge from. Or do they have another trick?

Does anybody have an idea why this FTW doesn't work?

Thanks,
Martin

mene mene tekel

  • Guest
Re: tag word
« Reply #1 on: December 30, 2008, 06:15:45 PM »
OK, got it!
We have to combine the FTW with the TOP pointer from the status word (FSW) reflecting the "register rolling" done by fdecstp - essentially simple... but this misunderstanding results from non-distiguish the relative register TOP named st0 and the absolute register Rn st0 is stored in... in almost all documentations...
Intel did ;-)
Thanks,
Martin