术语:汇编语言编程中的“寄存器”

时间:2023-01-14 03:15:59

I've heard the terminologies: register, hardware register, program register,register file.

我听说过术语:寄存器,硬件寄存器,程序寄存器,寄存器文件。

What's the difference between all these? And in assebmly, what is the type of the EAX register? Program register?

这些之间有什么区别?总而言之,EAX寄存器的类型是什么?程序注册?

6 个解决方案

#1


A register is a storage area inside the CPU. Here are some definitions:

寄存器是CPU内部的存储区域。以下是一些定义:

  • A register file is an array of registers - see http://en.wikipedia.org/wiki/Register_file for a full description.
  • 寄存器文件是寄存器数组 - 有关完整说明,请参阅http://en.wikipedia.org/wiki/Register_file。

  • The eax register is the accumulator register of the Intel x86 family of CPUs - it's the place where integer maths gets done.
  • eax寄存器是Intel x86系列CPU的累加器寄存器 - 它是整数数学完成的地方。

  • The program register (I think you mean program counter) is a special purpose register which contains the address of the next machine code instruction to be executed
  • 程序寄存器(我认为你的意思是程序计数器)是一个专用寄存器,它包含要执行的下一个机器代码指令的地址

#2


A register is the most basic data storage device. Now these are the main differences.

寄存器是最基本的数据存储设备。现在这些是主要的区别。

A register file is generally a large collection of registers organised in such a way so that they are used for computations. In a modern processor, all computations are performed between values stored in several registers in a register file.

寄存器文件通常是以这种方式组织的大量寄存器集合,以便它们用于计算。在现代处理器中,所有计算都在存储在寄存器文件中的若干寄存器中的值之间执行。

A hardware register generally refers to registers that store configuration and status information. This could be for the processor or some external hardware I/O device.

硬件寄存器通常是指存储配置和状态信息的寄存器。这可能适用于处理器或某些外部硬件I / O设备。

A programme register may refer to the programme counter, a special register that stores the memory location of the current instruction being executed by the processor.

程序寄存器可以指程序计数器,该程序计数器是存储由处理器执行的当前指令的存储位置的特殊寄存器。

#3


a register is a small bit of memory that sits inside the CPU. and is used by assembly language to perform various tasks.

寄存器是位于CPU内部的一小块内存。并由汇编语言用于执行各种任务。

could it be that by program register you mean program counter?

是不是通过程序注册你的意思是程序计数器?

#4


Well, you have general purpose registers, then you have registers which have special usage (for example, the program counter registers), and you have various others (memory/segment registers, SSE).

那么,你有通用寄存器,那么你有特殊用途的寄存器(例如,程序计数器寄存器),你有其他各种(存储器/段寄存器,SSE)。

EAX, EBX, etc. are the standard general purpose registers. You can use them for whatever you want. Usually, the return value is supposed to be put into EAX, but that's it basically. Then you have the stack pointer EBP, which points to the beginning of your stack. Finally, you have to program counter, which points to the current instruction, EIP. On x86, there are some special cases, where two registers get fused when doing 64-bit integer computations. More special cases exist for the string instructions. If you are about to learn assembly, the easiest would be to start with a PowerPC, which has more registers, and you're free to use all of them without restrictions.

EAX,EBX等是标准的通用寄存器。你可以随意使用它们。通常,返回值应该放入EAX中,但基本上就是这样。然后你有堆栈指针EBP,它指向堆栈的开头。最后,你必须编程计数器,它指向当前指令EIP。在x86上,有一些特殊情况,其中两个寄存器在进行64位整数计算时会被融合。字符串指令存在更多特殊情况。如果您要学习组装,最简单的方法是从PowerPC开始,它有更多的寄存器,您可以*地使用所有这些寄存器而不受限制。

All of these registers are of course hardware registers, that is, they are physically built into your CPU ;) The place where they are is called a register file.

所有这些寄存器当然都是硬件寄存器,也就是说,它们是物理内置在CPU中的;)它们所在的位置称为寄存器文件。

The other type of registers you can see is if you have a virtual machine which uses registers (Parrot), you get "virtual registers", which are later assigned to real registers. This is similar to what you can do when writing a compiler yourself, you basically assume an unlimited amount of registers (that is, you generate a new one on each usage), and do the transformation to real registers in a different phase (register allocation).

您可以看到的另一种类型的寄存器是,如果您有一个使用寄存器(Parrot)的虚拟机,您将获得“虚拟寄存器”,稍后将其分配给实际寄存器。这类似于你自己编写编译器时可以做的事情,你基本上假设无限量的寄存器(也就是说,你在每次使用时生成一个新的寄存器),并在不同的阶段转换为实际的寄存器(寄存器分配) )。

#5


A "hardware register" might also refer to a location inside some hardware device. For example, a UART (COM port) looks like a D-shaped connector with 9 or 25 pins from outside the cabinet, but to the device driver it looks like several configuration registers, a status register, and data registers holding the next character to send and the last character received. (I've left out a lot of detail there.)

“硬件寄存器”也可以指某些硬件设备内的位置。例如,UART(COM端口)看起来像一个D形连接器,从机柜外部有9或25个引脚,但对于设备驱动程序,它看起来像几个配置寄存器,状态寄存器和保存下一个字符的数据寄存器发送和收到的最后一个字符。 (我在那里遗漏了很多细节。)

In the x86 architecture those registers are usually located in a special physical address space that is accessed with I/O instructions. In other platforms, it is common for hardware registers to be mapped to some corner of the normal memory space. In either case, one of the important roles of an operating system and its device drivers is to prevent application code from needing to know the details of where the hardware registers are located and what they mean.

在x86架构中,这些寄存器通常位于使用I / O指令访问的特殊物理地址空间中。在其他平台中,硬件寄存器通常映射到普通存储空间的某个角落。在任何一种情况下,操作系统及其设备驱动程序的重要作用之一是防止应用程序代码需要知道硬件寄存器所在位置及其含义的详细信息。

In some kinds of hardware devices, the distinction between memory and hardware registers is less clear. For instance, your video adapter contains a block of memory known as the frame buffer that holds the color and brightness values for each individual pixel. Is that memory a large hardware register or is it just a buffer that has an interesting side effect?

在某些类型的硬件设备中,存储器和硬件寄存器之间的区别不太清楚。例如,您的视频适配器包含一个称为帧缓冲区的内存块,用于保存每个像素的颜色和亮度值。该内存是一个大型硬件寄存器,还是只是一个具有有趣副作用的缓冲区?

#6


In relation to the question, there are two general types of registers that you should consider:

关于这个问题,你应该考虑两种一般类型的寄存器:

  • program registers
  • hardware registers

The hardware registers are clocked (updated on clock ticks) and are used in the physical design of processor circuitry.

硬件寄存器是时钟控制的(按时钟周期更新),用于处理器电路的物理设计。

The program registers are random-access memory and are held in a register file located in the CPU. Assembly/machine code instructions access these registers through names like %eax, %esp, %rdi, %edi, etc.

程序寄存器是随机存取存储器,存放在CPU中的寄存器文件中。汇编/机器代码指令通过%eax,%esp,%rdi,%edi等名称访问这些寄存器。

#1


A register is a storage area inside the CPU. Here are some definitions:

寄存器是CPU内部的存储区域。以下是一些定义:

  • A register file is an array of registers - see http://en.wikipedia.org/wiki/Register_file for a full description.
  • 寄存器文件是寄存器数组 - 有关完整说明,请参阅http://en.wikipedia.org/wiki/Register_file。

  • The eax register is the accumulator register of the Intel x86 family of CPUs - it's the place where integer maths gets done.
  • eax寄存器是Intel x86系列CPU的累加器寄存器 - 它是整数数学完成的地方。

  • The program register (I think you mean program counter) is a special purpose register which contains the address of the next machine code instruction to be executed
  • 程序寄存器(我认为你的意思是程序计数器)是一个专用寄存器,它包含要执行的下一个机器代码指令的地址

#2


A register is the most basic data storage device. Now these are the main differences.

寄存器是最基本的数据存储设备。现在这些是主要的区别。

A register file is generally a large collection of registers organised in such a way so that they are used for computations. In a modern processor, all computations are performed between values stored in several registers in a register file.

寄存器文件通常是以这种方式组织的大量寄存器集合,以便它们用于计算。在现代处理器中,所有计算都在存储在寄存器文件中的若干寄存器中的值之间执行。

A hardware register generally refers to registers that store configuration and status information. This could be for the processor or some external hardware I/O device.

硬件寄存器通常是指存储配置和状态信息的寄存器。这可能适用于处理器或某些外部硬件I / O设备。

A programme register may refer to the programme counter, a special register that stores the memory location of the current instruction being executed by the processor.

程序寄存器可以指程序计数器,该程序计数器是存储由处理器执行的当前指令的存储位置的特殊寄存器。

#3


a register is a small bit of memory that sits inside the CPU. and is used by assembly language to perform various tasks.

寄存器是位于CPU内部的一小块内存。并由汇编语言用于执行各种任务。

could it be that by program register you mean program counter?

是不是通过程序注册你的意思是程序计数器?

#4


Well, you have general purpose registers, then you have registers which have special usage (for example, the program counter registers), and you have various others (memory/segment registers, SSE).

那么,你有通用寄存器,那么你有特殊用途的寄存器(例如,程序计数器寄存器),你有其他各种(存储器/段寄存器,SSE)。

EAX, EBX, etc. are the standard general purpose registers. You can use them for whatever you want. Usually, the return value is supposed to be put into EAX, but that's it basically. Then you have the stack pointer EBP, which points to the beginning of your stack. Finally, you have to program counter, which points to the current instruction, EIP. On x86, there are some special cases, where two registers get fused when doing 64-bit integer computations. More special cases exist for the string instructions. If you are about to learn assembly, the easiest would be to start with a PowerPC, which has more registers, and you're free to use all of them without restrictions.

EAX,EBX等是标准的通用寄存器。你可以随意使用它们。通常,返回值应该放入EAX中,但基本上就是这样。然后你有堆栈指针EBP,它指向堆栈的开头。最后,你必须编程计数器,它指向当前指令EIP。在x86上,有一些特殊情况,其中两个寄存器在进行64位整数计算时会被融合。字符串指令存在更多特殊情况。如果您要学习组装,最简单的方法是从PowerPC开始,它有更多的寄存器,您可以*地使用所有这些寄存器而不受限制。

All of these registers are of course hardware registers, that is, they are physically built into your CPU ;) The place where they are is called a register file.

所有这些寄存器当然都是硬件寄存器,也就是说,它们是物理内置在CPU中的;)它们所在的位置称为寄存器文件。

The other type of registers you can see is if you have a virtual machine which uses registers (Parrot), you get "virtual registers", which are later assigned to real registers. This is similar to what you can do when writing a compiler yourself, you basically assume an unlimited amount of registers (that is, you generate a new one on each usage), and do the transformation to real registers in a different phase (register allocation).

您可以看到的另一种类型的寄存器是,如果您有一个使用寄存器(Parrot)的虚拟机,您将获得“虚拟寄存器”,稍后将其分配给实际寄存器。这类似于你自己编写编译器时可以做的事情,你基本上假设无限量的寄存器(也就是说,你在每次使用时生成一个新的寄存器),并在不同的阶段转换为实际的寄存器(寄存器分配) )。

#5


A "hardware register" might also refer to a location inside some hardware device. For example, a UART (COM port) looks like a D-shaped connector with 9 or 25 pins from outside the cabinet, but to the device driver it looks like several configuration registers, a status register, and data registers holding the next character to send and the last character received. (I've left out a lot of detail there.)

“硬件寄存器”也可以指某些硬件设备内的位置。例如,UART(COM端口)看起来像一个D形连接器,从机柜外部有9或25个引脚,但对于设备驱动程序,它看起来像几个配置寄存器,状态寄存器和保存下一个字符的数据寄存器发送和收到的最后一个字符。 (我在那里遗漏了很多细节。)

In the x86 architecture those registers are usually located in a special physical address space that is accessed with I/O instructions. In other platforms, it is common for hardware registers to be mapped to some corner of the normal memory space. In either case, one of the important roles of an operating system and its device drivers is to prevent application code from needing to know the details of where the hardware registers are located and what they mean.

在x86架构中,这些寄存器通常位于使用I / O指令访问的特殊物理地址空间中。在其他平台中,硬件寄存器通常映射到普通存储空间的某个角落。在任何一种情况下,操作系统及其设备驱动程序的重要作用之一是防止应用程序代码需要知道硬件寄存器所在位置及其含义的详细信息。

In some kinds of hardware devices, the distinction between memory and hardware registers is less clear. For instance, your video adapter contains a block of memory known as the frame buffer that holds the color and brightness values for each individual pixel. Is that memory a large hardware register or is it just a buffer that has an interesting side effect?

在某些类型的硬件设备中,存储器和硬件寄存器之间的区别不太清楚。例如,您的视频适配器包含一个称为帧缓冲区的内存块,用于保存每个像素的颜色和亮度值。该内存是一个大型硬件寄存器,还是只是一个具有有趣副作用的缓冲区?

#6


In relation to the question, there are two general types of registers that you should consider:

关于这个问题,你应该考虑两种一般类型的寄存器:

  • program registers
  • hardware registers

The hardware registers are clocked (updated on clock ticks) and are used in the physical design of processor circuitry.

硬件寄存器是时钟控制的(按时钟周期更新),用于处理器电路的物理设计。

The program registers are random-access memory and are held in a register file located in the CPU. Assembly/machine code instructions access these registers through names like %eax, %esp, %rdi, %edi, etc.

程序寄存器是随机存取存储器,存放在CPU中的寄存器文件中。汇编/机器代码指令通过%eax,%esp,%rdi,%edi等名称访问这些寄存器。