为什么32位应用程序可以在64位x86 CPU上运行?

编程入门 行业动态 更新时间:2024-10-28 06:23:54
本文介绍了为什么32位应用程序可以在64位x86 CPU上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

32位应用程序可执行文件包含用于32位CPU的机器代码,但是32位和64位Intel CPU的程序集和内部体系结构(寄存器数,寄存器宽度,调用约定)不同,因此如何处理在64位计算机上运行的32位exe?

32-bit application executables contain machine code for a 32-bit CPU, but the assembly and internal architecture (number of registers, register width, calling convention) of 32-bit and 64-bit Intel CPU's differ, so how can a 32-bit exe run on a 64-bit machine?

维基百科的x86-64文章说:

x86-64与16位和32位x86代码完全向后兼容. 由于完整的x86 16位和32位指令集仍在硬件中实现,而没有任何中间仿真,因此,现有的x86可执行文件在运行时没有兼容性或性能上的损失,而对现有的应用程序进行了重新编码以利用处理器设计的新功能可能会提高性能.

x86-64 is fully backwards compatible with 16-bit and 32-bit x86 code. Because the full x86 16-bit and 32-bit instruction sets remain implemented in hardware without any intervening emulation, existing x86 executables run with no compatibility or performance penalties, whereas existing applications that are recoded to take advantage of new features of the processor design may achieve performance improvements.

我不理解它们的意思是说在没有任何中间仿真的情况下保持在硬件中实现.是什么意思?

I don't understand what they mean by saying remain implemented in hardware without any intervening emulation. What does it mean?

推荐答案

简短的答案是x86系列处理器均设计为向后兼容.在新CPU中执行算术和读/写操作的逻辑电路仍然能够执行为较旧的CPU设计的指令,同时还能执行较新的指令(例如64位加法和减法).

The short answer is that the x86 family of processors were all designed to be backward compatible. The logic circuits that perform arithmetic and read/write operations in new CPUs are still capable of carrying out instructions designed for older CPUs while also carrying out newer instructions like 64-bit add and subtract.

如果您想要更多历史记录...

If you want more history...

x86指令集可以追溯到1970年代中期,始于Intel的第一个16位处理器 8086 .该CPU上的通用16位(2字节)寄存器称为AX,BX,CX和DX. 8086还允许访问每个寄存器的高字节和低字节.例如,您可以使用名称AL访问AX的低8位,或使用AH访问高8位.

The x86 instruction set dates back to the mid-1970s, beginning with Intel's first 16-bit processor, the 8086. The general-purpose 16-bit (2-byte) registers on this CPU were called AX, BX, CX, and DX. The 8086 also allowed access to the high and low bytes of each register. For example, you could access the lower 8 bits of AX using the name AL, or the higher 8 bits using AH.

当英特尔开始开发具有新功能的新处理器时,他们希望它们与8086及其以后的任何处理器向后兼容.接下来的产品是80186、80286和80386,它们的最后一个是他们的第一个32位处理器.

When Intel started developing new processors with new features, they wanted them to be backward compatible with the 8086 and any processors that came afterward. Next in line came the 80186, the 80286, and the 80386--the last of which was their first 32-bit processor.

当然,80386上的所有寄存器都必须是32位的,但是还必须与旧的x86处理器向后兼容.因此,英特尔没有取代寄存器,而是仅将现有寄存器扩展到了EAX,EBX,ECX等. (E表示扩展"). AX寄存器只是EAX寄存器的低16位,并且仍然可以访问.

Of course, all the registers on the 80386 had to be 32-bit, but it also had to be backward compatible with older x86 processors. So rather than replace the registers, Intel merely extended the existing ones to EAX, EBX, ECX, ...etc. (E meaning "extended"). The AX register is merely the lower 16 bits of theEAXregister, and is still accessible.

英特尔首款64位处理器遵循相同的逻辑; 32位EAX已扩展到64位RAX,依此类推.当前的x86-64汇编语言仍然可以使用addl,subl,andl,orl,...等指令在32位寄存器上执行算术运算,其中l表示"long" ",即4字节/32位.使用addq,subq,andq,orq,...等完成64位伪指令,其中q代表8字节/64位的四字".

The same logic was followed with Intel's first 64-bit processor; the 32-bit EAX was extended to the 64-bit RAX and so on. The current x86-64 assembly language can still perform arithmetic operations on 32-bit registers using instructions like addl, subl, andl, orl, ... etc, with the l standing for "long", which is 4 bytes/32 bits. 64-bit arthimetic is done with addq, subq, andq, orq, ...etc, with q standing for "quadword", which is 8 bytes/64 bits.

编辑:此pdf 看起来很好地介绍了32位和64位x86体系结构之间的区别.

EDIT: This pdf looks like it gives a good introduction to the differences between 32-bit and 64-bit x86 architectures.

更多推荐

为什么32位应用程序可以在64位x86 CPU上运行?

本文发布于:2023-11-04 17:21:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1558553.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   CPU

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!