Page 62 - ARM 64 Bit Assembly Language
P. 62
46 Chapter 2
The period “.” in the expression (. - myfunc) is a reference to the current location counter
value. The expression (. - myfunc) means “Subtract the location of myfunc from the cur-
rent location.” This directive calculates how many bytes there are between the label myfunc
and the location of the .size directive, and provides that information for the linker and/or
debugger.
2.3.6 Conditional assembly
Sometimes it is desirable to skip assembly of portions of a file. The assembler provides some
directives to allow conditional assembly. One use for these directives is to optionally assemble
code as an aid for debugging.
.if expression
.if marks the beginning of a section of code which is only considered part of the
source program being assembled if the argument (which must be an absolute expres-
sion) is non-zero. The end of the conditional section of code must be marked by the
.endif directive. Optionally, code may be included for the alternative condition by us-
ing the .else directive.
.ifdef symbol
Assembles the following section of code if the specified symbol has been defined.
.ifndef symbol
Assembles the following section of code if the specified symbol has not been defined.
.else
Assembles the following section of code only if the condition for the preceding .if or
.ifdef was false.
.endif
Marks the end of a block of code that is only assembled conditionally.
2.3.7 Including other source files
.include "file"
This directive provides a way to include supporting files at specified points in the source
program. The code from the included file is assembled as if it followed the point of the
.include directive. When the end of the included file is reached, assembly of the orig-
inal file continues. The search paths used can be controlled with the ‘-I’ command line
parameter when running the assembler. Quotation marks are required around file.
This assembler directive is similar to including header files in C and C++ using the
#include compiler directive.