哪个更快?

发布于 2024-10-07 22:50:27 字数 27 浏览 0 评论 0原文

哪个更快更有用?累加器、寄存器还是堆栈?

which is faster and usefull ? accumulator , register , or stack?

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

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

发布评论

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

评论(5

凉世弥音 2024-10-14 22:50:27

寄存器是最快的。累加器也是一个寄存器,用于存储中间算术和逻辑结果(信息来自 Wikipedia)。

堆栈会更慢,因为它是内存区域,而内存总是比寄存器慢。

然而,由于 CPU 存储非常昂贵,因此可用内存总是比寄存器多。

底线:它们都很有用,而且它们的速度与可用存储空间成反比。

Registers are the fastest. An accumulator is also a register in which intermediate arithmetic and logic results are stored (info from Wikipedia).

A stack will be slower since it's a region of memory, and memory will always be slower than registers.

However, you will always have more memory available than registers since CPU storage is very costly.

Bottom line: they're all useful and their speed is inversely proportional to their available storage.

瀞厅☆埖开 2024-10-14 22:50:27

这些问题没有任何有关 CPU 架构的上下文或您想要完成的其他信息,无法以任何有用的方式回答。

通常累加器只是寄存器之一 - 现代 CPU 不再区分,因此对于旧的累加器可能更快 - 或者实际上是唯一允许您进行某些操作的寄存器。寄存器总是比外部存储器快,但它们的数量有限(并且它们需要由编译器/汇编器明确命名)。

堆栈是 RAM 中用于存储数据的区域。所以这肯定会慢一些:)

Those questions without any context about CPU architecture or other information what you want to accomplish cannot be answered in any useful way.

Usually the accumulator is just one of the registers - modern CPUs don't differentiate anymore, so for old one accu might be faster - or actually the only register allowing you certain operations. Registers are always faster then external memory, but there are just a limited amount of them (and they need to be explicitely named by the compiler/assember).

The stack is an area of RAM used to store data. So that's slower for sure :)

記柔刀 2024-10-14 22:50:27

问题不太正确。 “快”与操作有关,而不是与寄存器等有关。另一点 - 第一条消息中没有任何关于 CPU 架构的信息 :-)

根据 CPU 架构,累加器是一个寄存器,但可以有特殊的实现。这样,使用累加器的操作通常比寄存器操作更快。

关于堆栈。一些处理器不支持寄存器-寄存器操作(即输入-输出处理器)。在这种情况下,堆栈上的某些操作可能会更快,因为不需要计算有效地址。

Quistion is not quite correct. "Fast" is related to the operations, not to the registers and etc. Another point - there is nothing about architecture of CPU in first message :-)

Depending on CPU architecture accumulator is a register but can have a special implementation. This way the operations that use accumulateor usualy faster than register operations.

About stack. Some processors have no support of Register-Register operations(i.e. input-output processor). That case some operations on the stack can be faster because it is not required to calculate effective address.

洋洋洒洒 2024-10-14 22:50:27

寄存器总是更快,因为它不会将数据读取到内存中,但更清楚情况。

当您有许多类似 x64 或 Arm 架构时,寄存器非常有用。

Register are always faster because it doesn't go get data into the memory, but be more clear about the situation.

Registers are usefull when you have many like x64 or Arm architecture.

疯狂的代价 2024-10-14 22:50:27

一般来说,寄存器速度更快,因为它们实际上是微处理器的一部分。而累加器只是寄存器之一(通常存储各种运算结果的寄存器)。

堆栈只是像任何其他内存一样的内存,分配用于跟踪返回地址和局部变量。

但您不能将寄存器用于所有用途,因为可用的寄存器数量非常有限。

如果您解释了为什么要问这些问题,它们可能会更有意义。

Generally, registers are faster because they are actually part of the microprocessor. And the accumulator is just one of the register (the one that normally stores the result of various operations).

The stack is just memory like any other memory, allocated for the purpose of tracking return addresses and local variables.

But you can't use registers for everything because there are only a very limited number of them available.

If you explained why you were asking these questions, they might make a little more sense.

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