Intel 64 and IA-32 Architectures Software Developers Manual Volume 1, Basic Architecture

Vol. 1 7-1
CHAPTER 7
PROGRAMMING WITH
GENERAL-PURPOSE INSTRUCTIONS
General-purpose (GP) instructions are a subset of the IA-32 instructions that repre-
sent the fundamental instruction set for the Intel IA-32 processors. These instruc-
tions were introduced into the IA-32 architecture with the first IA-32 processors (the
Intel 8086 and 8088). Additional instructions were added to the general-purpose
instruction set in subsequent families of IA-32 processors (the Intel 286, Intel386,
Intel486, Pentium, Pentium Pro, and Pentium II processors).
Intel 64 architecture further extends the capability of most general-purpose instruc-
tions so that they are able to handle 64-bit data in 64-bit mode. A small number of
general-purpose instructions (still supported in non-64-bit modes) are not supported
in 64-bit mode.
General-purpose instructions perform basic data movement, memory addressing,
arithmetic and logical, program flow control, input/output, and string operations on a
set of integer, pointer, and BCD data types. This chapter provides an overview of the
general-purpose instructions. See Intel® 64 and IA-32 Architectures Software Devel-
oper’s Manual, Volumes 3A & 3B, for detailed descriptions of individual instructions.
7.1 PROGRAMMING ENVIRONMENT FOR GP
INSTRUCTIONS
The programming environment for the general-purpose instructions consists of the
set of registers and address space. The environment includes the following items:
General-purpose registers — Eight 32-bit general-purpose registers (see
Section 3.4.1, “General-Purpose Registers”) are used in non-64-bit modes to
address operands in memory. These registers are referenced by the names EAX,
EBX, ECX, EDX, EBP, ESI EDI, and ESP.
Segment registers — The six 16-bit segment registers contain segment
pointers for use in accessing memory (see Section 3.4.2, “Segment Registers”).
These registers are referenced by the names CS, DS, SS, ES, FS, and GS.
EFLAGS register — This 32-bit register (see Section 3.4.3, “EFLAGS Register”)
is used to provide status and control for basic arithmetic, compare, and system
operations.
EIP register — This 32-bit register contains the current instruction pointer (see
Section 3.4.3, “EFLAGS Register”).
General-purpose instructions operate on the following data types. The width of valid
data types is dependent on processor mode (see Chapter 4):
Bytes, words, doublewords