8086/8088中有多少个寄存器?

问题描述 投票:8回答:4

我参加了计算机体系结构课程,并且我知道处理器具有32个32位寄存器。现在,我正在学习计算机体系结构课程,其中我读到8086具有8 registers only。但是我读过的书和this网站显示了许多寄存器。我对8086和8088中的寄存器感到困惑。请帮助我。

注意:

我对不同处理器中的不同寄存器大小有很好的了解。我只是对寄存器的数量感到困惑。

x86 cpu cpu-registers microprocessors
4个回答
29
投票

8086和8088是16位处理器-它们的寄存器的宽度均为16位。 (一些指令将DX和AX的组合视为32位整数,例如div输入和mul输出。)

请注意,8086具有16位数据总线; 8088具有8位数据总线。 (因此,加载/存储一个16位字需要2个总线周期。两个地址都仍为20位。)

通用目的寄存器

8086 CPU有8个通用寄存器,每个寄存器都有其自己的名称:

AX-累加器寄存器(分为AH / AL):

Generates shortest machine code: short-form encodings exist
Arithmetic, logic and data transfer
One number must be in AL or AX
Multiplication & Division
Input & Output

BX-基址寄存器(分为BH / BL)。

Offset address relative to DS by default

CX-计数寄存器(分为CH / CL):

The LOOP instruction uses it implicitly as a counter
Repetitive operations on strings with the REP command
Count (in CL) of bits to shift and rotate

DX-数据寄存器(分为DH / DL):

DX:AX concatenated into 32-bit register for some MUL and DIV operations
Specifying ports in some IN and OUT operations

SI-源索引寄存器:

Can be used for pointer addressing of data
Used as source in some string processing instructions
Offset address relative to DS by default

DI-目标索引寄存器:

Can be used for pointer addressing of data
Used as destination in some string processing instructions as ES:DI
Offset address relative to DS outside of string instructions

BP-基本指针:

Primarily used to access parameters and locals on the stack
Offset address relative to SS

SP-堆栈指针:

Always points to top item on the stack
Offset address relative to SS (but can't be used in 16-bit addressing modes)
Should always points to word (byte at even address)
An empty stack will have SP = FFFEh

分部记录器

  • CS-指向包含当前程序的段。
  • DS-通常指向定义变量的段。
  • ES-额外的段寄存器,取决于编码器来定义其用法。
  • SS-指向包含堆栈的段。

尽管可以在段寄存器中存储任何数据,但这绝不是一个好主意。段寄存器有一个非常特殊的用途-指向可访问的内存块。

段寄存器与通用寄存器一起使用以访问任何存储器值。例如,如果我们要访问物理地址12345h(十六进制)处的内存,则可以将DS = 1230h和SI = 0045h设置为。这样,我们可以形成20位线性地址,而不是单个寄存器仅16位。 (这适用于实模式;在保护模式下,分段是不同的。)

CPU通过将段寄存器乘以10h并向其添加通用寄存器(1230h * 10h + 45h = 12345h)来计算物理地址:

由2个寄存器组成的地址称为有效地址。默认情况下,BX,SI和DI寄存器与DS段寄存器一起使用。BP和SP与SS段寄存器一起工作。其他通用寄存器不能形成有效地址。同样,尽管BX可以形成有效地址,但BH和BL不能。

特殊目的寄存器

IP-指令指针:

Always points to next instruction to be executed
Offset address relative to CS

IP寄存器始终与CS段寄存器一起使用,它指向当前正在执行的指令。

标志寄存器

标志寄存器-确定处理器的当前状态。 CPU在进行数学运算后会自动对其进行修改,从而可以确定结果的类型,并确定将控制权转移到程序其他部分的条件。通常,您不能直接访问这些寄存器。

Carry Flag (CF) - this flag is set to 1 when there is an unsigned overflow. For example when you add bytes 255 + 1 (result is not in range 0...255). When there is no overflow this flag is set to 0.
Parity Flag (PF) - this flag is set to 1 when there is even number of one bits in (the low 8 bits of a) result, and to 0 when there is odd number of one bits. 
Auxiliary Flag (AF) - set to 1 when there is an unsigned overflow (carry-out) for low nibble (4 bits).
Zero Flag (ZF) - set to 1 when result is zero. For non-zero result this flag is set to 0.
Sign Flag (SF) - set to 1 when result is negative. When result is positive it is set to 0. (This flag takes the value of the most significant bit.)
Trap Flag (TF) - Used for on-chip debugging.
Interrupt enable Flag (IF) - when this flag is set to 1 CPU reacts to interrupts from external devices.
Direction Flag (DF) - this flag is used by some instructions to process arrays.  When this flag is set to 0 the processing is done forward, when this flag is set to 1 the processing is done backward.
Overflow Flag (OF) - set to 1 when there is a signed overflow. For example, when you add bytes 100 + 50 (result is not in range -128...127). 

3
投票

我参加了计算机体系结构课程,并且了解该处理器每个32位都有32个寄存器。

这不能回答您的问题,但是如果您想与其他工程师交流,则必须使用正确的语言。说“(一个)处理器具有32个32位大小的寄存器”将使您无所适从,处理器数量不计其数。

8086具有八个(或多或少是通用的)16位寄存器,包括堆栈指针,但不包括指令指针,标志寄存器和段寄存器。其中四个AX,BX,CX,DX可还可以访问两倍于8位寄存器(见图)的寄存器,而其他四个BP,SI,DI,SP仅是16位。

我假设混淆来自维基百科上的这句话。您阅读的两种资料都是正确的。有8个通用的目的寄存器(在文章中被称为“或多或少的通用”,我不知道谁能写出来),它们是:AX BX CX DX和SI DI BP SP。还有段寄存器,特殊用途寄存器和标志寄存器(在“排除”一词后注明,我想应该被读作“有寄存器,如果排除这些,则有8个) 3组”,这是含糊的)。

问题在于措辞。引用的句子令人困惑,我可以看到您的问题从何而来。提出这个问题从来没有什么麻烦,但是您应该了解Wikipedia并不是可靠的知识来源,如果您感到困惑,只需捡起一本书。


3
投票

8086有14个16位寄存器。 AX,BX,CX,DX,SI,DI,BP,SP,CS,DS,SS,ES,IP和标志寄存器。后两个只能间接访问。


2
投票

计算机体系结构书籍经常以MIPS为例,因为它非常简单且具有教育意义。 MIPS具有32个寄存器,但这确实意味着其他32位体系结构也具有32个寄存器。 32位此处仅表示计算机具有32-bit address/32-bit integer registers。它与寄存器的数量没有任何关系。ARM,最流行的32位体系结构,具有16个寄存器(尽管ARMv8 64位将这个数字增加了一倍至32)。许多其他32位体系结构也具有除32以外的寄存器号,例如Motoroka 68k和SuperH v2 / 3/4,均具有16个寄存器。有关体系结构的列表,请参见here。您会看到,64位体系结构很少有64个寄存器,因为这会大大增加寄存器文件的大小,并使上下文切换更糟。他们大多数有32个寄存器。

x86,几十年前就与8086向后兼容,只有8个可见整数寄存器。但是实际上,当今x86 CPU内部有数百个寄存器,并使用register renaming克服了寄存器数量的限制。

© www.soinside.com 2019 - 2024. All rights reserved.