本文介绍了8086/8088中有多少个寄存器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我参加了计算机体系结构课程,并且了解到处理器具有32个32位寄存器。现在,我正在研究计算机体系结构课程,在该课程中我读到8086仅具有。但是我读过的书和网站显示了许多寄存器。我对8086和8088中的寄存器感到困惑。请帮帮我。



注意:



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

解决方案

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



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



通用寄存器



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



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

 生成最短的机器代码:存在短格式编码
算术,逻辑和数据传输
一个数字必须为AL或AX
乘法&
除法输出

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

 默认情况下相对于DS的偏移地址

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

  LOOP指令隐式地将其用作计数器
使用REP命令对字符串进行重复操作
要移位和旋转的位数(按CL计)

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

  DX:AX连接到32-某些MUL和DIV操作的位寄存器
在某些IN和OUT操作中指定端口

SI -源索引寄存器:

 可用于数据的指针寻址
在某些字符串处理指令中用作源
相对于DS的默认偏移地址

DI-目标索引寄存器:

 可以b e用于数据的指针寻址
在某些字符串处理指令中用作目标,如ES:DI
在字符串指令


BP-基本指针:

 主要用于访问参数和堆栈上的本地变量
相对于SS
的偏移地址

SP-堆栈指针:

 始终指向堆栈中的最高位
相对于SS的偏移地址(但不能用于16位寻址模式)
应始终指向单词(偶数地址处的字节)
空堆栈将具有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-指令指针:

 始终指向要执行的下一条指令
偏移量相对于CS的地址

IP寄存器始终与CS段寄存器一起工作,并且指向当前正在执行的指令。



标志寄存器



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

  Carry Flag(CF)-当存在该标志时,此标志设置为1。是一个未签名的溢出。例如,当您添加字节255 + 1(结果不在0 ... 255范围内)时。当没有溢出时,此标志设置为0。
奇偶校验标志(PF)-当结果中有偶数个位(a的低8位)时,此标志设置为1,并设置为0当奇数个一位时。
辅助标志(AF)-当低位半字节(4位)发生无符号溢出(执行)时,设置为1。
零标志(ZF)-当结果为零时设置为1。对于非零结果,此标志设置为0。
符号标志(SF)-当结果为负时设置为1。当结果为正时,将其设置为0。(此标志采用最高有效位的值。)
陷阱标志(TF)-用于片上调试。
中断允许标志(IF)-当该标志设置为1时,CPU对来自外部设备的中断作出反应。
方向标志(DF)-某些指令使用此标志来处理数组。当此标志设置为0时,处理向前进行;当此标志设置为1时,处理向后进行。
溢出标志(OF)-当有符号溢出时设置为1。例如,当您添加100 + 50字节时(结果不在-128 ... 127范围内)。


I took Computer Architecture course and I understood that processor has 32 registers each of 32 bit. Now I am studying computer architecture course in which I read that 8086 has 8 registers only. But the book I read and this website shows many registers. I am getting confused about the registers in 8086 and 8088. Please help me out.

NOTE:

I have a good understanding of different register sizes in different processors. I am just getting confused in the number of registers.

解决方案

The 8086 and 8088 are 16 bit processors - their registers are each 16 bits in width. (A few instructions treat the combination of DX and AX as a 32 bit integer, like div input and mul output.)

Note that the 8086 has 16 bit data bus; the 8088 has an 8 bit data bus. (So loading/storing a 16-bit word takes 2 bus cycles. Addresses are still 20-bit for both.)

GENERAL PURPOSE REGISTERS

8086 CPU has 8 general purpose registers, each register has its own name:

AX - the accumulator register (divided into 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 - the base address register (divided into BH / BL).

Offset address relative to DS by default

CX - the count register (divided into 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 - the data register (divided into DH / DL):

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

SI - source index register:

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

DI - destination index register:

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 - base pointer:

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

SP - stack pointer:

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

SEGMENT REGISTERS

  • CS - points at the segment containing the current program.
  • DS - generally points at segment where variables are defined.
  • ES - extra segment register, it's up to a coder to define its usage.
  • SS - points at the segment containing the stack.

Although it is possible to store any data in the segment registers, this is never a good idea. The segment registers have a very special purpose - pointing at accessible blocks of memory.

Segment registers work together with general purpose register to access any memory value. For example if we would like to access memory at the physical address 12345h (hexadecimal), we could set the DS = 1230h and SI = 0045h. This way we can form 20-bit linear addresses, instead of just 16 bit with a single register. (This applies in real mode; in protected mode segmentation is different.)

The CPU makes a calculation of the physical address by multiplying the segment register by 10h and adding the general purpose register to it (1230h * 10h + 45h = 12345h):

The address formed with 2 registers is called an effective address.
By default BX, SI and DI registers work with DS segment register;
BP and SP work with SS segment register.
Other general purpose registers cannot form an effective address.
Also, although BX can form an effective address, BH and BL cannot.

SPECIAL PURPOSE REGISTERS

IP - the instruction pointer:

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

IP register always works together with CS segment register and it points to currently executing instruction.

FLAGS REGISTER

Flags Register - determines the current state of the processor. They are modified automatically by CPU after mathematical operations, this allows to determine the type of the result, and to determine conditions to transfer control to other parts of the program.Generally you cannot access these registers directly.

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).

这篇关于8086/8088中有多少个寄存器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 09:04