什么是 16 位、32 位和 64 位架构?
对于微处理器和/或操作系统,16 位、32 位和 64 位架构意味着什么?
对于微处理器,它是否意味着通用寄存器
的最大大小或整数
的大小或地址行
的数量或数量数据总线
还是什么?
我们所说的“DOS 是 16 位操作系统
”、“32 位操作系统中的 Windows
”等是什么意思?
What do 16-bit, 32-bit and 64-bit architectures mean in case of Microprocessors and/or Operating Systems?
In case of Microprocessors, does it mean maximum size of General Purpose Register
s or size of Integer
or number of Address-line
s or number of Data Bus line
s or what?
What do we mean by saying "DOS is a 16-bit OS
", "Windows in a 32-bit OS
", etc...?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我的原答案如下,想了解的请评论。
新答案
正如你所说,有多种措施。幸运的是,对于许多 CPU 来说,许多措施都是相同的,因此不会造成混乱。让我们看一些数据(抱歉图片上传,我看不到在 Markdown 中制作表格的好方法)。
正如您所看到的,许多列都是不错的候选列。然而,我认为通用寄存器(绿色)的大小是最常见的答案。
当处理器的不同寄存器的大小差异很大时,通常会对其进行更详细的描述,例如 Motorola 68k 被描述为16/32位芯片。
其他人则认为指令总线宽度(黄色)也与表中匹配。然而,在当今的流水线世界中,我认为对于大多数应用来说,与通用寄存器的大小相比,这是一个不太相关的衡量标准。
原始答案
不同的人可能意味着不同的事情,因为正如你所说,有几种措施。例如,谈论内存寻址的人可能与谈论整数算术的人意味着不同的东西。不过,我将尝试定义我认为的共识。
我的看法是,对于 CPU 来说,它意味着“用于标准操作的典型寄存器的大小”或“数据总线的大小”(两者通常是等效的)。
我用以下逻辑来证明这一点。 Z80 具有 8 位累加器和 8 位数据总线,同时具有 16 位内存寻址寄存器(IX、 IY、SP、PC)和16位内存地址总线。而Z80被称为8位微处理器。这意味着人们通常指的是主整数算术大小或数据总线大小,而不是内存寻址大小。
这不是指令的大小,因为 Z80(再次)有 1,2 和 3 字节指令,尽管当然多字节是在多次读取中读取的。另一方面,8086 是一个 16 位微处理器,可以读取 8 或 16 位指令。所以我不得不不同意说这是指令大小的答案。
对于操作系统,我将其定义为“代码被编译为在该大小的 CPU 上运行”,因此 32 位操作系统的代码被编译为在 32 位 CPU 上运行(根据上面的定义)。
My original answer is below, if you want to understand the comments.
New Answer
As you say, there are a variety of measures. Luckily for many CPUs a lot of the measures are the same, so there is no confusion. Let's look at some data (Sorry for image upload, I couldn't see a good way to do a table in markdown).
As you can see, many columns are good candidates. However, I would argue that the size of the general purpose registers (green) is the most commonly understood answer.
When a processor is very varied in size for different registers, it will often be described in more detail, eg the Motorola 68k being described as a 16/32bit chip.
Others have argued it is the instruction bus width (yellow) which also matches in the table. However, in today's world of pipelining I would argue this is a much less relevant measure for most applications than the size of the general purpose registers.
Original answer
Different people can mean different things, because as you say there are several measures. So for example someone talking about memory addressing might mean something different to someone talking about integer arithmetic. However, I'll try and define what i think is the common understanding.
My take is that for a CPU it means "The size of the typical register used for standard operations" or "the size of the data bus" (the two are normally equivalent).
I justify this with the following logic. The Z80 has an 8bit accumulator and an 8 bit databus, while having 16bit memory addressing registers (IX, IY, SP, PC), and a 16bit memory address bus. And the Z80 is called an 8bit microprocessor. This means people must normally mean the main integer arithmetic size, or databus size, not the memory addressing size.
It is not the size of instructions, as the Z80 (again) had 1,2 and 3 byte instructions, though of course the multi-byte were read in multiple reads. In the other direction, the 8086 is a 16bit microprocessor and can read 8 or 16bit instructions. So I would have to disagree with the answers that say it is instruction size.
For Operating systems, I would define it as "the code is compiled to run on a CPU of that size", so a 32bit OS has code compiled to run on a 32 bit CPU (as per the definition above).
CPU“有”多少位,意味着它的指令字长是多少。
在 32 位 CPU 上,此类指令的字长为 32 位,这意味着这是 CPU 可以作为指令或数据处理的宽度,通常会产生具有该宽度的总线。
出于类似的原因,寄存器的大小与 CPU 的字长相同,但出于不同的目的,您通常会使用更大的寄存器。
以PDP-8计算机为例。这是一台 12 位计算机。每条指令长 12 位。为了处理相同宽度的数据,累加器也是12位的。
但 12 位计算机之所以成为 12 位机器,是因为它的指令字长。它的前面板上有 12 个开关,可以通过它们逐条指令进行编程。
这是突破 8/16/32 位焦点的一个很好的例子。
位计数通常也是地址总线的大小。因此,它通常表示最大可寻址内存。
维基百科对此有很好的解释:
现在我们来谈谈操作系统。
对于 OS-es,这与 CPU 的实际“位数”的关系较小,它通常反映了操作码的组装方式(CPU 的字长)以及寄存器的寻址方式(您无法加载16 位寄存器中的 32 位值)以及如何寻址内存。将其视为已完成、已编译的程序。它存储为二进制指令,因此必须适合 CPU 的字长。从任务角度来看,它必须能够寻址整个内存,否则它无法进行适当的内存管理。
但归根结底,程序是 32 位还是 64 位(操作系统本质上是一个程序),它的二进制指令如何存储以及寄存器和内存如何寻址。总而言之,这适用于所有类型的程序,而不仅仅是操作系统。这就是为什么您要为 32 位或 64 位编译程序。
How many bits a CPU "is", means what it's instruction word length is.
On a 32 bit CPU, the word length of such instruction is 32 bit, meaning that this is the width what a CPU can handle as instructions or data, often resulting in a bus line with that width.
For a similar reason, registers have the size of the CPU's word length, but you often have larger registers for different purposes.
Take the PDP-8 computer as an example. This was a 12 bit computer. Each instruction was 12 bit long. To handle data of the same width, the accumulator was also 12 bit.
But what makes the 12-bit computer a 12 bit machine, was its instruction word length. It had twelve switches on the front panel with which it could be programmed, instruction by instruction.
This is a good example to break out of the 8/16/32 bit focus.
The bit count is also typically the size of the address bus. It therefore usually tells the maximum addressable memory.
There's a good explanation of this at Wikipedia:
Now let's talk about OS.
With OS-es, this is way less bound to the actual "bitty-ness" of the CPU, it usually reflects how opcodes are assembled (for which word length of the CPU) and how registers are adressed (you can't load a 32 bit value in a 16 bit register) and how memory is adressed. Think of it as the completed, compiled program. It is stored as binary instructions and has therefore to fit into the CPUs word length. Task-wise, it has to be able to address the whole memory, otherwise it couldn't do proper memory management.
But what come's down to it, is whether a program is 32 or 64 bit (an OS is essentially a program here) it how its binary instructions are stored and how registers and memory are addressed. All in all, this applies to all kinds of programs, not just OS-es. That's why you have programs compiled for 32 bit or 64 bit.
差异归结为传递到通用寄存器进行操作的指令集的位宽度。 16 位一次可以操作 2 个字节,64 位一次可以操作 8 个字节的指令。通常可以通过在每个时钟周期执行更密集的指令来提高处理器的吞吐量。
The difference comes down to the bit width of an instruction set passed to a general purpose register for operating on. 16 bits can operate on 2 bytes, 64 on 8 bytes of instruction at a time. You can often increase throughput of a processor by executing more dense instructions per clock cycle.
这些定义更多的是营销术语,而不是精确的技术术语。
用模糊技术术语来说,它们与架构上可见的宽度比任何实际实现寄存器或总线宽度更相关。例如,68008 被归类为 32 位 CPU,但芯片中有 16 位寄存器,并且只有 8 位数据总线和 20 多位地址位。
The definitions are marketing terms more than precise technical terms.
In fuzzy technical term they are more related to architecturally visible widths than any real implementation register or bus width. For instance the 68008 was classed as a 32-bit CPU, but had 16-bit registers in the silicon and only an 8-bit data bus and 20-odd address bits.
http://en.wikipedia.org/wiki/64-bit#64- bit_data_models 数据模型意味着语言的位数。
“OS is x-bit”这句话通常意味着该操作系统是为 x-bit cpu 模式编写的,即 64 位 Windows 在 x86-64 上使用长模式,其中寄存器为 64 位,地址空间为 64 位大,并且与 32 位模式还有其他明显的区别,在 32 位模式中,寄存器通常为 32 位宽,地址空间为 32 位大。在 x86 上,32 位和 64 位模式之间的主要区别在于 32 位中存在分段以实现历史兼容性。
通常,操作系统在编写时会考虑到 CPU 位数,x86-64 是数十年向后兼容性的著名示例 - 您可以拥有从 16 位实模式程序到 32 位保护模式程序再到 64 位长程序的所有内容 -模式程序。
另外,还有不同的虚拟化方法,因此您的程序可能会像在 32 位模式下运行一样,但实际上它是由非 x86 内核执行的。
http://en.wikipedia.org/wiki/64-bit#64-bit_data_models the data models mean bitness for the language.
The "OS is x-bit" phrase usually means that the OS was written for x-bit cpu mode, that is, 64-bit Windows uses long mode on x86-64, where registers are 64 bits and address space is 64-bits large and there are other distinct differences from 32-bits mode, where typically registers are 32-bits wide and address space is 32-bits large. On x86 a major difference between 32 and 64 bits modes is presence of segmentation in 32-bits for historical compatibility.
Usually the OS is written with CPU bitness in mind, x86-64 being a notable example of decades of backwards compatibility - you can have everything from 16-bit real-mode programs through 32-bits protected-mode programs to 64-bits long-mode programs.
Plus there are different ways to virtualise, so your program may run as if in 32-bits mode, but in reality it is executed by a non-x86 core at all.
当我们谈论计算机科学中的 2^n 位架构时,我们基本上谈论的是内存寄存器、地址总线大小或数据总线大小。 2^n 位架构术语背后的基本概念是表示此处的 2^n 位数据可用于由进程寻址/传输大小为 2^n 的数据。
When we talk about 2^n bit architectures in computer science then we are basically talking about memory registers, address buses size or data buses size. The basic concept behind term of 2^n bit architecture is to signify that this here 2^n bit of data can be made use to address/transport the data of size 2^n by processes.
据我所知,从技术上讲,它是整数路径的宽度。我听说过 16 位芯片具有 32 位寻址。但实际上,它是地址宽度。 sizeof(void*) 在 16 位芯片上为 16 位,在 32 位芯片上为 32 位,在 64 位芯片上为 64 位。
这会导致问题,因为 C 和 C++ 允许 void* 和整型类型之间的转换,并且如果整型类型足够大(与指针大小相同),那么它是安全的。这会导致各种不安全的事情,
因为 void* 现在是 int 的两倍,因此在 64 位代码上会严重崩溃和烧毁(在 32 位上工作)。
在大多数语言中,您必须努力关心您正在使用的系统的宽度。
As far as I know, technically, it's the width of the integer pathways. I've heard of 16bit chips that have 32bit addressing. However, in reality, it is the address width. sizeof(void*) is 16bit on a 16bit chip, 32bit on a 32bit, and 64bit on a 64bit.
This leads to problems because C and C++ allow conversions between void* and integral types, and it's safe if the integral type is large enough (the same size as the pointer). This lead to all sorts of unsafe stuff in terms of
Which will horrifically crash and burn on 64bit code (works on 32bit) because void* is now twice as big as int.
In most languages, you have to work hard to care about the width of the system you're working on.