为什么32位应用程序可以在64位x86 CPU上运行? [英] Why do 32-bit applications work on 64-bit x86 CPUs?

查看:400
本文介绍了为什么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字节)寄存器称为AXBXCXDX. 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处理器向后兼容.因此,英特尔没有取代寄存器,而是仅将现有寄存器扩展到了EAXEBXECX等. (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汇编语言仍然可以使用addlsublandlorl,...等指令在32位寄存器上执行算术运算,其中l表示"long" ",即4字节/32位.使用addqsubqandqorq,...等完成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.

编辑:

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上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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