Keil Logo

C51: Problems with #pragma ASM

Information in this article applies to:

  • C166 Version 3 and Later
  • C251 All Versions
  • C51 All Versions

SYMPTOMS

We're having trouble using the pragma directive to introduce assembly code in the middle of a C program. We put '#pragma ASM' to begin assembly code and '#pragma ENDASM' to exit assembly code, but the compiler gave us an error:

'asm/endasm' requires src-control to be active

CAUSE

This error message displays when the SRC directive is not included when using in-line assembly.

RESOLUTION

Specify the SRC directive on the command line whenever you use the #pragma asm/endasm directives.

The SRC directive instructs the C compiler to generate a .SRC file which contains the assembly code generated from your C code. Once you have the .SRC file, you use the assembler to assemble it into an .OBJ file.

If your project does not include any C files that are compiled into OBJ files by the C compiler, you must manually include the proper library files in the project.

If your project does include at least one C file that is compiled into an OBJ file by the C compiler, the linker automatically includes the correct libraries.

MORE INFORMATION

  • Refer to SRC in the Cx51 User's Guide.

SEE ALSO

Last Reviewed: Wednesday, December 9, 2020


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.