MMX 和 XMM 寄存器的区别? [英] difference between MMX and XMM register?

查看:135
本文介绍了MMX 和 XMM 寄存器的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在学习英特尔 x86 处理器上的汇编编程.

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

谁能给我解释一下,MMX和XMM寄存器有什么区别?我很困惑它们提供什么功能以及它们之间的异同?

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?

推荐答案

MM 寄存器是 MMX 指令集使用的寄存器,第一次尝试添加(仅限整数)SIMD 到 x86.它们是 64 位宽,它们实际上是 x87 寄存器尾数部分的别名(但它们不受 FPU 栈顶位置的影响);这样做是为了保持与现有操作系统的兼容性(它们已经在上下文切换时保存了 FPU 堆栈),但同时使用 MMX 和浮点成为一项重要的工作.

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.

如今,它们只是历史上的古怪,我认为实际上没有人再使用 MMX,因为它已被各种 SSE 扩展完全取代.编辑:正如 Peter Cordes 在评论中指出的那样,仍有相当多的 MMX 代码.

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 寄存器是一个完全独立的寄存器集,随 SSE 一起引入,至今仍被广泛使用.它们是 128 位宽,指令可以将它们视为 64、32(整数和浮点)、16 或 8 位(仅限整数)值的数组.其中 8 个在 32 位模式下,16 个在 64 位模式下.实际上,所有浮点数学运算都是在 64 位模式下在 SSE(以及 XMM 寄存器)中完成的,因此,与 MMX 寄存器不同,它们仍然非常相关.

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.

如今,您可能还会遇到 YMM 和 ZMM 寄存器;它们分别与 AVX (2011) 和 AVX-512 (2015) 指令集一起引入,并且它们扩展了 XMM 寄存器,与 er 扩展到通用寄存器(rax 扩展 eax 扩展了 ax 可以作为 ah:al).

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).

在支持 AVX 的处理器中,XMM 寄存器文件中的每个寄存器都扩展到 256 位.整个 256 位寄存器被称为 YMMx(x 从 0 到 15),可以被新的 AVX 指令使用,下半部分是 XMMx,仍然可以被旧的 SSE 指令使用.

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.

同理,AVX-512 将上面的寄存器扩展为 512 位;整个寄存器是 ZMMx(可用于 AVX-512 指令),低 256 位是 YMMx(也可用于 AVX 指令),低 128 位仍然是 XMMx(也可用于 SSE).此外,寄存器数量增加到 32 个,因此这些寄存器更大,数量增加了两倍.

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.

这篇关于MMX 和 XMM 寄存器的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆