8-10
PROGRAMMING WITH THE INTEL MMX TECHNOLOGY
If a high-level language, such as C, is used, the data types could be defined as a 64-bit structure
with packed data types.
When implementing usage of MMX instructions in high-level languages other approaches
can be taken, such as:
Passing parameters to an MMX routine by passing a pointer to a structure via the integer
stack.
Returning a value from a function by returning the pointer to a structure.
8.5.4.Writing Code with MMX and Floating-Point Instructions
The MMX technology aliases the MMX registers on the floating-point registers. The main
reason for this is to enable MMX technology to be fully compatible and transparent to existing
software environments (operating systems and applications). This way operating systems will
be able to include new applications and drivers that use the MMX technology.
An application can contain both floating-point and MMX code. However, the user is discour-
aged from causing frequent transitions between MMX and floating-point instructions by
mixing MMX code and floating-point code.
8.5.4.1.RECOMMENDATIONS AND GUIDELINES
Do not mix MMX code and floating-point code at the instruction level for the following
reasons:
The TOS (top of stack) value of the floating-point status word is set to 0 after each
MMX instruction. This means that the floating-point code loses its pointer to its
floating-point registers if the code mixes MMX instructions within a floating-point
routine.
An MMX instruction write to an MMX register writes ones (11s) to the exponent part
of the corresponding floating-point register.
Floating-point code that uses register contents that were generated by the MMX instruc-
tions may cause floating-point exceptions or incorrect results. These floating-point
exceptions are related to undefined floating-point values and floating-point stack usage.
All MMX instructions (except EMMS) set the entire tag word to the valid state (00s in
all tag fields) without preserving the previous floating-point state.
Frequent transitions between the MMX and floating-point instructions may result in
significant performance degradation in some implementations.