Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between MMX and XMM register?

I'm currently learning assembly programming on Intel x86 processor.

Could someone please explain to me, what is the difference between MMX and XMM register? I'm very confused in terms of what functions they serve and the difference and similarities between them?

like image 620
Thor Avatar asked Jun 01 '17 05:06

Thor


People also ask

What is a XMM register?

XMM registers, instead, are a completely separate registers set, introduced with SSE and still widely used to this day. They are 128 bit wide, with instructions that can treat them as arrays of 64, 32 (integer and floating point),16 or 8 bit (integer only) values. You have 8 of them in 32 bit mode, 16 in 64 bit.

What is MMX register?

Each register is 64 bits wide and can be used to hold either 64-bit integers, or multiple smaller integers in a "packed" format: one instruction can then be applied to two 32-bit integers, four 16-bit integers, or eight 8-bit integers at once. MMX provides only integer operations.

How many XMM registers are there?

There are eight XMM registers available in non -64-bit modes and 16 XMM registers in long mode, which allow simultaneous operations on: 16 bytes.

What are SSE registers?

SSE stands for Streaming SIMD Extensions. It is essentially the floating-point equivalent of the MMX instructions. The SSE registers are 128 bits, and can be used to perform operations on a variety of data sizes and types. Unlike MMX, the SSE registers do not overlap with the floating point stack.


1 Answers

MM registers are the registers used by the MMX instruction set, one of the first attempts to add (integer-only) SIMD to x86. They are 64 bit wide and they are actually aliases for the mantissa parts of the x87 registers (but they are not affected by the FPU top of the stack position); this was done to keep compatibility with existing operating systems (which already saved the FPU stack on context switch), but made using MMX together with floating point a non trivial job.

Nowadays they are just a historical oddity, I don't think anybody actually uses MMX anymore, as it has been completely superseded by the various SSE extensions. Edit: as Peter Cordes points out in the comments, there is still quite some MMX code around.


XMM registers, instead, are a completely separate registers set, introduced with SSE and still widely used to this day. They are 128 bit wide, with instructions that can treat them as arrays of 64, 32 (integer and floating point),16 or 8 bit (integer only) values. You have 8 of them in 32 bit mode, 16 in 64 bit. Virtually all floating point math is done in SSE (and thus XMM registers) in 64 bit mode, so, unlike MMX registers, they are still quite relevant.

Nowadays you may also meet the YMM and ZMM registers; they were introduced respectively with the AVX (2011) and AVX-512 (2015) instruction sets, and they expand the XMM registers, not unlike the e and r extensions to the general-purpose registers (rax extended eax which extended ax which can be accessed as ah:al).

In an AVX-capable processor, each register in the XMM register file is expanded to 256 bits. The whole 256 bit register is referred to as YMMx (x from 0 to 15) and can be used by the new AVX instructions, the lower half is XMMx, and can be still used by older SSE instructions.

Similarly, AVX-512 expands the registers above to 512 bit; the whole register is ZMMx (usable with the AVX-512 instructions), the lower 256 bit is YMMx (also usable with AVX instructions), the lower 128 bits are still XMMx (usable also with SSE). Also, the register count is increased to 32, so these registers are both bigger and twice in number.

like image 119
Matteo Italia Avatar answered Sep 23 '22 00:09

Matteo Italia