Volume 1 - Chapter 3: Basic Execution Environment(Section 3.1)

This chapter describes the basic execution environment of an Intel 64 or IA-32 processor as seen by assembly-language programmers. It describes how the processor executes instructions and how it stores and manipulates data. The execution environment described here includes memory (the address space), general purpose data registers, segment registers, the flag register, and the instruction pointer register.
本章从汇编程序员的角度描述了Intel 64和IA-32处理器的基本执行环境。描述了处理器如何执行指令,如何存储和操纵数据。此处描述的执行环境包括内存(地址空间)、通用目的数据寄存器、段寄存器、标志寄存器和指令指针寄存器。

 

3.1 Modes Of Operation

The IA-32 architecture supports three basic operating modes: protected mode, real address mode, and system management mode. The operating mode determines which instructions and architectural features are accessible:

  • Protected mode — This mode is the native state of the processor. Among the capabilities of protected mode is the ability to directly execute “real-address mode” 8086 software in a protected, multi-tasking environment. This feature is called virtual-8086 mode, although it is not actually a processor mode. Virtual-8086 mode is actually a protected mode attribute that can be enabled for any task.
  • Real-address mode — This mode implements the programming environment of the Intel 8086 processor with extensions (such as the ability to switch to protected or system management mode). The processor is placed in real-address mode following power-up or a reset.
  • System management mode (SMM) — This mode provides an operating system or executive with a transparent mechanism for implementing platform specific functions such as power management and system security. The processor enters SMM when the external SMM interrupt pin (SMI#) is activated or an SMI is received from the advanced programmable interrupt controller (APIC).
    In SMM, the processor switches to a separate address space while saving the basic context of the currently running program or task. SMM-specific code may then be executed transparently. Upon returning from SMM, the processor is placed back into its state prior to the system management interrupt. SMM was introduced with the Intel386™ SL and Intel486™ SL processors and became a standard IA-32 feature with the Pentium processor family.

IA-32体系架构支持三种基本的运行模式:保护模式、实地址模式和系统管理模式。运行模式决定了可以使用哪些指令和体系架构特性:

  • 保护模式 — 处理器的原生状态。在受保护、多任务环境下直接执行“实地址模式”的8086软件是保护模式的能力之一。这种特性叫做虚拟8086模式,尽管它实际上并不是一种处理器模式。虚拟8086模式实际上是可用于任何任务的保护模式属性。
  • 实地址模式 — 这种模式实现了带扩展(例如切换到保护模式或系统管理模式的能力)的8086处理器的编程环境。处理器在加电和复位时处于实地址模式。
  • 系统管理模式(SMM) — .....

 

3.1.1 Intel 64 Architechure

Intel 64 architecture adds IA-32e mode. IA-32e mode has two sub-modes.These are:

  • Compatibility mode (sub-mode of IA-32e mode) — Compatibility mode permits most legacy 16-bit and 32-bit applications to run without re-compilation under a 64-bit operating system. For brevity, the compatibility sub-mode is referred to as compatibility mode in IA-32 architecture. The execution environment of compatibility mode is the same as described in Section 3.2. Compatibility mode also supports all of the privilege levels that are supported in 64-bit and protected modes. Legacy applications that run in Virtual 8086 mode or use hardware task management will not work in this mode. Compatibility mode is enabled by the operating system (OS) on a code segment basis. This means that a single 64-bit OS can support 64-bit applications running in 64-bit mode and support legacy 32-bit applications (not recompiled for 64-bits) running in compatibility mode. Compatibility mode is similar to 32-bit protected mode. Applications access only the first 4 GByte of linear-address space. Compatibility mode uses 16-bit and 32- bit address and operand sizes. Like protected mode, this mode allows applications to access physical memory greater than 4 GByte using PAE (Physical Address Extensions).
  • 64-bit mode (sub-mode of IA-32e mode) — This mode enables a 64-bit operating system to run applications written to access 64-bit linear address space. For brevity, the 64-bit sub-mode is referred to as 64-bit mode in IA-32 architecture.64-bit mode extends the number of general purpose registers and SIMD extension registers from 8 to 16. General purpose registers are widened to 64 bits. The mode also introduces a new opcode prefix (REX) to access the register extensions. See Section 3.2.1 for a detailed description. 64-bit mode is enabled by the operating system on a code-segment basis. Its default address size is 64 bits and its default operand size is 32 bits. The default operand size can be overridden on an instruction-by-instruction basis using a REX opcode prefix in conjunction with an operand size override prefix. REX prefixes allow a 64-bit operand to be specified when operating in 64-bit mode. By using this mechanism, many existing instructions have been promoted to allow the use of 64-bit registers and 64-bit addresses.

Intel 64架构添加了IA-32e模式。IA-32e模式有两种子模式。它们是:

  • 兼容模式(IA-32e模式的子模式)— 兼容模式允许旧有的16位和32位应用程序无需重新编译就可以在64位操作系统下运行。简单的说,兼容子模式被称为IA-32架构中的兼容模式。兼容模式的执行环境和3.2节描述的一样。兼容模式还支持64位和保护模式所支持的全部特权级。旧有的运行在虚拟8086模式或使用硬件任务管理的应用程序不能运行在此模式下。兼容模式由操作系统在代码段的基础之上启用。这意味着一个64位的OS可以支持64位模式中的64位应用程序和运行在兼容模式的旧有32位应用程序(不重新编译为64位)。兼容模式类似于32位保护模式。应用程序只能访问前4G线性地址空间。兼容模式使用16位和32位的地址和操作数尺寸。和保护模式一样,它允许应用程序使用PAE(Physical Address Extensions)允许访问大于4G的物理内存。
  • 64位模式(IA-32e模式的子模式)— 这个模式允许64位的操作系统运行访问64位线性地址空间的应用程序。简单的说,64位子模式指的是IA-32架构中的64位模式。64位模式将通用目的寄存器和SIMD扩展寄存器从8个扩展到16个。通用目的寄存器加宽到64位。这个模式还引入了新的操作码前缀(REX)从而访问寄存器扩展。更详细的描述参见3.2.1节。64位模式由操作系统在代码段的基础上启用。它的默认地址大小是64位,默认操作数大小是32位。默认操作数的大小可以在每条指令的基础上使用REX操作码前缀以及操作数大小覆盖前缀来修改。REX前缀允许当运行在64位模式时指定64位操作数。通过使用这种机制,很多现存的指令被提升允许使用64位寄存器和64位地址。
posted @ 2009-04-13 14:04  DEMENTiA  阅读(361)  评论(0编辑  收藏  举报