ARM Technical Support Knowledge Articles


Applies to: uVision (Version 1) IDE


Information in this article applies to:


How do I include in-line assembly in my C files and use the Project Manager in uVision Version 1 to compile the C file and assemble the SRC file?


In-line assembly requires that you do a number of things that fall outside the "normal" project build process. All of these can be implemented using the uVision IDE.

The process for building in-line assembly files is:

  1. Compile the C source file using the SRC directive. This directive tells the compiler to generate an assembly file with the .SRC file extension (unless you specify a different one). This file must then be assembled using the Assembler.
  2. Assemble the .SRC file generated by the compiler.
  3. Include the object file generated by the assembler in your project.

To do this in uVision:

  1. Add the C source file to the project.
  2. On the first line in the C file, add #pragma SRC. This causes the compiler to generate the assembly file. You should not specify this directive in the general compiler options because that would generate assembly for ALL C files.
  3. Compile this file using the Compile File command from the project menu. This generates the .SRC file, which is the assembly source file.
  4. Open the Project dialog box using the Edit Project command in the Project menu.
  5. Select the C file for which an assembly file is desired and un-check the "Include in Link/Lib" check box. When this checkbox is un-checked, uVision does not include the object file in the linker command line. This is necessary since the compiler does not generate an object file when the SRC directive is used.
  6. Add the assembler .SRC file to the project. When you do this, uVision will complain that is does not recognize that file type. This is normal. Just click OK and close the Add File To Project dialog. uVision uses the file extensions that are defined in the Make Options dialog box. If you add SRC to the assembler extensions list, uVision automatically recognizes and adds the SRC file. However, this is not necessary. It is easy to manually add one or two files.
  7. Next, select the assembler .SRC file in the Project dialog box and change the translator type to Assembler.
  8. Un-check the "Always Build" checkbox. When checked, this control forces re-compilation or re-assembly of the source file.
  9. Check the "Include in Link/Lib" checkbox. This includes the object file in the linker command line.

If you have only one file included in the linkage, the linker may complain that it has unresolved symbols for library routines that you used. This is due to the way the compiler and assembler generate object modules, but it is easy to fix.

When the compiler generates object files, the library information is included in the object file that is emitted.

When the assembler generates object files, references to the C library are not included. So, you must manually specify that the linker include the C libraries.

You can include the libraries in the uVision project manager by simply selecting the appropriate library from the lib directory. uVision correctly identifies library files and automatically adds them to the project.


Article last edited on: 2005-07-18 09:57:06

Rate this article

Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential