Keil Logo

C51: GETTING INLINE ASSEMBLY TO WORK


Information in this article applies to:

  • C51 All Versions

QUESTION

How do I implement inline assembly in C51 using the ASM and ENDASM directives. I have read some of the knowledgebase articles relating to this problem, but I still cannot get it to work.

ANSWER

The following example program, MAIN.C, demonstrates some simple inline assembly.

void main(void){
   test();

#pragma asm
      JMP   $           ; endless loop
#pragma endasm
}

The following rules apply to C51 inline assembly:

  • To use #pragma ASM/ENDASM, you must set the Generate Assembler SRC File and Assemble SRC File source file compile options in µVision by right-clicking your source file name in the Project Workspace and selecting Options for File.
  • When using the Generate Assembler SRC File and Assemble SRC File options in µVision, if there are no other C modules in your project, you must manually include the C51 Run-Time Library (C51S.LIB, C51C.LIB, or C51L.LIB).

MORE INFORMATION

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Monday, April 8, 2013


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.