Next Chapter | Previous Chapter | Contents | Index
The
directive (see
section 4.6.4) includes one of
the standard macro packages included with the NASM distribution and
compiled into the NASM binary. It operates like the
directive (see
section 4.6.1), but the included
contents is provided by NASM itself.
The names of standard macro packages are case insensitive, and can be quoted or not.
altreg
: Alternate Register NamesThe
standard macro package provides
alternate register names. It provides numeric register names for all
registers (not just
-
), the
Intel-defined aliases
-
for the low
bytes of register (as opposed to the NASM/AMD standard names
-
), and the
names
-
(by
analogy with
-
)
for
,
,
, and
.
Example use:
%use altreg proc: mov r0l,r3h ; mov al,bh ret
See also section 11.1.
smartalign
: Smart ALIGN
MacroThe
standard macro package provides
for an
macro which is more powerful than
the default (and backwards-compatible) one (see
section 4.12.12). When the
package is enabled, when
is used without a second argument, NASM
will generate a sequence of instructions more efficient than a series of
. Furthermore, if the padding exceeds a
specific threshold, then NASM will generate a jump over the entire padding
sequence.
The specific instructions generated can be controlled with the new
macro. This macro takes two parameters:
one mode, and an optional jump threshold override. If (for any reason) you
need to turn off the jump completely just set jump threshold value to -1
(or set it to
). The following modes are
possible:
generic
: Works on all x86 CPUs and should
have reasonable performance. The default jump threshold is 8. This is the
default.
nop
: Pad out with
NOP
instructions. The only difference compared to
the standard ALIGN
macro is that NASM can still
jump over a large padding area. The default jump threshold is 16.
k7
: Optimize for the AMD K7 (Athlon/Althon
XP). These instructions should still work on all x86 CPUs. The default jump
threshold is 16.
k8
: Optimize for the AMD K8 (Opteron/Althon
64). These instructions should still work on all x86 CPUs. The default jump
threshold is 16.
p6
: Optimize for Intel CPUs. This uses the
long NOP
instructions first introduced in Pentium
Pro. This is incompatible with all CPUs of family 5 or lower, as well as
some VIA CPUs and several virtualization solutions. The default jump
threshold is 16.
The macro
is defined to contain
the current alignment mode. A number of other macros beginning with
are used internally by this macro
package.
fp
: Floating-point macrosThis packages contains the following floating-point convenience macros:
%define Inf __Infinity__ %define NaN __QNaN__ %define QNaN __QNaN__ %define SNaN __SNaN__ %define float8(x) __float8__(x) %define float16(x) __float16__(x) %define float32(x) __float32__(x) %define float64(x) __float64__(x) %define float80m(x) __float80m__(x) %define float80e(x) __float80e__(x) %define float128l(x) __float128l__(x) %define float128h(x) __float128h__(x)
ifunc
: Integer functionsThis package contains a set of macros which implement integer functions. These are actually implemented as special operators, but are most conveniently accessed via this macro package.
The macros provided are:
These functions calculate the integer logarithm base 2 of their argument, considered as an unsigned integer. The only differences between the functions is their behavior if the argument provided is not a power of two.
The function
(alias
) generate an error if the argument is not
a power of two.
The function
generate a warning if
the argument is not a power of two.
The function
rounds the argument down
to the nearest power of two; if the argument is zero it returns zero.
The function
rounds the argument up
to the nearest power of two.