How do I add in-line assembly code to my Keil C programs?
The attached file, Blinky_inline.zip, contains an example with ASM code embedded (in-line) in a C file for the Keil compiler.
After opening the Silicon Labs IDE project, you will see two files added to project. The Blinky_inline.c file contains several sections of in-line ASM code. The '#pragma SRC' Keil directive at the top of this file tells the compiler to create an assembly file of this code, Blinky_inline.asm. The created ASM file has been added to the project and also to the project build process. When the project is built, the ASM file is the only file used to generate the actual code downloaded to the device.
It is important to note that source-level debugging occurs at the Assembly level for '*.c' files that use the '#pragma SRC' directive. For this reason, we recommend moving all functions that have in-line assembly to their own file. This will enable source level debugging of pure C functions at the C level.
Note: If the C source file with in-line assembly is the only C file in the project, the Keil compiler will not automatically add the C run-time libraries, and the Linker will give the following warning:
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
This can be resolved by manually linking the C run-time libraries to the build. The Keil C51 run-time libraries can be found in the C51/LIB directory. The library should be added as follows:
C51S.LIB for the SMALL memory model
C51C.LIB for the COMPACT memory model
C51L.LIB for the LARGE memory model
The external OBJ can be added in the Project's Build Customization Linker options in the Silicon Labs IDE.
Generate SRC/Assembly file in Simplicity Studio
In the Simplicity studio V4, there are two ways to generate the SRC file/assembly file which is required when trying to build a project which includes in-line assembly code within the Keil C programs.
Using '#pragma SRC' Keil directive:
By modifying the C/C++ build properties:
What is contained in a development kit?
Along with a Target Board, the following items are included in all development kits: debug adapter and cables, power supply, Silicon Laboratories IDE, and an evaluation C compiler, assembler, and linker. Once you have purchased a kit you can use each of these items with all Silicon Labs Target Boards and devices. See the Silicon Laboratories website for more details.
You can find more information about development kits and development tools on this page: