segment register

来源:互联网 发布:优化公司机构设置 编辑:程序博客网 时间:2024/05/16 12:47

2.3.2 Segment Registers
The segment registers of the 80386 give systems software designers the
flexibility to choose among various models of memory organization.
Implementation of memory models is the subject of Part II ── Systems
Programming. Designers may choose a model in which applications programs do
not need to modify segment registers, in which case applications programmers
may skip this section.

段寄存器使软件设计者可以比较灵活的选择各种内存组织模式。设计者可以不需要确定段寄存器的

情况下选择一种模式。在这种情况下可以跳过这章。
Complete programs generally consist of many different modules, each
consisting of instructions and data. However, at any given time during
program execution, only a small subset of a program's modules are actually
in use. The 80386 architecture takes advantage of this by providing
mechanisms to support direct access to the instructions and data of the
current module's environment, with access to additional segments on demand.
At any given instant, six segments of memory may be immediately accessible
to an executing 80386 program. The segment registers CS, DS, SS, ES, FS, and
GS are used to identify these six current segments. Each of these registers
specifies a particular kind of segment, as characterized by the associated
mnemonics ("code," "data," or "stack") shown in Figure 2-6.

完整的程序通常包含不同的单位,每种都包含指令和数据。经管如此事实上在程序执行的任何给出的时间

里只有一部分单位是被使用的。内存的六个段可以被直接的进入在任何位置。段寄存器被用于识别先行

段,每个寄存器指定一个特别的段类型 。

Each register
uniquely determines one particular segment, from among the segments that
make up the program, that is to be immediately accessible at highest speed.
The segment containing the currently executing sequence of instructions is
known as the current code segment; it is specified by means of the CS
register. The 80386 fetches all instructions from this code segment, using
as an offset the contents of the instruction pointer. CS is changed
implicitly as the result of intersegment control-transfer instructions (for
example, CALL and JMP), interrupts, and exceptions.

每个寄存器决定一个特定段 ,可以以高速度立即的存取。包含正在指令序列的段被认作

是代码段,它有cs寄存器指定。在经过段间控制转换和中断异常之后会隐含的自动转变
Subroutine calls, parameters, and procedure activation records usually
require that a region of memory be allocated for a stack. All stack
operations use the SS register to locate the stack. Unlike CS, the SS
register can be loaded explicitly, thereby permitting programmers to define
stacks dynamically.

子程序调用,线程恢复 通常需要指定一个堆栈,所有的堆栈由堆栈寄存器指定,不像代码段

寄存器 堆栈段寄存器可以直接被加载。因此允许程序员去动态的定义堆栈。
The DS, ES, FS, and GS registers allow the specification of four data
segments, each addressable by the currently executing program. Accessibility
to four separate data areas helps programs efficiently access different
types of data structures; for example, one data segment register can point
to the data structures of the current module, another to the exported data
of a higher-level module, another to a dynamically created data structure,
and another to data shared with another task. An operand within a data
segment is addressed by specifying its offset either directly in an
instruction or indirectly via general registers.

ds es fs gs 被许可指定为数据段,可以由现行程序编址。可以让程序高效的不同数据结构

单独数据区域。例如一个数据段即孙琪可以执行一个现行单元的数据结构,另一个输出高一

单元的数据。另一个去动态的创建数据结构另一个由其他任务共享。在一个数据段里的的

操作数可以直接通过指定一个偏移地址也可以间接的通过通用寄存器。
Depending on the structure of data (e.g., the way data is parceled into one
or more segments), a program may require access to more than four data
segments. To access additional segments, the DS, ES, FS, and GS registers
can be changed under program control during the course of a program's
execution. This simply requires that the program execute an instruction to
load the appropriate segment register prior to executing instructions that
access the data.

依靠数据的结构。程序可以存取多于4个数据段。为了进入额外的段 ds es fs gs可以在

程序执行的过程中有程序控制改变。一个简单的要求就是在执行存取数据之前,程序必须

执行一个加载适当寄存器的指令。

The processor associates a base address with each segment selected by a
segment register. To address an element within a segment, a 32-bit offset is
added to the segment's base address. Once a segment is selected (by loading
the segment selector into a segment register), a data manipulation
instruction only needs to specify the offset. Simple rules define which
segment register is used to form an address when only an offset is
specified.
处理器关联某个段的基地址是由一个段寄存器选择的。为了到达段内的一个单元,必须添加一个

32位的偏移地址。一旦通过加载一个段选择子到一个段寄存器选择一个段,一个数据操作指令

仅仅需要指定便宜地址。

原创粉丝点击