How do I write assembly code in a C source file for PSoC 3 projects in PSoC Creator?
There are two options to write assembly code in PSoC Creator:
Option 1: Create a separate assembly source file
- Right-click on the project name in Project Explorer and select Add new item.
- Select "8051 Keil Assembly File" and provide a name for the file. This creates an assembly source file with a .a51 extension in the Source Files folder in the project.
- Add assembly code to this file with the standard 8051 instruction set.
See the Ax51 Assembler User Guide for help on instructions, template, etc. from Help > Documentation > Keil.
Note: With this choice, it is not necessary to enable the inline assembly option in the Option 2.
Option 2: Inline Assembly in a C source file
- In the C source file, put the assembly code between the directive “#pragma asm” and “#pragma endasm”.
- In Project Explorer, right-click on the source file that has the inline assembly, and select Build Settings.
- Select the Compiler option and set the value for the Inline Assembly parameter to True.
Now, the compiler will process the inline assembly code during compilation