[XviD-devel] Very minor correction

Dark Sylinc dark_sylinc at yahoo.com.ar
Sun Jan 2 00:38:48 CET 2005


Hi,
	I was looking at \src\util\emms.c and i found that
the notes corresponding
to "emms_c()" says:

"emms functions are used to restored the fpu context
after mmx operations
"because mmx and fpu share their registers/context
(??? need to be confirmed)"

Well... I confirm it. If somebody doesn´t trust me,
look at Intel´s manual
(www.intel.com)

"IA-32 Intel® Architecture
Software Developer’s
Manual
Volume 1:
Basic Architecture
Order Number
253665"
Chapter 9:
"9.5. COMPATIBILITY WITH X87 FPU ARCHITECTURE
The MMX state is aliased to the x87 FPU state. No new
states or modes have been added to
IA-32 architecture to support the MMX technology. The
same floating-point instructions that
save and restore the x87 FPU state also handle the MMX
state (for example, during context
switching). (...)"
"9.6.4. Mixing MMX and x87 FPU Instructions
(...)
• Do not rely on register contents across
transitions between x87 FPU and MMX code
modules. (...)"

Or try using an x87 FPU instruction and then a MMX
instruction. That will
override st(x).
ie:
fld	[my_float_in_memory] ;st(0) = my_float_in_memory
movd	mm0, 25		     ;st(0) = pfsdfsf or #QNAN/SNAN/etc
emms

The confusion can be made because of the emms
instruction. It seems that it
sets mm0 through mm7 to zero (also st(0)-st(7) = 0)
but emms doesn´t clear
the registers, it clears only the STATE. The state is
another 16-bit "register"
that contains information about the seven FPU regs.
(empty/valid/special/etc)
If that register (called TAG) doesn´t say empty" for
at least one FPU register,
the FPU cannot be used. Any mmx instructions (except
for those after an femms)
clears the whole TAG to "valid". That´s why we need to
emms after an MMX instruction
in order to use back the x87 FPU

Another reason could be that, when writing in C, no
data is loss. That is just luck,
because data may be lost, however most C compilers
stores data on memory, not in
registers, in order to prevent this.

Dark Sylinc


	

	
		
___________________________________________________________ 
250MB gratis, Antivirus y Antispam 
Correo Yahoo!, el mejor correo web del mundo 
http://correo.yahoo.com.ar


More information about the XviD-devel mailing list