Intel 64 and IA-32 Architectures Software Developers Manual Volume 1, Basic Architecture
Vol. 1 3-29
BASIC EXECUTION ENVIRONMENT
3.7.4 Specifying a Segment Selector
The segment selector can be specified either implicitly or explicitly. The most
common method of specifying a segment selector is to load it in a segment register
and then allow the processor to select the register implicitly, depending on the type
of operation being performed. The processor automatically chooses a segment
according to the rules given in Table 3-5.
When storing data in memory or loading data from memory, the DS segment default
can be overridden to allow other segments to be accessed. Within an assembler, the
segment override is generally handled with a colon “:” operator. For example, the
following MOV instruction moves a value from register EAX into the segment pointed
to by the ES register. The offset into the segment is contained in the EBX register:
MOV ES:[EBX], EAX;
Figure 3-10. Memory Operand Address in 64-Bit Mode
Table 3-5. Default Segment Selection Rules
Reference
Type
Register
Used
Segment
Used Default Selection Rule
Instructions CS Code Segment All instruction fetches.
Stack SS Stack Segment All stack pushes and pops.
Any memory reference which uses the ESP or EBP
register as a base register.
Local Data DS Data Segment All data references, except when relative to stack or
string destination.
Destination
Strings
ES Data Segment
pointed to with
the ES register
Destination of string instructions.
Offset (or Linear Address)
015
Segment
630
Selector