# 4.6. 寄存器：CPU 的存储单元

CPU 与内存是两个独立的芯片，计算机运行时，CPU 通过总线与内存交换数据，这种数据传输通道的速率远远低于CPU的时钟周期，为了加快CPU的处理速度，芯片制造者们在CPU内部加入了寄存器（Register）。

寄存器是位于 CPU 内部的存储组件，构造寄存器的底层原理与构造内存是一样的。CPU 中的寄存器分为专用寄存器与通用寄存器，专用寄存器有专门的用途，甚至其内容不允许用户直接修改，例如 PC(Program Counter); 而通用寄存器的用途由编程人员自己决定。下图是英特尔 X86 系列最早的芯片 Intel 8086 所定义的寄存器：

![Intel 8086 Registers](/files/-MdWSw8QrutKihpO203y)

寄存器的数目是极其有限的，因此 CPU 内部的每个寄存器都有固定的编码，例如上图中，寄存器 AX 指代的就是由 AH 与 AL 两个 8 位寄存器组成的一个 16 位寄存器。也就是说，从编程人员的视角来看（除非直接写二进制的机器指令），CPU 指令对寄存器的寻址是通过名字进行的，这是与内存寻址方式最大的不同。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://s2.shizhz.me/s2e4/6.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
