- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 x86-64 Tour of Intel Manuals ,我读过
Perhaps the most surprising fact is that an instruction such as
MOV EAX, EBX
automatically zeroes upper 32 bits ofRAX
register.
同一来源引用的英特尔文档(《基本架构》手册中的 3.4.1.1 64 位模式下的通用寄存器)告诉我们:
- 64-bit operands generate a 64-bit result in the destination general-purpose register.
- 32-bit operands generate a 32-bit result, zero-extended to a 64-bit result in the destination general-purpose register.
- 8-bit and 16-bit operands generate an 8-bit or 16-bit result. The upper 56 bits or 48 bits (respectively) of the destination general-purpose register are not be modified by the operation. If the result of an 8-bit or 16-bit operation is intended for 64-bit address calculation, explicitly sign-extend the register to the full 64-bits.
在 x86-32 和 x86-64 汇编中,16 位指令如
mov ax, bx
不要表现出这种 eax 的高位字被清零的“奇怪”行为。
因此:引入这种行为的原因是什么?乍一看似乎不合逻辑(但原因可能是我习惯了 x86-32 汇编的怪癖)。
最佳答案
我不是 AMD,也不是他们的代言人,但我也会以同样的方式做到这一点。因为将上半部分清零不会产生对前一个值的依赖,所以 CPU 必须等待。 register renaming如果不这样做,机制基本上就会被击败。
这样您就可以在 64 位模式下使用 32 位值编写快速代码,而不必一直显式地破坏依赖关系。如果没有这种行为,64 位模式下的每条 32 位指令都必须等待之前发生的事情,即使该高位部分几乎永远不会被使用。 (将 int
设为 64 位会浪费缓存占用空间和内存带宽;x86-64 most efficiently supports 32 and 64-bit operand sizes)
8 位和 16 位操作数大小的行为很奇怪。疯狂的依赖性是现在避免使用 16 位指令的原因之一。 x86-64 继承了 8 位的 8086 和 16 位的 386,并决定让 8 位和 16 位寄存器在 64 位模式下的工作方式与在 32 位模式下的工作方式相同。
<小时/>另请参阅Why doesn't GCC use partial registers?了解实际 CPU 如何处理 8 位和 16 位部分寄存器的写入(以及随后读取完整寄存器)的实际细节。
关于assembly - 为什么 32 位寄存器上的 x86-64 指令会将整个 64 位寄存器的上部清零?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11177137/
这个问题在这里已经有了答案: Mute specified sections of an audio file using ffmpeg (3 个回答) 6年前关闭。 我想使用一些命令行工具(ffmp
我想使用 STL 容器(加上 std::basic_string)在内存中临时存储 key 或密码,完成后我想将内存归零。 我最初计划使用在自定义分配器上参数化的 STL 容器,该分配器将 alloc
我正在使用Windows credentials store像这样: PCREDENTIAL cred = nullptr; if (CredRead(entryName, 1, 0, &cred)
我正在开发一个 LKM,并且在分配它之后将一个 8192 字节的 vmalloc 区域归零。我知道我可以使用 vzalloc(),但它让我感到困惑,为什么我这样做: pmem = vmalloc(81
试试nodejs几天吧。我应该在 fs.readFile() 之后以某种方式关闭文件吗?如果是的话怎么办?为了更好的性能和内存安全,我应该使用 null 还是使用一些不必要的变量? 谢谢。 最佳答案
我读过一些关于 V8 隐藏类的文章。不过,我脑子里还有几个问题: 假设有两个对象: var a = { } a.x = 5 a.y = 6 var b = { } b.y = 7 b.x = 8 他们
我想将系统范围内的标准 malloc(通过 LD_PRELOAD 或仅替换已安装的 libc)替换为一个将已释放 block 中所有可能的内容清零的 malloc。有谁知道现有的解决方案? 在堆的未使
我是一名优秀的程序员,十分优秀!