Introduction to MMX instruction set-based programming

Source: Internet
Author: User
Tags arithmetic
MMX Technology Overview
Intel's MMX & #8482; (multimedia enhancement instruction set) technology can greatly improve application processing capabilities for 2D and 3D graphics and images. Intel MMX technology can be used for complex processing of large amounts of data and complex arrays. The basic units of data that can be processed using MMX technology can be byte, word ), or double-word ).
Visual Studio. NET 2003 provides support for MMX instruction set features, so that you can directly use C ++ code to implement MMX commands without having to write assembly code. By referring to Intel Software manuals [1] and reading the MMX programming technology topics in MSDN, you can better grasp the highlights of MMX programming.
MMX technology implements the execution mode of multiple data streams (SIMD, single-instruction, multiple-data) with single commands. Consider the following task to be programmed and add a number to each element in a BYTE array. In traditional programs, the algorithm for implementing this function is as follows:
For each B in array // for each element B in the array
B = B + n // add the previous number n
Let's take a look at its implementation details:
For each B in array // for each element B in the array
{
Load B into the register
Add n to the number in this register
Return the result in the obtained register to the memory.
}
The processor with MMX instruction set support has eight 64-bit registers. Each register can store 8 bytes and 4 words) double-word ). The MMX technology also provides an MMX instruction set, where instructions can load a value (its type can be byte, word, or dual word) into these MMX registers, perform arithmetic or logical operations in the register, and then put the results in the Register back into the memory storage unit. The above example uses the MMX algorithm as follows:
For each 8 members in array // retrieves 8 bytes in the array (one of which is a unit in the array) as a group
{
Load these 8 bytes into the MMX register
Adds n to the 8 bytes in this register through a CPU instruction execution cycle
Write the calculation result in the Register back to the memory.
}
C ++ programmers do not have to directly use commands in the MMX instruction set to access these MMX registers. You can use the 64-bit data type _ m64 and a series of C ++ functions for related arithmetic and logical operations. It determines which MMX register the program uses and code optimization is a C ++ compiler task.
Visual C ++ MMXSwarm [4] is a good example of image processing using MMX technology provided by MSDN. It contains encapsulated classes that simplify operations using MMX technology, it also shows you how to process images of different formats (such as 24-bit RGB and 32-bit RGB ). This article is just a brief introduction to MMX program design using Visual C ++. If you are interested, refer to the MMXSwarm example on MSDN.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.