www.national.com
42
Revision 3.1
Processor Programming (
Continued
)
G
3.3.1.2
The 16-bit segment registers, part of the main memory
addressing mechanism, are described in Section 3.5 “Off-
set, Segment, and Paging Mechanisms” on page 61. The
six segment registers are:
Segment Registers
CS
DS
SS
ES
FS
GS
-
-
-
-
-
-
Code Segment
Data Segment
Stack Segment
Extra Segment
Additional Data Segment
Additional Data Segment
The segment registers are used to select segments in
main memory. A segment acts as private memory for dif-
ferent elements of a program such as code space, data
space, and stack space.
There are two segment mechanisms, one for real and vir-
tual 8086 operating modes and one for protective mode.
Initialization and transition to protective mode is described
in Section 3.13.4 “Initialization and Transition to Protected
Mode” on page 87. The segment mechanisms are
described in Section 3.7 “Descriptors and Segment Mech-
anisms” on page 62.
The active segment register is selected according to the
rules listed in Table 3-3 and the type of instruction being
currently processed. In general, the DS register selector is
used for data references. Stack references use the SS
register, and instruction fetches use the CS register. While
some of these selections may be overridden, instruction
fetches, stack operations, and the destination write opera-
tion of string operations cannot be overridden. Special
segment-override instruction prefixes allow the use of
alternate segment registers. These segment registers
include the ES, FS, and GS registers.
3.3.1.3
The
Instruction Pointer (EIP) Register
contains the off-
set into the current code segment of the next instruction to
be executed. The register is normally incremented by the
length of the current instruction with each instruction exe-
cution unless it is implicitly modified through an interrupt,
exception, or an instruction that changes the sequential
execution flow (for example JMP and CALL).
Instruction Pointer Register
Table 3-3 illustrates the code segment selection rules.
Table 3-3. Segment Register Selection Rules
Type of Memory Reference
Implied (Default)
Segment
Segment-Override
Prefix
Code Fetch
CS
None
Destination of PUSH, PUSHF, INT, CALL, PUSHA instructions
SS
None
Source of POP, POPA, POPF, IRET, RET instructions
SS
None
Destination of STOS, MOVS, REP STOS, REP MOVS instructions
ES
None
Other data references with effective address using base registers of:
EAX, EBX, ECX, EDX, ESI, EDI, EBP, ESP
DS
SS
CS, ES, FS, GS, SS
CS, DS, ES, FS, GS