问题描述
我是一个CS的学生在英特尔的x86-64汇编编写,用 NASM
编制,并与Ubuntu 12.04的酷睿i7处理器作为客户操作系统上运行。有谁有一个如何用一个例子 XSAVE
和 XRSTOR
?我读过英特尔架构软件开发者手册上多次 XSAVE
部分。我试图执行 xsave
在C ++中,然后拆解二进制来获得它做什么的认识。当然,我已经冲刷互联网的例子。任何建议将非常感激。
I'm a CS student writing in Intel x86-64 assembly, compiling with nasm
, and running on an Core i7 processor with Ubuntu 12.04 as the guest OS. Does anyone have an example of how to use XSAVE
and XRSTOR
? I've read the section on XSAVE
in Intel Architectures Software Developers manual several times. I tried to implement xsave
in C++ and then disassemble the binary to get an understanding of what it's doing. And of course I've scoured the Internet for examples. Any suggestions would be much obliged.
推荐答案
最后,这个问题的答案。由于用户:哈罗德谁帮助回答这个问题对我来说。什么,我已经找到了一个总结:
Finally, an answer to this question. Thanks to user: harold who helped answer the question for me. A summary of what I've found:
设置在的.data的存储空间,并对齐在64字节边界上。然后,可以使用内存空间使用的命令。如果你想使用堆栈,你应该能够这样做同样确保栈64字节对齐,但为此这种方式似乎更容易给我。
Set up a memory space in .data and align it on a 64-byte boundary. Then you can use the commands with that memory space. If you want to use the stack, you should be able to do so similarly ensuring that the stack is 64-byte aligned, but this way seems easier to me for this purpose.
EAX:EDX是用于设置寄存器要保存的标志,恢复。这种组合是64位,并相与内部控制,知道哪些寄存器可以保存/恢复(这允许没有YMM例如忽略这些寄存器处理器),我觉得最简单的只是设置所有位,保存/恢复一切:
eax: edx is used to set the flags of which registers you WANT to save, restore. This combined is 64-bits and is ANDed with an internal control which knows which registers you CAN save/restore (this allows processors that don't have ymm for example to ignore those registers) I find it easiest to just set all bits on and save / restore everything:
段的.data P>
segment .data
align 64
regsave times 1024 dq 0
段的.text
segment .text
mov rdx, 0xFFFFFFFFFFFFFFFF
mov rax, 0xFFFFFFFFFFFFFFFF
xsave [regsave]
vzeroall
mov rdx, 0xFFFFFFFFFFFFFFFF
mov rax, 0xFFFFFFFFFFFFFFFF
xrstor [regsave]
这篇关于英特尔X86-64 XSAVE / XRSTOR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!