为什么一字节是8位?

来源:互联网 发布:java标识符规范 编辑:程序博客网 时间:2024/04/30 12:40

历史回溯

回溯70年计算机发展史,多到64和少到1位的计算机都曾设计过,比如常见的1, 5, 6, 7, 8, 9, 12, 18, 20 和36 bits;

1bit--这个最原始,设想一下只有1bit的指令,1bit的数据宽度,1bit的寄存器,一次只能操作1bit,比老爷机还要老爷机,会不会疯掉?好像不会存在的东西,但是Motorola MC14500B就是这么个玩意。虽然很简单,但是不要小看它!因为它才开启人类计算时代的新纪元,就像智人从森林走进草原开辟人类的新世纪一样。参考文献1bitwiki

5bit--这个要来源于5-bit的 baudot codes(波多码),不过编码的字符有限,很快就被淘汰了!再到6bit,其表示的字符也是不够充足,再加上逻辑电路复杂性!也是没活多久!

然后就是12, 18 (或 36) -bit在 60s, 70s 以及80s的某个时段的计算机架构中十分流行; 20-bit bytes在50s的"IAS machines"十分普遍 (具体细节就不罗列了,有兴趣自行wiki或google,关键字: x bit computer, 其中x是具体的bit位数)

到目前为止,所有计算机都遵循“8bits/byte,byte作为最小可寻址存储单位”这一没有“明文”规定的规定!简单了解一下为什么!

瞅瞅8bit/byte的来源:

"The IBM System/360 introduced byte-addressable memory with 8-bit bytes, as opposed to bit-addressable or decimal digit-addressable or word-addressable memory, although its general purpose registers were 32 bits wide, and addresses were contained in the lower 24 bits of those addresses. Different models of System/360 had different internal data path widths; the IBM System/360 Model 30 (1965) implemented the 32-bit System/360 architecture, but had an 8 bit native path width, and performed 32-bit arithmetic 8 bits at a time.

The first widely adopted 8-bit microprocessor was the Intel 8080, being used in many hobbyist computers of the late 1970s and early 1980s, often running the CP/M operating system; it had 8-bit data words and 16-bit addresses. The Zilog Z80 (compatible with the 8080) and the Motorola 6800 were also used in similar computers. The Z80 and the MOS Technology 6502 8-bit CPUs were widely used in home computers and second- and third-generation game consoles of the '70s and '80s. Many 8-bit CPUs or microcontrollers are the basis of today's ubiquitous embedded systems."——引自8bitwiki

因此,所有体系结构最终都以IBM的先河,而以2的幂方以及bits包含在最小可寻址单元内byte内而统一起来!!!

目前bit和byte的比较

bit:

  • 计算机中的最小存储单元
  • 存储内容总是0或1
  • 所有二进制状态的实体都可以使用1bit表示
  • 8bits组成1byte
  • 不能够单独寻址

byte:

  • 1byte包含8bits
  • 可以存储所有ASCII所有字符(这是它包含8bits的初衷)
  • 十进制整数范围[-128,127]或[0, 255]
  • 最小的可寻址存储单元

在C语言中的体现

C标准规定char至少是8bit,1byte存储不了的字符使用wchar(宽字符)类型存储,占用2字节!此外,要想操作位有两种方式,一是位域,二是寄存器操作!

总结

时代在前进,计算机在进化,为了更好的量化现实客观世界,导致计算机的bit不断再进化!IBM的先河,开辟了1byte-8bits的架构,而后纷纷效仿,一直延续至今!此外,为了表示世界语言,8bit是办不到的,目前的Unicode用2字节,16bits编码,即C中的wchar。


0 0
原创粉丝点击