为什么x86 int寄存器的数量是8? [英] Why the number of x86 int registers is 8?

查看:118
本文介绍了为什么x86 int寄存器的数量是8?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我开始学习x86汇编语言和CPU体系结构.我注意到int寄存器的总数是8,但是对于x86-64来说,它是16.

Recently I started to learn x86 assembly language and CPU architecture. I noticed that total number of int registers is 8, but for x86-64 it is 16.

为什么?必须有一些解释.

Why? There must be some explanation.

推荐答案

x86体系结构从最早的版本演变为

The x86 architecture has evolved from its earliest incarnation as an 8008 back in the early 1970s. At the time, memory bytes and therefore opcode space was extremely precious; only 3 bits were set aside for the (at the time) A, B, C, D, E, F, (and IIRC) H and L registers, all 8 bits. (I remember how painfully hard those machines were to program, and how slow! You had to load H and L with a memory address, before a memory read or write!)

从那时起,英特尔通过1980年代后期的8080、8086、80186、80286、80386、80486体系结构改进了指令集,将寄存器扩展到16位和32位,但保持相同的3位来选择注册.

Since then, Intel has evolved the instruction set, through 8080, 8086, 80186, 80286, 80386, 80486 architectures of the late 1980s, extending the registers to 16 and 32 bits, but staying with the same 3 bits to select a register.

直到AMD设计了64486版本的80486架构后,才通过添加指令前缀字节(因为现在的内存和操作码字节比较便宜)添加了第4个寄存器位.本质上,该前缀字节在由相同的3个旧式寄存器位选择的寄存器号中加上"8";这意味着寄存器号"分散在整个指令中,这使解码器看起来很丑陋,但是晶体管现在也很便宜.

It wasn't until AMD designed a 64 bit version of the 80486 architure, that a 4th register bit was added by virtue of adding (since now memory and therefore opcode bytes are cheap) an instruction prefix byte. This prefix byte in essence adds "8" to the register number selected by those same 3 legacy register bits; this means the "register number" is spread out across the instruction, which makes for an ugly decoder, but transistors are now cheap, too.

16个寄存器的借口是寄存器压力".理想的CPU将在其寄存器中执行所有必要的算术运算,始终具有足够的运算能力,因此它有时不必将寄存器溢出(以后存储并重新加载)到内存中以腾出空间进行其他计算.测量(和经验)表明,8个寄存器实际上不足以避免此类溢出,并且由于溢出触摸内存,它们大大降低了处理器的速度.我认为(仔细测量)32个寄存器已绰绰有余,但这需要 2 位,而16个值非常接近理想值,因此非常实用.而且,AMD能够将其64位产品和16个寄存器(而不是仅仅8个)用作有效的高科技营销功能.

The excuse for 16 registers is "register pressure". The ideal CPU will do all necessary arithmetic in its registers, always having enough so it doesn't have to sometimes spill (store and reload later) a register to memory to make space for another computation. Measurements (and experience) have shown that 8 registers was not really quite enough to avoid such spills, and since spills touch memory, they slow down the processor considerably. I think 32 is considered (carefully measured) to be more than enough registers, but that would have required 2 bits, and 16 is close enough to ideal to be very practical. And, AMD for awhile was able to use their 64 bit offering, and 16 registers rather than a mere 8, as effective high-tech marketing features.

英特尔发现自己失去了AMD的64位处理器之战,试图生产自己的x86 64位扩展,但是微软表示他们支持AMD指令集,并且不支持2种不同的x86 64位指令.套.英特尔折叠了,现在基本上具有与AMD提供的相同的基本64位指令集.

Intel, discovering they were losing the 64 bit processor war to AMD, tried to produce their own 64 bit extension of the x86, but Microsoft said they were supporting the AMD instruction set, and would not support 2 different x86 64 bit instruction sets. Intel folded, and now has essentially the same basic 64 bit instruction set that AMD offered.

您会发现,这些CPU的极现代版本具有向量寄存器集,分别由16个和32个(我认为)寄存器组成.操作码位现在便宜得多,指令提取率也令人难以置信.

You'll find that extremely modern versions of these CPUs have vector registers sets of 16 and 32 (I think) registers; opcode bits are much cheaper now and instruction fetch rates are incredible.

这篇关于为什么x86 int寄存器的数量是8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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