News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

view of fpu registers step by step

Started by ToutEnMasm, June 30, 2009, 06:46:19 AM

Previous topic - Next topic

ToutEnMasm


There is not too many answers  :P
Perhaps this link give it
http://iptraf.org/instruction-mmx/page-1/index-Instruction%20mmx.html

If I understand well,this mean:
XSAVE_FORMAT.TagWord == 0 (Byte) ----> MMX mode ELSE fpu mode
And if we do an fpu instruction in the MMX mode:
Quote
If a floating-point instruction loads one of the registers in the FPU register stack before the FPU tag word has been reset by the EMMS instruction, a floating-point stack overflow can occur that will result in a floating-point exception or incorrect result.
Is it Good ?


FORTRANS

Hi,

   The tag word shows the status of the FPU registers (in FPU
mode of course).  Four states are shown in the documentation.


   Tag  Register
  value  state

   00  =  Valid
   01  =  Zero
   10  =  Special
   11  =  Empty


   So, all zeroes can exist outside the MMX mode if all of
the registers are full and contain valid numbers.

Regards,

Steve N.

clive

#17
Quote from: ToutEnMasm
There is not too many answers  :P

I was thinking about it, but couldn't find a quick cite, and wasn't sufficiently invested to look at the CPU behaviour. I don't think it would be too hard to verify/validate.

The information should also exist in the FSAVE/FNSAVE frames, as MMX was supposed to work in systems without explicit knowledge of the scheme. So legacy code to preserve the FPU context should maintain the MMX state across interrupts and task switches.
It could be a random act of randomness. Those happen a lot as well.

ToutEnMasm


Perhaps i can do simply as this:
;here avoid the cases where FXSAVE don't work (2 cases)
FXSAVE
emms              ;be sure to be in FPU
--- use of fpu registers allowed --------
FXRSTOR
;if not returned in mmx mode
;the first mmx instruction made the fpu return in mmx mode (that is what is said of them)

clive

Ok, so it is the Tag Word, in the FSAVE/FNSAVE 108 byte variant it is the word at +8, with MMX it is 0x5555 and after the EMMS it is 0xFFFF. So the MMX state is "special"

FSAVE after PXOR MM7,MM7
                               vv vv
0000 : 7F 03 FF FF 00 00 FF FF-AA AA FF FF 00 00 00 00 ................
0010 : 00 00 00 00 00 00 00 00-00 00 FF FF 00 00 00 00 ................
0020 : A0 39 16 00 00 00 AA B8-15 00 0A D8 90 7C 11 B4 .9...........|..
0030 : 17 00 00 00 4C F5 13 00-24 00 01 00 00 00 48 98 ....L...$.....H.
0040 : 15 00 61 B4 00 00 03 02-00 00 00 00 04 00 00 00 ..a.............
0050 : 00 00 00 00 00 00 04 00-D8 F9 13 00 38 02 15 00 ............8...
0060 : AC F5 00 00 00 00 00 00-00 00 FF FF             ............

FSAVE after EMMS

0000 : 7F 03 FF FF 00 00 FF FF-FF FF FF FF 00 00 00 00 ................
0010 : 00 00 00 00 00 00 00 00-00 00 FF FF 00 00 00 00 ................
0020 : A0 39 16 00 00 00 AA B8-15 00 0A D8 90 7C 11 B4 .9...........|..
0030 : 17 00 00 00 4C F5 13 00-24 00 01 00 00 00 48 98 ....L...$.....H.
0040 : 15 00 61 B4 00 00 03 02-00 00 00 00 04 00 00 00 ..a.............
0050 : 00 00 00 00 00 00 04 00-D8 F9 13 00 38 02 15 00 ............8...
0060 : AC F5 00 00 00 00 00 00-00 00 FF FF             ............
It could be a random act of randomness. Those happen a lot as well.