This directive may not be specified on the command line.
Description
The ASM directive signals the beginning of a block of
assembler source text to merge into the .SRC file generated
using the SRC directive.
The ENDASM directive signals the end of the source text
block.
The syntax __asm { } can be used as an alternative to
ASM / ENDASM sequences. __asm { JMP $ } is
therefore identical with the example below.
The source text can be thought of as in-line assembly. However, it
is output to the source file generated only when using the SRC
directive.
The compiler does not track the assembler instructions inserted
in ASM/ENDASM sections. To prevent from generating
incorrect programs, the user must be aware of the following side
effects and consider this in the inserted assembler code.
The compiler tracks registers of functions, but not of the
instructions inserted in ASM/ENDASM sections. When
registers are modified in such sections, the registers must be
saved and restored in the inserted assembler code to avoid
conflicts with the compiler generated register assignment.
The compiler avoids to reload variable contents, but does not
track variable modifications done by instructions inserted in
ASM/ENDASM sections. When a variable is modified in
such sections, this variable should be defined using the volatile
attribute, which prevents the compiler from optimizing for
register accesses.
In µVision you may set a file specific option for C source files
that contain ASM/ENDASM sections as follows:
Right click on the file in the Project Window — Files tab
Choose Options for... to open Options — Properties
page
Enable Generate Assembler SRC file
Enable Assemble SRC file.
µVision generates an assembler source file (.SRC) and
translates this file with the Assembler, which generates an object
file (.OBJ). The linker links this object file with other
object files from the project and creates the target application
program.
Note
The ASM and ENDASM directives may occur only in
the source file as part of a #pragma.
In a ASM/ENDASM only assembler instructions are
permitted. Assembler directives and controls are not allowed.
To use in-line assembly instructions with #define
preprocessor macros, use the alternative syntax __asm {
}.
When possible, avoid using in-line assembly instructions.
Instead, use intrinsic functions available for most assembler
instructions that do not have direct support in the C
language.
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.