64 位/32 位的底层优点和缺点是什么?

发布于 2024-08-01 21:59:29 字数 286 浏览 2 评论 0原文

我相信我们都听说过 64 位和 32 位这两个术语,但它们实际上意味着什么?

我很确定它们与内存地址的大小有关。 在 64 位机器上,对对象的引用是 64 位。 但我想更深入地挖掘......

  1. 人们经常听到“64 位机器”这个短语。 计算机的哪一部分实际上是针对位数的? 处理器? 操作系统?

  2. 拥有更大的内存地址有什么好处?

我可以添加更多问题,但我认为简短更好。

谢谢大家:D

I'm sure we've all heard the terms 64bit and 32bit thrown around, but what do they actually mean?

I'm pretty sure they have to do with the size of a memory address. On a 64bit machine, a reference to an object is 64 bits. But I want to dig a little deeper....

  1. One often hears the phrase "64bit machine." What part of the computer is actually geared toward the number of bits? Processor? Operating System?

  2. What is the advantage of having larger memory addresses?

I could add more questions, but I think brief is better.

Thanks guys :D

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

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

发布评论

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

评论(7

暮光沉寂 2024-08-08 21:59:29

64 位指的是寄存器宽度、内存寻址空间等。好处之一是能够寻址超过 4GB 的内存。

Wikipedia 有一篇关于 64 位计算的文章,其中包含更多详细信息。

编辑:更多内存的优点是操作系统和程序拥有更多的虚拟寻址空间 - 16 艾字节(172 亿 GB) - 更重要的是,可以添加更多的物理内存系统并进行寻址,从而减少虚拟内存与磁盘之间的交换。

更宽的寄存器和数据总线的优点是可以更容易、更快速地移动相同数量的数据。 需要两个或多个寄存器的操作现在只需一个即可完成。

因此,当软件重新编译为 64 位时,性能通常会得到提高。

缺点是更广泛的数据可能意味着相同数据占用更多空间。 例如,存储数字 300 需要 9 位。 如果以 32 位整数存储,则浪费了 23 位。 在 64 位中,这种浪费变成了 55 位。 因此,无需重新工具,简单地重新编译为 64 位即可生成速度更快但稍显臃肿的软件。

编辑:这里还有64位技术页面

64 bit refers to the width of registers, memory addressing space, etc. One benefit is the ability to address more than 4GB of memory.

Wikipedia has an article on 64-bit computing with more details.

Edit: The advantages to more memory are that the operating system and programs have more virtual addressing space--16 exabytes (17.2 billion GB)--and, more importantly, that more physical memory can be added to a system and addressed, causing less swapping of virtual memory to and from disk.

The advantage to wider registers and data buses are that it is easier and faster to move the same amount of data around. An operation that required two or more registers can now be done with one.

So, performance is typically increased when software is recompiled for 64 bits.

A disadvantage is that wider data can mean more space taken by the same data. For instance storing the number 300 requires nine bits. If it's stored in a 32 bit integer, 23 bits are wasted. In 64 bit, that wastage becomes 55 bits. So, without retooling, a simple recompile to 64 bit can yield faster, but slightly more bloated software.

Edit: Also there are 64-bit technology pages here:

情徒 2024-08-08 21:59:29
  • 64 位系统可以直接寻址更多的内存
  • 64 位系统可以处理两倍于 32 位的数据块,这有助于某些操作更快地进行

对于某些程序(例如办公自动化套件),32 位与 64 位几乎没有明显的差异。

但对于其他应用程序,例如数据库、图形/视频处理或托管虚拟机,能够一次访问更多物理内存并能够使用每条指令处理更多信息可以在性能上产生巨大差异。

请注意,如今许多 32 位芯片都具有 64 位扩展功能,正如许多 FPU (数学)或 SSMD(向量)操作已在 64 位模式下完成。

请参阅 32 位与 32 位 64 位系统:有什么区别? 了解更多信息。

  • 64bit systems can directly address significantly more memory
  • 64bit systems can process data in chunks twice as large as 32bit, which helps some operations go more quickly

For some programs, like office automation suites, 32bit vs 64bit makes little observable difference.

But for other applications, such as databases, graphics/video processing, or hosting virtual machines, being able to reach more physical memory at once and being able to process more information with each instruction can make a huge difference in performance.

Note that today, many 32bit chips have 64bit extension functions, as many FPU (math) or SSMD (vector) operations are done in 64bit mode already.

See 32-bit Vs. 64-bit Systems: What's The Difference? for more.

太傻旳人生 2024-08-08 21:59:29
  1. CPU 寄存器和内存寻址。

  2. 系统可以引用(查看)更多内存。

  1. CPU registers and memory addressing.

  2. The system can reference (see) much more memory.

枕梦 2024-08-08 21:59:29

我认为最好的答案是 x86 位 x64 汇编程序中的比较

当你的 x32 位程序注册一个变量时,例如整数(5),代码相当于这样:

push 5

为了更好地理解事物,'push X' 是一个快捷方式to:

sub esp,4 //substracts esp with 4(4*8=32 bits.That's the size of a pointer in x32 executables) in order to make space for our variable
mov [esp],X //moves variable in @esp

这些寄存器是32位(4字节长),这是任何32位编程语言中指针的大小。

然而,在 64 位代码中,大小要大两倍,寄存器也是如此。我们的寄存器 ESP 存在于 x64 可执行文件中,但它的使用并不像 x32 可执行文件中那样广泛。

相反,所有寄存器的名称前面都会有一个“R”(EAX 变为 RAX,ESP 变为 RSP,EDX 变为 RDX 等等)。

因此,我们在 x64 可执行文件中的代码不会有任何不同,除了“push X”的快捷方式将是

sub esp,8
mov [rsp],X

RSP 的大小是 ESP 的两倍 - 64 位,8 字节。

最重要的是,x64 位可执行文件比 x32 位可执行文件使用更多的内存。

I think the best answer would be a comparison in x86 bit x64 assembler

When your x32 bit program registers a variable,for example an integer(5),the code is equivalent to this:

push 5

To Understand things better,'push X' is a shortcut to:

sub esp,4 //substracts esp with 4(4*8=32 bits.That's the size of a pointer in x32 executables) in order to make space for our variable
mov [esp],X //moves variable in @esp

Those registeres are 32 bit(4 bytes long),which is the size of a pointer in any 32 bit programming language.

In 64 bit code,however the size is twice bigger and so are registers.Our register ESP exists in x64 executables,but its not widely used as it is in x32 executables.

Instead all of the registeres get a "R" in front of their name(EAX becomes RAX,ESP becomes RSP,EDX becomes RDX and so on).

So our code in x64 executable won't be any different,except the shortcut for 'push X' will be

sub esp,8
mov [rsp],X

RSP has double the size of ESP - 64 bits,8 bytes.

The bottom line is that x64 bit executables use more memory than x32 bit executables.

狼性发作 2024-08-08 21:59:29

让我们回到基础知识。

如今 99% 的计算机都基于所谓的 冯诺依曼架构。 本质上,计算机处于以下恒定循环中:

  1. 从 RAM 获取命令
  2. 在 CPU 上执行命令

替代文本
(来源:wikimedia.org

当提到 32/64 位系统(或任何其他位大小)时,本质上您正在谈论计算机的体系结构和实现:

  • 空间 (RAM) 的大小
  • CPU 寄存器的
  • 大小 总线大小(即 CPU 之间、 RAM、I/O 等...)

如果您有 64 位系统,则您的地址空间为 2^64。 这就是为什么32位系统不能有超过4GB的RAM。 如何寻址大于2^32的内存空间?

关于性能差异,没有明确的答案(就像没有明确的答案 CISC 或 RISC 架构更好一样)。 这很大程度上取决于您使用的应用程序。

总而言之:64 位架构只是构建计算机的一种不同方式。 这并不意味着它更好或更差,或者以不同的方式做事(在低级别上,每台计算机都在执行获取执行)。 这只是实现计算机的不同方式

Let's go back to the basics.

99% of computer these days are based on what is referred to as the Von Neumann architecture. Essentially, the computer is in a constant cycle of:

  1. Fetching a command from RAM
  2. Executing the command on the CPU

alt text
(source: wikimedia.org)

When referring to 32/64-bit system (or any other bit size), essentially you are talking about the architecture and implementation of the computer:

  • size of memory space (RAM)
  • size of CPU registers
  • bus size (i.e. between CPU, RAM, I/O, etc...)

If you have a 64-bit system, you have an address space of 2^64. This is why 32-bit system cannot have more than 4GB of RAM. How can you address a memory space which is larger than 2^32?

Regarding the performance differences, there is no clear cut answer (just as there is no clear answer if CISC or RISC architecture is better). It vastly depends on the applications you are using.

To sum: a 64-bit architecture is simply a different way to build a computer. It does not mean it is better, or worse, or does things differently (on a low level, every computer is doing fetch-execute). It's simply a different way of implementing a computer.

网名女生简单气质 2024-08-08 21:59:29

区别在于 32 位;-)

您需要 64 位硬件(处理器)才能运行 64 位操作系统。
您需要 64 位操作系统才能运行 64 位软件。
这是依赖关系。

  • 在 32 位系统中,您只能寻址 4 GiByte (2^32) 内存,在 64 位系统中,理论限制为 2^64 字节。
  • 64 位软件需要稍多的内存,主要是因为指针是 8 字节而不是
  • x86_64 上的 4 个字节,64 位可执行文件需要更多内存,因为许多指令有一个额外的操作码,因此
  • 在 x86_64 上可能运行速度较慢,64 位软件可以使用更多寄存器并且有可能运行得更快

The difference is exactly 32 bit ;-)

You need 64 bit hardware (processor) to run a 64 bit OS.
You need a 64 bit OS to run 64 bit software.
This are the dependencies.

  • In a 32 bit system you are limited to addressing 4 GiByte (2^32) memory, in a 64 bit there is a theoretical limit of 2^64 byte.
  • 64 Bit software needs slightly more memory, mainly for pointers are 8 Bytes instead of 4
  • on x86_64, 64 Bit executables need more memory, as there is an additional opcode for many instructions, and thus may run slower
  • on x86_64, 64 Bit software can use more registers and has the potential to run faster
顾挽 2024-08-08 21:59:29

确切地说,64 位或 32 位仅指主总线的宽度。

Exactly the 64bit or 32bit references just to the width of the main bus.

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