一个 WORD 在 32/64 位操作系统中分别包含多少位? [英] How many bits does a WORD contain in 32/64 bit OS respectively?

查看:72
本文介绍了一个 WORD 在 32/64 位操作系统中分别包含多少位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人有明确的答案吗?

有人说在 32 位操作系统上 WORD 表示 16 位,对吗?

Someone says that on 32 bit OS a WORD means 16bit,true?

推荐答案

词"的概念有几个意思.问题中有 3 个含义.

The concept of a "word" has several meanings. There's 3 meanings embedded in the question.

  • 通用术语处理器词",在 CPU 架构的上下文中
  • 位大小"软件/操作系统与位大小"的对比硬件
  • 全大写术语 WORD,表示 16 位值 - 这是 WindowsWin32"的一部分C语言API
  • The generic term "processor word", in context of CPU architectures
  • The "bit size" of software/OS, vs the "bit size" of hardware
  • The all-caps term WORD, meaning a 16 bit value - This is a part of the Windows "Win32" C language API

在描述 Win32 WORD 类型定义时,也会出现这个:

When describing the Win32 WORD type definition, this also comes up:

  • 字"、双字"和四字"的 Intel/AMD 指令集概念

在常见/通用用法中,处理器词"是指指处理器寄存器的大小.它也可以指 CPU 指令的大小,或指针的大小(取决于确切的 CPU 架构).在简单的情况下,一个 32 位的处理器将有一个 32 位的字".大小(和指针大小).64 位处理器将具有 64 位字"大小(和指针大小).

In common/generic usage, a "processor word" refers to the size of a processor register. It can also refer to the size of CPU instruction, or the size of a pointer (depending on which exact CPU architecture). In simple cases, a 32 bit processor will have a 32 bit "word" size (and pointer size). A 64 bit processor will have a 64 bit "word" size (and pointer size).

维基百科文章关于这个处理器词";概念,详细说明了该术语的所有通用用法,以及几种当前和历史 CPU 架构的大小.

There is a wikipedia article on this "processor word" concept, which details all the generic uses of the term, and the sizes for several current and historical CPU architectures.

64 位"CPU 和64 位"操作系统是运行64 位"所必需的.软件.这可能是显而易见的.

A "64 bit" CPU and a "64 bit" OS are necessary in order to run "64 bit" software. This much is probably obvious.

64 位软件"使用 64 位指令(例如,将 64 位数字相加,或同时将 64 位数据从处理器寄存器复制到 RAM).它还可以使用 64 位指针大小.这意味着它不仅可以使用最多 4 GB 的 RAM(如32 位软件"),而且理论上可以使用大约 170 亿 GB 的 RAM(16 艾字节).

"64 bit software" uses 64 bit instructions (e.g. adding 64 bit numbers together, or copying 64 bits of data from a processor register to RAM at the same time). It also can use a 64 bit pointer size. This means that instead of only being able to use a maximum of 4 Gigabytes of RAM (like "32 bit software"), it can theoretically use about 17 Billion Gigabytes of RAM (16 Exabytes).

64 位"x64/x86 CPU 也可以运行32 位"(甚至16 位")软件.它可以做到这一点而无需对代码进行任何更改,也无需重新构建软件.这是因为所有旧 CPU 指令仍然存在于新 CPU 上,并且它们向后兼容.

A "64 bit" x64/x86 CPU can also run "32 bit" (or even "16 bit") software. It can do this without any changes to the code, and without having to rebuild the software. This is because all the old CPU instructions still exist on new CPUs, and they are backwards compatible.

这些概念与处理器字"的一般概念并不严格相同,但密切相关.

These concepts aren't strictly the same as the generic concept of a "processor word", but are closely related.

注意:当您谈论较旧和更专业的处理器(尤其是较旧的视频游戏系统)时,这个概念开始变得稍微复杂一些,但问题并非真正与那些有关,因此我不会详细介绍.那些往往被称为64 位".或8位"系统,但事实比这要复杂一些.请参阅处理器词";我在上面链接的 wiki 文章,或有关相关特定系统的文章.

Note: This concept starts getting slightly more complicated when you talk about older and more specialized processors (especially older video game systems), but the question wasn't really about those so I won't go into detail. Those tend to be talked about as "64 bit" or "8 bit" systems, but the truth is a bit more complicated than that. See the "processor word" wiki article I linked above, or an article about the specific system in question.

问题中的大写和特定大小(WORD 为 16 位,在 32 位操作系统上)意味着与通用术语处理器字"不同的内容.

The capitalization and the specific sizes in the question (16 bit for WORD, on a 32 bit OS) imply something different than the generic term "processor word".

在传统的 Windows 编程(Win32 API)中,定义了一个名为 WORD 的宏,其大小为 16 位.当处理器为 16 位时,这是有道理的.但是,即使您为 32 位或 64 位目标编译包含此宏的代码,它仍然是 16 位.Win32 API 中的 DWORD 为 32 位,QWORD 为 64 位.

In legacy Windows programming (the Win32 API), there is a macro defined called WORD, the size of which is 16 bits. This made sense when processors were 16 bit. However, even when you compile code that contains this macro for a 32 bit or 64 bit target, it will still be 16 bits. A DWORD in the Win32 API is 32 bits, and a QWORD is 64 bits.

这是因为 Microsoft 在其 Win32 API 中确实非常努力地支持向后兼容性,而无需对代码进行任何更改.在大多数情况下,您可以不加更改地编译 Windows 95 时代的 Win32 示例,它们今天仍然以完全相同的方式工作.

This is because Microsoft really tries very hard in their Win32 API to support backwards compatibility without having to do any changes to code. For the most part you can compile the Win32 samples from the Windows 95 era without changes, and they'll still work exactly the same way today.

微软很可能从英特尔(也可能是 AMD)文档中继承了这个命名方案.

Microsoft very likely inherited this naming scheme from Intel (and possibly AMD) documentation.

在英特尔文档中,Word"(Win32 WORD) 是 16 位.一个双字"(Win32 DWORD) 是 32 位.一个四字"(Win32 QWORD) 是 64 位.相关的汇编指令名称也反映了这种命名方案(例如 MMX Add Packed Integers PADD 指令:PADDWPADDDPADDQ代码>).

In Intel docs, a "Word" (Win32 WORD) is 16 bits. A "Doubleword" (Win32 DWORD) is 32 bits. A "Quadword" (Win32 QWORD) is 64 bits. The related assembly instruction names also reflect this naming scheme (e.g. MMX Add Packed Integers PADD instructions: PADDW, PADDD, PADDQ).

对于一些示例,您可以查看这篇关于 x86 指令集的维基百科文章,或者英特尔软件开发手册.

For some examples, you can check this wikipedia article on the x86 instruction set, or the Intel software development manuals.

就处理器字"的一般概念而言,此命名方案不一定有意义,因为这些概念仅针对寄存器的一部分.然而,它们在为 x86 程序创建稳定的编程接口方面确实有意义.这是您可以使用32 位"的很大一部分原因.(和 16 位)程序在64 位"之上操作系统.

This naming scheme doesn't necessarily make sense in terms of the general concept of a "processor word", since these concepts only address a part of a register. However they do make sense in terms of creating a stable programming interface for x86 programs. This is a big part of why you can use "32 bit" (and 16 bit) programs on top of a "64 bit" OS.

这篇关于一个 WORD 在 32/64 位操作系统中分别包含多少位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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