
14
Programming Considerations
AMD-K6 MMX Enhanced Processor Multimedia Technology
20726D/0—January 2000
Preliminary Information
Mixing MMX
and Floating-Point Instructions
The programmer must take care when writing code that
contains both MMX and floating-point instructions. The MMX
code modules should be separated from the floating-point code
modules. All code of one type (MMX or floating-point code)
should be grouped together as often as possible. To obtain the
highest performance, routines should not contain any
conditional branches at the end of loops that jump to code of a
different type than the code that is currently being executed.
In certain multimedia environments, floating-point and MMX
instructions may be mixed. For example, if a programmer wants
to change the viewing perspective of a three-dimensional scene,
the perspective can be changed through transformation
matrices using floating-point registers. The picture/pixel
information is integer-based and requires MMX instructions to
manipulate this information. Both MMX and floating-point
instructions are required to perform this task.
The software must clean up after itself at the end of an MMX
code module. The EMMS instruction must be used at the end of
an MMX code module to mark all floating-point registers as
empty (11=empty/invalid). In cooperative multitasking
operating systems, the EMMS instruction must be used when
switching between tasks.
Note:
In some situations, experienced programmers can utilize the
MMX registers to pass information between tasks. In these
situations, the EMMS instruction is not required.
The tag bits are affected by every MMX and floating-point
instruction. After every MMX instruction except EMMS, all the
tag bits in the floating-point tag word are set to 0. When the
EMMS instruction is executed, all the tag bits in the tag word
are set to 1.
Prefixes
All instructions in the x86 architecture translate to a binary
value or opcode. This 1 or 2 byte opcode value is different for
each instruction. If an instruction is two bytes long, the second
byte is called the Mod R/M byte. The Mod R/M byte is used to
further describe the type of instruction that is used.