为什么 Windows 64 选择要求保存/恢复 xmm6 和 xmm7?

发布于 2024-07-07 15:40:55 字数 393 浏览 10 评论 0原文

为什么 Windows 64 选择要求保存/恢复 xmm6 和 xmm7?

在 Windows 32 中,您可以编写破坏 xmm0...xmm7 的汇编例程。 但是,如果您采用相同的汇编代码并在 Windows 64 中运行它,通常会导致应用程序错误,因为 VS2007 在 xmm6 和 xmm7 中存储双精度值。

在我看来,既然 X64 有 16 个 xmm 寄存器 xmm0...xmm15 (而 X32 只有 8 个 xmm 寄存器),那么微软可以选择允许用户破坏 xmm0..xmm7 (这样他们就可以重用 Win32 中的汇编例程)不考虑它)但要求用户保存/恢复 xmm8...xmm15。

那么,为了满足我自己的好奇心,为什么 Windows 64 选择要求保存/恢复 xmm6 和 xmm7?

Why did Windows 64 choose to require xmm6 and xmm7 to be saved/restored?

In Windows 32, you could write assembly routines which clobbered xmm0...xmm7. But if you take that same assembly code and run it in Windows 64, it will usually cause an application fault because VS2007 stores double-precision values in xmm6 and xmm7.

It seemed to me that since X64 has 16 xmm registers xmm0...xmm15 (whereas X32 only has 8 xmm registers), then Microsoft could have chosen to allow users to clobber xmm0..xmm7 (so that they could reuse assembly routines from Win32 without thinking about it) but require users to save/restore xmm8...xmm15.

So, to satisfy my own curiousity, why did Windows 64 choose to require xmm6 and xmm7 to be saved/restored?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温柔嚣张 2024-07-14 15:40:55

有趣的问题。 我发现了这个: Win64 结构化异常处理 ,其中指出必须保存/恢复 XMM6 到 XMM15,但没有说明原因。

维基百科表示 Microsoft x64 调用约定 使用 XMM0 - XMM3,这意味着其他调用约定假设被保留。 同样,它没有说明原因。

Interesting question. I found this: Win64 Structured Exception Handling, which states that XMM6 to XMM15 must be saved/restored, but doesn't say why.

Wikipedia says that the Microsoft x64 calling convention uses XMM0 - XMM3, which implies that the others are assumed to be preserved. Again, it doesn't say why.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文