The DEFAULT
directive changes the assembler defaults. Normally, Yasm
defaults to a mode where the programmer is expected to explicitly specify most features
directly. However, sometimes this is not desirable if a certain behavior is very
commmonly used.
Currently, the only DEFAULT
that is settable is whether
or not registerless effective addresses in 64-bit mode are RIP
-relative or not. By default, they are absolute unless overridden
with the REL
specifier (see Section 3.3). However, if DEFAULT
REL
is specified, REL
is default, unless overridden
with the ABS
specifier, a FS
or GS
segment override is used, or another register is part of the
effective address.
The special handling of FS
and GS
overrides are due to the fact that these segments are the only
segments which can have non-0 base addresses in 64-bit mode, and thus are generally used
as thread pointers or other special functions. With a non-zero base address, generating
RIP
-relative addresses for these forms would be extremely
confusing. Other segment registers such as DS
always have a
base address of 0, so RIP-relative access still makes sense.
DEFAULT REL
is disabled with DEFAULT ABS
. The default mode of the assembler at start-up is
DEFAULT ABS
.